diff options
author | shentao <shentao@chinamobile.com> | 2017-12-05 16:07:51 +0800 |
---|---|---|
committer | shentao <shentao@chinamobile.com> | 2017-12-05 16:08:00 +0800 |
commit | 62430d66781234816d4eee66600380b915c04089 (patch) | |
tree | 9173411c78ffc6a44db6a75b0b8ab3545be212a1 /usecaseui-monitor/src/main/webapp/app/uui/fusion/scripts/controller | |
parent | 3caa21ed184ef2c75902896433d2ec485fd33f82 (diff) |
Fix alarm and performance display bugs
Change-Id: I12b07d4252336de7e4a4c64ea578ef625873e432
Issue-ID: USECASEUI-62
Signed-off-by: shentao <shentao@chinamobile.com>
Diffstat (limited to 'usecaseui-monitor/src/main/webapp/app/uui/fusion/scripts/controller')
4 files changed, 396 insertions, 414 deletions
diff --git a/usecaseui-monitor/src/main/webapp/app/uui/fusion/scripts/controller/alarm-chartController.js b/usecaseui-monitor/src/main/webapp/app/uui/fusion/scripts/controller/alarm-chartController.js index 5906c42c..9153cc40 100644 --- a/usecaseui-monitor/src/main/webapp/app/uui/fusion/scripts/controller/alarm-chartController.js +++ b/usecaseui-monitor/src/main/webapp/app/uui/fusion/scripts/controller/alarm-chartController.js @@ -16,9 +16,11 @@ app.controller('alarmchartCtrl', ['$scope', '$http', '$routeParams', '$window', function ($scope, $http, $routeParams, $window) { - $scope.goIsShow = false; - $scope.chartShow = false; + $scope.chartShow = false; $scope.valuess = []; + $scope.ndaShow = false; + $scope.hdaShow = false; + $scope.sourceId = ""; $scope.today = function () { $scope.startTime = new Date(); $scope.endTime = new Date(); @@ -27,11 +29,9 @@ app.controller('alarmchartCtrl', ['$scope', '$http', '$routeParams', '$window', url: global_url + "/alarm/sourceId", headers: { 'Access-Control-Allow-Origin': "*", - "Content-Type": "application/json", - "Authorization": "Basic " + btoa("usecase" + ':' + "usecase") + "Content-Type": "application/json" } }).then(function successCallback(resp) { - //console.info(resp); $scope.sourceIds = resp.data; }, function errorCallback(resp) { @@ -39,6 +39,64 @@ app.controller('alarmchartCtrl', ['$scope', '$http', '$routeParams', '$window', }; $scope.today(); + $scope.options = { + chart: { + type: 'historicalBarChart', + height: 300, + margin : { + top: 20, + right: 20, + bottom: 65, + left: 50 + }, + x: function(d){return d[0];}, + y: function(d){return d[1];}, + showValues: true, + valueFormat: function(d){ + return d3.format(',.1f')(d); + }, + duration: 100, + xAxis: { + //axisLabel: 'X Axis', + tickFormat: function(d) { + return d3.time.format('%x %H:%M')(new Date(d)) + }, + rotateLabels: 30, + showMaxMin: true + }, + yAxis: { + //axisLabel: 'Y Axis', + axisLabelDistance: -10, + tickFormat: function(d){ + return d3.format(',.1f')(d); + } + }, + tooltip: { + keyFormatter: function(d) { + return d3.time.format('%x %H:%M')(new Date(d)); + } + }, + zoom: { + enabled: true, + scaleExtent: [1, 10], + useFixedDomain: false, + useNiceScale: false, + horizontalOff: false, + verticalOff: true, + unzoomEventType: 'dblclick.zoom' + } + } + }; + + + $scope.data = [ + { + "key" : "Quantity" , + "bar": true, + "values" : [] + }]; + + $scope.genDiagram = function () { $http({ method: 'POST', @@ -46,7 +104,8 @@ app.controller('alarmchartCtrl', ['$scope', '$http', '$routeParams', '$window', data: { "sourceId": $scope.sourceId, "startTime": FormatDate($scope.startTime), - "endTime": FormatDate($scope.endTime) + "endTime": FormatDate($scope.endTime), + "showMode" : ($scope.showModeId==undefined?"auto":$scope.showModeId) }, headers: {'Content-Type': 'application/x-www-form-urlencoded'}, transformRequest: function (obj) { @@ -57,42 +116,43 @@ app.controller('alarmchartCtrl', ['$scope', '$http', '$routeParams', '$window', return str.join("&"); } }).then(function successCallback(resp) { - console.info(resp); $scope.chartShow = true; - if (resp.data.length > 0) - for (var i = 0; i < resp.data.length; i++) { - $scope.valuess[i] = {}; - $scope.valuess[i].x = resp.data[i].Time; - $scope.valuess[i].y = resp.data[i].Count; - } - else - $scope.valuess = []; - for (var d = 0; d < 5; d++) { - window.setTimeout(function () { - redraw("_alarm", $scope.valuess); - }, 1500); - }; + if (resp.data.length > 0){ + $scope.ndaShow = false; + $scope.hdaShow = true; + $scope.data = [ + { + "key" : "Max" , + "bar": true, + "values" : resp.data + }]; + $scope.api.refresh(); + } + else{ + $scope.ndaShow = true; + $scope.hdaShow = false; + $scope.data = [ + { + "key" : "Max" , + "bar": true, + "values" : [] + }]; + $scope.api.refresh(); + } + }, function errorCallback(resp) { }); } - $scope.sourceIdChanged = function(){ - if ($scope.sourceId != null) - $scope.goIsShow = true; - else - $scope.goIsShow = false; - }; $scope.startTimeChanged = function () { if ($scope.startTime > $scope.endTime) $scope.endTime = ""; - // console.info($scope.startTime); }; $scope.endTimeChanged = function () { if ($scope.endTime < $scope.startTime) $scope.startTime = ""; - // console.info($scope.endTime); }; $scope.open1 = function () { @@ -111,6 +171,8 @@ app.controller('alarmchartCtrl', ['$scope', '$http', '$routeParams', '$window', opened: false }; + $scope.showModeIds = ["minute","hour","day","month","year"]; + function FormatDate(strTime) { var date = new Date(strTime); return date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + date.getDate() + " " + date.getHours() + ":" + date.getMinutes(); 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 f73785a6..6a2daf65 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 @@ -14,7 +14,7 @@ limitations under the License. */ var alarmDetailId = ""; -app.controller('alarmGridCtrl', ['$scope', '$log', '$http', '$timeout', '$interval' , '$window' ,'uiGridConstants', 'uiGridGroupingConstants', +app.controller('alarmGridCtrl', ['$scope', '$log', '$http', '$timeout', '$interval' , '$window', function ($scope, $log, $http, $timeout, $interval,$window) { $scope.jump = function(value){ alarmDetailId=value; @@ -26,197 +26,42 @@ app.controller('alarmGridCtrl', ['$scope', '$log', '$http', '$timeout', '$interv var obj = $("#lm"); angular.element(obj).scope().currentTab = "app/uui/fusion/scripts/view-models/alarm-chart.html"; }; - $scope.selectedRows = new Array(); - $scope.condition1 = ""; - $scope.condition2 = ""; - $scope.condition3 = ""; - $scope.condition4 = ""; - $scope.condition5 = ""; $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" : "/" + FormatDate(arguments[5]); - url += arguments[6] === "" ? "/null" : "/" + FormatDate(arguments[6]); - url += arguments[7] === "" ? "/null" : "/" + arguments[7]; - $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.alarms; - }); - }; - $scope.gridOptions = { - columnDefs: [ - { - field: 'alarmsHeader.eventName', - displayName: 'eventName', - width : '10%', - enableHiding: false, - suppressRemoveSort: true, - enableCellEdit: false - }, - {field: "alarmsHeader.eventId", displayName: 'eventId', enableCellEdit: false}, - {field: "alarmsHeader.sourceId", displayName: 'Source Id', enableCellEdit: false,cellTemplate: '<a ng-click="grid.appScope.jump(row.entity.alarmsHeader.sourceId)"; style="cursor:pointer" href="">{{row.entity.alarmsHeader.sourceId}}</a>'}, - {field: "alarmsHeader.sourceName", displayName: 'Source Name', enableCellEdit: false}, - {field: "alarmsHeader.reportingEntityId", displayName: 'Reporting Entity Id', enableCellEdit: false}, - {field: "alarmsHeader.reportingEntityName", displayName: 'Reporting Entity Name', enableCellEdit: false}, - {field: "alarmsHeader.createTime", displayName: 'Start Time', enableCellEdit: false}, - {field: "alarmsHeader.status", displayName: 'Status', cellFilter: 'mapGender',enableCellEdit: false}, - {field: "option",displayName: 'option', enableCellEdit: false ,cellTemplate: '<button ng-click="grid.appScope.jump(row.entity.alarmsHeader.sourceId)" class="btn btn-primary" >Details</button>'}, - ], - 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, - 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: 28, - //---------------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.alarmsHeader.eventId, $scope.selectedRows); - if (num == -1) { - $scope.selectedRows.push(row.entity.alarmsHeader.eventId); - } - else { - $scope.selectedRows.splice(num, 1); - } - } - }); - $scope.gridApi.grid.registerRowsProcessor($scope.singleFilter, 200); - } - }; - 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.vfstatus); - $interval(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.vfstatus); - },10000) - - $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: '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.open = [ - {id: 1, name: 'Active', count: 10}, - {id: 2, name: 'Closed', count: 8}, - {id: undefined, name: 'All', count: 7} - ]; $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.vfstatus); $scope.selectedOpen = v; }; + $scope.itemsByPage = 15; + + + $http({ + url : global_url + "/alarm/statusCount", + method : "GET" + }).then(function successCallback(resp) { + $scope.open[0].count = resp.data[1]; + $scope.open[1].count = resp.data[2]; + $scope.open[2].count = resp.data[0]; + + }); + + $scope.open = [ + {id: 1, name: 'Active', count: 0}, + {id: 2, name: 'Closed', count: 0}, + {id: undefined, name: 'All', count: 0} + ]; + + $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 = true; - if (!match) { - row.visible = false; - } - }); - return renderableRows; - }; - $scope.menuState = {show: false} + + $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); - } - }); - }); - $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.vfstatus); }; + $scope.open1 = function () { $scope.popup1.opened = true; }; @@ -232,21 +77,83 @@ app.controller('alarmGridCtrl', ['$scope', '$log', '$http', '$timeout', '$interv $scope.popup2 = { opened: false }; - function FormatDate(strTime) { - var date = new Date(strTime); - return date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + date.getDate() + " " + date.getHours() + ":" + date.getMinutes(); - } - }]).filter('mapGender', function () { - var genderHash = { - 1: 'Active', - 2: 'Closed' + + }]); +app.controller('pipeAlarmCtrl', ['$scope','ResourceAlarm', function ($scope,service) { + $scope.condition1 = ""; + $scope.condition2 = ""; + $scope.condition3 = ""; + $scope.condition4 = ""; + $scope.condition5 = ""; + + + 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.condition1===""?"":$scope.condition1, + $scope.condition2===""?"":$scope.condition2, $scope.condition3===""?"":$scope.condition3, + $scope.condition4===""?"":$scope.condition4, $scope.condition5===""?"":$scope.condition5, + $scope.vfstatus).then(function (result) { + ctrl.displayed = result.data; + tableState.pagination.numberOfPages = result.numberOfPages; + ctrl.isLoading = false; + }); }; - return function (input) { - if (!input) { - return ''; - } else { - return genderHash[input]; - } + +}]).factory('ResourceAlarm', ['$q', '$filter', '$timeout','$http', function ($q, $filter, $timeout,$http) { + var randomsItems = []; + var totalCount = 0; + function getPage(start, number) { + var url = global_url+'/alarm/' + start + '/' + number + ''; + url += arguments[2] === "" ? "/null" : "/" + arguments[2]; + url += arguments[3] === "" ? "/null" : "/" + arguments[3]; + url += arguments[4] === "" ? "/null" : "/" + arguments[4]; + url += arguments[5] === "" ? "/null" : "/" + FormatDate(arguments[5]); + url += arguments[6] === "" ? "/null" : "/" + FormatDate(arguments[6]); + url += arguments[7] === "" ? "/null" : "/" + arguments[7]; + $http({ + url : url, + method : "GET" + }).then(function SuccessCallback(resp) { + console.info(resp); + if (resp.data.alarms.length > 0){ + randomsItems = resp.data.alarms; + 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; } -});
\ No newline at end of file + function FormatDate(strTime) { + var date = new Date(strTime); + return date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + date.getDate() + " " + date.getHours() + ":" + date.getMinutes(); + }; + + return { + getPage: getPage + }; + + +}]);
\ No newline at end of file diff --git a/usecaseui-monitor/src/main/webapp/app/uui/fusion/scripts/controller/performance-chartController.js b/usecaseui-monitor/src/main/webapp/app/uui/fusion/scripts/controller/performance-chartController.js index 39845e87..1e9c0e1b 100644 --- a/usecaseui-monitor/src/main/webapp/app/uui/fusion/scripts/controller/performance-chartController.js +++ b/usecaseui-monitor/src/main/webapp/app/uui/fusion/scripts/controller/performance-chartController.js @@ -15,12 +15,13 @@ */ app.controller('pertabCtrl', ['$scope', '$http', '$routeParams', '$window' , - function ($scope, $http, $routeParams, $window) { + function ($scope, $http,$routeParams,$window) { $scope.chartShow = false; + $scope.ndaShow = false; + $scope.hdaShow = false; $scope.valuess = []; $scope.namesPIsShow = false; - $scope.namesCIsShow = false; - $scope.goIsShow = false; + $scope.goIsShow = true; $scope.today = function() { $scope.startTime = new Date(); $scope.endTime = new Date(); @@ -73,9 +74,8 @@ app.controller('pertabCtrl', ['$scope', '$http', '$routeParams', '$window' , }); } else{ - $scope.goIsShow = false; + $scope.goIsShow = true; $scope.namesPIsShow = false; - $scope.namesCIsShow = false; } }; @@ -95,29 +95,86 @@ app.controller('pertabCtrl', ['$scope', '$http', '$routeParams', '$window' , return str.join("&"); } }).then(function successCallback(resp) { - $scope.goIsShow = true; - $scope.chartShow = true; + $scope.goIsShow = false; },function errorCallback(resq) { }); } else{ - $scope.goIsShow = false; + $scope.goIsShow = true; $scope.namesCIsShow = false; } }; - $scope.nameCChanged = function () { - if ($scope.nameC != null){ - $scope.goIsShow = true; - } + $scope.options = { + chart: { + type: 'historicalBarChart', + height: 300, + margin : { + top: 20, + right: 20, + bottom: 65, + left: 50 + }, + x: function(d){return d[0];}, + y: function(d){return d[1];}, + showValues: true, + valueFormat: function(d){ + return d3.format(',.1f')(d); + }, + duration: 100, + xAxis: { + //axisLabel: 'X Axis', + tickFormat: function(d) { + return d3.time.format('%x %H:%M')(new Date(d)) + }, + rotateLabels: 30, + showMaxMin: true + }, + yAxis: { + //axisLabel: 'Y Axis', + axisLabelDistance: -10, + tickFormat: function(d){ + return d3.format(',.1f')(d); + } + }, + tooltip: { + keyFormatter: function(d) { + return d3.time.format('%x %H:%M')(new Date(d)); + } + }, + zoom: { + enabled: false, + scaleExtent: [1, 10], + useFixedDomain: false, + useNiceScale: false, + horizontalOff: false, + verticalOff: false, + unzoomEventType: 'dblclick.zoom' + } + } }; + + $scope.data = [ + { + "key" : "Quantity" , + "bar": true, + "values" : [] + }]; + $scope.genDiagram = function () { + $scope.chartShow = true; $http({ method : 'POST', url : global_url + "/performance/diagram", - data : { "sourceId":$scope.sourceId,"startTime":FormatDate($scope.startTime),"endTime":FormatDate($scope.endTime),"nameParent":$scope.nameP,"nameChild":$scope.nameC!=null?$scope.nameC:"" }, + data : { + "sourceId":$scope.sourceId, + "startTime":FormatDate($scope.startTime), + "endTime":FormatDate($scope.endTime), + "nameParent":$scope.nameP, + "format":$scope.showModeId==undefined?"auto":$scope.showModeId + }, headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, transformRequest: function(obj) { var str = []; @@ -127,26 +184,34 @@ app.controller('pertabCtrl', ['$scope', '$http', '$routeParams', '$window' , return str.join("&"); } }).then(function successCallback(resp) { - console.info(resp.data); - chartShow = true; - if (resp.data.length > 0) - for (var i = 0 ; i<resp.data.length ; i++){ - $scope.valuess[i] = {}; - $scope.valuess[i].x = i+1; - $scope.valuess[i].y = resp.data[i]; - $scope.valuess[i].x.length = i; - } - else - $scope.valuess = []; - for (var d = 0; d < 5; d++) { - window.setTimeout(function () { - redraw("_performance", $scope.valuess); - }, 1500); - }; + console.info(resp); + if (resp.data.length > 0){ + $scope.ndaShow = false; + $scope.hdaShow = true; + $scope.data = [ + { + "key" : "Count" , + "bar": true, + "values" : resp.data + }]; + $scope.api.refresh(); + } + else{ + $scope.ndaShow = true; + $scope.hdaShow = false; + $scope.data = [ + { + "key" : "Count" , + "bar": true, + "values" : [] + }]; + $scope.api.refresh(); + } + },function errorCallback(resp) { }); - } + }; $scope.open1 = function() { $scope.popup1.opened = true; @@ -164,8 +229,14 @@ app.controller('pertabCtrl', ['$scope', '$http', '$routeParams', '$window' , opened: false }; + $scope.modeShow = false; + + $scope.showModeIds = ["minute","hour","day","month","year"]; + function FormatDate (strTime) { var date = new Date(strTime); return date.getFullYear()+"-"+(date.getMonth()+1)+"-"+date.getDate()+" "+date.getHours()+":"+date.getMinutes(); } -}]); + + + }]); 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: '<a ng-click="grid.appScope.jump(row.entity.performanceHeader.sourceId)"; style="cursor:pointer" href="">{{row.entity.performanceHeader.sourceId}}</a>', - }, - {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: '<button ng-click="grid.appScope.jump(row.entity.performanceHeader.sourceId)" class="btn btn-primary" >Details</button>'} - ], - 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:"<div></div>", - 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: '<input type="text" class="select-page" ng-model="inputPage" ng-change="selectPage(inputPage)">', + link: function(scope, element, attrs) { + scope.$watch('currentPage', function(c) { + scope.inputPage = c; + }); + } + } +}); + |