|
|
|
@ -50,11 +50,8 @@ function DatasourceEntity($compile, $templateCache, $q, $mdDialog, $window, $doc |
|
|
|
scope.alarmFields.push(alarmField); |
|
|
|
} |
|
|
|
|
|
|
|
scope.selectedTimeseriesDataKey = null; |
|
|
|
scope.timeseriesDataKeySearchText = null; |
|
|
|
|
|
|
|
scope.selectedAttributeDataKey = null; |
|
|
|
scope.attributeDataKeySearchText = null; |
|
|
|
scope.selectedDataKey = null; |
|
|
|
scope.dataKeySearchText = null; |
|
|
|
|
|
|
|
scope.selectedAlarmDataKey = null; |
|
|
|
scope.alarmDataKeySearchText = null; |
|
|
|
@ -92,11 +89,7 @@ function DatasourceEntity($compile, $templateCache, $q, $mdDialog, $window, $doc |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
scope.$watch('timeseriesDataKeys', function () { |
|
|
|
updateDataKeys(); |
|
|
|
}, true); |
|
|
|
|
|
|
|
scope.$watch('attributeDataKeys', function () { |
|
|
|
scope.$watch('dataKeys', function () { |
|
|
|
updateDataKeys(); |
|
|
|
}, true); |
|
|
|
|
|
|
|
@ -107,10 +100,9 @@ function DatasourceEntity($compile, $templateCache, $q, $mdDialog, $window, $doc |
|
|
|
function updateDataKeys() { |
|
|
|
if (ngModelCtrl.$viewValue) { |
|
|
|
var dataKeys = []; |
|
|
|
dataKeys = dataKeys.concat(scope.timeseriesDataKeys); |
|
|
|
dataKeys = dataKeys.concat(scope.attributeDataKeys); |
|
|
|
dataKeys = dataKeys.concat(scope.dataKeys); |
|
|
|
dataKeys = dataKeys.concat(scope.alarmDataKeys); |
|
|
|
if (ngModelCtrl.$viewValue.dataKeys != dataKeys) |
|
|
|
if (!angular.equals(ngModelCtrl.$viewValue.dataKeys, dataKeys)) |
|
|
|
{ |
|
|
|
ngModelCtrl.$setDirty(); |
|
|
|
ngModelCtrl.$viewValue.dataKeys = dataKeys; |
|
|
|
@ -128,21 +120,17 @@ function DatasourceEntity($compile, $templateCache, $q, $mdDialog, $window, $doc |
|
|
|
} else { |
|
|
|
scope.entityAlias = null; |
|
|
|
} |
|
|
|
var timeseriesDataKeys = []; |
|
|
|
var attributeDataKeys = []; |
|
|
|
var dataKeys = []; |
|
|
|
var alarmDataKeys = []; |
|
|
|
for (var d in ngModelCtrl.$viewValue.dataKeys) { |
|
|
|
var dataKey = ngModelCtrl.$viewValue.dataKeys[d]; |
|
|
|
if (dataKey.type === types.dataKeyType.timeseries) { |
|
|
|
timeseriesDataKeys.push(dataKey); |
|
|
|
} else if (dataKey.type === types.dataKeyType.attribute) { |
|
|
|
attributeDataKeys.push(dataKey); |
|
|
|
if ((dataKey.type === types.dataKeyType.timeseries) || (dataKey.type === types.dataKeyType.attribute)) { |
|
|
|
dataKeys.push(dataKey); |
|
|
|
} else if (dataKey.type === types.dataKeyType.alarm) { |
|
|
|
alarmDataKeys.push(dataKey); |
|
|
|
} |
|
|
|
} |
|
|
|
scope.timeseriesDataKeys = timeseriesDataKeys; |
|
|
|
scope.attributeDataKeys = attributeDataKeys; |
|
|
|
scope.dataKeys = dataKeys; |
|
|
|
scope.alarmDataKeys = alarmDataKeys; |
|
|
|
} |
|
|
|
}; |
|
|
|
@ -152,30 +140,19 @@ function DatasourceEntity($compile, $templateCache, $q, $mdDialog, $window, $doc |
|
|
|
} |
|
|
|
|
|
|
|
scope.selectedEntityAliasChange = function () { |
|
|
|
if (!scope.timeseriesDataKeySearchText || scope.timeseriesDataKeySearchText === '') { |
|
|
|
scope.timeseriesDataKeySearchText = scope.timeseriesDataKeySearchText === '' ? null : ''; |
|
|
|
} |
|
|
|
if (!scope.attributeDataKeySearchText || scope.attributeDataKeySearchText === '') { |
|
|
|
scope.attributeDataKeySearchText = scope.attributeDataKeySearchText === '' ? null : ''; |
|
|
|
if (!scope.dataKeySearchText || scope.dataKeySearchText === '') { |
|
|
|
scope.dataKeySearchText = scope.dataKeySearchText === '' ? null : ''; |
|
|
|
} |
|
|
|
if (!scope.alarmDataKeySearchText || scope.alarmDataKeySearchText === '') { |
|
|
|
scope.alarmDataKeySearchText = scope.alarmDataKeySearchText === '' ? null : ''; |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
scope.transformTimeseriesDataKeyChip = function (chip) { |
|
|
|
if (scope.maxDataKeys > 0 && ngModelCtrl.$viewValue.dataKeys.length >= scope.maxDataKeys ) { |
|
|
|
return null; |
|
|
|
} else { |
|
|
|
return scope.generateDataKey({chip: chip, type: types.dataKeyType.timeseries}); |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
scope.transformAttributeDataKeyChip = function (chip) { |
|
|
|
scope.transformDataKeyChip = function (chip) { |
|
|
|
if (scope.maxDataKeys > 0 && ngModelCtrl.$viewValue.dataKeys.length >= scope.maxDataKeys ) { |
|
|
|
return null; |
|
|
|
} else { |
|
|
|
return scope.generateDataKey({chip: chip, type: types.dataKeyType.attribute}); |
|
|
|
return scope.generateDataKey({chip: chip.name, type: chip.type}); |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
@ -230,10 +207,8 @@ function DatasourceEntity($compile, $templateCache, $q, $mdDialog, $window, $doc |
|
|
|
w.triggerHandler('resize'); |
|
|
|
} |
|
|
|
}).then(function (dataKey) { |
|
|
|
if (dataKey.type === types.dataKeyType.timeseries) { |
|
|
|
scope.timeseriesDataKeys[index] = dataKey; |
|
|
|
} else if (dataKey.type === types.dataKeyType.attribute) { |
|
|
|
scope.attributeDataKeys[index] = dataKey; |
|
|
|
if ((dataKey.type === types.dataKeyType.timeseries) || (dataKey.type === types.dataKeyType.attribute)) { |
|
|
|
scope.dataKeys[index] = dataKey; |
|
|
|
} else if (dataKey.type === types.dataKeyType.alarm) { |
|
|
|
scope.alarmDataKeys[index] = dataKey; |
|
|
|
} |
|
|
|
@ -242,7 +217,7 @@ function DatasourceEntity($compile, $templateCache, $q, $mdDialog, $window, $doc |
|
|
|
}); |
|
|
|
}; |
|
|
|
|
|
|
|
scope.dataKeysSearch = function (searchText, type) { |
|
|
|
scope.dataKeysSearch = function (searchText) { |
|
|
|
if (scope.widgetType == types.widgetType.alarm.value) { |
|
|
|
var dataKeys = searchText ? scope.alarmFields.filter( |
|
|
|
scope.createFilterForDataKey(searchText)) : scope.alarmFields; |
|
|
|
@ -250,9 +225,25 @@ function DatasourceEntity($compile, $templateCache, $q, $mdDialog, $window, $doc |
|
|
|
} else { |
|
|
|
if (scope.entityAlias) { |
|
|
|
var deferred = $q.defer(); |
|
|
|
scope.fetchEntityKeys({entityAliasId: scope.entityAlias.id, query: searchText, type: type}) |
|
|
|
scope.fetchEntityKeys({entityAliasId: scope.entityAlias.id, query: searchText, type: types.dataKeyType.timeseries}) |
|
|
|
.then(function (dataKeys) { |
|
|
|
deferred.resolve(dataKeys); |
|
|
|
var items = []; |
|
|
|
for (var i = 0; i < dataKeys.length; i++) { |
|
|
|
items.push({ name: dataKeys[i], type: types.dataKeyType.timeseries }); |
|
|
|
} |
|
|
|
if (scope.widgetType == types.widgetType.latest.value) { |
|
|
|
scope.fetchEntityKeys({entityAliasId: scope.entityAlias.id, query: searchText, type: types.dataKeyType.attribute}) |
|
|
|
.then(function (dataKeys) { |
|
|
|
for (var i = 0; i < dataKeys.length; i++) { |
|
|
|
items.push({ name: dataKeys[i], type: types.dataKeyType.attribute }); |
|
|
|
} |
|
|
|
deferred.resolve(items); |
|
|
|
}, function (e) { |
|
|
|
deferred.reject(e); |
|
|
|
}); |
|
|
|
} |
|
|
|
else |
|
|
|
deferred.resolve(items); |
|
|
|
}, function (e) { |
|
|
|
deferred.reject(e); |
|
|
|
}); |
|
|
|
@ -270,13 +261,13 @@ function DatasourceEntity($compile, $templateCache, $q, $mdDialog, $window, $doc |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
scope.createKey = function (event, chipsId) { |
|
|
|
scope.createKey = function (event, type, chipsId) { |
|
|
|
var chipsChild = $(chipsId, element)[0].firstElementChild; |
|
|
|
var el = angular.element(chipsChild); |
|
|
|
var chipBuffer = el.scope().$mdChipsCtrl.getChipBuffer(); |
|
|
|
event.preventDefault(); |
|
|
|
event.stopPropagation(); |
|
|
|
el.scope().$mdChipsCtrl.appendChip(chipBuffer.trim()); |
|
|
|
el.scope().$mdChipsCtrl.appendChip({ name: chipBuffer.trim(), type: type}); |
|
|
|
el.scope().$mdChipsCtrl.resetChipBuffer(); |
|
|
|
} |
|
|
|
|
|
|
|
|