<commit_before>'use strict'
/**
 * @ngdoc function
 * @name sbAdminApp.controller:MainCtrl
 * @description
 * # MainCtrl
 * Controller of the sbAdminApp
 */
angular.module('sbAdminApp')
    .controller('TableCtrl',
        function($scope, $timeout) {
            $scope.onChangeHandler4M = function(dataItem) {
                $timeout(function() {
                    $scope.onChangeHandler();
                    $scope.trafficStatus = 0;
                    var data = $scope.fourMDataSource.data();
                    for (var i in data) {
                        if (data[i].today === "red") {
                            $scope.trafficStatus = 2;
                            break;
                        }
                        if (data[i].today === "yellow") {
                            $scope.trafficStatus = 1;
                        }
                    }
                    return;
                });
            }
            $scope.onChangeHandler = function(dataItem) {
                $scope.fpyDataGrid.refresh();
                $scope.issueDataGrid.refresh();
                $scope.fourMDataGrid.refresh();
            }

            $scope.trafficStatus = 0;
            $scope.flagEditShow = false;
            $scope.flagDoneShow = false;
            $scope.outputDaily = {
                id: 10,
                target: '6',
                yesterday: '6',
                today: '6'
            };
            $scope.outputCummulative = {
                id: 20,
                target: '6',
                acheived: '6'
            };
            $scope.underAcheivedToday = false;
            $scope.underAcheivedYday = false;

            function initFPYTable() {
                //Ideally Data should come from
                $scope.dataSourceSample = new kendo.data.DataSource({
                    data: [{
                        "id": 1,
                        "products": "QS3 0.2 ml",
                        "week1": "5",
                        "week2": "5",
                        "week3": "4",
                        "week4": "6",
                        "remarks": "Achieved"

                    }, {
                        "id": 2,
                        "products": "QS3 0.6 ml",
                        "week1": "13",
                        "week2": "14",
                        "week3": "6",
                        "week4": "11",
                        "remarks": "Ahead"

                    }, {
                        "id": 3,
                        "products": "QS5 0.2 ml",
                        "week1": "1",
                        "week2": "2",
                        "week3": "4",
                        "week4": "4",
                        "remarks": "Behind"

                    }, {
                        "id": 2,
                        "products": "QS3 0.6 ml",
                        "week1": "1",
                        "week2": "2",
                        "week3": "4",
                        "week4": "4",
                        "remarks": "Remarks"

                    }],
                    schema: {
                        model: {
                            id: "id",
                            fields: {
                                products: {
                                    type: "string",
                                    editable: true
                                },

                                week1: {
                                    type: "string",
                                    editable: true
                                },
                                week2: {
                                    type: "string",
                                    editable: true
                                },
                                week3: {
                                    type: "string",
                                    editable: true
                                },
                                week4: {
                                    type: "string",
                                    editable: true
                                },
                                remarks: {
                                    type: "string",
                                    editable: true
                                },
                            }
                        }
                    },
                });
                $scope.sampleOptions = {

                    columns: [{
                        field: "products",
                        title: "Prod",
                        // width: 15
                    }, {
                        field: "week1",
                        title: "Week1",
                        // width: 10
                    }, {
                        field: "week2",
                        title: "Week2",
                        // width: 10
                    }, {
                        field: "week3",
                        title: "Week3",
                        // width: 10
                    }, {
                        field: "week4",
                        title: "Week4",
                        // width: 10
                    }, {
                        field: "remarks",
                        title: "Remarks",
                        // width: 15
                    }, {
                        command: [{
                            name: "Delete",
                            imageClass: "k-icon k-i-close",
                            click: function(e) {
                                e.preventDefault();
                                var dataItem = this.dataItem($(e.target).closest("tr"));
                                // if (confirm('Do you really want to delete this record?')) {
                                $scope.dataSourceSample.remove(dataItem);
                                $scope.dataSourceSample.sync();
                                // }
                            }
                        }],
                        title: " ",
                        width: "100px"
                    }],
                    editable: false,
                    save: $scope.onChangeHandler
                };
            }

            function initFourMTable() {
                $scope.fourMDataSource = new kendo.data.DataSource({
                    data: [{
                        id: 1,
                        item: 'Man',
                        yesterday: 'red',
                        today: 'green',
                        remarks: '@modo'
                    }, {
                        id: 2,
                        item: 'Material',
                        yesterday: 'yellow',
                        today: 'green',
                        remarks: '@fat'
                    }, {
                        id: 3,
                        item: 'Machine',
                        yesterday: 'yellow',
                        today: 'green',
                        remarks: '@twitter'
                    }, {
                        id: 4,
                        item: 'Method',
                        yesterday: 'green',
                        today: 'green',
                        remarks: '@twitter'
                    }],
                    schema: {
                        model: {
                            id: "id",
                            fields: {
                                item: {
                                    type: "string",
                                    editable: true
                                },
                                yesterday: {
                                    type: "string",
                                    editable: true
                                },
                                today: {
                                    type: "string",
                                    editable: true
                                },
                                remarks: {
                                    type: "string",
                                    editable: true
                                }
                            }
                        }
                    }
                });
                $scope.trafficLightDataSource = new kendo.data.DataSource({
                    data: [{
                        "text": "red",
                        "value": "red"
                    }, {
                        "text": "yellow",
                        "value": "yellow"
                    }, {
                        "text": "green",
                        "value": "green"
                    }]
                });
                $scope.onDropdownChange4M = function(val) {
                    $scope.trafficStatus = 1;

                };

                $scope.categoryDropDownEditor = function(container, options) {
                    var editor = $('<input kendo-drop-down-list required k-data-text-field="\'text\'" k-data-value-field="\'value\'" k-data-source="trafficLightDataSource" data-bind="value:' + options.field + '"/>')
                        .appendTo(container);
                };
                $scope.fourMOptions = {
                    columns: [{
                        field: "item",
                        title: "#",
                        // width: 15
                    }, {
                        field: "yesterday",
                        title: "Yesterday",
                        template: function(dataItem) {
                            if (dataItem.yesterday === "red") {
                                return "

";
                            }
                            if (dataItem.yesterday === "green") {
                                return "

";
                            }
                            if (dataItem.yesterday === "yellow") {
                                return "

";
                            }
                        },
                        editor: $scope.categoryDropDownEditor,

                        // width: 10
                    }, {
                        field: "today",
                        title: "Today",
                        template: function(dataItem) {
                            if (dataItem.today === "red") {
                                return "

";
                            }
                            if (dataItem.today === "green") {
                                return "

";
                            }
                            if (dataItem.today === "yellow") {
                                return "

";
                            }
                        },
                        editor: $scope.categoryDropDownEditor,
                        // width: 10
                    }, {
                        field: "remarks",
                        title: "Remarks",
                        // width: 10
                    }],
                    editable: false,
                    save: $scope.onChangeHandler4M
                };
            }

            function initIssueTrackerTable() {
                //Ideally Data should come from
                $scope.issueDataSource = new kendo.data.DataSource({
                    data: [{
                        "id": 1,
                        "date": "Fri Mar 30 2012 00:00:00 GMT+0200",
                        "issue": "1",
                        "action": "2",
                        "who": "4",
                        "due": "4",
                        "status": "Behind"

                    }, {
                        "id": 2,
                        "date": "Fri Mar 30 2012 00:00:00 GMT+0200",
                        "issue": "1",
                        "action": "2",
                        "who": "4",
                        "due": "4",
                        "status": "Behind"

                    }, {
                        "id": 3,
                        "date": "Fri Mar 30 2012 00:00:00 GMT+0200",
                        "issue": "1",
                        "action": "2",
                        "who": "4",
                        "due": "4",
                        "status": "Behind"

                    }, {
                        "id": 4,
                        "date": "Fri Mar 30 2012 00:00:00 GMT+0200",
                        "issue": "1",
                        "action": "2",
                        "who": "4",
                        "due": "4",
                        "status": "Behind"

                    }],
                    schema: {
                        model: {
                            id: "id",
                            fields: {
                                date: {
                                    type: "date",
                                    editable: true,

                                },

                                issue: {
                                    type: "string",
                                    editable: true
                                },
                                action: {
                                    type: "string",
                                    editable: true
                                },
                                who: {
                                    type: "string",
                                    editable: true
                                },
                                due: {
                                    type: "string",
                                    editable: true
                                },
                                status: {
                                    type: "string",
                                    editable: true
                                },
                            }
                        }
                    },
                });
                $scope.issueOptions = {

                    columns: [{
                        field: "date",
                        title: "Date",
                        format: "{0:MM-dd-yyyy}"
                        // width: 15
                    }, {
                        field: "issue",
                        title: "Issue/Root cause ",
                        // width: 10
                    }, {
                        field: "action",
                        title: "Action(s)",
                        // width: 10
                    }, {
                        field: "who",
                        title: "Who",
                        // width: 10
                    }, {
                        field: "due",
                        title: "Due",
                        // width: 10
                    }, {
                        field: "status",
                        title: "Staus",
                        // width: 15
                    }, {
                        command: [{
                            name: "Delete",
                            imageClass: "k-icon k-i-close",
                            click: function(e) {
                                e.preventDefault();
                                var dataItem = this.dataItem($(e.target).closest("tr"));
                                //  if (confirm('Do you really want to delete this record?')) {
                                $scope.issueDataSource.remove(dataItem);
                                $scope.issueDataSource.sync();
                                //  }
                            }
                        }],
                        title: " ",
                        width: "100px"
                    }],
                    editable: false,
                    save: $scope.onChangeHandler
                };
            }

            function initTableData() {
                initFPYTable();
                initFourMTable();
                initIssueTrackerTable();

            }
            // initTableData();

            $scope.addIssueRow = function() {
                $scope.issueDataSource.add({

                    "id": 4,
                    "date": "Fri Mar 30 2012 00:00:00 GMT+0200",
                    "issue": "1",
                    "action": "2",
                    "who": "4",
                    "due": "4",
                    "status": "Behind"

                });
                $scope.issueDataSource.sync();

            }

            $scope.addRow = function() {
                $scope.dataSourceSample.add({

                    "id": 12,
                    "products": "New Product",
                    "week1": "0",
                    "week2": "0",
                    "week3": "0",
                    "week4": "0",
                    "remarks": "Remarks"

                });
                $scope.dataSourceSample.sync();

            }
            $scope.getColor = function() {
                if ($scope.outputDaily.target > $scope.outputDaily.today) {
                    return "{color: red;}";
                } else {
                    return "{color: green;}";
                }
            }

            $scope.editTable = function() {
                // 1. output status
                for (var id = $scope.outputDaily.id; id < $scope.outputDaily.id + 3; id++) {
                    var obj = $("#" + id);
                    obj.attr("readOnly", false);
                }
                for (var id = $scope.outputCummulative.id; id < $scope.outputCummulative.id + 3; id++) {
                    var obj = $("#" + id);
                    obj.attr("readOnly", false);
                }

                // flag
                $scope.flagEditShow = !$scope.flagEditShow;
                $scope.flagDoneShow = !$scope.flagDoneShow;

                $scope.sampleOptions.editable = $scope.flagEditShow;
                $scope.issueOptions.editable = $scope.flagEditShow;
                $scope.fourMOptions.editable = $scope.flagEditShow;
                $timeout(function() {
                    $scope.fpyDataGrid.refresh();
                    $scope.issueDataGrid.refresh();
                    $scope.$apply();
                });
            }

            $scope.editDone = function() {
                // 1. output status
                for (var id = $scope.outputDaily.id; id < $scope.outputDaily.id + 3; id++) {
                    var obj = $("#" + id);
                    obj.attr("readOnly", true);
                }
                for (var id = $scope.outputCummulative.id; id < $scope.outputCummulative.id + 3; id++) {
                    var obj = $("#" + id);
                    obj.attr("readOnly", true);
                }

                if (($scope.outputDaily.target > $scope.outputDaily.today)) {
                    $scope.underAcheivedToday = true;
                } else {
                    $scope.underAcheivedToday = false;
                }
                if (($scope.outputDaily.target > $scope.outputDaily.yesterday)) {
                    $scope.underAcheivedYday = true;
                } else {
                    $scope.underAcheivedYday = false;
                }

                // flag
                $scope.flagEditShow = !$scope.flagEditShow;
                $scope.flagDoneShow = !$scope.flagDoneShow;
                $timeout(function() {
                    // initTableData();
                    $scope.$apply();

                });
            }

            $scope.callOnce = function() {

            };
            $timeout(function() {
                initTableData();
                $scope.$apply();
            });
        }
);<commit_msg>changed template of dropdown to colors instead of text<commit_after>'use strict'
/**
 * @ngdoc function
 * @name sbAdminApp.controller:MainCtrl
 * @description
 * # MainCtrl
 * Controller of the sbAdminApp
 */
