[webapp] 通知红标,近期未处理告警展示

This commit is contained in:
tomsun28
2021-12-20 17:10:06 +08:00
parent 64112c0a15
commit b21662cb1b
13 changed files with 91 additions and 155 deletions

View File

@@ -20,11 +20,11 @@
</button>
<button nz-button nzType="primary" (click)="onMarkReadAlerts()">
<i nz-icon nzType="down-circle" nzTheme="outline"></i>
标记已
标记已处理
</button>
<button nz-button nzType="primary" (click)="onMarkUnReadAlerts()">
<i nz-icon nzType="up-circle" nzTheme="outline"></i>
标记未
标记未处理
</button>
<button nz-button nzType="primary" (click)="sync()" nz-tooltip nzTooltipTitle="刷新">
<i nz-icon nzType="sync" nzTheme="outline"></i>
@@ -38,8 +38,8 @@
<nz-select style="margin-right: 10px;float: right;width: 120px;" nzAllowClear
[nzPlaceHolder]="'告警状态过滤'" [(ngModel)]="filterStatus">
<nz-option nzLabel="全部状态" nzValue="9"></nz-option>
<nz-option nzLabel="未读告警" nzValue="0"></nz-option>
<nz-option nzLabel="已读告警" nzValue="3"></nz-option>
<nz-option nzLabel="未处理" nzValue="0"></nz-option>
<nz-option nzLabel="已处理" nzValue="3"></nz-option>
</nz-select>
<nz-select style="margin-right: 10px;float: right;width: 120px;" nzAllowClear
[nzPlaceHolder]="'告警级别过滤'" [(ngModel)]="filterPriority">
@@ -97,17 +97,17 @@
</td>
<td nzAlign="center">{{ data.content }}</td>
<td nzAlign="center">
{{ data.status === 0 ? '未' : '已' }}
{{ data.status === 0 ? '未处理' : '已处理' }}
</td>
<td nzAlign="center">{{ data.gmtCreate }}</td>
<td nzAlign="center" nzRight>
<button nz-button nzType="primary" (click)="onDeleteOneAlert(data.id)" nz-tooltip nzTooltipTitle="删除告警">
<i nz-icon nzType="delete" nzTheme="outline"></i>
</button>
<button nz-button nzType="primary" (click)="onMarkReadOneAlert(data.id)" nz-tooltip nzTooltipTitle="标记已">
<button nz-button nzType="primary" (click)="onMarkReadOneAlert(data.id)" nz-tooltip nzTooltipTitle="标记已处理">
<i nz-icon nzType="down-circle" nzTheme="outline"></i>
</button>
<button nz-button nzType="primary" (click)="onMarkUnReadOneAlert(data.id)" nz-tooltip nzTooltipTitle="标记未">
<button nz-button nzType="primary" (click)="onMarkUnReadOneAlert(data.id)" nz-tooltip nzTooltipTitle="标记未处理">
<i nz-icon nzType="up-circle" nzTheme="outline"></i>
</button>
</td>

View File

@@ -2,13 +2,11 @@ import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { ExceptionComponent } from './exception.component';
import { ExceptionTriggerComponent } from './trigger.component';
const routes: Routes = [
{ path: '403', component: ExceptionComponent, data: { type: 403 } },
{ path: '404', component: ExceptionComponent, data: { type: 404 } },
{ path: '500', component: ExceptionComponent, data: { type: 500 } },
{ path: 'trigger', component: ExceptionTriggerComponent }
{ path: '500', component: ExceptionComponent, data: { type: 500 } }
];
@NgModule({

View File

@@ -6,10 +6,9 @@ import { NzCardModule } from 'ng-zorro-antd/card';
import { ExceptionRoutingModule } from './exception-routing.module';
import { ExceptionComponent } from './exception.component';
import { ExceptionTriggerComponent } from './trigger.component';
@NgModule({
imports: [CommonModule, DelonExceptionModule, NzButtonModule, NzCardModule, ExceptionRoutingModule],
declarations: [ExceptionComponent, ExceptionTriggerComponent]
declarations: [ExceptionComponent]
})
export class ExceptionModule {}

View File

@@ -1,35 +0,0 @@
import { Component, Inject } from '@angular/core';
import { DA_SERVICE_TOKEN, ITokenService } from '@delon/auth';
import { _HttpClient } from '@delon/theme';
@Component({
selector: 'exception-trigger',
template: `
<div class="pt-lg">
<nz-card>
<button *ngFor="let t of types" (click)="go(t)" nz-button nzDanger>触发{{ t }}</button>
<button nz-button nzType="link" (click)="refresh()">触发刷新Token</button>
</nz-card>
</div>
`
})
export class ExceptionTriggerComponent {
types = [401, 403, 404, 500];
constructor(private http: _HttpClient, @Inject(DA_SERVICE_TOKEN) private tokenService: ITokenService) {}
go(type: number): void {
this.http.get(`/api/${type}`).subscribe();
}
refresh(): void {
this.tokenService.set({ token: 'invalid-token' });
// 必须提供一个后端地址,无法通过 Mock 来模拟
this.http.post(`https://localhost:5001/auth`).subscribe(
res => console.warn('成功', res),
err => {
console.log('最后结果失败', err);
}
);
}
}

View File

@@ -7,7 +7,7 @@
<nz-form-item>
<nz-form-control [nzErrorTip]="'validation.password.required' | i18n">
<nz-input-group nzSuffixIcon="lock">
<input type="password" nz-input formControlName="password" />
<input type="password" nz-input formControlName="password" placeholder="输入任意解锁"/>
</nz-input-group>
</nz-form-control>
</nz-form-item>

View File

@@ -1,7 +1,6 @@
import { Component, Inject } from '@angular/core';
import { Component } from '@angular/core';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { Router } from '@angular/router';
import { DA_SERVICE_TOKEN, ITokenService } from '@delon/auth';
import { SettingsService, User } from '@delon/theme';
@Component({
@@ -18,7 +17,6 @@ export class UserLockComponent {
constructor(
fb: FormBuilder,
@Inject(DA_SERVICE_TOKEN) private tokenService: ITokenService,
private settings: SettingsService,
private router: Router
) {
@@ -33,11 +31,6 @@ export class UserLockComponent {
this.f.controls[i].updateValueAndValidity();
}
if (this.f.valid) {
console.log('Valid!');
console.log(this.f.value);
this.tokenService.set({
token: '123'
});
this.router.navigate(['dashboard']);
}
}