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

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

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);
}
);
}
}