angular.module('sbAdminApp')
    .controller('TableCtrl',
        function($scope, $timeout) {
            $scope.onChangeHandler4M = function(dataItem) {
                $timeout(function() {
                    $scope.onChangeHandler();
                    $scope.trafficStatus = 0;
                    var data = $scope.fourMDataSource.data();
                    for (var i in data) {
                        if (data[i].today === "red") {
                            $scope.trafficStatus = 2;
                            break;
                        }
                        if (data[i].today === "yellow") {
                            $scope.trafficStatus = 1;
                        }
                    }
                    return;
                });
            }
            $scope.onChangeHandler = function(dataItem) {
                $scope.fpyDataGrid.refresh();
                $scope.issueDataGrid.refresh();
                $scope.fourMDataGrid.refresh();
            }

            $scope.trafficStatus = 0;
            $scope.flagEditShow = false;
            $scope.flagDoneShow = false;
            $scope.outputDaily = {
                id: 10,
                target: '6',
                yesterday: '6',
                today: '6'
            };
            $scope.outputCummulative = {
                id: 20,
                target: '6',
                acheived: '6'
            };
            $scope.underAcheivedToday = false;
            $scope.underAcheivedYday = false;

            function initFPYTable() {
                //Ideally Data should come from
                $scope.dataSourceSample = new kendo.data.DataSource({
                    data: [{
                        "id": 1,
                        "products": "QS3 0.2 ml",
                        "week1": "5",
                        "week2": "5",
                        "week3": "4",
                        "week4": "6",
                        "remarks": "Achieved"

                    }, {
                        "id": 2,
                        "products": "QS3 0.6 ml",
                        "week1": "13",
                        "week2": "14",
                        "week3": "6",
                        "week4": "11",
                        "remarks": "Ahead"

                    }, {
                        "id": 3,
                        "products": "QS5 0.2 ml",
                        "week1": "1",
                        "week2": "2",
                        "week3": "4",
                        "week4": "4",
                        "remarks": "Behind"

                    }, {
                        "id": 2,
                        "products": "QS3 0.6 ml",
                        "week1": "1",
                        "week2": "2",
                        "week3": "4",
                        "week4": "4",
                        "remarks": "Remarks"

                    }],
                    schema: {
                        model: {
                            id: "id",
                            fields: {
                                products: {
                                    type: "string",
                                    editable: true
                                },

                                week1: {
                                    type: "string",
                                    editable: true
                                },
                                week2: {
                                    type: "string",
                                    editable: true
                                },
                                week3: {
                                    type: "string",
                                    editable: true
                                },
                                week4: {
                                    type: "string",
                                    editable: true
                                },
                                remarks: {
                                    type: "string",
                                    editable: true
                                },
                            }
                        }
                    },
                });
                $scope.sampleOptions = {

                    columns: [{
                        field: "products",
                        title: "Prod",
                        // width: 15
                    }, {
                        field: "week1",
                        title: "Week1",
                        // width: 10
                    }, {
                        field: "week2",
                        title: "Week2",
                        // width: 10
                    }, {
                        field: "week3",
                        title: "Week3",
                        // width: 10
                    }, {
                        field: "week4",
                        title: "Week4",
                        // width: 10
                    }, {
                        field: "remarks",
                        title: "Remarks",
                        // width: 15
                    }, {
                        command: [{
                            name: "Delete",
                            imageClass: "k-icon k-i-close",
                            click: function(e) {
                                e.preventDefault();
                                var dataItem = this.dataItem($(e.target).closest("tr"));
                                // if (confirm('Do you really want to delete this record?')) {
                                $scope.dataSourceSample.remove(dataItem);
                                $scope.dataSourceSample.sync();
                                // }
                            }
                        }],
                        title: " ",
                        width: "100px"
                    }],
                    editable: false,
                    save: $scope.onChangeHandler
                };
            }

            function initFourMTable() {
                $scope.fourMDataSource = new kendo.data.DataSource({
                    data: [{
                        id: 1,
                        item: 'Man',
                        yesterday: 'red',
                        today: 'green',
                        remarks: '@modo'
                    }, {
                        id: 2,
                        item: 'Material',
                        yesterday: 'yellow',
                        today: 'green',
                        remarks: '@fat'
                    }, {
                        id: 3,
                        item: 'Machine',
                        yesterday: 'yellow',
                        today: 'green',
                        remarks: '@twitter'
                    }, {
                        id: 4,
                        item: 'Method',
                        yesterday: 'green',
                        today: 'green',
                        remarks: '@twitter'
                    }],
                    schema: {
                        model: {
                            id: "id",
                            fields: {
                                item: {
                                    type: "string",
                                    editable: true
                                },
                                yesterday: {
                                    type: "string",
                                    editable: true
                                },
                                today: {
                                    type: "string",
                                    editable: true
                                },
                                remarks: {
                                    type: "string",
                                    editable: true
                                }
                            }
                        }
                    }
                });
                $scope.trafficLightDataSource = new kendo.data.DataSource({
                    data: [{
                        "text": "

",
                        "value": "red",
                        "color": "red"
                    }, {
                        "text": "yellow",
                        "value": "yellow",
                        "color": "#f0ad4e"
                    }, {
                        "text": "green",
                        "value": "green",
                        "color": "green"
                    }]
                });
                $scope.onDropdownChange4M = function(val) {
                    $scope.trafficStatus = 1;

                };
                $scope.valueTemplate4M = "

";
                $scope.categoryDropDownEditor = function(container, options) {
                    var editor = $('<input kendo-drop-down-list required k-data-text-field="\'text\'" k-data-value-field="\'value\'" k-value-template="valueTemplate4M" k-template="valueTemplate4M" k-data-source="trafficLightDataSource" data-bind="value:' + options.field + '"/>')
                        .appendTo(container);
                };
                $scope.fourMOptions = {
                    columns: [{
                        field: "item",
                        title: "#",
                        // width: 15
                    }, {
                        field: "yesterday",
                        title: "Yesterday",
                        template: function(dataItem) {
                            if (dataItem.yesterday === "red") {
                                return "

";
                            }
                            if (dataItem.yesterday === "green") {
                                return "

";
                            }
                            if (dataItem.yesterday === "yellow") {
                                return "

";
                            }
                        },
                        editor: $scope.categoryDropDownEditor,

                        // width: 10
                    }, {
                        field: "today",
                        title: "Today",
                        template: function(dataItem) {
                            if (dataItem.today === "red") {
                                return "

";
                            }
                            if (dataItem.today === "green") {
                                return "

";
                            }
                            if (dataItem.today === "yellow") {
                                return "

";
                            }
                        },
                        editor: $scope.categoryDropDownEditor,
                        // width: 10
                    }, {
                        field: "remarks",
                        title: "Remarks",
                        // width: 10
                    }],
                    editable: false,
                    save: $scope.onChangeHandler4M
                };
            }

            function initIssueTrackerTable() {
                //Ideally Data should come from
                $scope.issueDataSource = new kendo.data.DataSource({
                    data: [{
                        "id": 1,
                        "date": "Fri Mar 30 2012 00:00:00 GMT+0200",
                        "issue": "1",
                        "action": "2",
                        "who": "4",
                        "due": "4",
                        "status": "Behind"

                    }, {
                        "id": 2,
                        "date": "Fri Mar 30 2012 00:00:00 GMT+0200",
                        "issue": "1",
                        "action": "2",
                        "who": "4",
                        "due": "4",
                        "status": "Behind"

                    }, {
                        "id": 3,
                        "date": "Fri Mar 30 2012 00:00:00 GMT+0200",
                        "issue": "1",
                        "action": "2",
                        "who": "4",
                        "due": "4",
                        "status": "Behind"

                    }, {
                        "id": 4,
                        "date": "Fri Mar 30 2012 00:00:00 GMT+0200",
                        "issue": "1",
                        "action": "2",
                        "who": "4",
                        "due": "4",
                        "status": "Behind"

                    }],
                    schema: {
                        model: {
                            id: "id",
                            fields: {
                                date: {
                                    type: "date",
                                    editable: true,

                                },

                                issue: {
                                    type: "string",
                                    editable: true
                                },
                                action: {
                                    type: "string",
                                    editable: true
                                },
                                who: {
                                    type: "string",
                                    editable: true
                                },
                                due: {
                                    type: "string",
                                    editable: true
                                },
                                status: {
                                    type: "string",
                                    editable: true
                                },
                            }
                        }
                    },
                });
                $scope.issueOptions = {

                    columns: [{
                        field: "date",
                        title: "Date",
                        format: "{0:MM-dd-yyyy}"
                        // width: 15
                    }, {
                        field: "issue",
                        title: "Issue/Root cause ",
                        // width: 10
                    }, {
                        field: "action",
                        title: "Action(s)",
                        // width: 10
                    }, {
                        field: "who",
                        title: "Who",
                        // width: 10
                    }, {
                        field: "due",
                        title: "Due",
                        // width: 10
                    }, {
                        field: "status",
                        title: "Staus",
                        // width: 15
                    }, {
                        command: [{
                            name: "Delete",
                            imageClass: "k-icon k-i-close",
                            click: function(e) {
                                e.preventDefault();
                                var dataItem = this.dataItem($(e.target).closest("tr"));
                                //  if (confirm('Do you really want to delete this record?')) {
                                $scope.issueDataSource.remove(dataItem);
                                $scope.issueDataSource.sync();
                                //  }
                            }
                        }],
                        title: " ",
                        width: "100px"
                    }],
                    editable: false,
                    save: $scope.onChangeHandler
                };
            }

            function initTableData() {
                initFPYTable();
                initFourMTable();
                initIssueTrackerTable();

            }
            // initTableData();

            $scope.addIssueRow = function() {
                $scope.issueDataSource.add({

                    "id": 4,
                    "date": "Fri Mar 30 2012 00:00:00 GMT+0200",
                    "issue": "1",
                    "action": "2",
                    "who": "4",
                    "due": "4",
                    "status": "Behind"

                });
                $scope.issueDataSource.sync();

            }

            $scope.addRow = function() {
                $scope.dataSourceSample.add({

                    "id": 12,
                    "products": "New Product",
                    "week1": "0",
                    "week2": "0",
                    "week3": "0",
                    "week4": "0",
                    "remarks": "Remarks"

                });
                $scope.dataSourceSample.sync();

            }
            $scope.getColor = function() {
                if ($scope.outputDaily.target > $scope.outputDaily.today) {
                    return "{color: red;}";
                } else {
                    return "{color: green;}";
                }
            }

            $scope.editTable = function() {
                // 1. output status
                for (var id = $scope.outputDaily.id; id < $scope.outputDaily.id + 3; id++) {
                    var obj = $("#" + id);
                    obj.attr("readOnly", false);
                }
                for (var id = $scope.outputCummulative.id; id < $scope.outputCummulative.id + 3; id++) {
                    var obj = $("#" + id);
                    obj.attr("readOnly", false);
                }

                // flag
                $scope.flagEditShow = !$scope.flagEditShow;
                $scope.flagDoneShow = !$scope.flagDoneShow;

                $scope.sampleOptions.editable = $scope.flagEditShow;
                $scope.issueOptions.editable = $scope.flagEditShow;
                $scope.fourMOptions.editable = $scope.flagEditShow;
                $timeout(function() {
                    $scope.fpyDataGrid.refresh();
                    $scope.issueDataGrid.refresh();
                    $scope.$apply();
                });
            }

            $scope.editDone = function() {
                // 1. output status
                for (var id = $scope.outputDaily.id; id < $scope.outputDaily.id + 3; id++) {
                    var obj = $("#" + id);
                    obj.attr("readOnly", true);
                }
                for (var id = $scope.outputCummulative.id; id < $scope.outputCummulative.id + 3; id++) {
                    var obj = $("#" + id);
                    obj.attr("readOnly", true);
                }

                if (($scope.outputDaily.target > $scope.outputDaily.today)) {
                    $scope.underAcheivedToday = true;
                } else {
                    $scope.underAcheivedToday = false;
                }
                if (($scope.outputDaily.target > $scope.outputDaily.yesterday)) {
                    $scope.underAcheivedYday = true;
                } else {
                    $scope.underAcheivedYday = false;
                }

                // flag
                $scope.flagEditShow = !$scope.flagEditShow;
                $scope.flagDoneShow = !$scope.flagDoneShow;
                $timeout(function() {
                    // initTableData();
                    $scope.$apply();

                });
            }

            $scope.callOnce = function() {

            };
            $timeout(function() {
                initTableData();
                $scope.$apply();
            });
        }
);<|endoftext|>


