58 changed files with 371 additions and 740 deletions
@ -1,41 +0,0 @@ |
|||
///
|
|||
/// Copyright © 2016-2023 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 { NgModule } from '@angular/core'; |
|||
import { RouterModule, Routes } from '@angular/router'; |
|||
import { Authority } from '@shared/models/authority.enum'; |
|||
import { NotificationCenterComponent } from '@home/pages/notification-center/notification-center.component'; |
|||
|
|||
const routes: Routes = [ |
|||
{ |
|||
path: 'notification-center', |
|||
component: NotificationCenterComponent, |
|||
data: { |
|||
auth: [Authority.SYS_ADMIN, Authority.TENANT_ADMIN, Authority.CUSTOMER_USER], |
|||
title: 'notification.notification-center', |
|||
breadcrumb: { |
|||
label: 'notification.notification-center', |
|||
icon: 'notifications' |
|||
} |
|||
} |
|||
} |
|||
]; |
|||
|
|||
@NgModule({ |
|||
imports: [RouterModule.forChild(routes)], |
|||
exports: [RouterModule] |
|||
}) |
|||
export class NotificationCenterRoutingModule { } |
|||
@ -1,69 +0,0 @@ |
|||
<!-- |
|||
|
|||
Copyright © 2016-2023 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. |
|||
|
|||
--> |
|||
<div class="tb-notification-center"> |
|||
<div class="tb-notification-center-content"> |
|||
<div class="tabs-container"> |
|||
<ng-container *ngIf="isCustomerUser(); else notificationTabs"> |
|||
<tb-notification-table |
|||
[notificationType]="entityType.NOTIFICATION"> |
|||
</tb-notification-table> |
|||
</ng-container> |
|||
<ng-template #notificationTabs> |
|||
<mat-tab-group #matTabGroup (selectedIndexChange)="updateData()" mat-stretch-tabs="false"> |
|||
<mat-tab label="{{ 'notification.inbox' | translate }}"> |
|||
<tb-notification-table |
|||
[notificationType]="entityType.NOTIFICATION"> |
|||
</tb-notification-table> |
|||
</mat-tab> |
|||
<mat-tab label="{{ 'notification.sent' | translate }}" #requestTab="matTab"> |
|||
<tb-notification-table |
|||
#notificationRequest |
|||
[notificationType]="entityType.NOTIFICATION_REQUEST"> |
|||
</tb-notification-table> |
|||
</mat-tab> |
|||
<mat-tab label="{{ 'notification.templates' | translate }}"> |
|||
<tb-notification-table |
|||
[notificationType]="entityType.NOTIFICATION_TEMPLATE"> |
|||
</tb-notification-table> |
|||
</mat-tab> |
|||
<mat-tab label="{{ 'notification.targets' | translate }}"> |
|||
<tb-notification-table |
|||
[notificationType]="entityType.NOTIFICATION_TARGET"> |
|||
</tb-notification-table> |
|||
</mat-tab> |
|||
<mat-tab label="{{ 'notification.rules' | translate }}"> |
|||
<tb-notification-table |
|||
[notificationType]="entityType.NOTIFICATION_RULE"> |
|||
</tb-notification-table> |
|||
</mat-tab> |
|||
<mat-tab disabled> |
|||
<ng-template mat-tab-label> |
|||
<div fxFlex="100" fxLayout="row" fxLayoutAlign="end center"> |
|||
<button mat-flat-button color="primary" (click)="sendNotification($event)"> |
|||
<div fxLayout="row" fxLayoutAlign="start center"> |
|||
<mat-icon>send</mat-icon>{{ 'notification.send-notification' | translate }} |
|||
</div> |
|||
</button> |
|||
</div> |
|||
</ng-template> |
|||
</mat-tab> |
|||
</mat-tab-group> |
|||
</ng-template> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
@ -1,101 +0,0 @@ |
|||
/** |
|||
* Copyright © 2016-2023 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 '../../../../../scss/constants'; |
|||
|
|||
:host { |
|||
width: 100%; |
|||
height: 100%; |
|||
display: block; |
|||
.tb-notification-center { |
|||
padding: 8px; |
|||
width: 100%; |
|||
height: 100%; |
|||
display: block; |
|||
|
|||
.tb-notification-center-content { |
|||
width: 100%; |
|||
height: 100%; |
|||
background: #fff; |
|||
border-radius: 4px; |
|||
box-shadow: 0 4px 10px rgba(23, 33, 90, 0.08); |
|||
display: flex; |
|||
flex-direction: column; |
|||
|
|||
.tabs-container { |
|||
position: relative; |
|||
flex-direction: column; |
|||
flex: 1 1 100%; |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
:host ::ng-deep { |
|||
.tabs-container { |
|||
> .mat-mdc-tab-group { |
|||
> .mat-mdc-tab-body-wrapper { |
|||
position: absolute; |
|||
top: 49px; |
|||
left: 0; |
|||
right: 0; |
|||
bottom: 0; |
|||
} |
|||
|
|||
> .mat-mdc-tab-header { |
|||
.mat-mdc-tab { |
|||
&.mat-mdc-tab-disabled { |
|||
opacity: 1; |
|||
flex: 1; |
|||
|
|||
.mdc-tab__content, .mdc-tab__text-label { |
|||
flex: 1; |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
.tb-entity-table { |
|||
padding: 0; |
|||
|
|||
.mat-toolbar-single-row, .mat-toolbar-tools { |
|||
height: 56px; |
|||
} |
|||
|
|||
.mat-toolbar-tools > div { |
|||
width: 100%; |
|||
} |
|||
|
|||
.mat-toolbar-single-row { |
|||
padding: 0 24px 0 12px; |
|||
} |
|||
} |
|||
} |
|||
|
|||
@media #{$mat-xs} { |
|||
.tabs-container { |
|||
> .mat-mdc-tab-group { |
|||
> .mat-mdc-tab-header { |
|||
.mat-mdc-tab { |
|||
&.mat-tab-disabled { |
|||
width: auto; |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -1,74 +0,0 @@ |
|||
///
|
|||
/// Copyright © 2016-2023 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, QueryList, ViewChild, ViewChildren } from '@angular/core'; |
|||
import { PageComponent } from '@shared/components/page.component'; |
|||
import { Store } from '@ngrx/store'; |
|||
import { AppState } from '@core/core.state'; |
|||
import { MatTab, MatTabGroup } from '@angular/material/tabs'; |
|||
import { |
|||
NotificationTableComponent |
|||
} from '@home/pages/notification-center/notification-table/notification-table.component'; |
|||
import { EntityType } from '@shared/models/entity-type.models'; |
|||
import { Authority } from '@shared/models/authority.enum'; |
|||
import { AuthState } from '@core/auth/auth.models'; |
|||
import { getCurrentAuthState } from '@core/auth/auth.selectors'; |
|||
import { AuthUser } from '@shared/models/user.model'; |
|||
|
|||
@Component({ |
|||
selector: 'tb-notification-center', |
|||
templateUrl: './notification-center.component.html', |
|||
styleUrls: ['notification-center.component.scss'] |
|||
}) |
|||
export class NotificationCenterComponent extends PageComponent { |
|||
|
|||
private authState: AuthState = getCurrentAuthState(this.store); |
|||
private authUser: AuthUser = this.authState.authUser; |
|||
|
|||
entityType = EntityType; |
|||
|
|||
@ViewChild('matTabGroup') matTabs: MatTabGroup; |
|||
@ViewChild('requestTab') requestTab: MatTab; |
|||
@ViewChild('notificationRequest') notificationRequestTable: NotificationTableComponent; |
|||
@ViewChildren(NotificationTableComponent) tableComponent: QueryList<NotificationTableComponent>; |
|||
|
|||
|
|||
constructor( |
|||
protected store: Store<AppState>) { |
|||
super(store); |
|||
} |
|||
|
|||
updateData() { |
|||
this.currentTableComponent?.updateData(); |
|||
} |
|||
|
|||
openSetting() { |
|||
|
|||
} |
|||
|
|||
private get currentTableComponent(): NotificationTableComponent { |
|||
return this.tableComponent.get(this.matTabs.selectedIndex); |
|||
} |
|||
|
|||
sendNotification($event: Event) { |
|||
this.notificationRequestTable.entityTableConfig |
|||
.onEntityAction({event: $event, action: this.requestTab.isActive ? 'add' : 'add-without-update', entity: null}); |
|||
} |
|||
|
|||
public isCustomerUser(): boolean { |
|||
return this.authUser.authority === Authority.CUSTOMER_USER; |
|||
} |
|||
} |
|||
@ -1,83 +0,0 @@ |
|||
///
|
|||
/// Copyright © 2016-2023 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 { NgModule } from '@angular/core'; |
|||
import { CommonModule } from '@angular/common'; |
|||
import { SharedModule } from '@shared/shared.module'; |
|||
import { NotificationCenterRoutingModule } from './notification-center-routing.module'; |
|||
import { NotificationCenterComponent } from './notification-center.component'; |
|||
import { HomeComponentsModule } from '@home/components/home-components.module'; |
|||
import { |
|||
TargetNotificationDialogComponent |
|||
} from '@home/pages/notification-center/targets-table/target-notification-dialog.componet'; |
|||
import { |
|||
NotificationTableComponent |
|||
} from '@home/pages/notification-center/notification-table/notification-table.component'; |
|||
import { |
|||
TemplateNotificationDialogComponent |
|||
} from '@home/pages/notification-center/template-table/template-notification-dialog.component'; |
|||
import { |
|||
TargetTableHeaderComponent |
|||
} from '@home/pages/notification-center/targets-table/target-table-header.component'; |
|||
import { |
|||
TemplateTableHeaderComponent |
|||
} from '@home/pages/notification-center/template-table/template-table-header.component'; |
|||
import { |
|||
RequestNotificationDialogComponent |
|||
} from '@home/pages/notification-center/request-table/request-notification-dialog.componet'; |
|||
import { |
|||
TemplateAutocompleteComponent |
|||
} from '@home/pages/notification-center/template-table/template-autocomplete.component'; |
|||
import { InboxTableHeaderComponent } from '@home/pages/notification-center/inbox-table/inbox-table-header.component'; |
|||
import { RuleTableHeaderComponent } from '@home/pages/notification-center/rule-table/rule-table-header.component'; |
|||
import { |
|||
RuleNotificationDialogComponent |
|||
} from '@home/pages/notification-center/rule-table/rule-notification-dialog.component'; |
|||
import { EscalationsComponent } from '@home/pages/notification-center/rule-table/escalations.component'; |
|||
import { EscalationFormComponent } from '@home/pages/notification-center/rule-table/escalation-form.component'; |
|||
import { |
|||
InboxNotificationDialogComponent |
|||
} from '@home/pages/notification-center/inbox-table/inbox-notification-dialog.component'; |
|||
import { |
|||
NotificationRequestErrorDialogComponent |
|||
} from '@home/pages/notification-center/request-table/notification-request-error-dialog.component'; |
|||
|
|||
@NgModule({ |
|||
declarations: [ |
|||
NotificationCenterComponent, |
|||
TargetNotificationDialogComponent, |
|||
TemplateNotificationDialogComponent, |
|||
RequestNotificationDialogComponent, |
|||
TargetTableHeaderComponent, |
|||
TemplateTableHeaderComponent, |
|||
NotificationTableComponent, |
|||
TemplateAutocompleteComponent, |
|||
InboxTableHeaderComponent, |
|||
RuleTableHeaderComponent, |
|||
RuleNotificationDialogComponent, |
|||
EscalationsComponent, |
|||
EscalationFormComponent, |
|||
InboxNotificationDialogComponent, |
|||
NotificationRequestErrorDialogComponent |
|||
], |
|||
imports: [ |
|||
CommonModule, |
|||
SharedModule, |
|||
NotificationCenterRoutingModule, |
|||
HomeComponentsModule |
|||
] |
|||
}) |
|||
export class NotificationCenterModule { } |
|||
@ -1,18 +0,0 @@ |
|||
<!-- |
|||
|
|||
Copyright © 2016-2023 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-entities-table [entitiesTableConfig]="entityTableConfig"></tb-entities-table> |
|||
@ -1,98 +0,0 @@ |
|||
///
|
|||
/// Copyright © 2016-2023 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, Input, OnInit, ViewChild } from '@angular/core'; |
|||
import { EntitiesTableComponent } from '@home/components/entity/entities-table.component'; |
|||
import { NotificationService } from '@core/http/notification.service'; |
|||
import { TargetsTableConfig } from '@home/pages/notification-center/notification-table/targets-table-config'; |
|||
import { TranslateService } from '@ngx-translate/core'; |
|||
import { MatDialog } from '@angular/material/dialog'; |
|||
import { EntityType } from '@shared/models/entity-type.models'; |
|||
import { EntityTableConfig } from '@home/models/entity/entities-table-config.models'; |
|||
import { InboxTableConfig } from '@home/pages/notification-center/notification-table/inbox-table-config'; |
|||
import { DatePipe } from '@angular/common'; |
|||
import { TemplateTableConfig } from '@home/pages/notification-center/notification-table/template-table-config'; |
|||
import { RequestTableConfig } from '@home/pages/notification-center/notification-table/request-table-config'; |
|||
import { RuleTableConfig } from '@home/pages/notification-center/notification-table/rule-table-config'; |
|||
|
|||
@Component({ |
|||
selector: 'tb-notification-table', |
|||
templateUrl: './notification-table.component.html' |
|||
}) |
|||
export class NotificationTableComponent implements OnInit { |
|||
|
|||
@Input() |
|||
notificationType = EntityType.NOTIFICATION; |
|||
|
|||
@ViewChild(EntitiesTableComponent, {static: true}) entitiesTable: EntitiesTableComponent; |
|||
|
|||
entityTableConfig: EntityTableConfig<any>; |
|||
|
|||
constructor(private notificationService: NotificationService, |
|||
private translate: TranslateService, |
|||
private datePipe: DatePipe, |
|||
private dialog: MatDialog) { |
|||
} |
|||
|
|||
ngOnInit() { |
|||
this.entityTableConfig = this.getTableConfig(); |
|||
this.entityTableConfig.pageMode = false; |
|||
this.entityTableConfig.detailsPanelEnabled = false; |
|||
this.entityTableConfig.selectionEnabled = false; |
|||
this.entityTableConfig.addEnabled = false; |
|||
} |
|||
|
|||
updateData() { |
|||
this.entitiesTable.updateData(); |
|||
} |
|||
|
|||
private getTableConfig(): EntityTableConfig<any> { |
|||
switch (this.notificationType) { |
|||
case EntityType.NOTIFICATION_TARGET: |
|||
return new TargetsTableConfig( |
|||
this.notificationService, |
|||
this.translate, |
|||
this.dialog |
|||
); |
|||
case EntityType.NOTIFICATION: |
|||
return new InboxTableConfig( |
|||
this.notificationService, |
|||
this.translate, |
|||
this.dialog, |
|||
this.datePipe |
|||
); |
|||
case EntityType.NOTIFICATION_TEMPLATE: |
|||
return new TemplateTableConfig( |
|||
this.notificationService, |
|||
this.translate, |
|||
this.dialog |
|||
); |
|||
case EntityType.NOTIFICATION_REQUEST: |
|||
return new RequestTableConfig( |
|||
this.notificationService, |
|||
this.translate, |
|||
this.dialog, |
|||
this.datePipe |
|||
); |
|||
case EntityType.NOTIFICATION_RULE: |
|||
return new RuleTableConfig( |
|||
this.notificationService, |
|||
this.translate, |
|||
this.dialog |
|||
); |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue