|
|
@ -47,11 +47,37 @@ function TimeseriesTableWidget() { |
|
|
/*@ngInject*/ |
|
|
/*@ngInject*/ |
|
|
function TimeseriesTableWidgetController($element, $scope, $filter) { |
|
|
function TimeseriesTableWidgetController($element, $scope, $filter) { |
|
|
var vm = this; |
|
|
var vm = this; |
|
|
|
|
|
let dateFormatFilter = 'yyyy-MM-dd HH:mm:ss'; |
|
|
|
|
|
|
|
|
vm.sources = []; |
|
|
vm.sources = []; |
|
|
vm.sourceIndex = 0; |
|
|
vm.sourceIndex = 0; |
|
|
vm.defaultPageSize = 10; |
|
|
vm.defaultPageSize = 10; |
|
|
vm.defaultSortOrder = '-0'; |
|
|
vm.defaultSortOrder = '-0'; |
|
|
|
|
|
vm.query = { |
|
|
|
|
|
"search": null |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
vm.enterFilterMode = enterFilterMode; |
|
|
|
|
|
vm.exitFilterMode = exitFilterMode; |
|
|
|
|
|
|
|
|
|
|
|
function enterFilterMode () { |
|
|
|
|
|
vm.query.search = ''; |
|
|
|
|
|
vm.ctx.hideTitlePanel = true; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function exitFilterMode () { |
|
|
|
|
|
vm.query.search = null; |
|
|
|
|
|
vm.ctx.hideTitlePanel = false; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
vm.searchAction = { |
|
|
|
|
|
name: 'action.search', |
|
|
|
|
|
show: true, |
|
|
|
|
|
onAction: function() { |
|
|
|
|
|
vm.enterFilterMode(); |
|
|
|
|
|
}, |
|
|
|
|
|
icon: 'search' |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
$scope.$watch('vm.ctx', function() { |
|
|
$scope.$watch('vm.ctx', function() { |
|
|
if (vm.ctx) { |
|
|
if (vm.ctx) { |
|
|
@ -64,6 +90,7 @@ function TimeseriesTableWidgetController($element, $scope, $filter) { |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
function initialize() { |
|
|
function initialize() { |
|
|
|
|
|
vm.ctx.widgetActions = [ vm.searchAction ]; |
|
|
vm.showTimestamp = vm.settings.showTimestamp !== false; |
|
|
vm.showTimestamp = vm.settings.showTimestamp !== false; |
|
|
var origColor = vm.widgetConfig.color || 'rgba(0, 0, 0, 0.87)'; |
|
|
var origColor = vm.widgetConfig.color || 'rgba(0, 0, 0, 0.87)'; |
|
|
var defaultColor = tinycolor(origColor); |
|
|
var defaultColor = tinycolor(origColor); |
|
|
@ -167,7 +194,7 @@ function TimeseriesTableWidgetController($element, $scope, $filter) { |
|
|
|
|
|
|
|
|
vm.cellContent = function(source, index, row, value) { |
|
|
vm.cellContent = function(source, index, row, value) { |
|
|
if (index === 0) { |
|
|
if (index === 0) { |
|
|
return $filter('date')(value, 'yyyy-MM-dd HH:mm:ss'); |
|
|
return $filter('date')(value, dateFormatFilter); |
|
|
} else { |
|
|
} else { |
|
|
var strContent = ''; |
|
|
var strContent = ''; |
|
|
if (angular.isDefined(value)) { |
|
|
if (angular.isDefined(value)) { |
|
|
@ -291,7 +318,30 @@ function TimeseriesTableWidgetController($element, $scope, $filter) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function reorder(source) { |
|
|
function reorder(source) { |
|
|
|
|
|
let searchRegExp = new RegExp(vm.query.search); |
|
|
|
|
|
|
|
|
source.data = $filter('orderBy')(source.data, source.query.order); |
|
|
source.data = $filter('orderBy')(source.data, source.query.order); |
|
|
|
|
|
if (vm.query.search !== null) { |
|
|
|
|
|
source.data = source.data.filter(function(item){ |
|
|
|
|
|
for (let i = 0; i < item.length; i++) { |
|
|
|
|
|
if (vm.showTimestamp) { |
|
|
|
|
|
if (i === 0) { |
|
|
|
|
|
if (searchRegExp.test($filter('date')(item[i], dateFormatFilter))) { |
|
|
|
|
|
return true; |
|
|
|
|
|
} |
|
|
|
|
|
} else { |
|
|
|
|
|
if (searchRegExp.test(item[i])) { |
|
|
|
|
|
return true; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} else { |
|
|
|
|
|
if (searchRegExp.test(item[i])) { |
|
|
|
|
|
return true; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function convertData(data) { |
|
|
function convertData(data) { |
|
|
|