From fdc95484da793f4bc66b36a2066ad3cebcb6246d Mon Sep 17 00:00:00 2001 From: shentao Date: Mon, 30 Oct 2017 17:59:37 +0800 Subject: Fix Monitor bug Change-Id: I7608578aa57feee97e0265b71ca97e285e2f89e0 Issue-Id: USECASEUI-50 Signed-off-by: shentao --- .../fusion/scripts/controller/alarmController.js | 270 ++++++++++----------- 1 file changed, 123 insertions(+), 147 deletions(-) (limited to 'usecaseui-monitor/src/main/webapp/app/uui/fusion/scripts/controller/alarmController.js') diff --git a/usecaseui-monitor/src/main/webapp/app/uui/fusion/scripts/controller/alarmController.js b/usecaseui-monitor/src/main/webapp/app/uui/fusion/scripts/controller/alarmController.js index b268ed31..a7fd1c7a 100644 --- a/usecaseui-monitor/src/main/webapp/app/uui/fusion/scripts/controller/alarmController.js +++ b/usecaseui-monitor/src/main/webapp/app/uui/fusion/scripts/controller/alarmController.js @@ -13,88 +13,68 @@ See the License for the specific language governing permissions and limitations under the License. */ -app.controller('perCtrl', function ($scope) { - -}); - -app.controller('alarmGridCtrl', ['$scope','$log', '$http', '$timeout', '$interval', 'uiGridConstants', 'uiGridGroupingConstants', - function ($scope,$log, $http, $timeout, $interval) { +app.controller('alarmGridCtrl', ['$scope', '$log', '$http', '$timeout', '$interval' , '$window' ,'uiGridConstants', 'uiGridGroupingConstants', + function ($scope, $log, $http, $timeout, $interval,$window) { $scope.selectedRows = new Array(); - var mydefalutData = [ - {name: "shebei1", Id: "22", State: '1', Cpu: "40%", Memory: "60,0", Disk: "60,000", Network: "60,000"}, - {name: "shebei1", Id: "226", State: '2', Cpu: "40%", Memory: "60", Disk: "60,", Network: "60,000"}, - { - name: "shebei1", - Id: "225", - State: '2', - Cpu: "40%", - Memory: "60,000", - Disk: "60,000", - Network: "60,000" - }, - {name: "shebei1", Id: "224", State: '3', Cpu: "40%", Memory: "600", Disk: "60,000", Network: "60,000"}, - - { - name: "shebei1", - Id: "223", - State: '2', - Cpu: "40%", - Memory: "60,000", - Disk: "60,000", - Network: "60,000" - }, - { - name: "shebei1", - Id: "221", - State: '3', - Cpu: "40%", - Memory: "60,000", - Disk: "60,000", - Network: "60,000" - } - - ]; - $scope.items = [ - 'The first choice!', - 'And another choice for you.', - 'but wait! A third!' - ]; - - $scope.toggled = function(open) { - $log.log('Dropdown is now: ', open); - }; - - $scope.status = { - isopen: false - }; - - $scope.toggleDropdown = function($event) { - $event.preventDefault(); - $event.stopPropagation(); - $scope.status.isopen = !$scope.status.isopen; - }; - - $scope.appendToEl = angular.element(document.querySelector('#dropdown-long-content')); + $scope.condition1 = ""; + $scope.condition2 = ""; + $scope.condition3 = ""; + $scope.condition4 = ""; + $scope.condition5 = ""; + $scope.alarmStatus = "null"; + $scope.vfstatus = "null"; + $scope.toggled = function (open) { + $log.log('Dropdown is now: ', open); + }; + $scope.status = { + isopen: false + }; + $scope.toggleDropdown = function ($event) { + $event.preventDefault(); + $event.stopPropagation(); + $scope.status.isopen = !$scope.status.isopen; + }; + var getPage = function (curPage, pageSize) { + var firstRow = (curPage - 1) * pageSize; + var url = global_url+'/alarm/' + curPage + '/' + pageSize + ''; + url += arguments[2] === "" ? "/null" : "/" + arguments[2]; + url += arguments[3] === "" ? "/null" : "/" + arguments[3]; + url += arguments[4] === "" ? "/null" : "/" + arguments[4]; + url += arguments[5] === "" ? "/null" : "/" + arguments[5]; + url += arguments[6] === "" ? "/null" : "/" + arguments[6]; + url += arguments[7] === "" ? "/null" : "/" + arguments[7]; + url += arguments[8] === "" ? "/null" : "/" + arguments[8]; + console.info(url); + $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; + //console.info($scope.gridOptions.totalItems); + $scope.gridOptions.data = data.alarms; + }); + }; $scope.gridOptions = { - data: 'myData', - columnDefs: [{ - field: 'name', - displayName: 'name', - width: '8%', - enableColumnMenu: false, - enableHiding: false, - suppressRemoveSort: true, - enableCellEdit: false - }, - {field: "Id"}, - {field: "State",cellFilter:'mapGender'}, - {field: "Cpu"}, - {field: "Memory"}, - {field: "Disk"}, - {field: "Network"}, - {field: "Action", cellTemplate : - '
' - , enableCellEdit:false}, + columnDefs: [ + {field: "alarmsHeader.eventId", displayName: 'Id', enableCellEdit: false}, + { + field: 'alarmsHeader.eventName', + displayName: 'eventName', + width: '8%', + enableColumnMenu: false, + enableHiding: false, + suppressRemoveSort: true, + enableCellEdit: false + }, + {field: "alarmsHeader.vfStatus", displayName: 'IsOpen', enableCellEdit: false}, + {field: "alarmsHeader.status", displayName: 'Status', cellFilter: 'mapGender', enableCellEdit: false}, + {field: "alarmsInformation[0].name", displayName: 'Name', enableCellEdit: false}, + {field: "alarmsInformation[0].value", displayName: 'Value', enableCellEdit: false}, + {field: "alarmsHeader.createTime", displayName: 'CreateTime', enableCellEdit: false}, ], enableSorting: true, useExternalSorting: false, @@ -103,7 +83,6 @@ app.controller('alarmGridCtrl', ['$scope','$log', '$http', '$timeout', '$interva enableHorizontalScrollbar: 1, enableVerticalScrollbar: 0, enableFiltering: true, - enablePagination: true, enablePaginationControls: true, paginationPageSizes: [10, 15, 20], @@ -112,7 +91,6 @@ app.controller('alarmGridCtrl', ['$scope','$log', '$http', '$timeout', '$interva //paginationTemplate:"
", totalItems: 0, useExternalPagination: true, - enableFooterTotalSelected: true, enableFullRowSelection: true, enableRowHeaderSelection: true, @@ -127,9 +105,7 @@ app.controller('alarmGridCtrl', ['$scope','$log', '$http', '$timeout', '$interva modifierKeysToMultiSelect: false, multiSelect: true, noUnselect: false, - selectionRowHeaderWidth: 20, - - + selectionRowHeaderWidth: 28, //---------------api--------------------- onRegisterApi: function (gridApi) { $scope.gridApi = gridApi; @@ -139,48 +115,50 @@ app.controller('alarmGridCtrl', ['$scope','$log', '$http', '$timeout', '$interva getPage(newPage, pageSize); } }); - $scope.gridApi.selection.on.rowSelectionChanged($scope, function (row, event) { if (row) { - var num = $.inArray(row.entity.Id, $scope.selectedRows); + var num = $.inArray(row.entity.alarmsHeader.eventId, $scope.selectedRows); if (num == -1) { - $scope.selectedRows.push(row.entity.Id); + $scope.selectedRows.push(row.entity.alarmsHeader.eventId); } else { $scope.selectedRows.splice(num, 1); } } }); - $scope.gridApi.grid.registerRowsProcessor( $scope.singleFilter, 200 ); + $scope.gridApi.grid.registerRowsProcessor($scope.singleFilter, 200); } }; - - var getPage = function (curPage, pageSize) { - var firstRow = (curPage - 1) * pageSize; - $scope.gridOptions.totalItems = mydefalutData.length; - $scope.gridOptions.data = mydefalutData.slice(firstRow, firstRow + pageSize); - - //$scope.myData = mydefalutData.slice(firstRow, firstRow + pageSize); - }; - getPage(1, $scope.gridOptions.paginationPageSize); - - $scope.trashcan = function () { - alert('delete ' + $scope.selectedRows); + getPage(1, $scope.gridOptions.paginationPageSize, $scope.condition1===""?"":$scope.condition1, + $scope.condition2===""?"":$scope.condition2, $scope.condition3===""?"":$scope.condition3, + $scope.condition4===""?"":$scope.condition4, $scope.condition5===""?"":$scope.condition5, + $scope.alarmStatus, $scope.vfstatus); + + $scope.generateCsv = function () { + if ($scope.selectedRows.length == 0){ + alert("please select row!"); + }else{ + $window.location = global_url+"/alarm/genCsv/"+$scope.selectedRows; + } }; - $scope.status = [ - {id: 1, name: 'danger', count: 10}, - {id: 2, name: 'warming', count: 8}, - {id: 3, name: 'normal', count: 7}, + {id: 1, name: 'CRITICAL', count: 10}, + {id: 2, name: 'MALOR', count: 8}, + {id: 3, name: 'MINOR', count: 7}, + {id: 4, name: 'WARNING', count: 8}, + {id: 5, name: 'NORMAL', count: 7}, {id: undefined, name: 'All', count: 7} ]; - $scope.selectStatus = function (v) { + $scope.alarmStatus = typeof(v) == "undefined" ? "" : v; + getPage(1, $scope.gridOptions.paginationPageSize, $scope.condition1===""?"":$scope.condition1, + $scope.condition2===""?"":$scope.condition2, $scope.condition3===""?"":$scope.condition3, + $scope.condition4===""?"":$scope.condition4, $scope.condition5===""?"":$scope.condition5, + $scope.alarmStatus, $scope.vfstatus); $scope.selectedStatus = v; - $scope.gridApi.grid.refresh(); + }; $scope.activeStatus = function (status_id) { - return status_id == $scope.selectedStatus; }; $scope.open = [ @@ -190,63 +168,61 @@ app.controller('alarmGridCtrl', ['$scope','$log', '$http', '$timeout', '$interva ]; $scope.selectOpen = function (v) { + $scope.vfstatus = typeof(v) == "undefined" ? "null" : v; + getPage(1, $scope.gridOptions.paginationPageSize, $scope.condition1===""?"":$scope.condition1, + $scope.condition2===""?"":$scope.condition2, $scope.condition3===""?"":$scope.condition3, + $scope.condition4===""?"":$scope.condition4, $scope.condition5===""?"":$scope.condition5, + $scope.alarmStatus, $scope.vfstatus); $scope.selectedOpen = v; - $scope.gridApi.grid.refresh(); }; $scope.activeOpen = function (open_id) { - return open_id == $scope.selectedOpen; }; - $scope.singleFilter = function (renderableRows) { var matcher = new RegExp($scope.selectedStatus); renderableRows.forEach(function (row) { - var match = false; - ['State'].forEach(function (field) { - if (row.entity[field].match(matcher)) { - match = true; - } - }); + var match = true; if (!match) { row.visible = false; } }); return renderableRows; }; -//input -$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.menuState = {show: false} + $scope.toggleMenu = function () { + $scope.menuState.show = !$scope.menuState.show; + } + $scope.singleModel = 1; + $scope.radioModel = 'Middle'; - $scope.$watchCollection('checkModel', function () { - $scope.checkResults = []; - angular.forEach($scope.checkModel, function (value, key) { - if (value) { - $scope.checkResults.push(key); - } - }); - }); + $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); + } + }); + }); + $scope.alarmSearch = function () { + getPage(1, $scope.gridOptions.paginationPageSize, $scope.condition1===""?"":$scope.condition1, + $scope.condition2===""?"":$scope.condition2, $scope.condition3===""?"":$scope.condition3, + $scope.condition4===""?"":$scope.condition4, $scope.condition5===""?"":$scope.condition5, + $scope.alarmStatus, $scope.vfstatus); + }; }]).filter('mapGender', function () { var genderHash = { - 1: 'danger', - 2: 'alarm' , - 3: 'normal' + 1: 'CRITICAL', + 2: 'MAJOR', + 3: 'MINOR', + 4: 'WARNING', + 5: 'NORMAL' }; - return function (input) { if (!input) { return ''; @@ -254,5 +230,5 @@ $scope.menuState={show: false} return genderHash[input]; } } - + }); \ No newline at end of file -- cgit 1.2.3-korg