From 5d8c3ae76f5d254f7aa9ae0a5eff03f061de0fa4 Mon Sep 17 00:00:00 2001 From: Kacper Date: Mon, 19 Aug 2024 22:09:42 +0200 Subject: [PATCH 1/2] add api getreporttemplates --- src/app/settings/settings.component.ts | 51 +++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) diff --git a/src/app/settings/settings.component.ts b/src/app/settings/settings.component.ts index 7c61852f7..1ca14ca3f 100644 --- a/src/app/settings/settings.component.ts +++ b/src/app/settings/settings.component.ts @@ -67,7 +67,7 @@ export class SettingsComponent implements OnInit { reportProfileList = []; reportTemplateList = []; reportProfileList_int = []; - + reportTemplateList_int = []; ReportProfilesdisplayedColumns: string[] = ['source', 'profile_name', 'profile_settings']; ReportProfilesdataSource = new MatTableDataSource([]); @@ -388,6 +388,7 @@ getTemplates(): void { this.sessionsub.setSessionStorageItem('VULNREPO-API', JSON.stringify(vaultobj)); this.getReportProfiles(); + this.getReportTemplates(); } removeapikey() { @@ -958,5 +959,53 @@ editTemplateItem(item: any): void { } +getReportTemplates() { + this.indexeddbService.retrieveReportTemplates().then(ret => { + if (ret) { + this.ReportTemplatesdataSource = new MatTableDataSource(ret); + this.reportTemplateList = this.ReportTemplatesdataSource.data; + } + this.getAPITemplates(); + }); +} + +getAPITemplates() { + + const localkey = this.sessionsub.getSessionStorageItem('VULNREPO-API'); + if (localkey) { + this.msg = 'API connection please wait...'; + + const vaultobj = JSON.parse(localkey); + + vaultobj.forEach( (element) => { + + this.apiService.APISend(element.value, element.apikey, 'getreporttemplates', '').then(resp => { + this.reportTemplateList_int = []; + if (resp.length > 0) { + resp.forEach((ele) => { + ele.api = 'remote'; + ele.apiurl = element.value; + ele.apikey = element.apikey; + ele.apiname = element.viewValue; + }); + this.reportTemplateList_int.push(...resp); + } + + }).then(() => { + this.ReportTemplatesdataSource.data = [...this.reportTemplateList, ...this.reportTemplateList_int]; + this.reportTemplateList = this.ReportTemplatesdataSource.data; + + this.msg = ''; + }).catch(() => {}); + + setTimeout(() => { + // console.log('hide progress timeout'); + this.msg = ''; + }, 10000); + + }); + + } +} } From dd60d59cb2e41198bc82d02e1a047bc4e5dd05f9 Mon Sep 17 00:00:00 2001 From: Kacper Date: Mon, 19 Aug 2024 22:12:23 +0200 Subject: [PATCH 2/2] api pagination fix --- src/app/settings/settings.component.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/app/settings/settings.component.ts b/src/app/settings/settings.component.ts index 1ca14ca3f..e26905aac 100644 --- a/src/app/settings/settings.component.ts +++ b/src/app/settings/settings.component.ts @@ -644,8 +644,8 @@ getAPIReportProfiles() { }).then(() => { this.ReportProfilesdataSource.data = [...this.reportProfileList, ...this.reportProfileList_int]; - //this.dataSource.sort = this.sort; - //this.dataSource.paginator = this.paginator; + this.ReportProfilesdataSource.paginator = this.paginator; + this.ReportProfilesdataSource.sort = this.sort; this.msg = ''; }).catch(() => {}); @@ -994,7 +994,8 @@ getAPITemplates() { }).then(() => { this.ReportTemplatesdataSource.data = [...this.reportTemplateList, ...this.reportTemplateList_int]; this.reportTemplateList = this.ReportTemplatesdataSource.data; - + this.ReportTemplatesdataSource.paginator = this.paginator2; + this.ReportTemplatesdataSource.sort = this.sort2; this.msg = ''; }).catch(() => {});