@@ -2,7 +2,7 @@ import { Injectable } from '@angular/core';
22import { HttpClient , HttpHeaders } from '@angular/common/http' ;
33import { Observable , of } from 'rxjs' ;
44import { catchError , map , tap } from 'rxjs/operators' ;
5- import { AuthUser , Application , Certificate , Domain , AppAdmin , VulnType , APIResponse , NodesKey , Node , LastRegexLogs , LastCCLogs } from './models' ;
5+ import { AuthUser , Application , Certificate , Domain , AppAdmin , VulnType , APIResponse , NodesKey , Node , LastRegexLogs , LastCCLogs , OAuthInfo } from './models' ;
66import { MessageService } from './message.service' ;
77
88const httpOptions = {
@@ -23,6 +23,7 @@ export class ApplicationService {
2323 vulntypemap : object = new ( Object ) ;
2424 lastRegexLogs : LastRegexLogs = new ( LastRegexLogs ) ;
2525 lastCCLogs : LastCCLogs = new ( LastCCLogs ) ;
26+ oauth : OAuthInfo = new ( OAuthInfo ) ;
2627
2728 constructor ( private http : HttpClient ,
2829 private messageService : MessageService ) { }
@@ -54,6 +55,19 @@ export class ApplicationService {
5455 } ) ;
5556 }
5657
58+ getResponseByURL ( url :string , callback :( obj : object ) => any , id ?:number , obj ?:object ) {
59+ // Get Request
60+ this . http . get < APIResponse > ( url , httpOptions ) . pipe (
61+ tap ( _ => { } ) ,
62+ catchError ( this . handleError < APIResponse > ( 'Get response' ) )
63+ ) . subscribe ( ( response : APIResponse ) => {
64+ if ( response . err == null ) {
65+ callback ( response . object ) ;
66+ }
67+ else this . messageService . add ( 'Error:' + response . err ) ;
68+ } ) ;
69+ }
70+
5771 getApplications ( ) {
5872 var self = this ;
5973 this . getResponse ( 'getapps' , function ( obj : Application [ ] ) {
0 commit comments