diff --git a/ui-ngx/src/app/modules/home/components/entity/entities-table.component.html b/ui-ngx/src/app/modules/home/components/entity/entities-table.component.html index e6c85b70dd..a6b204b279 100644 --- a/ui-ngx/src/app/modules/home/components/entity/entities-table.component.html +++ b/ui-ngx/src/app/modules/home/components/entity/entities-table.component.html @@ -46,22 +46,41 @@
- - - + + + + + + + -
+
+
mobile.applications
+
+
diff --git a/ui-ngx/src/app/modules/home/pages/mobile/applications/mobile-app-table-header.component.scss b/ui-ngx/src/app/modules/home/pages/mobile/applications/mobile-app-table-header.component.scss index 17ca4ae7c7..18b4520b54 100644 --- a/ui-ngx/src/app/modules/home/pages/mobile/applications/mobile-app-table-header.component.scss +++ b/ui-ngx/src/app/modules/home/pages/mobile/applications/mobile-app-table-header.component.scss @@ -14,5 +14,5 @@ * limitations under the License. */ :host{ - width: 100000px; + width: 100%; } diff --git a/ui-ngx/src/app/modules/home/pages/mobile/applications/mobile-app-table-header.component.ts b/ui-ngx/src/app/modules/home/pages/mobile/applications/mobile-app-table-header.component.ts index a5ced5ddb8..58ba65688d 100644 --- a/ui-ngx/src/app/modules/home/pages/mobile/applications/mobile-app-table-header.component.ts +++ b/ui-ngx/src/app/modules/home/pages/mobile/applications/mobile-app-table-header.component.ts @@ -30,8 +30,4 @@ export class MobileAppTableHeaderComponent extends EntityTableHeaderComponent) { super(store); } - - createMobile($event: Event) { - this.entitiesTableConfig.getTable().addEntity($event); - } } diff --git a/ui-ngx/src/app/modules/home/pages/mobile/bundes/mobile-bundle-table-config.resolve.ts b/ui-ngx/src/app/modules/home/pages/mobile/bundes/mobile-bundle-table-config.resolve.ts index 177f41ba1b..ac9445c615 100644 --- a/ui-ngx/src/app/modules/home/pages/mobile/bundes/mobile-bundle-table-config.resolve.ts +++ b/ui-ngx/src/app/modules/home/pages/mobile/bundes/mobile-bundle-table-config.resolve.ts @@ -32,7 +32,6 @@ import { DatePipe } from '@angular/common'; import { MobileAppService } from '@core/http/mobile-app.service'; import { finalize, map, skip, take, takeUntil } from 'rxjs/operators'; import { TranslateService } from '@ngx-translate/core'; -import { EntityAction } from '@home/models/entity/entity-component.models'; import { MatDialog } from '@angular/material/dialog'; import { MobileBundleDialogComponent, @@ -45,7 +44,7 @@ import { import { select, Store } from '@ngrx/store'; import { AppState } from '@core/core.state'; import { selectUserSettingsProperty } from '@core/auth/auth.selectors'; -import { forkJoin, of } from 'rxjs'; +import { forkJoin, Observable, of, switchMap } from 'rxjs'; @Injectable() export class MobileBundleTableConfigResolver { @@ -64,16 +63,17 @@ export class MobileBundleTableConfigResolver { ) { this.config.selectionEnabled = false; this.config.entityType = EntityType.MOBILE_APP_BUNDLE; - this.config.addEnabled = false; + this.config.addAsTextButton = true; this.config.rowPointer = true; this.config.detailsPanelEnabled = false; this.config.entityTranslations = entityTypeTranslations.get(EntityType.MOBILE_APP_BUNDLE); this.config.entityResources = entityTypeResources.get(EntityType.MOBILE_APP_BUNDLE); this.config.headerComponent = MobileBundleTableHeaderComponent; - this.config.onEntityAction = action => this.onBundleAction(action); this.config.addDialogStyle = {width: '850px', maxHeight: '100vh'}; this.config.defaultSortOrder = {property: 'createdTime', direction: Direction.DESC}; + this.config.addEntity = () => this.editBundle(null, true); + this.config.columns.push( new DateEntityTableColumn('createdTime', 'common.created-time', this.datePipe, '170px'), new EntityTableColumn('title', 'mobile.title', '25%'), @@ -114,15 +114,28 @@ export class MobileBundleTableConfigResolver { if (!this.openingEditDialog) { this.openingEditDialog = true; this.mobileAppService.getMobileAppBundleInfoById(bundle.id.id).pipe( + switchMap(appBundleInfo => this.editBundle(appBundleInfo)), takeUntil(this.router.events.pipe(skip(1))), finalize(() => {this.openingEditDialog = false;}) - ).subscribe( - appBundleInfo => this.editBundle($event, appBundleInfo) - ); + ).subscribe((res) => { + if (res) { + this.config.updateData(); + } + }); } return true; }; + this.config.entityAdded = (bundle) => { + this.store.pipe(select(selectUserSettingsProperty('notDisplayConfigurationAfterAddMobileBundle'))).pipe( + take(1) + ).subscribe((settings: boolean) => { + if(!settings) { + this.configurationApp(null, bundle, true); + } + }); + } + this.config.cellActionDescriptors = this.configureCellActions(); } @@ -141,11 +154,8 @@ export class MobileBundleTableConfigResolver { ]; } - private editBundle($event: Event, bundle: MobileAppBundleInfo, isAdd = false) { - if ($event) { - $event.stopPropagation(); - } - this.dialog.open { + return this.dialog.open(MobileBundleDialogComponent, { disableClose: true, panelClass: ['tb-dialog', 'tb-fullscreen-dialog'], @@ -153,33 +163,7 @@ export class MobileBundleTableConfigResolver { isAdd, bundle } - }).afterClosed() - .subscribe((res) => { - if (res) { - if (!isAdd) { - this.config.updateData(); - } else { - this.store.pipe(select(selectUserSettingsProperty('notDisplayConfigurationAfterAddMobileBundle'))).pipe( - take(1) - ).subscribe((settings: boolean) => { - if (!settings) { - this.configurationApp(null, res, true); - } else { - this.config.updateData(); - } - }); - } - } - }); - } - - private onBundleAction(action: EntityAction): boolean { - switch (action.action) { - case 'add': - this.editBundle(action.event, action.entity, true); - return true; - } - return false; + }).afterClosed(); } private configurationApp($event: Event, entity: MobileAppBundleInfo, afterAdd = false) { diff --git a/ui-ngx/src/app/modules/home/pages/mobile/bundes/mobile-bundle-table-header.component.html b/ui-ngx/src/app/modules/home/pages/mobile/bundes/mobile-bundle-table-header.component.html index bf2a571e98..c6711d5879 100644 --- a/ui-ngx/src/app/modules/home/pages/mobile/bundes/mobile-bundle-table-header.component.html +++ b/ui-ngx/src/app/modules/home/pages/mobile/bundes/mobile-bundle-table-header.component.html @@ -15,12 +15,7 @@ limitations under the License. --> -
-
-
mobile.bundles
-
-
- -
+
+
mobile.bundles
+
+
diff --git a/ui-ngx/src/app/modules/home/pages/mobile/bundes/mobile-bundle-table-header.component.scss b/ui-ngx/src/app/modules/home/pages/mobile/bundes/mobile-bundle-table-header.component.scss index 17ca4ae7c7..18b4520b54 100644 --- a/ui-ngx/src/app/modules/home/pages/mobile/bundes/mobile-bundle-table-header.component.scss +++ b/ui-ngx/src/app/modules/home/pages/mobile/bundes/mobile-bundle-table-header.component.scss @@ -14,5 +14,5 @@ * limitations under the License. */ :host{ - width: 100000px; + width: 100%; } diff --git a/ui-ngx/src/app/modules/home/pages/mobile/bundes/mobile-bundle-table-header.component.ts b/ui-ngx/src/app/modules/home/pages/mobile/bundes/mobile-bundle-table-header.component.ts index 7d97c82da0..28e227883e 100644 --- a/ui-ngx/src/app/modules/home/pages/mobile/bundes/mobile-bundle-table-header.component.ts +++ b/ui-ngx/src/app/modules/home/pages/mobile/bundes/mobile-bundle-table-header.component.ts @@ -30,8 +30,4 @@ export class MobileBundleTableHeaderComponent extends EntityTableHeaderComponent constructor(protected store: Store) { super(store); } - - createBundle($event: Event) { - this.entitiesTableConfig.onEntityAction({event: $event, action: 'add', entity: null}); - } } diff --git a/ui-ngx/src/app/modules/home/pages/notification/notification.module.ts b/ui-ngx/src/app/modules/home/pages/notification/notification.module.ts index e5588ecf31..39f6ee23ff 100644 --- a/ui-ngx/src/app/modules/home/pages/notification/notification.module.ts +++ b/ui-ngx/src/app/modules/home/pages/notification/notification.module.ts @@ -26,15 +26,12 @@ import { SentNotificationDialogComponent } from '@home/pages/notification/sent/s import { RecipientNotificationDialogComponent } from '@home/pages/notification/recipient/recipient-notification-dialog.component'; -import { RecipientTableHeaderComponent } from '@home/pages/notification/recipient/recipient-table-header.component'; import { TemplateNotificationDialogComponent } from '@home/pages/notification/template/template-notification-dialog.component'; -import { TemplateTableHeaderComponent } from '@home/pages/notification/template/template-table-header.component'; import { EscalationFormComponent } from '@home/pages/notification/rule/escalation-form.component'; import { EscalationsComponent } from '@home/pages/notification/rule/escalations.component'; import { RuleNotificationDialogComponent } from '@home/pages/notification/rule/rule-notification-dialog.component'; -import { RuleTableHeaderComponent } from '@home/pages/notification/rule/rule-table-header.component'; import { NotificationSettingsComponent } from '@home/pages/notification/settings/notification-settings.component'; import { NotificationSettingFormComponent @@ -53,13 +50,10 @@ import { SentErrorDialogComponent, SentNotificationDialogComponent, RecipientNotificationDialogComponent, - RecipientTableHeaderComponent, TemplateNotificationDialogComponent, - TemplateTableHeaderComponent, EscalationFormComponent, EscalationsComponent, RuleNotificationDialogComponent, - RuleTableHeaderComponent, NotificationSettingsComponent, NotificationSettingFormComponent, NotificationTemplateConfigurationComponent, diff --git a/ui-ngx/src/app/modules/home/pages/notification/recipient/recipient-table-config.resolver.ts b/ui-ngx/src/app/modules/home/pages/notification/recipient/recipient-table-config.resolver.ts index 354baf3877..2ffd51ec15 100644 --- a/ui-ngx/src/app/modules/home/pages/notification/recipient/recipient-table-config.resolver.ts +++ b/ui-ngx/src/app/modules/home/pages/notification/recipient/recipient-table-config.resolver.ts @@ -30,12 +30,11 @@ import { RecipientNotificationDialogData } from '@home/pages/notification/recipient/recipient-notification-dialog.component'; import { MatDialog } from '@angular/material/dialog'; -import { EntityAction } from '@home/models/entity/entity-component.models'; -import { RecipientTableHeaderComponent } from '@home/pages/notification/recipient/recipient-table-header.component'; import { ActivatedRouteSnapshot } from '@angular/router'; import { Injectable } from '@angular/core'; import { DatePipe } from '@angular/common'; import { CustomTranslatePipe } from '@shared/pipe/custom-translate.pipe'; +import { Observable } from 'rxjs'; @Injectable() export class RecipientTableConfigResolver { @@ -50,12 +49,14 @@ export class RecipientTableConfigResolver { this.config.entityType = EntityType.NOTIFICATION_TARGET; this.config.detailsPanelEnabled = false; - this.config.addEnabled = false; + this.config.addAsTextButton = true; this.config.rowPointer = true; this.config.entityTranslations = entityTypeTranslations.get(EntityType.NOTIFICATION_TARGET); this.config.entityResources = {} as EntityTypeResource; + this.config.addEntity = () => this.editTarget(null, true); + this.config.entitiesFetchFunction = pageLink => this.notificationService.getNotificationTargets(pageLink); this.config.deleteEntityTitle = target => this.translate.instant('notification.delete-recipient-title', {recipientName: target.name}); @@ -67,13 +68,15 @@ export class RecipientTableConfigResolver { this.config.cellActionDescriptors = this.configureCellActions(); - this.config.headerComponent = RecipientTableHeaderComponent; - this.config.onEntityAction = action => this.onTargetAction(action); - this.config.defaultSortOrder = {property: 'createdTime', direction: Direction.DESC}; this.config.handleRowClick = ($event, target) => { - this.editTarget($event, target); + $event?.stopPropagation(); + this.editTarget(target).subscribe((res) => { + if (res) { + this.config.updateData(); + } + }); return true; }; @@ -89,7 +92,7 @@ export class RecipientTableConfigResolver { ); } - resolve(route: ActivatedRouteSnapshot): EntityTableConfig { + resolve(_route: ActivatedRouteSnapshot): EntityTableConfig { return this.config; } @@ -97,11 +100,8 @@ export class RecipientTableConfigResolver { return []; } - private editTarget($event: Event, target: NotificationTarget, isAdd = false) { - if ($event) { - $event.stopPropagation(); - } - this.dialog.open { + return this.dialog.open(RecipientNotificationDialogComponent, { disableClose: true, panelClass: ['tb-dialog', 'tb-fullscreen-dialog'], @@ -109,20 +109,6 @@ export class RecipientTableConfigResolver { isAdd, target } - }).afterClosed() - .subscribe((res) => { - if (res) { - this.config.updateData(); - } - }); - } - - private onTargetAction(action: EntityAction): boolean { - switch (action.action) { - case 'add': - this.editTarget(action.event, action.entity, true); - return true; - } - return false; + }).afterClosed(); } } diff --git a/ui-ngx/src/app/modules/home/pages/notification/recipient/recipient-table-header.component.html b/ui-ngx/src/app/modules/home/pages/notification/recipient/recipient-table-header.component.html deleted file mode 100644 index e6a4d1efaf..0000000000 --- a/ui-ngx/src/app/modules/home/pages/notification/recipient/recipient-table-header.component.html +++ /dev/null @@ -1,24 +0,0 @@ - -
- -
diff --git a/ui-ngx/src/app/modules/home/pages/notification/recipient/recipient-table-header.component.scss b/ui-ngx/src/app/modules/home/pages/notification/recipient/recipient-table-header.component.scss deleted file mode 100644 index c7aa4c7398..0000000000 --- a/ui-ngx/src/app/modules/home/pages/notification/recipient/recipient-table-header.component.scss +++ /dev/null @@ -1,18 +0,0 @@ -/** - * Copyright © 2016-2024 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. - */ -:host{ - width: 10000px; -} diff --git a/ui-ngx/src/app/modules/home/pages/notification/recipient/recipient-table-header.component.ts b/ui-ngx/src/app/modules/home/pages/notification/recipient/recipient-table-header.component.ts deleted file mode 100644 index c028652524..0000000000 --- a/ui-ngx/src/app/modules/home/pages/notification/recipient/recipient-table-header.component.ts +++ /dev/null @@ -1,38 +0,0 @@ -/// -/// Copyright © 2016-2024 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. -/// - -import { Component } from '@angular/core'; -import { EntityTableHeaderComponent } from '@home/components/entity/entity-table-header.component'; -import { Store } from '@ngrx/store'; -import { AppState } from '@core/core.state'; -import { NotificationTarget } from '@shared/models/notification.models'; - -@Component({ - selector: 'tb-recipient-table-header', - templateUrl: './recipient-table-header.component.html', - styleUrls: ['recipient-table-header.component.scss'] -}) -export class RecipientTableHeaderComponent extends EntityTableHeaderComponent { - - constructor(protected store: Store) { - super(store); - } - - createTarget($event: Event) { - this.entitiesTableConfig.onEntityAction({event: $event, action: 'add', entity: null}); - } - -} diff --git a/ui-ngx/src/app/modules/home/pages/notification/rule/rule-table-config.resolver.ts b/ui-ngx/src/app/modules/home/pages/notification/rule/rule-table-config.resolver.ts index 8b23bf09ba..a8fbc3ff65 100644 --- a/ui-ngx/src/app/modules/home/pages/notification/rule/rule-table-config.resolver.ts +++ b/ui-ngx/src/app/modules/home/pages/notification/rule/rule-table-config.resolver.ts @@ -26,8 +26,6 @@ import { NotificationRule, TriggerTypeTranslationMap } from '@shared/models/noti import { NotificationService } from '@core/http/notification.service'; import { TranslateService } from '@ngx-translate/core'; import { MatDialog } from '@angular/material/dialog'; -import { EntityAction } from '@home/models/entity/entity-component.models'; -import { RuleTableHeaderComponent } from '@home/pages/notification/rule/rule-table-header.component'; import { RuleNotificationDialogComponent, RuleNotificationDialogData @@ -36,6 +34,7 @@ import { ActivatedRouteSnapshot } from '@angular/router'; import { Injectable } from '@angular/core'; import { DatePipe } from '@angular/common'; import { CustomTranslatePipe } from '@shared/pipe/custom-translate.pipe'; +import { Observable } from 'rxjs'; @Injectable() export class RuleTableConfigResolver { @@ -50,12 +49,14 @@ export class RuleTableConfigResolver { this.config.entityType = EntityType.NOTIFICATION_RULE; this.config.detailsPanelEnabled = false; - this.config.addEnabled = false; + this.config.addAsTextButton = true; this.config.rowPointer = true; this.config.entityTranslations = entityTypeTranslations.get(EntityType.NOTIFICATION_RULE); this.config.entityResources = {} as EntityTypeResource; + this.config.addEntity = () => this.editRule(null, null, true); + this.config.entitiesFetchFunction = pageLink => this.notificationService.getNotificationRules(pageLink); this.config.deleteEntityTitle = rule => this.translate.instant('notification.delete-rule-title', {ruleName: rule.name}); @@ -65,13 +66,15 @@ export class RuleTableConfigResolver { this.config.deleteEntity = id => this.notificationService.deleteNotificationRule(id.id); this.config.cellActionDescriptors = this.configureCellActions(); - this.config.headerComponent = RuleTableHeaderComponent; - this.config.onEntityAction = action => this.onTargetAction(action); this.config.defaultSortOrder = {property: 'createdTime', direction: Direction.DESC}; this.config.handleRowClick = ($event, rule) => { - this.editRule($event, rule); + this.editRule($event, rule).subscribe((res) => { + if (res) { + this.config.updateData(); + } + }); return true; }; @@ -88,7 +91,7 @@ export class RuleTableConfigResolver { ); } - resolve(route: ActivatedRouteSnapshot): EntityTableConfig { + resolve(_route: ActivatedRouteSnapshot): EntityTableConfig { return this.config; } @@ -110,11 +113,9 @@ export class RuleTableConfigResolver { }]; } - private editRule($event: Event, rule: NotificationRule, isAdd = false, isCopy = false) { - if ($event) { - $event.stopPropagation(); - } - this.dialog.open { + $event?.stopPropagation(); + return this.dialog.open(RuleNotificationDialogComponent, { disableClose: true, panelClass: ['tb-dialog', 'tb-fullscreen-dialog'], @@ -123,21 +124,7 @@ export class RuleTableConfigResolver { isCopy, rule } - }).afterClosed() - .subscribe((res) => { - if (res) { - this.config.updateData(); - } - }); - } - - private onTargetAction(action: EntityAction): boolean { - switch (action.action) { - case 'add': - this.editRule(action.event, action.entity, true); - return true; - } - return false; + }).afterClosed(); } private toggleEnableMode($event: Event, rule: NotificationRule): void { diff --git a/ui-ngx/src/app/modules/home/pages/notification/rule/rule-table-header.component.html b/ui-ngx/src/app/modules/home/pages/notification/rule/rule-table-header.component.html deleted file mode 100644 index 046f32a657..0000000000 --- a/ui-ngx/src/app/modules/home/pages/notification/rule/rule-table-header.component.html +++ /dev/null @@ -1,24 +0,0 @@ - -
- -
diff --git a/ui-ngx/src/app/modules/home/pages/notification/rule/rule-table-header.component.scss b/ui-ngx/src/app/modules/home/pages/notification/rule/rule-table-header.component.scss deleted file mode 100644 index c7aa4c7398..0000000000 --- a/ui-ngx/src/app/modules/home/pages/notification/rule/rule-table-header.component.scss +++ /dev/null @@ -1,18 +0,0 @@ -/** - * Copyright © 2016-2024 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. - */ -:host{ - width: 10000px; -} diff --git a/ui-ngx/src/app/modules/home/pages/notification/rule/rule-table-header.component.ts b/ui-ngx/src/app/modules/home/pages/notification/rule/rule-table-header.component.ts deleted file mode 100644 index 98079ecf49..0000000000 --- a/ui-ngx/src/app/modules/home/pages/notification/rule/rule-table-header.component.ts +++ /dev/null @@ -1,38 +0,0 @@ -/// -/// Copyright © 2016-2024 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. -/// - -import { Component } from '@angular/core'; -import { EntityTableHeaderComponent } from '@home/components/entity/entity-table-header.component'; -import { Store } from '@ngrx/store'; -import { AppState } from '@core/core.state'; -import { NotificationRule } from '@shared/models/notification.models'; - -@Component({ - selector: 'tb-rule-table-header', - templateUrl: './rule-table-header.component.html', - styleUrls: ['rule-table-header.component.scss'] -}) -export class RuleTableHeaderComponent extends EntityTableHeaderComponent { - - constructor(protected store: Store) { - super(store); - } - - createTarget($event: Event) { - this.entitiesTableConfig.onEntityAction({event: $event, action: 'add', entity: null}); - } - -} diff --git a/ui-ngx/src/app/modules/home/pages/notification/template/template-table-config.resolver.ts b/ui-ngx/src/app/modules/home/pages/notification/template/template-table-config.resolver.ts index 734688f30b..0b40b48eea 100644 --- a/ui-ngx/src/app/modules/home/pages/notification/template/template-table-config.resolver.ts +++ b/ui-ngx/src/app/modules/home/pages/notification/template/template-table-config.resolver.ts @@ -24,17 +24,16 @@ import { EntityType, EntityTypeResource, entityTypeTranslations } from '@shared/ import { Direction } from '@shared/models/page/sort-order'; import { NotificationTemplate, NotificationTemplateTypeTranslateMap } from '@shared/models/notification.models'; import { NotificationService } from '@core/http/notification.service'; -import { EntityAction } from '@home/models/entity/entity-component.models'; import { MatDialog } from '@angular/material/dialog'; import { TemplateNotificationDialogComponent, TemplateNotificationDialogData } from '@home/pages/notification/template/template-notification-dialog.component'; import { TranslateService } from '@ngx-translate/core'; -import { TemplateTableHeaderComponent } from '@home/pages/notification/template/template-table-header.component'; import { Injectable } from '@angular/core'; import { ActivatedRouteSnapshot } from '@angular/router'; import { DatePipe } from '@angular/common'; +import { Observable } from 'rxjs'; @Injectable() export class TemplateTableConfigResolver { @@ -48,12 +47,14 @@ export class TemplateTableConfigResolver { this.config.entityType = EntityType.NOTIFICATION_TEMPLATE; this.config.detailsPanelEnabled = false; - this.config.addEnabled = false; + this.config.addAsTextButton = true; this.config.rowPointer = true; this.config.entityTranslations = entityTypeTranslations.get(EntityType.NOTIFICATION_TEMPLATE); this.config.entityResources = {} as EntityTypeResource; + this.config.addEntity = () => this.editTemplate(null, null, true); + this.config.entitiesFetchFunction = pageLink => this.notificationService.getNotificationTemplates(pageLink); this.config.deleteEntityTitle = template => this.translate.instant('notification.delete-template-title', {templateName: template.name}); @@ -64,13 +65,14 @@ export class TemplateTableConfigResolver { this.config.cellActionDescriptors = this.configureCellActions(); - this.config.headerComponent = TemplateTableHeaderComponent; - this.config.onEntityAction = action => this.onTemplateAction(action); - this.config.defaultSortOrder = {property: 'createdTime', direction: Direction.DESC}; this.config.handleRowClick = ($event, template) => { - this.editTemplate($event, template); + this.editTemplate($event, template).subscribe((res) => { + if (res) { + this.config.updateData(); + } + }); return true; }; @@ -82,7 +84,7 @@ export class TemplateTableConfigResolver { ); } - resolve(route: ActivatedRouteSnapshot): EntityTableConfig { + resolve(_route: ActivatedRouteSnapshot): EntityTableConfig { return this.config; } @@ -97,11 +99,9 @@ export class TemplateTableConfigResolver { ]; } - private editTemplate($event: Event, template: NotificationTemplate, isAdd = false, isCopy = false) { - if ($event) { - $event.stopPropagation(); - } - this.dialog.open { + $event?.stopPropagation(); + return this.dialog.open(TemplateNotificationDialogComponent, { disableClose: true, panelClass: ['tb-dialog', 'tb-fullscreen-dialog'], @@ -110,21 +110,6 @@ export class TemplateTableConfigResolver { isCopy, template } - }).afterClosed() - .subscribe((res) => { - if (res) { - this.config.updateData(); - } - }); + }).afterClosed(); } - - private onTemplateAction(action: EntityAction): boolean { - switch (action.action) { - case 'add': - this.editTemplate(action.event, action.entity, true); - return true; - } - return false; - } - } diff --git a/ui-ngx/src/app/modules/home/pages/notification/template/template-table-header.component.html b/ui-ngx/src/app/modules/home/pages/notification/template/template-table-header.component.html deleted file mode 100644 index bc809ba8b1..0000000000 --- a/ui-ngx/src/app/modules/home/pages/notification/template/template-table-header.component.html +++ /dev/null @@ -1,24 +0,0 @@ - -
- -
diff --git a/ui-ngx/src/app/modules/home/pages/notification/template/template-table-header.component.scss b/ui-ngx/src/app/modules/home/pages/notification/template/template-table-header.component.scss deleted file mode 100644 index c7aa4c7398..0000000000 --- a/ui-ngx/src/app/modules/home/pages/notification/template/template-table-header.component.scss +++ /dev/null @@ -1,18 +0,0 @@ -/** - * Copyright © 2016-2024 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. - */ -:host{ - width: 10000px; -} diff --git a/ui-ngx/src/app/modules/home/pages/notification/template/template-table-header.component.ts b/ui-ngx/src/app/modules/home/pages/notification/template/template-table-header.component.ts deleted file mode 100644 index 60ad6b39e3..0000000000 --- a/ui-ngx/src/app/modules/home/pages/notification/template/template-table-header.component.ts +++ /dev/null @@ -1,38 +0,0 @@ -/// -/// Copyright © 2016-2024 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. -/// - -import { Component } from '@angular/core'; -import { EntityTableHeaderComponent } from '@home/components/entity/entity-table-header.component'; -import { Store } from '@ngrx/store'; -import { AppState } from '@core/core.state'; -import { NotificationTemplate } from '@shared/models/notification.models'; - -@Component({ - selector: 'tb-template-table-header', - templateUrl: './template-table-header.component.html', - styleUrls: ['template-table-header.component.scss'] -}) -export class TemplateTableHeaderComponent extends EntityTableHeaderComponent { - - constructor(protected store: Store) { - super(store); - } - - createTemplate($event: Event) { - this.entitiesTableConfig.onEntityAction({event: $event, action: 'add', entity: null}); - } - -} diff --git a/ui-ngx/src/app/shared/models/entity-type.models.ts b/ui-ngx/src/app/shared/models/entity-type.models.ts index 769ca2ce87..21bcb73d71 100644 --- a/ui-ngx/src/app/shared/models/entity-type.models.ts +++ b/ui-ngx/src/app/shared/models/entity-type.models.ts @@ -403,7 +403,8 @@ export const entityTypeTranslations = new Map