Commit 3881dc8423623e636d5c10b50160373b08a9433a
Committed by
GitHub
1 parent
fcf436c6
Add new alias Current tenant (#2596)
Showing
8 changed files
with
21 additions
and
5 deletions
... | ... | @@ -435,6 +435,10 @@ function EntityService($http, $q, $filter, $translate, $log, userService, device |
435 | 435 | if (user.authority === 'CUSTOMER_USER') { |
436 | 436 | entityId.id = user.customerId; |
437 | 437 | } |
438 | + } else if (entityType === types.aliasEntityType.current_tenant){ | |
439 | + let user = userService.getCurrentUser(); | |
440 | + entityId.entityType = types.entityType.tenant; | |
441 | + entityId.id = user.tenantId; | |
438 | 442 | } |
439 | 443 | return entityId; |
440 | 444 | } |
... | ... | @@ -806,6 +810,7 @@ function EntityService($http, $q, $filter, $translate, $log, userService, device |
806 | 810 | entityTypes.dashboard = types.entityType.dashboard; |
807 | 811 | if (useAliasEntityTypes) { |
808 | 812 | entityTypes.current_customer = types.aliasEntityType.current_customer; |
813 | + entityTypes.current_tenant = types.aliasEntityType.current_tenant; | |
809 | 814 | } |
810 | 815 | break; |
811 | 816 | case 'CUSTOMER_USER': | ... | ... |
... | ... | @@ -408,7 +408,8 @@ export default angular.module('thingsboard.types', []) |
408 | 408 | } |
409 | 409 | }, |
410 | 410 | aliasEntityType: { |
411 | - current_customer: "CURRENT_CUSTOMER" | |
411 | + current_customer: "CURRENT_CUSTOMER", | |
412 | + current_tenant: "CURRENT_TENANT" | |
412 | 413 | }, |
413 | 414 | entityTypeTranslations: { |
414 | 415 | "DEVICE": { |
... | ... | @@ -474,6 +475,10 @@ export default angular.module('thingsboard.types', []) |
474 | 475 | "CURRENT_CUSTOMER": { |
475 | 476 | type: 'entity.type-current-customer', |
476 | 477 | list: 'entity.type-current-customer' |
478 | + }, | |
479 | + "CURRENT_TENANT": { | |
480 | + type: 'entity.type-current-tenant', | |
481 | + list: 'entity.type-current-tenant' | |
477 | 482 | } |
478 | 483 | }, |
479 | 484 | entityField: { | ... | ... |
... | ... | @@ -22,13 +22,14 @@ import entitySelectTemplate from './entity-select.tpl.html'; |
22 | 22 | /* eslint-enable import/no-unresolved, import/default */ |
23 | 23 | |
24 | 24 | /*@ngInject*/ |
25 | -export default function EntitySelect($compile, $templateCache, entityService) { | |
25 | +export default function EntitySelect($compile, $templateCache, entityService, types) { | |
26 | 26 | |
27 | 27 | var linker = function (scope, element, attrs, ngModelCtrl) { |
28 | 28 | var template = $templateCache.get(entitySelectTemplate); |
29 | 29 | element.html(template); |
30 | 30 | |
31 | 31 | scope.tbRequired = angular.isDefined(scope.tbRequired) ? scope.tbRequired : false; |
32 | + scope.entityTypeCurrentTenant = types.aliasEntityType.current_tenant; | |
32 | 33 | |
33 | 34 | var entityTypes = entityService.prepareAllowedEntityTypesList(scope.allowedEntityTypes, scope.useAliasEntityTypes); |
34 | 35 | |
... | ... | @@ -48,7 +49,8 @@ export default function EntitySelect($compile, $templateCache, entityService) { |
48 | 49 | scope.updateView = function () { |
49 | 50 | if (!scope.disabled) { |
50 | 51 | var value = ngModelCtrl.$viewValue; |
51 | - if (scope.model && scope.model.entityType && scope.model.entityId) { | |
52 | + if (scope.model && scope.model.entityType && | |
53 | + (scope.model.entityId || scope.model.entityType === scope.entityTypeCurrentTenant)) { | |
52 | 54 | if (!value) { |
53 | 55 | value = {}; |
54 | 56 | } | ... | ... |
... | ... | @@ -25,11 +25,11 @@ |
25 | 25 | allowed-entity-types="allowedEntityTypes" |
26 | 26 | ng-model="model.entityType"> |
27 | 27 | </tb-entity-type-select> |
28 | - <tb-entity-autocomplete flex ng-if="model.entityType" | |
28 | + <tb-entity-autocomplete flex ng-if="model.entityType && model.entityType !== entityTypeCurrentTenant" | |
29 | 29 | the-form="theForm" |
30 | 30 | ng-disabled="disabled" |
31 | 31 | tb-required="tbRequired" |
32 | 32 | entity-type="model.entityType" |
33 | 33 | ng-model="model.entityId"> |
34 | 34 | </tb-entity-autocomplete> |
35 | -</div> | |
\ No newline at end of file | ||
35 | +</div> | ... | ... |
... | ... | @@ -770,6 +770,7 @@ |
770 | 770 | "list-of-rulenodes": "{ count, plural, 1 {Jeden uzel pravidla} other {Seznam # uzlů pravidel} }", |
771 | 771 | "rulenode-name-starts-with": "Uzly pravidel, jejichž název začíná '{{prefix}}'", |
772 | 772 | "type-current-customer": "Stávající zákazník", |
773 | + "type-current-tenant": "Stávající tenant", | |
773 | 774 | "search": "Vyhledat entity", |
774 | 775 | "selected-entities": "{ count, plural, 1 {1 entita} other {# entit} } zvoleno", |
775 | 776 | "entity-name": "Název entity", | ... | ... |
... | ... | @@ -811,6 +811,7 @@ |
811 | 811 | "list-of-rulenodes": "{ count, plural, 1 {One rule node} other {List of # rule nodes} }", |
812 | 812 | "rulenode-name-starts-with": "Rule nodes whose names start with '{{prefix}}'", |
813 | 813 | "type-current-customer": "Current Customer", |
814 | + "type-current-tenant": "Current Tenant", | |
814 | 815 | "search": "Search entities", |
815 | 816 | "selected-entities": "{ count, plural, 1 {1 entity} other {# entities} } selected", |
816 | 817 | "entity-name": "Entity name", | ... | ... |
... | ... | @@ -809,6 +809,7 @@ |
809 | 809 | "list-of-rulenodes": "{ count, plural, 1 {Одно правило} other {Список из # правил} }", |
810 | 810 | "rulenode-name-starts-with": "Правила, чьи названия начинаются с '{{prefix}}'", |
811 | 811 | "type-current-customer": "Текущий клиент", |
812 | + "type-current-tenant": "Текущий владелец", | |
812 | 813 | "search": "Поиск объектов", |
813 | 814 | "selected-entities": "Выбран(ы) { count, plural, 1 {1 объект} few {# объекта} other {# объектов} }", |
814 | 815 | "entity-name": "Название объекта", | ... | ... |
... | ... | @@ -942,6 +942,7 @@ |
942 | 942 | "list-of-rulenodes": "{ count, plural, 1 {Одне правило} other {Список # правил} }", |
943 | 943 | "rulenode-name-starts-with": "Список правил, імена яких починаються '{{prefix}}'", |
944 | 944 | "type-current-customer": "Поточний клієнт", |
945 | + "type-current-tenant": "Поточний власник", | |
945 | 946 | "search": "Пошук сутностей", |
946 | 947 | "selected-entities": "{ count, plural, 1 {1 сутність} other {# сутності} } вибрано", |
947 | 948 | "entity-name": "Ім'я сутності", | ... | ... |