From 62430d66781234816d4eee66600380b915c04089 Mon Sep 17 00:00:00 2001 From: shentao Date: Tue, 5 Dec 2017 16:07:51 +0800 Subject: Fix alarm and performance display bugs Change-Id: I12b07d4252336de7e4a4c64ea578ef625873e432 Issue-ID: USECASEUI-62 Signed-off-by: shentao --- .../scripts/controller/performanceController.js | 262 ++++++++------------- 1 file changed, 102 insertions(+), 160 deletions(-) (limited to 'usecaseui-monitor/src/main/webapp/app/uui/fusion/scripts/controller/performanceController.js') diff --git a/usecaseui-monitor/src/main/webapp/app/uui/fusion/scripts/controller/performanceController.js b/usecaseui-monitor/src/main/webapp/app/uui/fusion/scripts/controller/performanceController.js index 80896c7c..b944a7ed 100644 --- a/usecaseui-monitor/src/main/webapp/app/uui/fusion/scripts/controller/performanceController.js +++ b/usecaseui-monitor/src/main/webapp/app/uui/fusion/scripts/controller/performanceController.js @@ -15,180 +15,30 @@ */ // var permanceId=""; -app.controller('perGridCtrl', ['$scope','$http', '$window', '$interval', 'uiGridConstants', 'uiGridGroupingConstants', '$window' , - function ($scope, $http , $window, $interval ) { +app.controller('perGridCtrl', ['$scope','$http', '$window', '$interval', '$window', + function ($scope, $http , $window, $interval) { $scope.jump = function(value){ permanceId=value; var obj = $("#lm"); angular.element(obj).scope().currentTab = "app/uui/fusion/scripts/view-models/performance-details.html"; //angular.element(obj).scope().$apply(); }; - $scope.selectedRows = new Array(); - $scope.seek1 = ""; - $scope.seek2 = ""; - $scope.seek3 = ""; - $scope.seek4 = ""; - $scope.seek5 = ""; - $scope.getSearch = function (){ - getPage(1, $scope.gridOptions.paginationPageSize, $scope.seek1===""?"null":$scope.seek1, - $scope.seek2===""?"null":$scope.seek2, $scope.seek3===""?"null":$scope.seek3, - $scope.seek4===""?"null":$scope.seek4, $scope.seek5===""?"null":$scope.seek5); - }; + + $scope.itemsByPage = 15; + $scope.toChart = function () { var obj = $("#lm"); angular.element(obj).scope().currentTab = "app/uui/fusion/scripts/view-models/performance-chart.html"; }; - $scope.gridOptions = { - columnDefs: [{ - field: 'performanceHeader.eventName', - displayName: 'Event Name', - width: '10%', - enableColumnMenu: false, - enableHiding: false, - suppressRemoveSort: true, - enableCellEdit: false - }, { - field: "performanceHeader.eventId", - enableCellEdit: false, - displayName: 'Event Id', - cellTemplate: '{{row.entity.performanceHeader.sourceId}}', - }, - {field: "performanceHeader.sourceId", displayName: 'Source Id',enableCellEdit: false}, - {field: "performanceHeader.sourceName", displayName: 'Source Name',enableCellEdit: false}, - {field: "performanceHeader.reportingEntityId", displayName: 'Reporting Entity Id',enableCellEdit: false}, - {field: "performanceHeader.reportingEntityName", displayName: 'Reporting Entity Name',enableCellEdit: false}, - {field: "performanceHeader.priority", displayName: 'Priority',enableCellEdit: false}, - {field: "performanceHeader.createTime", displayName: 'Start Time',enableCellEdit: false}, - {field: "option",displayName: 'option', enableCellEdit: false , - cellTemplate: ''} - ], - enableSorting: true, - useExternalSorting: false, - enableGridMenu: true, - showGridFooter: true, - enableHorizontalScrollbar: 1, - enableVerticalScrollbar: 0, - enableFiltering: true, - // - enablePagination: true, - enablePaginationControls: true, - paginationPageSizes: [10, 15, 20], - paginationCurrentPage: 1, - paginationPageSize: 10, - //paginationTemplate:"
", - totalItems: 0, - useExternalPagination: true, - enableFooterTotalSelected: true, - enableFullRowSelection: true, - enableRowHeaderSelection: true, - enableRowSelection: false, - enableSelectAll: true, - enableSelectionBatchEvent: true, - isRowSelectable: function (row) { - if (row.entity.age > 45) { - row.grid.api.selection.selectRow(row.entity); - } - }, - modifierKeysToMultiSelect: false, - multiSelect: true, - noUnselect: false, - selectionRowHeaderWidth: 30, - - //---------------api--------------------- - onRegisterApi: function (gridApi) { - $scope.gridApi = gridApi; - - gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) { - if (getPage) { - getPage(newPage, pageSize); - } - }); - $scope.gridApi.selection.on.rowSelectionChanged($scope, function (row, event) { - if (row) { - var num = $.inArray(row.entity.performanceHeader.eventId, $scope.selectedRows); - if (num == -1) { - $scope.selectedRows.push(row.entity.performanceHeader.eventId); - } - else { - $scope.selectedRows.splice(num, 1); - } - } - }); - $scope.gridApi.grid.registerRowsProcessor($scope.singleFilter, 200); - } }; - - $scope.singleFilter = function (renderableRows) { - var matcher = new RegExp($scope.selectedStatus); - renderableRows.forEach(function (row) { - var match = true; - /*['State'].forEach(function (field) { - if (row.entity[field].match(matcher)) { - match = true; - } - });*/ - if (!match) { - row.visible = false; - } - }); - return renderableRows; - }; + $scope.menuState = {show: false} $scope.toggleMenu = function () { $scope.menuState.show = !$scope.menuState.show; } - $scope.singleModel = 1; - $scope.radioModel = 'Middle'; - $scope.checkModel = { - open: false, - close: true - }; $scope.checkResults = []; - $scope.$watchCollection('checkModel', function () { - $scope.checkResults = []; - angular.forEach($scope.checkModel, function (value, key) { - if (value) { - $scope.checkResults.push(key); - } - }); - }); - var getPage = function (curPage, pageSize) { - var firstRow = (curPage - 1) * pageSize; - var url = global_url+'/performance/' + curPage + '/' + pageSize + ''; - url += arguments[2] === "" ? "/null" : "/" + arguments[2]; - url += arguments[3] === "" ? "/null" : "/" + arguments[3]; - url += arguments[4] === "" ? "/null" : "/" + arguments[4]; - url += arguments[5] === "null" ? "/null" : "/" + FormatDate(arguments[5]); - url += arguments[6] === "null" ? "/null" : "/" + FormatDate(arguments[6]); - $http.get(url, { - headers: { - 'Access-Control-Allow-Origin': "*", - "Content-Type": "application/json", - "Authorization": "Basic " + btoa("usecase" + ':' + "usecase") - } - }) - .success(function (data) { - $scope.gridOptions.totalItems = data.totalRecords; - $scope.gridOptions.data = data.performances; - }); - }; - getPage(1, $scope.gridOptions.paginationPageSize, $scope.seek1===""?"null":$scope.seek1, - $scope.seek2===""?"null":$scope.seek2, $scope.seek3===""?"null":$scope.seek3, - $scope.seek4===""?"null":$scope.seek4, $scope.seek5===""?"null":$scope.seek5); - $interval(function () { - getPage(1, $scope.gridOptions.paginationPageSize, $scope.seek1===""?"null":$scope.seek1, - $scope.seek2===""?"null":$scope.seek2, $scope.seek3===""?"null":$scope.seek3, - $scope.seek4===""?"null":$scope.seek4, $scope.seek5===""?"null":$scope.seek5); - },10000) - $scope.generateCsv = function () { - if ($scope.selectedRows.length == 0){ - alert("please select row!"); - }else{ - $window.location = global_url+"/performance/genCsv/"+$scope.selectedRows; - } - }; - //input + $scope.menuState = {show: false} $scope.toggleMenu = function () { $scope.menuState.show = !$scope.menuState.show; @@ -208,10 +58,102 @@ app.controller('perGridCtrl', ['$scope','$http', '$window', '$interval', 'uiGrid $scope.popup2 = { opened: false }; + + }]); +app.controller('pipeCtrl', ['$scope','Resource', function ($scope,service) { + $scope.seek1 = ""; + $scope.seek2 = ""; + $scope.seek3 = ""; + $scope.seek4 = ""; + $scope.seek5 = ""; + + + var ctrl = this; + + this.displayed = []; + + this.callServer = function callServer(tableState) { + ctrl.isLoading = true; + $scope.tableState = tableState; + var pagination = tableState.pagination; + + var start = pagination.start/pagination.number+1 || 0; + var number = pagination.number || 10; + + service.getPage(start, number,$scope.seek1===""?"null":$scope.seek1, + $scope.seek2===""?"null":$scope.seek2, $scope.seek3===""?"null":$scope.seek3, + $scope.seek4===""?"null":$scope.seek4, $scope.seek5===""?"null":$scope.seek5).then(function (result) { + ctrl.displayed = result.data; + tableState.pagination.numberOfPages = result.numberOfPages; + ctrl.isLoading = false; + }); + }; + +}]) + .factory('Resource', ['$q', '$filter', '$timeout','$http', function ($q, $filter, $timeout,$http) { + var randomsItems = []; + var totalCount = 0; + function getPage(start, number) { + var url = global_url+'/performance/' + start + '/' + number + ''; + url += arguments[2] === "" ? "/null" : "/" + arguments[2]; + url += arguments[3] === "" ? "/null" : "/" + arguments[3]; + url += arguments[4] === "" ? "/null" : "/" + arguments[4]; + url += arguments[5] === "null" ? "/null" : "/" + FormatDate(arguments[5]); + url += arguments[6] === "null" ? "/null" : "/" + FormatDate(arguments[6]); + $http({ + url : url, + method : "GET" + }).then(function SuccessCallback(resp) { + if (resp.data.performances.length > 0){ + randomsItems = resp.data.performances; + totalCount = resp.data.totalRecords; + }else{ + randomsItems = []; + totalCount = 0; + } + }); + + var deferred = $q.defer(); + + $timeout(function () { + deferred.resolve({ + data: randomsItems, + numberOfPages: Math.ceil(totalCount / number) + }); + }, 1500); + + + return deferred.promise; + } + function FormatDate(strTime) { var date = new Date(strTime); return date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + date.getDate() + " " + date.getHours() + ":" + date.getMinutes(); }; - }]); - - \ No newline at end of file + + return { + getPage: getPage + }; + + + }]).directive('stRatio',function(){ + return { + link:function(scope, element, attr){ + var ratio=+(attr.stRatio); + + element.css('width',ratio+'%'); + + } + }; +}).directive('pageSelect', function() { + return { + restrict: 'E', + template: '', + link: function(scope, element, attrs) { + scope.$watch('currentPage', function(c) { + scope.inputPage = c; + }); + } + } +}); + -- cgit 1.2.3-korg