<commit_before>(function() {
  'use strict';

  function MinimapController(ol, proj4, SitesService, CamFrustumService, Messagebus, DrivemapService) {
    var me = this;

    var olProjectionCode = 'EPSG:3857';
    var siteProjectionCode = null;

    var vectorSource = new ol.source.GeoJSON({
      projection: olProjectionCode
    });

    var siteStyle = new ol.style.Style({
      stroke: new ol.style.Stroke({
        color: 'yellow',
        width: 10
      }),
      fill: new ol.style.Fill({
        color: 'rgba(255, 255, 0, 0.1)'
      })
    });

    var vectorLayer = new ol.layer.Vector({
      title: 'Sites',
      source: vectorSource,
      style: siteStyle
    });

    var transparentOverlays = new ol.layer.Group({
      'title': 'Overlay maps',
      layers: [
        new ol.layer.Tile({
          title: 'Canina Tavola XXXII',
          visible: false,
          opacity: 0.7,
          source: new ol.source.TileWMS(({
            url: 'http://54.228.203.57:6080/arcgis/services/VIA_APPIA/Historical_maps_Via_Appia/MapServer/WMSServer',
            params: {'LAYERS': 0, 'TRANSPARENT' : true, 'TILED': true}
          }))
        }),
        new ol.layer.Tile({
          title: 'P1050526editCUT3',
          visible: false,
          opacity: 0.7,
          source: new ol.source.TileWMS(({
            url: 'http://54.228.203.57:6080/arcgis/services/VIA_APPIA/Historical_maps_Via_Appia/MapServer/WMSServer',
            params: {'LAYERS': 2, 'TRANSPARENT' : true, 'TILED': true}
          }))
        }),
        new ol.layer.Tile({
          title: 'Pinza',
          visible: false,
          opacity: 0.7,
          source: new ol.source.TileWMS(({
            url: 'http://54.228.203.57:6080/arcgis/services/VIA_APPIA/Historical_maps_Via_Appia/MapServer/WMSServer',
            params: {'LAYERS': 3, 'TRANSPARENT' : true, 'TILED': true}
          }))
        })
      ]
    });

    var baseLayers = new ol.layer.Group({
      'title': 'Base maps',
      layers: [
        new ol.layer.Tile({
          title: 'MapQuest',
          type: 'base',
          visible: true,
          source: new ol.source.MapQuest({
            layer: 'osm'
          })
        }),
        new ol.layer.Tile({
          title: 'Water color',
          type: 'base',
          visible: false,
          source: new ol.source.Stamen({
            layer: 'watercolor'
          })
        }),
        new ol.layer.Tile({
          title: 'OSM',
          type: 'base',
          visible: false,
          source: new ol.source.OSM()
        }),
        new ol.layer.Tile({
          title: 'Satellite',
          type: 'base',
          visible: false,
          source: new ol.source.MapQuest({
            layer: 'sat'
          })
        })
      ]
    });

    var overlayLayers = new ol.layer.Group({
      title: 'Overlays',
      layers: [
        vectorLayer, transparentOverlays
      ]
    });

    this.map = new ol.Map({
      layers: [baseLayers, overlayLayers],
      view: new ol.View({
        center: ol.proj.transform([12.5469185, 41.8286509], 'EPSG:4326', 'EPSG:3857'),
        zoom: 17
      })
    });

    var syncSiteProjectionCode = function() {
      siteProjectionCode = DrivemapService.getCrs();
    };

    DrivemapService.ready.then(syncSiteProjectionCode);

    this.sites2GeoJSON = function(sites) {
      var features = sites.filter(function(site) {
        return 'footprint' in site;
      }).map(function(site) {
        return {
          'type': 'Feature',
          'id': site.id,
          'geometry': {
            'type': 'MultiPolygon',
            'coordinates': site.footprint
          }
        };
      });

      return {
        'type': 'FeatureCollection',
        'features': features,
        'crs': {
          'type': 'name',
          'properties': {
            'name': siteProjectionCode
          }
        }
      };
    };

    this.centerOnVisibleSites = function() {
      var sitesExtent = vectorSource.getExtent();
      me.fitMapToExtent(sitesExtent);
    };

    this.onSitesChanged = function(filtered) {
      var geojson = me.sites2GeoJSON(filtered);
      var featuresArray = vectorSource.readFeatures(geojson);
      vectorSource.clear();
      vectorSource.addFeatures(featuresArray);
      me.centerOnVisibleSites();
    };

    this.sitesChangedListener = function() {
      var sites = SitesService.filtered;
      me.onSitesChanged(sites);
    };

    Messagebus.subscribe('sitesChanged', this.sitesChangedListener);

    // TODO set initial location for the map
    // TODO toggle map on/of

    // setup click on a site
    this.onFeatureClick = function(event) {
      var feature = event.target.item(0);
      var site = SitesService.getById(feature.getId());
      SitesService.selectSite(site);
    };
    this.setupSiteClick = function() {
      var selectClick = new ol.interaction.Select({
        condition: ol.events.condition.click,
        layers: [vectorLayer],
        style: siteStyle
      });
      selectClick.getFeatures().on('add', this.onFeatureClick);
      this.map.addInteraction(selectClick);
    };
    this.setupSiteClick();

    this.onSiteHover = function(feature) {
      var text = feature.getId().toString();
      var siteHightlightedStyle = new ol.style.Style({
        stroke: new ol.style.Stroke({
          color: '#276BE7',
          width: 10
        }),
        fill: new ol.style.Fill({
          color: 'rgba(255, 255, 0, 0.1)'
        }),
        text: new ol.style.Text({
          font: '12px Calibri,sans-serif',
          text: text,
          fill: new ol.style.Fill({
            color: '#ccc'
          }),
          stroke: new ol.style.Stroke({
            color: '#276BE7',
            width: 3
          })
        })
      });
      return [siteHightlightedStyle];
    };

    this.setupSiteHover = function() {
      var siteHover = new ol.interaction.Select({
        condition: ol.events.condition.pointerMove,
        layers: [vectorLayer],
        style: this.onSiteHover
      });
      this.map.addInteraction(siteHover);
    };
    this.setupSiteHover();

    this.setupResizeControl = function() {
      function ResizeControl(optOptions) {
        var options = optOptions || {};

        var button = document.createElement('button');
        button.innerHTML = '';

        var this_ = this;
        var maximized = false;
        var clickOnResize = function() {
          maximized = !maximized;

          if (maximized) {
            this_.getMap().getTarget().classList.add('big-minimap');
            button.innerHTML = '';
          } else {
            this_.getMap().getTarget().classList.remove('big-minimap');
            button.innerHTML = '';
          }
          this_.getMap().updateSize();
          me.centerOnVisibleSites();
        };

        button.addEventListener('click', clickOnResize, false);
        button.addEventListener('touchstart', clickOnResize, false);

        var element = document.createElement('div');
        element.className = 'resize-minimap ol-unselectable ol-control';
        element.appendChild(button);

        ol.control.Control.call(this, {
          element: element,
          target: options.target
        });
      }
      ol.inherits(ResizeControl, ol.control.Control);

      this.map.addControl(new ResizeControl());
    };
    this.setupResizeControl();

    var layerSwitcher = new ol.control.LayerSwitcher({
      tipLabel: 'Legend'
    });
    this.map.addControl(layerSwitcher);

    this.map.addLayer(CamFrustumService.layer);

    this.fitMapToExtent = function(extent) {
      var mapSize = me.map.getSize();
      me.map.getView().fitExtent(extent, mapSize);
    };

    // Possible improvement: http://stackoverflow.com/a/26381201
    this.fitMapToFrustrumAndSearchedSites = function(event, frustum) {
      CamFrustumService.onCameraMove(frustum);

      //Disabled because the interaction was better without this -- Maarten
      /*
      var frustumExtent = CamFrustumService.getExtent();
      if (SitesService.searched) { // searched sites exist
        var sitesExtent = vectorSource.getExtent();
        var combinedExtent = [Math.min(sitesExtent[0], frustumExtent[0]),
          Math.min(sitesExtent[1], frustumExtent[1]),
          Math.max(sitesExtent[2], frustumExtent[2]),
          Math.max(sitesExtent[3], frustumExtent[3])
        ];
        me.fitMapToExtent(combinedExtent);
      } else { // no searched sites
        me.fitMapToExtent(frustumExtent);
      }
      */
    };

    Messagebus.subscribe('cameraMoved', this.fitMapToFrustrumAndSearchedSites);
  }

  angular.module('pattyApp.minimap')
    .controller('MinimapController', MinimapController);
})();
<commit_msg>MapQuest is closed, remove it as basemap, default to osm basemap<commit_after>(function() {
  'use strict';

  function MinimapController(ol, proj4, SitesService, CamFrustumService, Messagebus, DrivemapService) {
    var me = this;

    var olProjectionCode = 'EPSG:3857';
    var siteProjectionCode = null;

    var vectorSource = new ol.source.GeoJSON({
      projection: olProjectionCode
    });

    var siteStyle = new ol.style.Style({
      stroke: new ol.style.Stroke({
        color: 'yellow',
        width: 10
      }),
      fill: new ol.style.Fill({
        color: 'rgba(255, 255, 0, 0.1)'
      })
    });

    var vectorLayer = new ol.layer.Vector({
      title: 'Sites',
      source: vectorSource,
      style: siteStyle
    });

    var transparentOverlays = new ol.layer.Group({
      'title': 'Overlay maps',
      layers: [
        new ol.layer.Tile({
          title: 'Canina Tavola XXXII',
          visible: false,
          opacity: 0.7,
          source: new ol.source.TileWMS(({
            url: 'http://54.228.203.57:6080/arcgis/services/VIA_APPIA/Historical_maps_Via_Appia/MapServer/WMSServer',
            params: {'LAYERS': 0, 'TRANSPARENT' : true, 'TILED': true}
          }))
        }),
        new ol.layer.Tile({
          title: 'P1050526editCUT3',
          visible: false,
          opacity: 0.7,
          source: new ol.source.TileWMS(({
            url: 'http://54.228.203.57:6080/arcgis/services/VIA_APPIA/Historical_maps_Via_Appia/MapServer/WMSServer',
            params: {'LAYERS': 2, 'TRANSPARENT' : true, 'TILED': true}
          }))
        }),
        new ol.layer.Tile({
          title: 'Pinza',
          visible: false,
          opacity: 0.7,
          source: new ol.source.TileWMS(({
            url: 'http://54.228.203.57:6080/arcgis/services/VIA_APPIA/Historical_maps_Via_Appia/MapServer/WMSServer',
            params: {'LAYERS': 3, 'TRANSPARENT' : true, 'TILED': true}
          }))
        })
      ]
    });

    var baseLayers = new ol.layer.Group({
      'title': 'Base maps',
      layers: [
        new ol.layer.Tile({
          title: 'Water color',
          type: 'base',
          visible: false,
          source: new ol.source.Stamen({
            layer: 'watercolor'
          })
        }),
        new ol.layer.Tile({
          title: 'OSM',
          type: 'base',
          visible: true,
          source: new ol.source.OSM()
        })
      ]
    });

    var overlayLayers = new ol.layer.Group({
      title: 'Overlays',
      layers: [
        vectorLayer, transparentOverlays
      ]
    });

    this.map = new ol.Map({
      layers: [baseLayers, overlayLayers],
      view: new ol.View({
        center: ol.proj.transform([12.5469185, 41.8286509], 'EPSG:4326', 'EPSG:3857'),
        zoom: 17
      })
    });

    var syncSiteProjectionCode = function() {
      siteProjectionCode = DrivemapService.getCrs();
    };

    DrivemapService.ready.then(syncSiteProjectionCode);

    this.sites2GeoJSON = function(sites) {
      var features = sites.filter(function(site) {
        return 'footprint' in site;
      }).map(function(site) {
        return {
          'type': 'Feature',
          'id': site.id,
          'geometry': {
            'type': 'MultiPolygon',
            'coordinates': site.footprint
          }
        };
      });

      return {
        'type': 'FeatureCollection',
        'features': features,
        'crs': {
          'type': 'name',
          'properties': {
            'name': siteProjectionCode
          }
        }
      };
    };

    this.centerOnVisibleSites = function() {
      var sitesExtent = vectorSource.getExtent();
      me.fitMapToExtent(sitesExtent);
    };

    this.onSitesChanged = function(filtered) {
      var geojson = me.sites2GeoJSON(filtered);
      var featuresArray = vectorSource.readFeatures(geojson);
      vectorSource.clear();
      vectorSource.addFeatures(featuresArray);
      me.centerOnVisibleSites();
    };

    this.sitesChangedListener = function() {
      var sites = SitesService.filtered;
      me.onSitesChanged(sites);
    };

    Messagebus.subscribe('sitesChanged', this.sitesChangedListener);

    // TODO set initial location for the map
    // TODO toggle map on/of

    // setup click on a site
    this.onFeatureClick = function(event) {
      var feature = event.target.item(0);
      var site = SitesService.getById(feature.getId());
      SitesService.selectSite(site);
    };
    this.setupSiteClick = function() {
      var selectClick = new ol.interaction.Select({
        condition: ol.events.condition.click,
        layers: [vectorLayer],
        style: siteStyle
      });
      selectClick.getFeatures().on('add', this.onFeatureClick);
      this.map.addInteraction(selectClick);
    };
    this.setupSiteClick();

    this.onSiteHover = function(feature) {
      var text = feature.getId().toString();
      var siteHightlightedStyle = new ol.style.Style({
        stroke: new ol.style.Stroke({
          color: '#276BE7',
          width: 10
        }),
        fill: new ol.style.Fill({
          color: 'rgba(255, 255, 0, 0.1)'
        }),
        text: new ol.style.Text({
          font: '12px Calibri,sans-serif',
          text: text,
          fill: new ol.style.Fill({
            color: '#ccc'
          }),
          stroke: new ol.style.Stroke({
            color: '#276BE7',
            width: 3
          })
        })
      });
      return [siteHightlightedStyle];
    };

    this.setupSiteHover = function() {
      var siteHover = new ol.interaction.Select({
        condition: ol.events.condition.pointerMove,
        layers: [vectorLayer],
        style: this.onSiteHover
      });
      this.map.addInteraction(siteHover);
    };
    this.setupSiteHover();

    this.setupResizeControl = function() {
      function ResizeControl(optOptions) {
        var options = optOptions || {};

        var button = document.createElement('button');
        button.innerHTML = '';

        var this_ = this;
        var maximized = false;
        var clickOnResize = function() {
          maximized = !maximized;

          if (maximized) {
            this_.getMap().getTarget().classList.add('big-minimap');
            button.innerHTML = '';
          } else {
            this_.getMap().getTarget().classList.remove('big-minimap');
            button.innerHTML = '';
          }
          this_.getMap().updateSize();
          me.centerOnVisibleSites();
        };

        button.addEventListener('click', clickOnResize, false);
        button.addEventListener('touchstart', clickOnResize, false);

        var element = document.createElement('div');
        element.className = 'resize-minimap ol-unselectable ol-control';
        element.appendChild(button);

        ol.control.Control.call(this, {
          element: element,
          target: options.target
        });
      }
      ol.inherits(ResizeControl, ol.control.Control);

      this.map.addControl(new ResizeControl());
    };
    this.setupResizeControl();

    var layerSwitcher = new ol.control.LayerSwitcher({
      tipLabel: 'Legend'
    });
    this.map.addControl(layerSwitcher);

    this.map.addLayer(CamFrustumService.layer);

    this.fitMapToExtent = function(extent) {
      var mapSize = me.map.getSize();
      me.map.getView().fitExtent(extent, mapSize);
    };

    // Possible improvement: http://stackoverflow.com/a/26381201
    this.fitMapToFrustrumAndSearchedSites = function(event, frustum) {
      CamFrustumService.onCameraMove(frustum);

      //Disabled because the interaction was better without this -- Maarten
      /*
      var frustumExtent = CamFrustumService.getExtent();
      if (SitesService.searched) { // searched sites exist
        var sitesExtent = vectorSource.getExtent();
        var combinedExtent = [Math.min(sitesExtent[0], frustumExtent[0]),
          Math.min(sitesExtent[1], frustumExtent[1]),
          Math.max(sitesExtent[2], frustumExtent[2]),
          Math.max(sitesExtent[3], frustumExtent[3])
        ];
        me.fitMapToExtent(combinedExtent);
      } else { // no searched sites
        me.fitMapToExtent(frustumExtent);
      }
      */
    };

    Messagebus.subscribe('cameraMoved', this.fitMapToFrustrumAndSearchedSites);
  }

  angular.module('pattyApp.minimap')
    .controller('MinimapController', MinimapController);
})();
<|endoftext|>


<commit_before>/**
 * @author: @AngularClass
 */

const webpack = require('webpack');
const helpers = require('./helpers');

/*
 * Webpack Plugins
 */
// problem with copy-webpack-plugin
const AssetsPlugin = require('assets-webpack-plugin');
const NormalModuleReplacementPlugin = require('webpack/lib/NormalModuleReplacementPlugin');
const ContextReplacementPlugin = require('webpack/lib/ContextReplacementPlugin');
const CommonsChunkPlugin = require('webpack/lib/optimize/CommonsChunkPlugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const CheckerPlugin = require('awesome-typescript-loader').CheckerPlugin;
const HtmlElementsPlugin = require('./html-elements-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const LoaderOptionsPlugin = require('webpack/lib/LoaderOptionsPlugin');
const ScriptExtHtmlWebpackPlugin = require('script-ext-html-webpack-plugin');
const ngcWebpack = require('ngc-webpack');

/*
 * Webpack Constants
 */
const HMR = helpers.hasProcessFlag('hot');
const AOT = helpers.hasNpmFlag('aot');
const METADATA = {
  title: '广州APP开发|网站建设|微网站制作|IT开发 - 悦云',
  baseUrl: '/',
  isDevServer: helpers.isWebpackDevServer()
};

/*
 * Webpack configuration
 *
 * See: http://webpack.github.io/docs/configuration.html#cli
 */
module.exports = function (options) {
  isProd = options.env === 'production';
  return {

    /*
     * Cache generated modules and chunks to improve performance for multiple incremental builds.
     * This is enabled by default in watch mode.
     * You can pass false to disable it.
     *
     * See: http://webpack.github.io/docs/configuration.html#cache
     */
    //cache: false,

    /*
     * The entry point for the bundle
     * Our Angular.js app
     *
     * See: http://webpack.github.io/docs/configuration.html#entry
     */
    entry: {

      'polyfills': './src/polyfills.browser.ts',
      'main':      AOT ? './src/main.browser.aot.ts' :
                  './src/main.browser.ts'

    },

    /*
     * Options affecting the resolving of modules.
     *
     * See: http://webpack.github.io/docs/configuration.html#resolve
     */
    resolve: {

      /*
       * An array of extensions that should be used to resolve modules.
       *
       * See: http://webpack.github.io/docs/configuration.html#resolve-extensions
       */
      extensions: ['.ts', '.js', '.json'],

      // An array of directory names to be resolved to the current directory
      modules: [helpers.root('src'), helpers.root('node_modules')],

    },

    /*
     * Options affecting the normal modules.
     *
     * See: http://webpack.github.io/docs/configuration.html#module
     */
    module: {

      rules: [

        /*
         * Typescript loader support for .ts
         *
         * Component Template/Style integration using `angular2-template-loader`
         * Angular 2 lazy loading (async routes) via `ng-router-loader`
         *
         * `ng-router-loader` expects vanilla JavaScript code, not TypeScript code. This is why the
         * order of the loader matter.
         *
         * See: https://github.com/s-panferov/awesome-typescript-loader
         * See: https://github.com/TheLarkInn/angular2-template-loader
         * See: https://github.com/shlomiassaf/ng-router-loader
         */
        {
          test: /\.ts$/,
          use: [
            {
              loader: '@angularclass/hmr-loader',
              options: {
                pretty: !isProd,
                prod: isProd
              }
            },
            { // MAKE SURE TO CHAIN VANILLA JS CODE, I.E. TS COMPILATION OUTPUT.
              loader: 'ng-router-loader',
              options: {
                loader: 'async-import',
                genDir: 'compiled',
                aot: AOT
              }
            },
            {
              loader: 'awesome-typescript-loader',
              options: {
                configFileName: 'tsconfig.webpack.json'
              }
            },
            {
              loader: 'angular2-template-loader'
            }
          ],
          exclude: [/\.(spec|e2e)\.ts$/]
        },

        /*
         * Json loader support for *.json files.
         *
         * See: https://github.com/webpack/json-loader
         */
        {
          test: /\.json$/,
          use: 'json-loader'
        },

        /*
         * to string and css loader support for *.css files (from Angular components)
         * Returns file content as string
         *
         */
        {
          test: /\.css$/,
          use: ['to-string-loader', 'css-loader'],
          exclude: [helpers.root('src', 'styles')]
        },

        /*
         * to string and sass loader support for *.scss files (from Angular components)
         * Returns compiled css content as string
         *
         */
        {
          test: /\.scss$/,
          use: ['to-string-loader', 'css-loader', 'sass-loader'],
          exclude: [helpers.root('src', 'styles')]
        },

        /* Raw loader support for *.html
         * Returns file content as string
         *
         * See: https://github.com/webpack/raw-loader
         */
        {
          test: /\.html$/,
          use: 'raw-loader',
          exclude: [helpers.root('src/index.html')]
        },

        /*
         * File loader for supporting images, for example, in CSS files.
         */
        {
          test: /\.(jpg|png|gif)$/,
          use: 'file-loader'
        },

        /* File loader for supporting fonts, for example, in CSS files.
        */
        {
          test: /\.(eot|woff2?|svg|ttf)([\?]?.*)$/,
          use: 'file-loader'
        }

      ],

    },

    /*
     * Add additional plugins to the compiler.
     *
     * See: http://webpack.github.io/docs/configuration.html#plugins
     */
    plugins: [
      new AssetsPlugin({
        path: helpers.root('dist'),
        filename: 'webpack-assets.json',
        prettyPrint: true
      }),

      /*
       * Plugin: ForkCheckerPlugin
       * Description: Do type checking in a separate process, so webpack don't need to wait.
       *
       * See: https://github.com/s-panferov/awesome-typescript-loader#forkchecker-boolean-defaultfalse
       */
      new CheckerPlugin(),
      /*
       * Plugin: CommonsChunkPlugin
       * Description: Shares common code between the pages.
       * It identifies common modules and put them into a commons chunk.
       *
       * See: https://webpack.github.io/docs/list-of-plugins.html#commonschunkplugin
       * See: https://github.com/webpack/docs/wiki/optimization#multi-page-app
       */
      new CommonsChunkPlugin({
        name: 'polyfills',
        chunks: ['polyfills']
      }),
      // This enables tree shaking of the vendor modules
      new CommonsChunkPlugin({
        name: 'vendor',
        chunks: ['main'],
        minChunks: module => /node_modules/.test(module.resource)
      }),
      // Specify the correct order the scripts will be injected in
      new CommonsChunkPlugin({
        name: ['polyfills', 'vendor'].reverse()
      }),

      /**
       * Plugin: ContextReplacementPlugin
       * Description: Provides context to Angular's use of System.import
       *
       * See: https://webpack.github.io/docs/list-of-plugins.html#contextreplacementplugin
       * See: https://github.com/angular/angular/issues/11580
       */
      new ContextReplacementPlugin(
        // The (\\|\/) piece accounts for path separators in *nix and Windows
        /angular(\\|\/)core(\\|\/)src(\\|\/)linker/,
        helpers.root('src'), // location of your src
        {
          // your Angular Async Route paths relative to this root directory
        }
      ),

      /*
       * Plugin: CopyWebpackPlugin
       * Description: Copy files and directories in webpack.
       *
       * Copies project static assets.
       *
       * See: https://www.npmjs.com/package/copy-webpack-plugin
       */
      new CopyWebpackPlugin([
        { from: 'src/assets', to: 'assets' },
        { from: 'src/meta'}
      ]),

      /*
       * Plugin: HtmlWebpackPlugin
       * Description: Simplifies creation of HTML files to serve your webpack bundles.
       * This is especially useful for webpack bundles that include a hash in the filename
       * which changes every compilation.
       *
       * See: https://github.com/ampedandwired/html-webpack-plugin
       */
      new HtmlWebpackPlugin({
        template: 'src/index.html',
        title: METADATA.title,
        chunksSortMode: 'dependency',
        metadata: METADATA,
        inject: 'head'
      }),

      /*
       * Plugin: ScriptExtHtmlWebpackPlugin
       * Description: Enhances html-webpack-plugin functionality
       * with different deployment options for your scripts including:
       *
       * See: https://github.com/numical/script-ext-html-webpack-plugin
       */
      new ScriptExtHtmlWebpackPlugin({
        defaultAttribute: 'defer'
      }),

      /*
       * Plugin: HtmlElementsPlugin
       * Description: Generate html tags based on javascript maps.
       *
       * If a publicPath is set in the webpack output configuration, it will be automatically added to
       * href attributes, you can disable that by adding a "=href": false property.
       * You can also enable it to other attribute by settings "=attName": true.
       *
       * The configuration supplied is map between a location (key) and an element definition object (value)
       * The location (key) is then exported to the template under then htmlElements property in webpack configuration.
       *
       * Example:
       *  Adding this plugin configuration
       *  new HtmlElementsPlugin({
       *    headTags: { ... }
       *  })
       *
       *  Means we can use it in the template like this:
       *  <%= webpackConfig.htmlElements.headTags %>
       *
       * Dependencies: HtmlWebpackPlugin
       */
      new HtmlElementsPlugin({
        headTags: require('./head-config.common')
      }),

      /**
       * Plugin LoaderOptionsPlugin (experimental)
       *
       * See: https://gist.github.com/sokra/27b24881210b56bbaff7
       */
      new LoaderOptionsPlugin({}),

      // Fix Angular 2
      new NormalModuleReplacementPlugin(
        /facade(\\|\/)async/,
        helpers.root('node_modules/@angular/core/src/facade/async.js')
      ),
      new NormalModuleReplacementPlugin(
        /facade(\\|\/)collection/,
        helpers.root('node_modules/@angular/core/src/facade/collection.js')
      ),
      new NormalModuleReplacementPlugin(
        /facade(\\|\/)errors/,
        helpers.root('node_modules/@angular/core/src/facade/errors.js')
      ),
      new NormalModuleReplacementPlugin(
        /facade(\\|\/)lang/,
        helpers.root('node_modules/@angular/core/src/facade/lang.js')
      ),
      new NormalModuleReplacementPlugin(
        /facade(\\|\/)math/,
        helpers.root('node_modules/@angular/core/src/facade/math.js')
      ),

      new ngcWebpack.NgcWebpackPlugin({
        disabled: !AOT,
        tsConfig: helpers.root('tsconfig.webpack.json'),
        resourceOverride: helpers.root('config/resource-override.js')
      })

    ],

    /*
     * Include polyfills or mocks for various node stuff
     * Description: Node configuration
     *
     * See: https://webpack.github.io/docs/configuration.html#node
     */
    node: {
      global: true,
      crypto: 'empty',
      process: true,
      module: false,
      clearImmediate: false,
      setImmediate: false
    }

  };
}
<commit_msg>copy download.html<commit_after>/**
 * @author: @AngularClass
 */

const webpack = require('webpack');
const helpers = require('./helpers');

/*
 * Webpack Plugins
 */
// problem with copy-webpack-plugin
const AssetsPlugin = require('assets-webpack-plugin');
const NormalModuleReplacementPlugin = require('webpack/lib/NormalModuleReplacementPlugin');
const ContextReplacementPlugin = require('webpack/lib/ContextReplacementPlugin');
const CommonsChunkPlugin = require('webpack/lib/optimize/CommonsChunkPlugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const CheckerPlugin = require('awesome-typescript-loader').CheckerPlugin;
const HtmlElementsPlugin = require('./html-elements-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const LoaderOptionsPlugin = require('webpack/lib/LoaderOptionsPlugin');
const ScriptExtHtmlWebpackPlugin = require('script-ext-html-webpack-plugin');
const ngcWebpack = require('ngc-webpack');

/*
 * Webpack Constants
 */
const HMR = helpers.hasProcessFlag('hot');
const AOT = helpers.hasNpmFlag('aot');
const METADATA = {
  title: '广州APP开发|网站建设|微网站制作|IT开发 - 悦云',
  baseUrl: '/',
  isDevServer: helpers.isWebpackDevServer()
};

/*
 * Webpack configuration
 *
 * See: http://webpack.github.io/docs/configuration.html#cli
 */
module.exports = function (options) {
  isProd = options.env === 'production';
  return {

    /*
     * Cache generated modules and chunks to improve performance for multiple incremental builds.
     * This is enabled by default in watch mode.
     * You can pass false to disable it.
     *
     * See: http://webpack.github.io/docs/configuration.html#cache
     */
    //cache: false,

    /*
     * The entry point for the bundle
     * Our Angular.js app
     *
     * See: http://webpack.github.io/docs/configuration.html#entry
     */
    entry: {

      'polyfills': './src/polyfills.browser.ts',
      'main':      AOT ? './src/main.browser.aot.ts' :
                  './src/main.browser.ts'

    },

    /*
     * Options affecting the resolving of modules.
     *
     * See: http://webpack.github.io/docs/configuration.html#resolve
     */
    resolve: {

      /*
       * An array of extensions that should be used to resolve modules.
       *
       * See: http://webpack.github.io/docs/configuration.html#resolve-extensions
       */
      extensions: ['.ts', '.js', '.json'],

      // An array of directory names to be resolved to the current directory
      modules: [helpers.root('src'), helpers.root('node_modules')],

    },

    /*
     * Options affecting the normal modules.
     *
     * See: http://webpack.github.io/docs/configuration.html#module
     */
    module: {

      rules: [

        /*
         * Typescript loader support for .ts
         *
         * Component Template/Style integration using `angular2-template-loader`
         * Angular 2 lazy loading (async routes) via `ng-router-loader`
         *
         * `ng-router-loader` expects vanilla JavaScript code, not TypeScript code. This is why the
         * order of the loader matter.
         *
         * See: https://github.com/s-panferov/awesome-typescript-loader
         * See: https://github.com/TheLarkInn/angular2-template-loader
         * See: https://github.com/shlomiassaf/ng-router-loader
         */
        {
          test: /\.ts$/,
          use: [
            {
              loader: '@angularclass/hmr-loader',
              options: {
                pretty: !isProd,
                prod: isProd
              }
            },
            { // MAKE SURE TO CHAIN VANILLA JS CODE, I.E. TS COMPILATION OUTPUT.
              loader: 'ng-router-loader',
              options: {
                loader: 'async-import',
                genDir: 'compiled',
                aot: AOT
              }
            },
            {
              loader: 'awesome-typescript-loader',
              options: {
                configFileName: 'tsconfig.webpack.json'
              }
            },
            {
              loader: 'angular2-template-loader'
            }
          ],
          exclude: [/\.(spec|e2e)\.ts$/]
        },

        /*
         * Json loader support for *.json files.
         *
         * See: https://github.com/webpack/json-loader
         */
        {
          test: /\.json$/,
          use: 'json-loader'
        },

        /*
         * to string and css loader support for *.css files (from Angular components)
         * Returns file content as string
         *
         */
        {
          test: /\.css$/,
          use: ['to-string-loader', 'css-loader'],
          exclude: [helpers.root('src', 'styles')]
        },

        /*
         * to string and sass loader support for *.scss files (from Angular components)
         * Returns compiled css content as string
         *
         */
        {
          test: /\.scss$/,
          use: ['to-string-loader', 'css-loader', 'sass-loader'],
          exclude: [helpers.root('src', 'styles')]
        },

        /* Raw loader support for *.html
         * Returns file content as string
         *
         * See: https://github.com/webpack/raw-loader
         */
        {
          test: /\.html$/,
          use: 'raw-loader',
          exclude: [helpers.root('src/index.html')]
        },

        /*
         * File loader for supporting images, for example, in CSS files.
         */
        {
          test: /\.(jpg|png|gif)$/,
          use: 'file-loader'
        },

        /* File loader for supporting fonts, for example, in CSS files.
        */
        {
          test: /\.(eot|woff2?|svg|ttf)([\?]?.*)$/,
          use: 'file-loader'
        }

      ],

    },

    /*
     * Add additional plugins to the compiler.
     *
     * See: http://webpack.github.io/docs/configuration.html#plugins
     */
    plugins: [
      new AssetsPlugin({
        path: helpers.root('dist'),
        filename: 'webpack-assets.json',
        prettyPrint: true
      }),

      /*
       * Plugin: ForkCheckerPlugin
       * Description: Do type checking in a separate process, so webpack don't need to wait.
       *
       * See: https://github.com/s-panferov/awesome-typescript-loader#forkchecker-boolean-defaultfalse
       */
      new CheckerPlugin(),
      /*
       * Plugin: CommonsChunkPlugin
       * Description: Shares common code between the pages.
       * It identifies common modules and put them into a commons chunk.
       *
       * See: https://webpack.github.io/docs/list-of-plugins.html#commonschunkplugin
       * See: https://github.com/webpack/docs/wiki/optimization#multi-page-app
       */
      new CommonsChunkPlugin({
        name: 'polyfills',
        chunks: ['polyfills']
      }),
      // This enables tree shaking of the vendor modules
      new CommonsChunkPlugin({
        name: 'vendor',
        chunks: ['main'],
        minChunks: module => /node_modules/.test(module.resource)
      }),
      // Specify the correct order the scripts will be injected in
      new CommonsChunkPlugin({
        name: ['polyfills', 'vendor'].reverse()
      }),

      /**
       * Plugin: ContextReplacementPlugin
       * Description: Provides context to Angular's use of System.import
       *
       * See: https://webpack.github.io/docs/list-of-plugins.html#contextreplacementplugin
       * See: https://github.com/angular/angular/issues/11580
       */
      new ContextReplacementPlugin(
        // The (\\|\/) piece accounts for path separators in *nix and Windows
        /angular(\\|\/)core(\\|\/)src(\\|\/)linker/,
        helpers.root('src'), // location of your src
        {
          // your Angular Async Route paths relative to this root directory
        }
      ),

      /*
       * Plugin: CopyWebpackPlugin
       * Description: Copy files and directories in webpack.
       *
       * Copies project static assets.
       *
       * See: https://www.npmjs.com/package/copy-webpack-plugin
       */
      new CopyWebpackPlugin([
        { from: 'src/assets', to: 'assets' },
        { from: 'src/dowload.html'},
        { from: 'src/meta'}
      ]),

      /*
       * Plugin: HtmlWebpackPlugin
       * Description: Simplifies creation of HTML files to serve your webpack bundles.
       * This is especially useful for webpack bundles that include a hash in the filename
       * which changes every compilation.
       *
       * See: https://github.com/ampedandwired/html-webpack-plugin
       */
      new HtmlWebpackPlugin({
        template: 'src/index.html',
        title: METADATA.title,
        chunksSortMode: 'dependency',
        metadata: METADATA,
        inject: 'head'
      }),

      /*
       * Plugin: ScriptExtHtmlWebpackPlugin
       * Description: Enhances html-webpack-plugin functionality
       * with different deployment options for your scripts including:
       *
       * See: https://github.com/numical/script-ext-html-webpack-plugin
       */
      new ScriptExtHtmlWebpackPlugin({
        defaultAttribute: 'defer'
      }),

      /*
       * Plugin: HtmlElementsPlugin
       * Description: Generate html tags based on javascript maps.
       *
       * If a publicPath is set in the webpack output configuration, it will be automatically added to
       * href attributes, you can disable that by adding a "=href": false property.
       * You can also enable it to other attribute by settings "=attName": true.
       *
       * The configuration supplied is map between a location (key) and an element definition object (value)
       * The location (key) is then exported to the template under then htmlElements property in webpack configuration.
       *
       * Example:
       *  Adding this plugin configuration
       *  new HtmlElementsPlugin({
       *    headTags: { ... }
       *  })
       *
       *  Means we can use it in the template like this:
       *  <%= webpackConfig.htmlElements.headTags %>
       *
       * Dependencies: HtmlWebpackPlugin
       */
      new HtmlElementsPlugin({
        headTags: require('./head-config.common')
      }),

      /**
       * Plugin LoaderOptionsPlugin (experimental)
       *
       * See: https://gist.github.com/sokra/27b24881210b56bbaff7
       */
      new LoaderOptionsPlugin({}),

      // Fix Angular 2
      new NormalModuleReplacementPlugin(
        /facade(\\|\/)async/,
        helpers.root('node_modules/@angular/core/src/facade/async.js')
      ),
      new NormalModuleReplacementPlugin(
        /facade(\\|\/)collection/,
        helpers.root('node_modules/@angular/core/src/facade/collection.js')
      ),
      new NormalModuleReplacementPlugin(
        /facade(\\|\/)errors/,
        helpers.root('node_modules/@angular/core/src/facade/errors.js')
      ),
      new NormalModuleReplacementPlugin(
        /facade(\\|\/)lang/,
        helpers.root('node_modules/@angular/core/src/facade/lang.js')
      ),
      new NormalModuleReplacementPlugin(
        /facade(\\|\/)math/,
        helpers.root('node_modules/@angular/core/src/facade/math.js')
      ),

      new ngcWebpack.NgcWebpackPlugin({
        disabled: !AOT,
        tsConfig: helpers.root('tsconfig.webpack.json'),
        resourceOverride: helpers.root('config/resource-override.js')
      })

    ],

    /*
     * Include polyfills or mocks for various node stuff
     * Description: Node configuration
     *
     * See: https://webpack.github.io/docs/configuration.html#node
     */
    node: {
      global: true,
      crypto: 'empty',
      process: true,
      module: false,
      clearImmediate: false,
      setImmediate: false
    }

  };
}
<|endoftext|>


<commit_before>const webpack                      = require('webpack');
const DefinePlugin                 = require('webpack/lib/DefinePlugin');
const ProvidePlugin                = require('webpack/lib/ProvidePlugin');
const OccurrenceOrderPlugin        = require('webpack/lib/optimize/OccurrenceOrderPlugin');
const LoaderOptionsPlugin          = require('webpack/lib/LoaderOptionsPlugin');
const ContextReplacementPlugin     = require('webpack/lib/ContextReplacementPlugin');
const CopyWebpackPlugin            = require('copy-webpack-plugin');

const HtmlWebpackPlugin            = require('html-webpack-plugin');
const ExtractTextPlugin            = require('extract-text-webpack-plugin');
const ManifestPlugin               = require('webpack-manifest-plugin');
const InlineManifestWebpackPlugin  = require('inline-manifest-webpack-plugin');
const autoprefixer                 = require('autoprefixer');

const helpers                      = require('./helpers');
const TITLE                        = 'My MEAN Website';
const TITLE_ADMIN                  = 'Admin My MEAN Website';
const TEMPLATE_PATH                = './src/index.ejs';
const TEMPLATE_ADMIN_PATH          = './src/admin.ejs';
const TEMPLATE_HTML                = 'index.html';
const TEMPLATE_ADMIN_HTML          = 'admin.html';

module.exports = {
  entry: {
    polyfills: './src/polyfills.ts',
    vendor: './src/vendor.ts',
    app: './src/main.ts',
    admin: './src/admin.ts'
  },
  resolve: {
    descriptionFiles: ['package.json'],
    extensions: ['.ts', '.js', '.css', '.scss', 'json', '.html']
  },
  module: {
    rules: [
      {
        enforce: 'pre',
        test: /\.ts$/,
        loader: 'tslint-loader',
        exclude: [/\.(spec|e2e)\.ts$/, /node_modules/]
      },
      {
        test: /\.ts$/,
        loaders: [
          'awesome-typescript-loader',
          'angular2-template-loader'
        ],
        exclude: [/\.(spec|e2e)\.ts$/]
      },
      {
        test: /\.html$/,
        loader: 'raw-loader'
      },
      {
        test: /\.css$/,
        exclude: [helpers.root('src', 'app'), helpers.root('src', 'admin')],
        loader: ExtractTextPlugin
          .extract({
              fallbackLoader: "style-loader",
              loader: ['css-loader', 'postcss-loader']
          })
      },
      {
        test: /\.css$/,
        include: [helpers.root('src', 'app'), helpers.root('src', 'admin')],
        loader: 'raw-loader!postcss-loader'
      },
      {
        test: /\.scss$/,
        exclude: /node_modules/,
        loaders: ['raw-loader', 'sass-loader']
      },
      {
        test: /\.json$/,
        loader: 'json-loader'
      },
      {
        test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/,
        loader: "url-loader?limit=10000&mimetype=application/font-woff"
      },
      {
        test: /\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
        loader: "file-loader"
      },
      // Bootstrap 4
      { test: /bootstrap\/dist\/js\/umd\//, loader: 'imports?jQuery=jquery' }
    ],
    noParse: [/node_modules\/@angular\/\*\*\/bundles\//]
  },
  plugins: [
    new ManifestPlugin(), // TODO check if I can remove this
    new InlineManifestWebpackPlugin(), // TODO check if I can remove this
    new HtmlWebpackPlugin({
      title: TITLE,
      inject: true,
      // chunksSortMode: 'auto', // auto is the default value
      chunks: ['polyfills', 'vendor', 'app'],
      template: TEMPLATE_PATH,
      filename: TEMPLATE_HTML
    }),
    new HtmlWebpackPlugin({
      title: TITLE_ADMIN,
      inject: true,
      chunksSortMode: function (chunk1, chunk2) {
        let orders = ['polyfills', 'vendor', 'admin'];
        let order1 = orders.indexOf(chunk1.names[0]);
        let order2 = orders.indexOf(chunk2.names[0]);
        if (order1 > order2) {
          return 1;
        } else if (order1 < order2) {
          return -1;
        } else {
          return 0;
        }
      },
      chunks: ['polyfills', 'vendor', 'admin'],
      template: TEMPLATE_ADMIN_PATH,
      filename: TEMPLATE_ADMIN_HTML
    }),
    new OccurrenceOrderPlugin(true),
    new ProvidePlugin({
      jQuery: 'jquery',
      jquery: 'jquery',
      $: 'jquery',
      "Tether": 'tether',
      "window.Tether": "tether",
      //---------------------------------------------------
      //------------- temporary workaround ----------------
      // https://github.com/shakacode/bootstrap-loader/issues/172#issuecomment-247205500
      //this requires exports-loader installed from npm
      Tooltip: "exports-loader?Tooltip!bootstrap/js/dist/tooltip",
      Alert: "exports-loader?Alert!bootstrap/js/dist/alert",
      Button: "exports-loader?Button!bootstrap/js/dist/button",
      Carousel: "exports-loader?Carousel!bootstrap/js/dist/carousel",
      Collapse: "exports-loader?Collapse!bootstrap/js/dist/collapse",
      Dropdown: "exports-loader?Dropdown!bootstrap/js/dist/dropdown",
      Modal: "exports-loader?Modal!bootstrap/js/dist/modal",
      Popover: "exports-loader?Popover!bootstrap/js/dist/popover",
      Scrollspy: "exports-loader?Scrollspy!bootstrap/js/dist/scrollspy",
      Tab: "exports-loader?Tab!bootstrap/js/dist/tab",
      Util: "exports-loader?Util!bootstrap/js/dist/util"
      //---------------------------------------------------
    }),
    new CopyWebpackPlugin([{from: './assets', to: './assets'}]),
    new ContextReplacementPlugin(
      // The (\\|\/) piece accounts for path separators in *nix and Windows
      /angular(\\|\/)core(\\|\/)(esm(\\|\/)src|src)(\\|\/)linker/,
      helpers.root('./src') // location of your src
    ),
    new LoaderOptionsPlugin({
      debug: true,
      options: {
        context: __dirname,
        output: { path :  './' },
        postcss: [autoprefixer],
        tslint: {
          emitErrors: false,
          failOnHint: false,
          resourcePath: helpers.root('./src'),
          formattersDirectory: "./node_modules/tslint-loader/formatters/"
        }
      }
    })
  ],
  node: {
    global: true,
    process: true,
    Buffer: false,
    crypto: 'empty',
    module: false,
    clearImmediate: false,
    setImmediate: false,
    clearTimeout: true,
    setTimeout: true
  }
};
<commit_msg>fixed noParse regex #19<commit_after>const webpack                      = require('webpack');
const DefinePlugin                 = require('webpack/lib/DefinePlugin');
const ProvidePlugin                = require('webpack/lib/ProvidePlugin');
const OccurrenceOrderPlugin        = require('webpack/lib/optimize/OccurrenceOrderPlugin');
const LoaderOptionsPlugin          = require('webpack/lib/LoaderOptionsPlugin');
const ContextReplacementPlugin     = require('webpack/lib/ContextReplacementPlugin');
const CopyWebpackPlugin            = require('copy-webpack-plugin');

const HtmlWebpackPlugin            = require('html-webpack-plugin');
const ExtractTextPlugin            = require('extract-text-webpack-plugin');
const ManifestPlugin               = require('webpack-manifest-plugin');
const InlineManifestWebpackPlugin  = require('inline-manifest-webpack-plugin');
const autoprefixer                 = require('autoprefixer');

const helpers                      = require('./helpers');
const TITLE                        = 'My MEAN Website';
const TITLE_ADMIN                  = 'Admin My MEAN Website';
const TEMPLATE_PATH                = './src/index.ejs';
const TEMPLATE_ADMIN_PATH          = './src/admin.ejs';
const TEMPLATE_HTML                = 'index.html';
const TEMPLATE_ADMIN_HTML          = 'admin.html';

module.exports = {
  entry: {
    polyfills: './src/polyfills.ts',
    vendor: './src/vendor.ts',
    app: './src/main.ts',
    admin: './src/admin.ts'
  },
  resolve: {
    descriptionFiles: ['package.json'],
    extensions: ['.ts', '.js', '.css', '.scss', 'json', '.html']
  },
  module: {
    rules: [
      {
        enforce: 'pre',
        test: /\.ts$/,
        loader: 'tslint-loader',
        exclude: [/\.(spec|e2e)\.ts$/, /node_modules/]
      },
      {
        test: /\.ts$/,
        loaders: [
          'awesome-typescript-loader',
          'angular2-template-loader'
        ],
        exclude: [/\.(spec|e2e)\.ts$/]
      },
      {
        test: /\.html$/,
        loader: 'raw-loader'
      },
      {
        test: /\.css$/,
        exclude: [helpers.root('src', 'app'), helpers.root('src', 'admin')],
        loader: ExtractTextPlugin
          .extract({
              fallbackLoader: "style-loader",
              loader: ['css-loader', 'postcss-loader']
          })
      },
      {
        test: /\.css$/,
        include: [helpers.root('src', 'app'), helpers.root('src', 'admin')],
        loader: 'raw-loader!postcss-loader'
      },
      {
        test: /\.scss$/,
        exclude: /node_modules/,
        loaders: ['raw-loader', 'sass-loader']
      },
      {
        test: /\.json$/,
        loader: 'json-loader'
      },
      {
        test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/,
        loader: "url-loader?limit=10000&mimetype=application/font-woff"
      },
      {
        test: /\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
        loader: "file-loader"
      },
      // Bootstrap 4
      { test: /bootstrap\/dist\/js\/umd\//, loader: 'imports?jQuery=jquery' }
    ],
    noParse: [/node_modules\/@angular\/\*\*\/bundles\//,
              /@angular\/\*\*\/bundles\//]
  },
  plugins: [
    new ManifestPlugin(), // TODO check if I can remove this
    new InlineManifestWebpackPlugin(), // TODO check if I can remove this
    new HtmlWebpackPlugin({
      title: TITLE,
      inject: true,
      // chunksSortMode: 'auto', // auto is the default value
      chunks: ['polyfills', 'vendor', 'app'],
      template: TEMPLATE_PATH,
      filename: TEMPLATE_HTML
    }),
    new HtmlWebpackPlugin({
      title: TITLE_ADMIN,
      inject: true,
      chunksSortMode: function (chunk1, chunk2) {
        let orders = ['polyfills', 'vendor', 'admin'];
        let order1 = orders.indexOf(chunk1.names[0]);
        let order2 = orders.indexOf(chunk2.names[0]);
        if (order1 > order2) {
          return 1;
        } else if (order1 < order2) {
          return -1;
        } else {
          return 0;
        }
      },
      chunks: ['polyfills', 'vendor', 'admin'],
      template: TEMPLATE_ADMIN_PATH,
      filename: TEMPLATE_ADMIN_HTML
    }),
    new OccurrenceOrderPlugin(true),
    new ProvidePlugin({
      jQuery: 'jquery',
      jquery: 'jquery',
      $: 'jquery',
      "Tether": 'tether',
      "window.Tether": "tether",
      //---------------------------------------------------
      //------------- temporary workaround ----------------
      // https://github.com/shakacode/bootstrap-loader/issues/172#issuecomment-247205500
      //this requires exports-loader installed from npm
      Tooltip: "exports-loader?Tooltip!bootstrap/js/dist/tooltip",
      Alert: "exports-loader?Alert!bootstrap/js/dist/alert",
      Button: "exports-loader?Button!bootstrap/js/dist/button",
      Carousel: "exports-loader?Carousel!bootstrap/js/dist/carousel",
      Collapse: "exports-loader?Collapse!bootstrap/js/dist/collapse",
      Dropdown: "exports-loader?Dropdown!bootstrap/js/dist/dropdown",
      Modal: "exports-loader?Modal!bootstrap/js/dist/modal",
      Popover: "exports-loader?Popover!bootstrap/js/dist/popover",
      Scrollspy: "exports-loader?Scrollspy!bootstrap/js/dist/scrollspy",
      Tab: "exports-loader?Tab!bootstrap/js/dist/tab",
      Util: "exports-loader?Util!bootstrap/js/dist/util"
      //---------------------------------------------------
    }),
    new CopyWebpackPlugin([{from: './assets', to: './assets'}]),
    new ContextReplacementPlugin(
      // The (\\|\/) piece accounts for path separators in *nix and Windows
      /angular(\\|\/)core(\\|\/)(esm(\\|\/)src|src)(\\|\/)linker/,
      helpers.root('./src') // location of your src
    ),
    new LoaderOptionsPlugin({
      debug: true,
      options: {
        context: __dirname,
        output: { path :  './' },
        postcss: [autoprefixer],
        tslint: {
          emitErrors: false,
          failOnHint: false,
          resourcePath: helpers.root('./src'),
          formattersDirectory: "./node_modules/tslint-loader/formatters/"
        }
      }
    })
  ],
  node: {
    global: true,
    process: true,
    Buffer: false,
    crypto: 'empty',
    module: false,
    clearImmediate: false,
    setImmediate: false,
    clearTimeout: true,
    setTimeout: true
  }
};
<|endoftext|>


<commit_before>const path = require('path');
const FaviconsWebpackPlugin = require('favicons-webpack-plugin');
const Dotenv = require('dotenv-webpack');
require('dotenv').config();

module.exports = (env) => {
  const environment = (env && env.NODE_ENV) ?
    env.NODE_ENV.toLocaleLowerCase() : 'development';
  return {
    entry: {
      main: ['react-hot-loader/patch', path.resolve(__dirname, '../../src/index.jsx')],
      polyfills: path.resolve(__dirname, './polyfills.js'),
    },
    devtool: 'cheap-source-map',
    plugins: [
      new FaviconsWebpackPlugin({
        logo: path.resolve(__dirname, '../../assets/logo.png'),
        prefix: 'icons/[hash]/',
        emitStats: false,
        statsFilename: 'icons/stats-[hash].json',
        persistentCache: true,
        inject: true,
        background: '#fff',
        title: 'Antonios Karagiannis',
        // @see https://github.com/haydenbleasel/favicons#usage
        icons: {
          android: true,
          appleIcon: true,
          appleStartup: true,
          coast: false,
          favicons: true,
          firefox: true,
          opengraph: true,
          twitter: true,
          yandex: false,
          windows: false,
        },
      }),
      new Dotenv({
        path: path.resolve(__dirname, '../../.env'),
        safe: false,
        systemvars: true,
      }),
    ],
    output: {
      filename: '[name].bundle.js',
      path: path.resolve(__dirname, '../../dist'),
    },
    resolve: {
      extensions: ['.js', '.json', '.jsx'],
      alias: {
        Assets: path.resolve(__dirname, '../assets/'),
        Actions: path.resolve(__dirname, '../../src/actions/'),
        Components: path.resolve(__dirname, '../../src/components/'),
        Constants: path.resolve(__dirname, '../../src/constants/'),
        Containers: path.resolve(__dirname, '../../src/containers/'),
        Helpers: path.resolve(__dirname, '../../src/helpers/'),
        Reducers: path.resolve(__dirname, '../../src/reducers/'),
        ReduxLogger$: (environment !== 'production' ?
          'redux-logger' : path.resolve(__dirname, '../../src/helpers/empty.js')),
        ReduxDevtoolsExtension$: (environment !== 'production' ?
          'redux-devtools-extension' : path.resolve(__dirname, '../../src/helpers/empty.js')),
      },
    },
    module: {
      rules: [
        {
          test: /\.jsx?$/,
          enforce: 'pre',
          exclude: /(node_modules|bower_components)/,
          loader: 'eslint-loader',
          options: {
            cache: true,
            emitError: true,
            failOnWarning: environment !== 'development',
            failOnError: environment !== 'development',
            // Unfortunately, some config options must be duplicated here
            // even though they are defined within package.json[eslintConfig]
            // which is what IDEs use to configure ESLint but this one
            // uses the CLIEngine options instead...
            // @see https://github.com/eslint/eslint/issues/9484
            // @see https://eslint.org/docs/developer-guide/nodejs-api#cliengine
            plugins: [
              'jsx-a11y',
            ],
          },
        },
        {
          test: /\.jsx?$/,
          exclude: /(node_modules|bower_components)/,
          use: [
            {
              loader: 'babel-loader',
              options: {
                presets: [['es2015', { modules: false }], 'react'],
                plugins: ['transform-object-rest-spread'],
              },
            },
          ],
        },
        {
          test: /\.(png|jpg|gif|svg)$/,
          use: [{
            loader: 'file-loader',
            options: {
              outputPath: 'assets/',
            },
          }],
        },
      ],
    },
  };
};
<commit_msg>build(config/webpack/common.js): enforce env. variables safety<commit_after>const path = require('path');
const FaviconsWebpackPlugin = require('favicons-webpack-plugin');
const Dotenv = require('dotenv-webpack');
require('dotenv').config();

module.exports = (env) => {
  const environment = (env && env.NODE_ENV) ?
    env.NODE_ENV.toLocaleLowerCase() : 'development';
  return {
    entry: {
      main: ['react-hot-loader/patch', path.resolve(__dirname, '../../src/index.jsx')],
      polyfills: path.resolve(__dirname, './polyfills.js'),
    },
    devtool: 'cheap-source-map',
    plugins: [
      new FaviconsWebpackPlugin({
        logo: path.resolve(__dirname, '../../assets/logo.png'),
        prefix: 'icons/[hash]/',
        emitStats: false,
        statsFilename: 'icons/stats-[hash].json',
        persistentCache: true,
        inject: true,
        background: '#fff',
        title: 'Antonios Karagiannis',
        // @see https://github.com/haydenbleasel/favicons#usage
        icons: {
          android: true,
          appleIcon: true,
          appleStartup: true,
          coast: false,
          favicons: true,
          firefox: true,
          opengraph: true,
          twitter: true,
          yandex: false,
          windows: false,
        },
      }),
      new Dotenv({
        path: path.resolve(__dirname, '../../.env'),
        safe: true,
        systemvars: true,
      }),
    ],
    output: {
      filename: '[name].bundle.js',
      path: path.resolve(__dirname, '../../dist'),
    },
    resolve: {
      extensions: ['.js', '.json', '.jsx'],
      alias: {
        Assets: path.resolve(__dirname, '../assets/'),
        Actions: path.resolve(__dirname, '../../src/actions/'),
        Components: path.resolve(__dirname, '../../src/components/'),
        Constants: path.resolve(__dirname, '../../src/constants/'),
        Containers: path.resolve(__dirname, '../../src/containers/'),
        Helpers: path.resolve(__dirname, '../../src/helpers/'),
        Reducers: path.resolve(__dirname, '../../src/reducers/'),
        ReduxLogger$: (environment !== 'production' ?
          'redux-logger' : path.resolve(__dirname, '../../src/helpers/empty.js')),
        ReduxDevtoolsExtension$: (environment !== 'production' ?
          'redux-devtools-extension' : path.resolve(__dirname, '../../src/helpers/empty.js')),
      },
    },
    module: {
      rules: [
        {
          test: /\.jsx?$/,
          enforce: 'pre',
          exclude: /(node_modules|bower_components)/,
          loader: 'eslint-loader',
          options: {
            cache: true,
            emitError: true,
            failOnWarning: environment !== 'development',
            failOnError: environment !== 'development',
            // Unfortunately, some config options must be duplicated here
            // even though they are defined within package.json[eslintConfig]
            // which is what IDEs use to configure ESLint but this one
            // uses the CLIEngine options instead...
            // @see https://github.com/eslint/eslint/issues/9484
            // @see https://eslint.org/docs/developer-guide/nodejs-api#cliengine
            plugins: [
              'jsx-a11y',
            ],
          },
        },
        {
          test: /\.jsx?$/,
          exclude: /(node_modules|bower_components)/,
          use: [
            {
              loader: 'babel-loader',
              options: {
                presets: [['es2015', { modules: false }], 'react'],
                plugins: ['transform-object-rest-spread'],
              },
            },
          ],
        },
        {
          test: /\.(png|jpg|gif|svg)$/,
          use: [{
            loader: 'file-loader',
            options: {
              outputPath: 'assets/',
            },
          }],
        },
      ],
    },
  };
};
<|endoftext|>