16 changed files with 11 additions and 479 deletions
@ -1,21 +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. |
|
||||
|
|
||||
--> |
|
||||
<mat-tab *ngIf="entity && !isEdit" #auditLogsTab="matTab" |
|
||||
label="{{ 'audit-log.audit-logs' | translate }}"> |
|
||||
<tb-audit-log-table detailsMode="true" [active]="auditLogsTab.isActive" [auditLogMode]="auditLogModes.ENTITY" [entityId]="entity.id"></tb-audit-log-table> |
|
||||
</mat-tab> |
|
||||
@ -1,38 +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 } from '@angular/core'; |
|
||||
import { Store } from '@ngrx/store'; |
|
||||
import { AppState } from '@core/core.state'; |
|
||||
import { EntityTabsComponent } from '../../components/entity/entity-tabs.component'; |
|
||||
import { AlarmRule } from '@shared/models/alarm-rule.models'; |
|
||||
|
|
||||
@Component({ |
|
||||
selector: 'tb-alarm-rule-tabs', |
|
||||
templateUrl: './alarm-rule-tabs.component.html', |
|
||||
styleUrls: [] |
|
||||
}) |
|
||||
export class AlarmRuleTabsComponent extends EntityTabsComponent<AlarmRule> { |
|
||||
|
|
||||
constructor(protected store: Store<AppState>) { |
|
||||
super(store); |
|
||||
} |
|
||||
|
|
||||
ngOnInit() { |
|
||||
super.ngOnInit(); |
|
||||
} |
|
||||
|
|
||||
} |
|
||||
@ -1,47 +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-details-buttons" fxLayout.xs="column"> |
|
||||
<button mat-raised-button color="primary" |
|
||||
[disabled]="(isLoading$ | async)" |
|
||||
(click)="onEntityAction($event, 'open')" |
|
||||
[fxShow]="!isEdit && !isDetailsPage"> |
|
||||
{{'common.open-details-page' | translate }} |
|
||||
</button> |
|
||||
<button mat-raised-button color="primary" |
|
||||
[disabled]="(isLoading$ | async)" |
|
||||
(click)="onEntityAction($event, 'delete')" |
|
||||
[fxShow]="!hideDelete() && !isEdit"> |
|
||||
{{'alarm-rule.delete' | translate }} |
|
||||
</button> |
|
||||
</div> |
|
||||
<div class="mat-padding" fxLayout="column"> |
|
||||
<form [formGroup]="entityForm"> |
|
||||
<fieldset [disabled]="(isLoading$ | async) || !isEdit" style="min-width: 0;"> |
|
||||
<mat-form-field class="mat-block"> |
|
||||
<mat-label translate>alarm-rule.name</mat-label> |
|
||||
<input matInput formControlName="name" required/> |
|
||||
<mat-error *ngIf="entityForm.get('name').hasError('required')"> |
|
||||
{{ 'alarm-rule.name-required' | translate }} |
|
||||
</mat-error> |
|
||||
<mat-error *ngIf="entityForm.get('name').hasError('maxlength')"> |
|
||||
{{ 'alarm-rule.name-max-length' | translate }} |
|
||||
</mat-error> |
|
||||
</mat-form-field> |
|
||||
</fieldset> |
|
||||
</form> |
|
||||
</div> |
|
||||
@ -1,63 +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 { ChangeDetectorRef, Component, Inject, Optional } from '@angular/core'; |
|
||||
import { Store } from '@ngrx/store'; |
|
||||
import { AppState } from '@core/core.state'; |
|
||||
import { UntypedFormBuilder, UntypedFormGroup, Validators } from '@angular/forms'; |
|
||||
import { TranslateService } from '@ngx-translate/core'; |
|
||||
import { EntityTableConfig } from '@home/models/entity/entities-table-config.models'; |
|
||||
import { EntityComponent } from '@home/components/entity/entity.component'; |
|
||||
import { AlarmRule } from '@shared/models/alarm-rule.models'; |
|
||||
|
|
||||
@Component({ |
|
||||
selector: 'tb-alarm-rule', |
|
||||
templateUrl: './alarm-rule.component.html', |
|
||||
styleUrls: [] |
|
||||
}) |
|
||||
export class AlarmRuleComponent extends EntityComponent<AlarmRule> { |
|
||||
|
|
||||
constructor(protected store: Store<AppState>, |
|
||||
protected translate: TranslateService, |
|
||||
@Optional() @Inject('entity') protected entityValue: AlarmRule, |
|
||||
@Optional() @Inject('entitiesTableConfig') protected entitiesTableConfigValue: EntityTableConfig<AlarmRule>, |
|
||||
protected fb: UntypedFormBuilder, |
|
||||
protected cd: ChangeDetectorRef) { |
|
||||
super(store, fb, entityValue, entitiesTableConfigValue, cd); |
|
||||
} |
|
||||
|
|
||||
hideDelete() { |
|
||||
if (this.entitiesTableConfig) { |
|
||||
return !this.entitiesTableConfig.deleteEnabled(this.entity); |
|
||||
} else { |
|
||||
return false; |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
buildForm(entity: AlarmRule): UntypedFormGroup { |
|
||||
const form = this.fb.group( |
|
||||
{ |
|
||||
name: [entity ? entity.name : '', [Validators.required, Validators.maxLength(255)]] |
|
||||
} |
|
||||
); |
|
||||
return form; |
|
||||
} |
|
||||
|
|
||||
updateForm(entity: AlarmRule) { |
|
||||
this.entityForm.patchValue({name: entity.name}); |
|
||||
} |
|
||||
|
|
||||
} |
|
||||
@ -1,100 +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 { Injectable } from '@angular/core'; |
|
||||
import { Resolve, Router } from '@angular/router'; |
|
||||
import { |
|
||||
DateEntityTableColumn, |
|
||||
EntityTableColumn, |
|
||||
EntityTableConfig |
|
||||
} from '@home/models/entity/entities-table-config.models'; |
|
||||
import { TranslateService } from '@ngx-translate/core'; |
|
||||
import { DatePipe } from '@angular/common'; |
|
||||
import { EntityType, entityTypeResources, entityTypeTranslations } from '@shared/models/entity-type.models'; |
|
||||
import { EntityAction } from '@home/models/entity/entity-component.models'; |
|
||||
import { DialogService } from '@core/services/dialog.service'; |
|
||||
import { MatDialog } from '@angular/material/dialog'; |
|
||||
import { ImportExportService } from '@home/components/import-export/import-export.service'; |
|
||||
import { HomeDialogsService } from '@home/dialogs/home-dialogs.service'; |
|
||||
import { AlarmRuleComponent } from '@home/pages/alarm/alarm-rule.component'; |
|
||||
import { AlarmRuleTabsComponent } from '@home/pages/alarm/alarm-rule-tabs.component'; |
|
||||
import { AlarmRule } from '@shared/models/alarm-rule.models'; |
|
||||
import { emptyPageData } from '@shared/models/page/page-data'; |
|
||||
import { of } from 'rxjs'; |
|
||||
|
|
||||
@Injectable() |
|
||||
export class AlarmRulesTableConfigResolver implements Resolve<EntityTableConfig<AlarmRule>> { |
|
||||
|
|
||||
private readonly config: EntityTableConfig<AlarmRule> = new EntityTableConfig<AlarmRule>(); |
|
||||
|
|
||||
constructor(private importExport: ImportExportService, |
|
||||
private homeDialogs: HomeDialogsService, |
|
||||
private translate: TranslateService, |
|
||||
private datePipe: DatePipe, |
|
||||
private dialogService: DialogService, |
|
||||
private router: Router, |
|
||||
private dialog: MatDialog) { |
|
||||
|
|
||||
this.config.entityType = EntityType.ALARM_RULE; |
|
||||
this.config.entityComponent = AlarmRuleComponent; |
|
||||
this.config.entityTabsComponent = AlarmRuleTabsComponent; |
|
||||
this.config.entityTranslations = entityTypeTranslations.get(EntityType.ALARM_RULE); |
|
||||
this.config.entityResources = entityTypeResources.get(EntityType.ALARM_RULE); |
|
||||
|
|
||||
this.config.hideDetailsTabsOnEdit = false; |
|
||||
|
|
||||
this.config.columns.push( |
|
||||
new DateEntityTableColumn<AlarmRule>('createdTime', 'common.created-time', this.datePipe, '150px'), |
|
||||
new EntityTableColumn<AlarmRule>('name', 'alarm-rule.name', '50%') |
|
||||
); |
|
||||
|
|
||||
this.config.deleteEntityTitle = alarmRule => this.translate.instant('alarm-rule.delete-alarm-rule-title', |
|
||||
{ alarmRuleName: alarmRule.name }); |
|
||||
this.config.deleteEntityContent = () => this.translate.instant('alarm-rule.delete-alarm-rule-text'); |
|
||||
this.config.deleteEntitiesTitle = count => this.translate.instant('alarm-rule.delete-alarm-rules-title', {count}); |
|
||||
this.config.deleteEntitiesContent = () => this.translate.instant('alarm-rule.delete-alarm-rules-text'); |
|
||||
|
|
||||
this.config.entitiesFetchFunction = pageLink => of(emptyPageData<AlarmRule>()); // TODO
|
|
||||
this.config.loadEntity = id => of(null); // TODO
|
|
||||
this.config.saveEntity = alarmRule => of(alarmRule); // TODO
|
|
||||
this.config.deleteEntity = id => of(null); // TODO
|
|
||||
this.config.onEntityAction = action => this.onAlarmRuleAction(action); |
|
||||
} |
|
||||
|
|
||||
resolve(): EntityTableConfig<AlarmRule> { |
|
||||
this.config.tableTitle = this.translate.instant('alarm-rule.alarm-rules'); |
|
||||
|
|
||||
return this.config; |
|
||||
} |
|
||||
|
|
||||
private openAlarmRule($event: Event, alarmRule: AlarmRule) { |
|
||||
if ($event) { |
|
||||
$event.stopPropagation(); |
|
||||
} |
|
||||
const url = this.router.createUrlTree(['alarm', 'rules', alarmRule.id.id]); |
|
||||
this.router.navigateByUrl(url); |
|
||||
} |
|
||||
|
|
||||
onAlarmRuleAction(action: EntityAction<AlarmRule>): boolean { |
|
||||
switch (action.action) { |
|
||||
case 'open': |
|
||||
this.openAlarmRule(action.event, action.entity); |
|
||||
return true; |
|
||||
} |
|
||||
return false; |
|
||||
} |
|
||||
|
|
||||
} |
|
||||
@ -1,24 +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 { BaseData } from '@shared/models/base-data'; |
|
||||
import { TenantId } from '@shared/models/id/tenant-id'; |
|
||||
import { AlarmRuleId } from '@shared/models/id/alarm-rule-id'; |
|
||||
|
|
||||
export interface AlarmRule extends BaseData<AlarmRuleId> { |
|
||||
tenantId: TenantId; |
|
||||
name: string; |
|
||||
} |
|
||||
@ -1,26 +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 { EntityId } from './entity-id'; |
|
||||
import { EntityType } from '@shared/models/entity-type.models'; |
|
||||
|
|
||||
export class AlarmRuleId implements EntityId { |
|
||||
entityType = EntityType.ALARM_RULE; |
|
||||
id: string; |
|
||||
constructor(id: string) { |
|
||||
this.id = id; |
|
||||
} |
|
||||
} |
|
||||
Loading…
Reference in new issue