index.js 3.4 KB
Newer Older
Y
Your Name 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
(function () {
    //author:广州银云信息科技有限公司
    'use strict';
    angular.module('eolinker')
        .config(['$stateProvider', 'RouteHelpersProvider', function ($stateProvider, helper) {
            $stateProvider
                .state('home.panel', {
                    url: '/',
                    template: '<panel></panel>'
                })
        }])
        .component('panel', {
            templateUrl: 'app/ui/content/panel/index.html',
            controller: indexController
        })

    indexController.$inject = ['$scope', 'GatewayResource', '$state', 'CODE', '$rootScope', 'uibDateParser'];

    function indexController($scope, GatewayResource, $state, CODE, $rootScope, uibDateParser) {

        var vm = this,
            privateFun = {}
        vm.data = {}
        vm.fun = {};
        vm.ajaxRequest = {
            table: {
                beginTime: null,
                endTime: null,
                period: 0
            }
        }
        vm.ajaxResponse = {
            monitorInfo: null,
            redisArr: []
        };
        vm.directive = {
            tableTimeObject: {
                show: false,
                maxDate: new Date(),
                maxMode: 'month',
                request: {}
            }
        }
        vm.component = {
            overviewObject: {},
            listDefaultCommonObject: null
        }
        privateFun.initTable = function () {
            let tmpPromise;
            tmpPromise = GatewayResource.Monitor.Info().$promise;
            tmpPromise.then(function (response) {
                vm.ajaxResponse.monitorInfo = response || {};
            })
            return tmpPromise;
        }
        privateFun.refresh = function () {
            var tmpPromise = GatewayResource.Monitor.Refresh().$promise;
            tmpPromise.then(function (response) {
                switch (response.statusCode) {
                    case CODE.COMMON.SUCCESS: {
                        $rootScope.InfoModal('立即刷新成功!', 'success', function () {
                            $scope.$emit('$TransferStation', {
                                state: '$Init_LoadingCommonComponent'
                            });
                        });
                        break;
                    }
                }
            })
            return tmpPromise;
        }
        privateFun.initComponent = function () {
            vm.component.overviewObject = {
                setting: {
                    title: '基本信息',
                    showOperate: true
                }
            }
        }
        vm.fun.init = function (arg) {
            arg = arg || {
                type: 'default'
            }
            switch (arg.type) {
                default: {
                    return privateFun.initTable();;
                }
                case 'refresh': {
                    return privateFun.refresh();
                }
            }

        }
        vm.fun.refresh = function () {
            $scope.$emit('$TransferStation', {
                state: '$Init_LoadingCommonComponent',
                data: {
                    type: 'refresh',
                    tips: '刷新'
                }
            });
        }
        vm.$onInit = function () {
            $scope.$emit('$WindowTitleSet', {
                list: ['首页']
            });
            privateFun.initComponent();
        }
    }
})();