38 changed files with 1415 additions and 369 deletions
@ -0,0 +1,259 @@ |
|||
/* |
|||
* Copyright © 2016-2017 The Thingsboard Authors |
|||
* |
|||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|||
* you may not use this file except in compliance with the License. |
|||
* You may obtain a copy of the License at |
|||
* |
|||
* http://www.apache.org/licenses/LICENSE-2.0
|
|||
* |
|||
* Unless required by applicable law or agreed to in writing, software |
|||
* distributed under the License is distributed on an "AS IS" BASIS, |
|||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
* See the License for the specific language governing permissions and |
|||
* limitations under the License. |
|||
*/ |
|||
|
|||
const varsRegex = /\$\{([^\}]*)\}/g; |
|||
|
|||
export default class AliasController { |
|||
|
|||
constructor($scope, $q, $filter, utils, types, entityService, stateController, entityAliases) { |
|||
this.$scope = $scope; |
|||
this.$q = $q; |
|||
this.$filter = $filter; |
|||
this.utils = utils; |
|||
this.types = types; |
|||
this.entityService = entityService; |
|||
this.stateController = stateController; |
|||
this.entityAliases = angular.copy(entityAliases); |
|||
this.resolvedAliases = {}; |
|||
this.resolvedAliasesPromise = {}; |
|||
this.resolvedAliasesToStateEntities = {}; |
|||
} |
|||
|
|||
updateEntityAliases(newEntityAliases) { |
|||
var changedAliasIds = []; |
|||
for (var aliasId in newEntityAliases) { |
|||
var newEntityAlias = newEntityAliases[aliasId]; |
|||
var prevEntityAlias = this.entityAliases[aliasId]; |
|||
if (!angular.equals(newEntityAlias, prevEntityAlias)) { |
|||
changedAliasIds.push(aliasId); |
|||
this.setAliasUnresolved(aliasId); |
|||
} |
|||
} |
|||
for (aliasId in this.entityAliases) { |
|||
if (!newEntityAliases[aliasId]) { |
|||
changedAliasIds.push(aliasId); |
|||
this.setAliasUnresolved(aliasId); |
|||
} |
|||
} |
|||
this.entityAliases = angular.copy(newEntityAliases); |
|||
if (changedAliasIds.length) { |
|||
this.$scope.$broadcast('entityAliasesChanged', changedAliasIds); |
|||
} |
|||
} |
|||
|
|||
dashboardStateChanged() { |
|||
var newEntityId = this.stateController.getStateParams().entityId; |
|||
var changedAliasIds = []; |
|||
for (var aliasId in this.resolvedAliasesToStateEntities) { |
|||
var prevEntityId = this.resolvedAliasesToStateEntities[aliasId]; |
|||
if (!angular.equals(newEntityId, prevEntityId)) { |
|||
changedAliasIds.push(aliasId); |
|||
this.setAliasUnresolved(aliasId); |
|||
} |
|||
} |
|||
if (changedAliasIds.length) { |
|||
this.$scope.$broadcast('entityAliasesChanged', changedAliasIds); |
|||
} |
|||
} |
|||
|
|||
setAliasUnresolved(aliasId) { |
|||
delete this.resolvedAliases[aliasId]; |
|||
delete this.resolvedAliasesPromise[aliasId]; |
|||
delete this.resolvedAliasesToStateEntities[aliasId]; |
|||
} |
|||
|
|||
getEntityAliases() { |
|||
return this.entityAliases; |
|||
} |
|||
|
|||
getAliasInfo(aliasId) { |
|||
var deferred = this.$q.defer(); |
|||
var aliasInfo = this.resolvedAliases[aliasId]; |
|||
if (aliasInfo) { |
|||
deferred.resolve(aliasInfo); |
|||
return deferred.promise; |
|||
} else if (this.resolvedAliasesPromise[aliasId]) { |
|||
return this.resolvedAliasesPromise[aliasId]; |
|||
} else { |
|||
this.resolvedAliasesPromise[aliasId] = deferred.promise; |
|||
var aliasCtrl = this; |
|||
var entityAlias = this.entityAliases[aliasId]; |
|||
if (entityAlias) { |
|||
this.entityService.resolveAlias(entityAlias, this.stateController.getStateParams()).then( |
|||
function success(aliasInfo) { |
|||
aliasCtrl.resolvedAliases[aliasId] = aliasInfo; |
|||
if (entityAlias.filter.stateEntity) { |
|||
aliasCtrl.resolvedAliasesToStateEntities[aliasId] = |
|||
aliasCtrl.stateController.getStateParams().entityId; |
|||
} |
|||
deferred.resolve(aliasInfo); |
|||
}, |
|||
function fail() { |
|||
deferred.reject(); |
|||
} |
|||
); |
|||
} else { |
|||
deferred.reject(); |
|||
} |
|||
return this.resolvedAliasesPromise[aliasId]; |
|||
} |
|||
} |
|||
|
|||
resolveDatasource(datasource) { |
|||
var deferred = this.$q.defer(); |
|||
if (datasource.type === this.types.datasourceType.entity) { |
|||
if (datasource.entityAliasId) { |
|||
this.getAliasInfo(datasource.entityAliasId).then( |
|||
function success(aliasInfo) { |
|||
datasource.aliasName = aliasInfo.alias; |
|||
if (aliasInfo.resolveMultiple) { |
|||
var resolvedEntities = aliasInfo.resolvedEntities; |
|||
if (resolvedEntities && resolvedEntities.length) { |
|||
var datasources = []; |
|||
for (var i=0;i<resolvedEntities.length;i++) { |
|||
var resolvedEntity = resolvedEntities[i]; |
|||
var newDatasource = angular.copy(datasource); |
|||
newDatasource.entityId = resolvedEntity.id; |
|||
newDatasource.entityType = resolvedEntity.entityType; |
|||
newDatasource.entityName = resolvedEntity.name; |
|||
newDatasource.name = resolvedEntity.name; |
|||
newDatasource.generated = i > 0 ? true : false; |
|||
datasources.push(newDatasource); |
|||
} |
|||
deferred.resolve(datasources); |
|||
} else { |
|||
deferred.reject(); |
|||
} |
|||
} else { |
|||
var entity = aliasInfo.currentEntity; |
|||
datasource.entityId = entity.id; |
|||
datasource.entityType = entity.entityType; |
|||
datasource.entityName = entity.name; |
|||
datasource.name = entity.name; |
|||
deferred.resolve([datasource]); |
|||
} |
|||
}, |
|||
function fail() { |
|||
deferred.reject(); |
|||
} |
|||
); |
|||
} else { // entityId
|
|||
datasource.aliasName = datasource.entityName; |
|||
datasource.name = datasource.entityName; |
|||
deferred.resolve([datasource]); |
|||
} |
|||
} else { // function
|
|||
deferred.resolve([datasource]); |
|||
} |
|||
return deferred.promise; |
|||
} |
|||
|
|||
resolveDatasources(datasources) { |
|||
|
|||
function updateDataKeyLabel(dataKey, datasource) { |
|||
if (!dataKey.pattern) { |
|||
dataKey.pattern = angular.copy(dataKey.label); |
|||
} |
|||
var pattern = dataKey.pattern; |
|||
var label = dataKey.pattern; |
|||
var match = varsRegex.exec(pattern); |
|||
while (match !== null) { |
|||
var variable = match[0]; |
|||
var variableName = match[1]; |
|||
if (variableName === 'dsName') { |
|||
label = label.split(variable).join(datasource.name); |
|||
} else if (variableName === 'entityName') { |
|||
label = label.split(variable).join(datasource.entityName); |
|||
} else if (variableName === 'deviceName') { |
|||
label = label.split(variable).join(datasource.entityName); |
|||
} else if (variableName === 'aliasName') { |
|||
label = label.split(variable).join(datasource.aliasName); |
|||
} |
|||
match = varsRegex.exec(pattern); |
|||
} |
|||
dataKey.label = label; |
|||
} |
|||
|
|||
function updateDatasourceKeyLabels(datasource) { |
|||
for (var dk = 0; dk < datasource.dataKeys.length; dk++) { |
|||
updateDataKeyLabel(datasource.dataKeys[dk], datasource); |
|||
} |
|||
} |
|||
|
|||
var deferred = this.$q.defer(); |
|||
var newDatasources = angular.copy(datasources); |
|||
var datasorceResolveTasks = []; |
|||
var aliasCtrl = this; |
|||
newDatasources.forEach(function (datasource) { |
|||
var resolveDatasourceTask = aliasCtrl.resolveDatasource(datasource); |
|||
datasorceResolveTasks.push(resolveDatasourceTask); |
|||
}); |
|||
this.$q.all(datasorceResolveTasks).then( |
|||
function success(datasourcesArrays) { |
|||
var datasources = [].concat.apply([], datasourcesArrays); |
|||
datasources = aliasCtrl.$filter('orderBy')(datasources, '+generated'); |
|||
var index = 0; |
|||
var functionIndex = 0; |
|||
datasources.forEach(function(datasource) { |
|||
if (datasource.type === aliasCtrl.types.datasourceType.function) { |
|||
var name; |
|||
if (datasource.name && datasource.name.length) { |
|||
name = datasource.name; |
|||
} else { |
|||
functionIndex++; |
|||
name = aliasCtrl.types.datasourceType.function; |
|||
if (functionIndex > 1) { |
|||
name += ' ' + functionIndex; |
|||
} |
|||
} |
|||
datasource.name = name; |
|||
datasource.aliasName = name; |
|||
datasource.entityName = name; |
|||
} |
|||
datasource.dataKeys.forEach(function(dataKey) { |
|||
if (datasource.generated) { |
|||
dataKey._hash = Math.random(); |
|||
dataKey.color = aliasCtrl.utils.getMaterialColor(index); |
|||
} |
|||
index++; |
|||
}); |
|||
updateDatasourceKeyLabels(datasource); |
|||
}); |
|||
deferred.resolve(datasources); |
|||
}, |
|||
function fail() { |
|||
deferred.reject(); |
|||
} |
|||
); |
|||
return deferred.promise; |
|||
} |
|||
|
|||
getInstantAliasInfo(aliasId) { |
|||
return this.resolvedAliases[aliasId]; |
|||
} |
|||
|
|||
updateCurrentAliasEntity(aliasId, currentEntity) { |
|||
var aliasInfo = this.resolvedAliases[aliasId]; |
|||
if (aliasInfo) { |
|||
var prevCurrentEntity = aliasInfo.currentEntity; |
|||
if (!angular.equals(currentEntity, prevCurrentEntity)) { |
|||
aliasInfo.currentEntity = currentEntity; |
|||
this.$scope.$broadcast('entityAliasesChanged', [aliasId]); |
|||
} |
|||
} |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,104 @@ |
|||
/* |
|||
* Copyright © 2016-2017 The Thingsboard Authors |
|||
* |
|||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|||
* you may not use this file except in compliance with the License. |
|||
* You may obtain a copy of the License at |
|||
* |
|||
* http://www.apache.org/licenses/LICENSE-2.0
|
|||
* |
|||
* Unless required by applicable law or agreed to in writing, software |
|||
* distributed under the License is distributed on an "AS IS" BASIS, |
|||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
* See the License for the specific language governing permissions and |
|||
* limitations under the License. |
|||
*/ |
|||
|
|||
/*@ngInject*/ |
|||
export default function EntityFilterDialogController($scope, $mdDialog, $q, entityService, types, isAdd, allowedEntityTypes, filter) { |
|||
|
|||
var vm = this; |
|||
|
|||
vm.types = types; |
|||
vm.isAdd = isAdd; |
|||
vm.allowedEntityTypes = allowedEntityTypes; |
|||
vm.filter = filter; |
|||
|
|||
vm.cancel = cancel; |
|||
vm.save = save; |
|||
|
|||
$scope.$watch('vm.filter.type', function (newType, prevType) { |
|||
if (newType && newType != prevType) { |
|||
updateFilter(); |
|||
} |
|||
}); |
|||
|
|||
$scope.$watch('theForm.$pristine', function() { |
|||
if ($scope.theForm && !$scope.theForm.$pristine) { |
|||
$scope.theForm.$setValidity('entityFilter', true); |
|||
} |
|||
}); |
|||
|
|||
function updateFilter() { |
|||
var filter = {}; |
|||
filter.type = vm.filter.type; |
|||
filter.resolveMultiple = vm.filter.resolveMultiple; |
|||
switch (filter.type) { |
|||
case types.aliasFilterType.entityList.value: |
|||
filter.entityType = null; |
|||
filter.entityList = []; |
|||
filter.stateEntity = false; |
|||
break; |
|||
case types.aliasFilterType.entityName.value: |
|||
filter.entityType = null; |
|||
filter.entityNameFilter = ''; |
|||
break; |
|||
//TODO:
|
|||
} |
|||
vm.filter = filter; |
|||
} |
|||
|
|||
function validate() { |
|||
var deferred = $q.defer(); |
|||
var validationResult = { |
|||
entity: null, |
|||
stateEntity: false |
|||
} |
|||
entityService.resolveAliasFilter(vm.filter).then( |
|||
function success(result) { |
|||
validationResult.stateEntity = result.stateEntity; |
|||
var entities = result.entities; |
|||
if (entities.length) { |
|||
validationResult.entity = entities[0]; |
|||
} |
|||
deferred.resolve(validationResult); |
|||
}, |
|||
function fail() { |
|||
deferred.reject(); |
|||
} |
|||
); |
|||
return deferred.promise; |
|||
} |
|||
|
|||
function cancel() { |
|||
$mdDialog.cancel(); |
|||
} |
|||
|
|||
function save() { |
|||
$scope.theForm.$setPristine(); |
|||
validate().then( |
|||
function success(validationResult) { |
|||
$mdDialog.hide({ |
|||
filter: vm.filter, |
|||
entity: validationResult.entity, |
|||
stateEntity: validationResult.stateEntity |
|||
}); |
|||
}, |
|||
function fail() { |
|||
$scope.theForm.$setValidity('entityFilter', false); |
|||
} |
|||
) |
|||
} |
|||
|
|||
} |
|||
|
|||
@ -0,0 +1,100 @@ |
|||
<!-- |
|||
|
|||
Copyright © 2016-2017 The Thingsboard Authors |
|||
|
|||
Licensed under the Apache License, Version 2.0 (the "License"); |
|||
you may not use this file except in compliance with the License. |
|||
You may obtain a copy of the License at |
|||
|
|||
http://www.apache.org/licenses/LICENSE-2.0 |
|||
|
|||
Unless required by applicable law or agreed to in writing, software |
|||
distributed under the License is distributed on an "AS IS" BASIS, |
|||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
See the License for the specific language governing permissions and |
|||
limitations under the License. |
|||
|
|||
--> |
|||
<md-dialog class="tb-entity-filter-dialog" style="width: 600px;" aria-label="{{ 'alias.entity-filter' | translate }}"> |
|||
<form name="theForm" ng-submit="vm.save()"> |
|||
<md-toolbar> |
|||
<div class="md-toolbar-tools"> |
|||
<h2>{{ (vm.isAdd ? 'alias.create-entity-filter' : 'alias.edit-entity-filter') | translate }}</h2> |
|||
<span flex></span> |
|||
<md-button class="md-icon-button" ng-click="vm.cancel()"> |
|||
<ng-md-icon icon="close" aria-label="{{ 'dialog.close' | translate }}"></ng-md-icon> |
|||
</md-button> |
|||
</div> |
|||
</md-toolbar> |
|||
<md-progress-linear class="md-warn" md-mode="indeterminate" ng-disabled="!loading" ng-show="loading"></md-progress-linear> |
|||
<span style="min-height: 5px;" flex="" ng-show="!loading"></span> |
|||
<md-dialog-content> |
|||
<div class="md-dialog-content"> |
|||
<fieldset ng-disabled="loading"> |
|||
<div flex layout="column"> |
|||
<md-input-container> |
|||
<label>{{ 'alias.filter-type' | translate }}</label> |
|||
<md-select required name="filterType" |
|||
ng-model="vm.filter.type" aria-label="{{ 'alias.filter-type' | translate }}"> |
|||
<md-option ng-repeat="type in vm.types.aliasFilterType" ng-value="type.value"> |
|||
{{type.name | translate}} |
|||
</md-option> |
|||
</md-select> |
|||
<div ng-messages="theForm.filterType.$error"> |
|||
<div ng-message="required" translate>alias.filter-type-required</div> |
|||
</div> |
|||
</md-input-container> |
|||
<section layout="column" ng-if="vm.filter.type == vm.types.aliasFilterType.entityList.value" id="entityListFilter"> |
|||
<md-checkbox flex aria-label="{{ 'alias.use-state-entity' | translate }}" |
|||
ng-model="vm.filter.stateEntity">{{ 'alias.use-state-entity' | translate }} |
|||
</md-checkbox> |
|||
<tb-entity-type-select |
|||
ng-if="!vm.filter.stateEntity" |
|||
ng-model="vm.filter.entityType" |
|||
the-form="theForm" |
|||
ng-disabled="vm.filter.stateEntity" |
|||
tb-required="!vm.filter.stateEntity" |
|||
allowed-entity-types="vm.allowedEntityTypes"> |
|||
</tb-entity-type-select> |
|||
<tb-entity-list |
|||
ng-if="!vm.filter.stateEntity" |
|||
ng-model="vm.filter.entityList" |
|||
ng-disabled="vm.filter.stateEntity" |
|||
tb-required="!vm.filter.stateEntity" |
|||
entity-type="vm.filter.entityType"> |
|||
</tb-entity-list> |
|||
</section> |
|||
<section flex layout="column" ng-if="vm.filter.type == vm.types.aliasFilterType.entityName.value" id="entityNameFilter"> |
|||
<tb-entity-type-select |
|||
ng-model="vm.filter.entityType" |
|||
the-form="theForm" |
|||
tb-required="true" |
|||
allowed-entity-types="vm.allowedEntityTypes"> |
|||
</tb-entity-type-select> |
|||
<md-input-container flex> |
|||
<label translate>entity.name-starts-with</label> |
|||
<input required name="entityNameFilter" |
|||
ng-model="vm.filter.entityNameFilter" |
|||
aria-label="{{ 'entity.name-starts-with' | translate }}"> |
|||
<div ng-messages="theForm.entityNameFilter.$error"> |
|||
<div ng-message="required" translate>entity.entity-name-filter-required</div> |
|||
</div> |
|||
|
|||
</md-input-container> |
|||
</section> |
|||
<div class="tb-error-messages" ng-messages="theForm.$error" role="alert"> |
|||
<div translate ng-message="entityFilter" class="tb-error-message">alias.entity-filter-no-entity-matched</div> |
|||
</div> |
|||
</div> |
|||
</fieldset> |
|||
</div> |
|||
</md-dialog-content> |
|||
<md-dialog-actions layout="row"> |
|||
<span flex></span> |
|||
<md-button ng-disabled="loading || theForm.$invalid || !theForm.$dirty" type="submit" class="md-raised md-primary"> |
|||
{{ 'action.save' | translate }} |
|||
</md-button> |
|||
<md-button ng-disabled="loading" ng-click="vm.cancel()" style="margin-right:20px;">{{ 'action.cancel' | translate }}</md-button> |
|||
</md-dialog-actions> |
|||
</form> |
|||
</md-dialog> |
|||
@ -0,0 +1,130 @@ |
|||
/* |
|||
* Copyright © 2016-2017 The Thingsboard Authors |
|||
* |
|||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|||
* you may not use this file except in compliance with the License. |
|||
* You may obtain a copy of the License at |
|||
* |
|||
* http://www.apache.org/licenses/LICENSE-2.0
|
|||
* |
|||
* Unless required by applicable law or agreed to in writing, software |
|||
* distributed under the License is distributed on an "AS IS" BASIS, |
|||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
* See the License for the specific language governing permissions and |
|||
* limitations under the License. |
|||
*/ |
|||
|
|||
/* eslint-disable import/no-unresolved, import/default */ |
|||
|
|||
import entityListTemplate from './entity-list.tpl.html'; |
|||
|
|||
/* eslint-enable import/no-unresolved, import/default */ |
|||
|
|||
import './entity-list.scss'; |
|||
|
|||
/*@ngInject*/ |
|||
export default function EntityListDirective($compile, $templateCache, $q, $mdUtil, entityService) { |
|||
|
|||
var linker = function (scope, element, attrs, ngModelCtrl) { |
|||
|
|||
var template = $templateCache.get(entityListTemplate); |
|||
element.html(template); |
|||
|
|||
scope.ngModelCtrl = ngModelCtrl; |
|||
|
|||
scope.$watch('tbRequired', function () { |
|||
scope.updateValidity(); |
|||
}); |
|||
|
|||
scope.fetchEntities = function(searchText, limit) { |
|||
var deferred = $q.defer(); |
|||
entityService.getEntitiesByNameFilter(scope.entityType, searchText, limit).then( |
|||
function success(result) { |
|||
if (result) { |
|||
deferred.resolve(result); |
|||
} else { |
|||
deferred.resolve([]); |
|||
} |
|||
}, |
|||
function fail() { |
|||
deferred.reject(); |
|||
} |
|||
); |
|||
return deferred.promise; |
|||
} |
|||
|
|||
scope.updateValidity = function() { |
|||
var value = ngModelCtrl.$viewValue; |
|||
var valid = !scope.tbRequired || value && value.length > 0; |
|||
ngModelCtrl.$setValidity('entityList', valid); |
|||
} |
|||
|
|||
ngModelCtrl.$render = function () { |
|||
destroyWatchers(); |
|||
var value = ngModelCtrl.$viewValue; |
|||
scope.entityList = []; |
|||
if (value && value.length > 0) { |
|||
entityService.getEntities(scope.entityType, value).then(function (entities) { |
|||
scope.entityList = entities; |
|||
initWatchers(); |
|||
}); |
|||
} else { |
|||
initWatchers(); |
|||
} |
|||
} |
|||
|
|||
function initWatchers() { |
|||
scope.entityTypeDeregistration = scope.$watch('entityType', function (newEntityType, prevEntityType) { |
|||
if (!angular.equals(newEntityType, prevEntityType)) { |
|||
scope.entityList = []; |
|||
} |
|||
}); |
|||
scope.entityListDeregistration = scope.$watch('entityList', function () { |
|||
var ids = []; |
|||
if (scope.entityList && scope.entityList.length > 0) { |
|||
for (var i=0;i<scope.entityList.length;i++) { |
|||
ids.push(scope.entityList[i].id.id); |
|||
} |
|||
} |
|||
var value = ngModelCtrl.$viewValue; |
|||
if (!angular.equals(ids, value)) { |
|||
ngModelCtrl.$setViewValue(ids); |
|||
} |
|||
scope.updateValidity(); |
|||
}, true); |
|||
} |
|||
|
|||
function destroyWatchers() { |
|||
if (scope.entityTypeDeregistration) { |
|||
scope.entityTypeDeregistration(); |
|||
scope.entityTypeDeregistration = null; |
|||
} |
|||
if (scope.entityListDeregistration) { |
|||
scope.entityListDeregistration(); |
|||
scope.entityListDeregistration = null; |
|||
} |
|||
} |
|||
|
|||
$compile(element.contents())(scope); |
|||
|
|||
$mdUtil.nextTick(function(){ |
|||
var inputElement = angular.element('input', element); |
|||
inputElement.on('blur', function() { |
|||
scope.inputTouched = true; |
|||
} ); |
|||
}); |
|||
|
|||
} |
|||
|
|||
return { |
|||
restrict: "E", |
|||
require: "^ngModel", |
|||
link: linker, |
|||
scope: { |
|||
disabled:'=ngDisabled', |
|||
tbRequired: '=?', |
|||
entityType: '=' |
|||
} |
|||
}; |
|||
|
|||
} |
|||
@ -0,0 +1,30 @@ |
|||
/** |
|||
* Copyright © 2016-2017 The Thingsboard Authors |
|||
* |
|||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|||
* you may not use this file except in compliance with the License. |
|||
* You may obtain a copy of the License at |
|||
* |
|||
* http://www.apache.org/licenses/LICENSE-2.0 |
|||
* |
|||
* Unless required by applicable law or agreed to in writing, software |
|||
* distributed under the License is distributed on an "AS IS" BASIS, |
|||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
* See the License for the specific language governing permissions and |
|||
* limitations under the License. |
|||
*/ |
|||
|
|||
/*.tb-entity-list { |
|||
#entity_list_chips { |
|||
.md-chips { |
|||
padding-bottom: 1px; |
|||
} |
|||
} |
|||
.tb-error-messages { |
|||
margin-top: -11px; |
|||
height: 35px; |
|||
.tb-error-message { |
|||
padding-left: 1px; |
|||
} |
|||
} |
|||
}*/ |
|||
@ -0,0 +1,52 @@ |
|||
<!-- |
|||
|
|||
Copyright © 2016-2017 The Thingsboard Authors |
|||
|
|||
Licensed under the Apache License, Version 2.0 (the "License"); |
|||
you may not use this file except in compliance with the License. |
|||
You may obtain a copy of the License at |
|||
|
|||
http://www.apache.org/licenses/LICENSE-2.0 |
|||
|
|||
Unless required by applicable law or agreed to in writing, software |
|||
distributed under the License is distributed on an "AS IS" BASIS, |
|||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
See the License for the specific language governing permissions and |
|||
limitations under the License. |
|||
|
|||
--> |
|||
|
|||
<section flex layout='column' class="tb-entity-list"> |
|||
<md-chips flex |
|||
readonly="disabled" |
|||
id="entity_list_chips" |
|||
ng-required="tbRequired" |
|||
ng-model="entityList" |
|||
md-autocomplete-snap |
|||
md-require-match="true"> |
|||
<md-autocomplete |
|||
md-no-cache="true" |
|||
id="entity" |
|||
md-selected-item="selectedEntity" |
|||
md-search-text="entitySearchText" |
|||
md-items="item in fetchEntities(entitySearchText, 10)" |
|||
md-item-text="item.name" |
|||
md-min-length="0" |
|||
placeholder="{{ 'entity.entity-list' | translate }}"> |
|||
<md-item-template> |
|||
<span md-highlight-text="entitySearchText" md-highlight-flags="^i">{{item.name}}</span> |
|||
</md-item-template> |
|||
<md-not-found> |
|||
<span translate translate-values='{ entity: entitySearchText }'>entity.no-entities-matching</span> |
|||
</md-not-found> |
|||
</md-autocomplete> |
|||
<md-chip-template> |
|||
<span> |
|||
<strong>{{$chip.name}}</strong> |
|||
</span> |
|||
</md-chip-template> |
|||
</md-chips> |
|||
<div class="tb-error-messages" ng-messages="ngModelCtrl.$error" ng-if="inputTouched" role="alert"> |
|||
<div translate ng-message="entityList" class="tb-error-message">entity.entity-list-empty</div> |
|||
</div> |
|||
</section> |
|||
Loading…
Reference in new issue