diff --git a/smp-angular/src/app/alert/alert-controller.ts b/smp-angular/src/app/alert/alert-controller.ts index c3078584a6d3b6ffb4f0716b2d7ae2c0d25573a1..cb2841cad7cd0662f58741728c0e7f7cfe71c207 100644 --- a/smp-angular/src/app/alert/alert-controller.ts +++ b/smp-angular/src/app/alert/alert-controller.ts @@ -30,31 +30,32 @@ export class AlertController implements SearchTableController { return true; } - public showDetails(row: any) { - this.dialog.open(ObjectPropertiesDialogComponent, { + public showDetails(row: any): MatDialogRef<any> { + return this.dialog.open(ObjectPropertiesDialogComponent, { data: { title: "Alert details", - object: row.alertDetails, - + object: row, } }); } - public edit(row: any) { - this.dialog.open(ObjectPropertiesDialogComponent, { + public edit(row: any): MatDialogRef<any> { + return this.dialog.open(ObjectPropertiesDialogComponent, { data: { - title: "Alert details!", - object: row.alertDetails, - + title: "Update Alert", + object: row, } }); } - public delete(row: any) { } - newDialog(config?: MatDialogConfig): MatDialogRef<any> { - return this.dialog.open(ObjectPropertiesDialogComponent, config); + newDialog(config): MatDialogRef<any> { + if (config && config.data && config.data.edit) { + return this.edit(config.data); + } else { + return this.showDetails(config.data); + } } } diff --git a/smp-angular/src/app/alert/alert.component.html b/smp-angular/src/app/alert/alert.component.html index 3d1964d905ec519e159babea205d2db66a85551e..87752f5a06245c31f4f9cc185794d1a5d5d88719 100644 --- a/smp-angular/src/app/alert/alert.component.html +++ b/smp-angular/src/app/alert/alert.component.html @@ -17,7 +17,7 @@ <span style="width: 2px"> </span> </ng-template> <ng-template #dateTimeColumn let-value="value" ngx-datatable-cell-template> - <div class='truncate-text' title="{{value | date:dateTimeFormat}}" >{{value | date:dateFormat}}</div></ng-template> + <div class='truncate-text' title="{{value | date:dateTimeFormat}}">{{value | date:dateTimeFormat}}</div></ng-template> <ng-template #truncateText let-value="value" ngx-datatable-cell-template> <div class='truncate-text' title="{{value}}" >{{value}}</div> </ng-template> diff --git a/smp-angular/src/app/alert/alert.component.ts b/smp-angular/src/app/alert/alert.component.ts index f89d0b4f4bdb6bbe7db69df381bb8e9792b478c6..d36a0b660cfc444e189a20a822f9840c95f26fb1 100644 --- a/smp-angular/src/app/alert/alert.component.ts +++ b/smp-angular/src/app/alert/alert.component.ts @@ -19,7 +19,6 @@ import {SearchTableComponent} from "../common/search-table/search-table.componen import {SecurityService} from "../security/security.service"; import {ObjectPropertiesDialogComponent} from "../common/dialogs/object-properties-dialog/object-properties-dialog.component"; - @Component({ templateUrl: './alert.component.html', styleUrls: ['./alert.component.css'] @@ -34,7 +33,6 @@ export class AlertComponent implements OnInit, AfterViewInit, AfterViewChecked { @ViewChild('credentialType') credentialType: TemplateRef<any>; @ViewChild('forUser') forUser: TemplateRef<any>; - readonly dateTimeFormat: string = SmpConstants.DATE_TIME_FORMAT; readonly dateFormat: string = SmpConstants.DATE_FORMAT; @@ -44,7 +42,6 @@ export class AlertComponent implements OnInit, AfterViewInit, AfterViewChecked { filter: any = {}; isSMPIntegrationOn: boolean = false; - constructor(public securityService: SecurityService, protected lookups: GlobalLookups, protected http: HttpClient, @@ -68,7 +65,7 @@ export class AlertComponent implements OnInit, AfterViewInit, AfterViewChecked { title: "Alert date", prop: 'reportingTime', showInitially: true, - maxWidth: 100, + maxWidth: 250, cellTemplate: this.dateTimeColumn, }, { diff --git a/smp-angular/src/app/common/dialogs/object-properties-dialog/object-properties-dialog.component.html b/smp-angular/src/app/common/dialogs/object-properties-dialog/object-properties-dialog.component.html index 15511a6d54ec46a267f226066429a66cd7d4843d..48089c1020c41d64b34f7d9832f840c5a1108c37 100644 --- a/smp-angular/src/app/common/dialogs/object-properties-dialog/object-properties-dialog.component.html +++ b/smp-angular/src/app/common/dialogs/object-properties-dialog/object-properties-dialog.component.html @@ -2,22 +2,20 @@ <mat-dialog-content style="height: 400px;width: 800px;"> <table mat-table style="width: 100%" [dataSource]="dataSource"> - <!-- Name Column --> <ng-container matColumnDef="key"> - <th mat-header-cell *matHeaderCellDef> Key</th> - <td mat-cell *matCellDef="let element"> {{element[0]}} </td> + <th mat-header-cell *matHeaderCellDef>Key</th> + <td mat-cell *matCellDef="let element">{{element[0] | titlecase }}</td> </ng-container> <!-- Weight Column --> <ng-container matColumnDef="value"> - <th mat-header-cell *matHeaderCellDef> Value</th> - <td mat-cell *matCellDef="let element"> {{element[1]}} </td> + <th mat-header-cell *matHeaderCellDef>Value</th> + <td mat-cell *matCellDef="let element">{{element[1]}}</td> </ng-container> <tr mat-header-row *matHeaderRowDef="displayedColumns"></tr> <tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr> </table> - </mat-dialog-content> <mat-dialog-actions> diff --git a/smp-angular/src/app/common/dialogs/object-properties-dialog/object-properties-dialog.component.ts b/smp-angular/src/app/common/dialogs/object-properties-dialog/object-properties-dialog.component.ts index 5709f7bcbf780ab6f33628e5a8b10a91bb43e2ac..203c2a53a1300c6526a4ecde0ae027098c225f7a 100644 --- a/smp-angular/src/app/common/dialogs/object-properties-dialog/object-properties-dialog.component.ts +++ b/smp-angular/src/app/common/dialogs/object-properties-dialog/object-properties-dialog.component.ts @@ -8,18 +8,25 @@ import {MAT_DIALOG_DATA, MatDialogRef} from '@angular/material/dialog'; }) export class ObjectPropertiesDialogComponent { - title: string="Object properties"; + title: string = "Object properties"; object:Object displayedColumns: string[] = ['key', 'value']; dataSource : object[]; constructor(public dialogRef: MatDialogRef<ObjectPropertiesDialogComponent>, @Inject(MAT_DIALOG_DATA) public data: any) { - //this.title=data.title; - this.object=data.row.alertDetails; - this.dataSource = Object.keys(this.object).map((key) => [key, this.object[key]]); - - + this.title = data.title; + this.object = {...data.object.row.alertDetails, + statusDescription: data.object.row.alertStatusDesc}; + this.dataSource = Object.keys(this.object) + .map((key) => [ this.toTitleCase(key), this.object[key] ]) + .sort(); + } + private toTitleCase(input: string): string { + return input + .replace(/([A-Z]+)/g, " $1") // camelCase -> Title Case (part #1) + .replace(/([A-Z][a-z])/g, " $1") // camelCase -> Title Case (part #2) + .replaceAll('_', ''); } } diff --git a/smp-angular/src/app/common/search-table/search-table-controller.ts b/smp-angular/src/app/common/search-table/search-table-controller.ts index b8920a1ba7eae55491173ef7f23f3c2590e10192..4d0961431a36d92a64bd163a8559f64ee7f8e52c 100644 --- a/smp-angular/src/app/common/search-table/search-table-controller.ts +++ b/smp-angular/src/app/common/search-table/search-table-controller.ts @@ -2,14 +2,21 @@ import {MatDialogConfig, MatDialogRef} from '@angular/material/dialog'; import {SearchTableEntity} from './search-table-entity.model'; export interface SearchTableController { - showDetails(row); - edit(row); + + showDetails(row): MatDialogRef<any>; + + edit(row): MatDialogRef<any>; validateDeleteOperation(rows: Array<SearchTableEntity>); + delete(row); + newRow(): SearchTableEntity; - newDialog(config?: MatDialogConfig): MatDialogRef<any>; + + newDialog(config): MatDialogRef<any>; + dataSaved(); + isRecordChanged(oldModel, newModel): boolean; /** @@ -18,7 +25,4 @@ export interface SearchTableController { * @param row the row for which the row expander should be disabled or not */ isRowExpanderDisabled(row: SearchTableEntity): boolean; - - - } diff --git a/smp-angular/src/app/common/search-table/search-table.component.html b/smp-angular/src/app/common/search-table/search-table.component.html index d0725332c9b65ba06b6dcc55b2ffbc80f51645ef..b09d92dcdc7bbe6ca85c402ce2efa2ef57249f32 100644 --- a/smp-angular/src/app/common/search-table/search-table.component.html +++ b/smp-angular/src/app/common/search-table/search-table.component.html @@ -77,7 +77,7 @@ title="Expand/Collapse Row" (click)="toggleExpandRow(row)"> - <mat-icon > + <mat-icon> {{expanded ? 'expand_more' : 'chevron_right'}} </mat-icon> </a> diff --git a/smp-angular/src/app/common/search-table/search-table.component.ts b/smp-angular/src/app/common/search-table/search-table.component.ts index ead42b8c36dc9c6625661c6f2ed383a24ec96c09..46c9dadb576b6749ce0bb35516f9671b974a1db5 100644 --- a/smp-angular/src/app/common/search-table/search-table.component.ts +++ b/smp-angular/src/app/common/search-table/search-table.component.ts @@ -297,7 +297,6 @@ export class SearchTableComponent implements OnInit { this.editSearchTableEntity(this.rowNumber); } - onSaveButtonClicked(withDownloadCSV: boolean) { try { this.dialog.open(SaveDialogComponent).afterClosed().subscribe(result => { @@ -388,7 +387,7 @@ export class SearchTableComponent implements OnInit { private editSearchTableEntity(rowNumber: number) { const row = this.rows[rowNumber]; const formRef: MatDialogRef<any> = this.searchTableController.newDialog({ - data: {edit: row?.status!=EntityStatus.NEW, row} + data: {edit: row?.status != EntityStatus.NEW, row} }); if (!formRef) { return; diff --git a/smp-angular/src/app/service-group-search/service-group-search-controller.ts b/smp-angular/src/app/service-group-search/service-group-search-controller.ts index e5334db7db4f1c7e4ab2bf1146678a4a2e86b970..0cd08e5fda332226d76bf1d68bb278b97389dde5 100644 --- a/smp-angular/src/app/service-group-search/service-group-search-controller.ts +++ b/smp-angular/src/app/service-group-search/service-group-search-controller.ts @@ -1,5 +1,5 @@ import {SearchTableController} from '../common/search-table/search-table-controller'; -import {MatDialog, MatDialogConfig} from '@angular/material/dialog'; +import {MatDialog, MatDialogConfig, MatDialogRef} from '@angular/material/dialog'; import {ServiceGroupSearchRo} from './service-group-search-ro.model'; import {of} from "rxjs/internal/observable/of"; import {SearchTableValidationResult} from "../common/search-table/search-table-validation-result.model"; @@ -9,18 +9,25 @@ export class ServiceGroupSearchController implements SearchTableController { constructor(public dialog: MatDialog) { } - public showDetails(row: any) { + public showDetails(row): MatDialogRef<any> { + return null; } public showExtension(row: any) { } - public edit(row: any) { } + public edit(row): MatDialogRef<any> { + return null; + } public delete(row: any) { } - public newDialog(config?: MatDialogConfig) { - return null; + newDialog(config): MatDialogRef<any> { + if (config && config.data && config.data.edit) { + return this.edit(config); + } else { + return this.showDetails(config); + } } public newRow(): ServiceGroupSearchRo { diff --git a/smp-angular/src/app/system-settings/domain/domain-controller.ts b/smp-angular/src/app/system-settings/domain/domain-controller.ts index 7f333c67e9f43d205ed88d377f27f06ded9f2b4d..c56fc752857281b6721bfb12240e28d74f82d77a 100644 --- a/smp-angular/src/app/system-settings/domain/domain-controller.ts +++ b/smp-angular/src/app/system-settings/domain/domain-controller.ts @@ -14,22 +14,23 @@ export class DomainController implements SearchTableController { constructor(protected http: HttpClient, protected lookups: GlobalLookups, public dialog: MatDialog) { } - public showDetails( row: any) { - - let dialogRef: MatDialogRef<DomainDetailsDialogComponent> = this.dialog.open(DomainDetailsDialogComponent); - dialogRef.afterClosed().subscribe(result => { - console.log("Domain dialog is closed!"); - }); + public showDetails(row): MatDialogRef<any> { + return this.dialog.open(DomainDetailsDialogComponent); } - public edit(row: any) { + public edit(row): MatDialogRef<any> { + return this.dialog.open(DomainDetailsDialogComponent, row); } public delete(row: any) { } - public newDialog(config?: MatDialogConfig): MatDialogRef<DomainDetailsDialogComponent> { - return this.dialog.open(DomainDetailsDialogComponent, config); + newDialog(config): MatDialogRef<any> { + if (config && config.data && config.data.edit) { + return this.edit(config); + } else { + return this.showDetails(config); + } } public newRow(): DomainRo { diff --git a/smp-angular/src/app/system-settings/property/property-controller.ts b/smp-angular/src/app/system-settings/property/property-controller.ts index e6bceb1bb0572eed583214b095bdb504e82f0f29..5e9305028e5043e0d0c094e22e45912080c8b9a9 100644 --- a/smp-angular/src/app/system-settings/property/property-controller.ts +++ b/smp-angular/src/app/system-settings/property/property-controller.ts @@ -35,21 +35,23 @@ export class PropertyController implements SearchTableController { return true; } - public showDetails(row: any) { - let dialogRef: MatDialogRef<PropertyDetailsDialogComponent> = this.dialog.open(PropertyDetailsDialogComponent); - dialogRef.afterClosed().subscribe(result => { - console.log("Property dialog is closed!"); - }); + public showDetails(row: any): MatDialogRef<any> { + return this.dialog.open(PropertyDetailsDialogComponent); } - public edit(row: any) { + public edit(row: any): MatDialogRef<any> { + return this.dialog.open(PropertyDetailsDialogComponent, row); } public delete(row: any) { } - newDialog(config?: MatDialogConfig): MatDialogRef<any> { - return this.dialog.open(PropertyDetailsDialogComponent, config); + newDialog(config): MatDialogRef<any> { + if (config && config.data && config.data.edit) { + return this.edit(config); + } else { + return this.showDetails(config); + } } isEqual(val1, val2): boolean { diff --git a/smp-angular/src/app/system-settings/user/user-controller.ts b/smp-angular/src/app/system-settings/user/user-controller.ts index 5871567f18fa4a7ef0401230fa6308b4d921e254..2e4d486bacbcdfd5e56f1fc9e6d86b39ad816238 100644 --- a/smp-angular/src/app/system-settings/user/user-controller.ts +++ b/smp-angular/src/app/system-settings/user/user-controller.ts @@ -23,25 +23,23 @@ export class UserController implements SearchTableController { this.nullCert = this.newCertificateRo(); } - public showDetails(row: any) { - /*let dialogRef: MatDialogRef<UserDetailsDialogComponent> = this.dialog.open(UserDetailsDialogComponent); - dialogRef.afterClosed().subscribe(result => { - //Todo: - }); - */ + public showDetails(row): MatDialogRef<any> { + return null; } - public edit(row: any) { + public edit(row): MatDialogRef<any> { + return null; } public delete(row: any) { } - - public newDialog(config?: MatDialogConfig): MatDialogRef<any> { - //return this.dialog.open(UserDetailsDialogComponent, this.convertWithMode(config)); - return null; + newDialog(config): MatDialogRef<any> { + if (config && config.data && config.data.edit) { + return this.edit(config); + } else { + return this.showDetails(config); + } } - public changePasswordDialog(config?: MatDialogConfig): MatDialogRef<PasswordChangeDialogComponent> { return this.dialog.open(PasswordChangeDialogComponent, this.convertWithMode(config)); }