This commit is contained in:
pakintada@gmail.com 2023-09-25 16:17:21 +07:00
parent 9e8efa4cfc
commit d737eed480
5 changed files with 143 additions and 81 deletions

View file

@ -1,9 +1,10 @@
import { Component } from '@angular/core';
import { Component, OnInit } 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';
import { WebsocketService } from 'src/app/shared/services/websocket.service';
@Component({
selector: 'app-changelog',
@ -21,52 +22,64 @@ export class ChangelogComponent {
constructor(
private httpClient: HttpClient,
private wss: WebsocketService
){
this.fetchLoglist();
this.translateLogDirToString();
// this.translateLogDirToString();
}
public fetchLoglist(): string[]{
// TODO: Fetch changelog.html
// fetch("/changelog")
let dirlist: any[] = []
this.httpClient.get(environment.api+"/listFileInDir/changelog", {
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);
this.httpClient.get(environment.api+"/listFileInDir/merge", {
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.displayableMergeJson = value.dirs as any[];
}
}
},
error: (err) => {
console.error('Error fetch json: ',err);
}
this.wss.connect(environment.wsapi+"/listFileInDir");
this.wss.send({
"topic": "changelog",
})
let response = this.wss.data;
console.log(response);
// this.httpClient.get(environment.api+"/listFileInDir/changelog", {
// 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);
// this.httpClient.get(environment.api+"/listFileInDir/merge", {
// 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.displayableMergeJson = value.dirs as any[];
// }
// }
// },
// error: (err) => {
// console.error('Error fetch json: ',err);
// }
// })
return dirlist;
}

View file

@ -1,4 +1,5 @@
export const environment = {
production: false,
api: 'http://localhost:8080',
wsapi: 'ws://localhost:8080'
};