This is an automated email from the ASF dual-hosted git repository.

gongchao pushed a commit to branch integte-extern-alarm
in repository https://gitbox.apache.org/repos/asf/hertzbeat.git

commit a05e653ca10a529e438acba170b352ae16bd22a3
Author: tomsun28 <tomsu...@outlook.com>
AuthorDate: Sat Jan 11 10:18:33 2025 +0800

    [webapp] add alert integration
    
    Signed-off-by: tomsun28 <tomsu...@outlook.com>
---
 .../alert-integration/alert-integration.component.ts   | 18 ++++++++++++++++++
 web-app/src/app/service/auth.service.ts                |  5 +++++
 2 files changed, 23 insertions(+)

diff --git 
a/web-app/src/app/routes/alert/alert-integration/alert-integration.component.ts 
b/web-app/src/app/routes/alert/alert-integration/alert-integration.component.ts
index c06aaafecc..ba7dfe90d0 100644
--- 
a/web-app/src/app/routes/alert/alert-integration/alert-integration.component.ts
+++ 
b/web-app/src/app/routes/alert/alert-integration/alert-integration.component.ts
@@ -6,8 +6,12 @@ import { I18NService } from '@core';
 import { ALAIN_I18N_TOKEN, I18nPipe } from '@delon/theme';
 import { SharedModule } from '@shared';
 import { NzDividerComponent } from 'ng-zorro-antd/divider';
+import { NzNotificationService } from 'ng-zorro-antd/notification';
 import { MarkdownModule } from 'ngx-markdown';
 
+import { AuthService } from '../../../service/auth.service';
+import {NzModalService} from "ng-zorro-antd/modal";
+
 interface DataSource {
   id: string;
   name: string;
@@ -49,10 +53,14 @@ export class AlertIntegrationComponent implements OnInit {
 
   selectedSource: DataSource | null = null;
   markdownContent: string = '';
+  token: string = '';
 
   constructor(
     private http: HttpClient,
+    private authSvc: AuthService,
     @Inject(ALAIN_I18N_TOKEN) private i18nSvc: I18NService,
+    private notifySvc: NzNotificationService,
+    private modal: NzModalService,
     private router: Router,
     private route: ActivatedRoute
   ) {}
@@ -88,6 +96,16 @@ export class AlertIntegrationComponent implements OnInit {
     this.router.navigate(['/alert/integration', source.id]);
   }
 
+  public generateToken() {
+    this.authSvc.generateToken().subscribe(message => {
+      if (message.code === 0) {
+        this.token = message.data?.token;
+      } else {
+        this.notifySvc.warning('Failed generate token', message.msg);
+      }
+    });
+  }
+
   private loadMarkdownContent(source: DataSource) {
     const lang = this.i18nSvc.currentLang;
     const path = `${MARKDOWN_DOC_PATH}/${source.id}.${lang}.md`;
diff --git a/web-app/src/app/service/auth.service.ts 
b/web-app/src/app/service/auth.service.ts
index 606dff8150..fe8350ac3f 100644
--- a/web-app/src/app/service/auth.service.ts
+++ b/web-app/src/app/service/auth.service.ts
@@ -24,6 +24,7 @@ import { Observable } from 'rxjs';
 import { Message } from '../pojo/Message';
 
 const account_auth_refresh_uri = '/account/auth/refresh';
+const account_token = '/account/token';
 
 @Injectable({
   providedIn: 'root'
@@ -37,4 +38,8 @@ export class AuthService {
     };
     return this.http.post<Message<any>>(`${account_auth_refresh_uri}`, body);
   }
+
+  public generateToken(): Observable<Message<any>> {
+    return this.http.post<Message<any>>(`${account_token}` + '/generate', {});
+  }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@hertzbeat.apache.org
For additional commands, e-mail: notifications-h...@hertzbeat.apache.org

Reply via email to