import { Component } from '@angular/core'; import { MergeComponent } from '../merge/merge.component'; import { HttpClient } from '@angular/common/http'; import { environment } from 'src/environments/environment.development'; import { CommonModule } from '@angular/common'; import { FetchLogService } from 'src/app/shared/services/fetch-log.service'; @Component({ selector: 'app-changelog', standalone: true, templateUrl: './changelog.component.html', styleUrls: ['./changelog.component.css'], imports: [CommonModule,MergeComponent] }) export class ChangelogComponent { public displayableLogs: string[] = []; showLogModal:boolean = false; constructor( private httpClient: HttpClient, ){ this.fetchLoglist(); this.translateLogDirToString(); } public fetchLoglist(): string[]{ // TODO: Fetch changelog.html // fetch("/changelog") let dirlist: any[] = [] this.httpClient.get(environment.api+"/mergelogList", { withCredentials: true }).subscribe({ next: (value) => { console.log(value) if(typeof value === "object" && value !== null){ if("dirs" in value){ console.log("dirs", value) // dirlist.push(...(value as {dirs: unknown[]})["dirs"]); this.displayableLogs = value.dirs as any[]; } } }, error: (err) => { console.error('Error fetch json: ',err); } }) console.log(dirlist); return dirlist; } public translateLogDirToString(){ console.log("LogDirList: ", this.displayableLogs) let dirSelector = document.getElementById("log-dir-list") // for(let dir of this.displayableLogs){ // console.log(dir) // const p = document.createElement('p'); // p.innerText = dir; // dirSelector!.appendChild(p); // dirSelector?.replaceChild(p, dirSelector.children[]) // } } refreshLogList(){ this.fetchLoglist(); this.translateLogDirToString(); } viewLog(name:string){ let cli = new FetchLogService(this.httpClient); this.showLogModal = !this.showLogModal; cli.fetchLogsToDisplay("", true, false, name); cli.fetchLogsToDisplay("", false, false, name); } toggleLogModal(){ this.showLogModal = !this.showLogModal; } }