add fetch all merge logs
This commit is contained in:
parent
baa66609ee
commit
325020fd37
6 changed files with 205 additions and 70 deletions
|
|
@ -6,11 +6,13 @@ import { MergeServiceService } from './merge-service.service';
|
|||
import { HttpClient, HttpParams } from '@angular/common/http';
|
||||
import { environment } from 'src/environments/environment.development';
|
||||
import { Observable } from 'rxjs';
|
||||
import { ChangelogComponent } from '../changelog/changelog.component';
|
||||
import { FetchLogService } from 'src/app/shared/services/fetch-log.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-merge',
|
||||
standalone: true,
|
||||
imports: [CommonModule, ReactiveFormsModule],
|
||||
imports: [CommonModule, ReactiveFormsModule, ChangelogComponent],
|
||||
templateUrl: './merge.component.html',
|
||||
styleUrls: ['./merge.component.css']
|
||||
})
|
||||
|
|
@ -25,12 +27,16 @@ export class MergeComponent<T> {
|
|||
changelog_path: ""
|
||||
});
|
||||
|
||||
default_output_path = "cofffeemachineConfig/merge/"
|
||||
default_changelog_path = "cofffeemachineConfig/changelog/"
|
||||
|
||||
mergeLogs: Map<string, string> | void | undefined
|
||||
|
||||
constructor(
|
||||
private targets: MergeServiceService,
|
||||
private formBuilder: FormBuilder,
|
||||
private httpClient: HttpClient,
|
||||
private chlog: ChangelogComponent
|
||||
){
|
||||
// Default fetching logs
|
||||
|
||||
|
|
@ -52,8 +58,8 @@ export class MergeComponent<T> {
|
|||
}
|
||||
this.targets.master_version = this.mergeForm.value.master_version!;
|
||||
this.targets.dev_version = this.mergeForm.value.dev_version!;
|
||||
this.targets.output_path = this.mergeForm.value.output_path!;
|
||||
this.targets.changelog_path = this.mergeForm.value.changelog_path!;
|
||||
this.targets.output_path = this.default_output_path + this.mergeForm.value.output_path!;
|
||||
this.targets.changelog_path = this.default_changelog_path + this.mergeForm.value.changelog_path!;
|
||||
|
||||
// TODO: Fetch merge. Modify this to websocket
|
||||
this.httpClient.post<T>(environment.api+"/merge", {
|
||||
|
|
@ -69,71 +75,18 @@ export class MergeComponent<T> {
|
|||
if(typeof value === "object" && value !== null){
|
||||
if("message" in value){
|
||||
// fetch html
|
||||
this.fetchLogsToDisplay("", true, false);
|
||||
// this.fetchLogsToDisplay("", true, false);
|
||||
// fetch log file
|
||||
this.fetchLogsToDisplay("", false, false);
|
||||
// this.fetchLogsToDisplay("", false, false);
|
||||
// fetch json
|
||||
this.mergeLogs = this.fetchLogsToDisplay("", false, true);
|
||||
this.mergeLogs = new FetchLogService(this.httpClient).fetchLogsToDisplay("", false, true,"");
|
||||
this.chlog.fetchLoglist();
|
||||
this.chlog.translateLogDirToString();
|
||||
}
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
fetchLogsToDisplay(query: string, isDisplayOnly: boolean, requestJson: boolean) : Map<string, string> | void{
|
||||
let additionalParams:string = "?query=";
|
||||
if(query != ""){
|
||||
additionalParams += query
|
||||
} else {
|
||||
additionalParams = ""
|
||||
}
|
||||
|
||||
let jsontarget;
|
||||
|
||||
if(requestJson){
|
||||
this.httpClient.post(environment.api+"/dllog"+additionalParams, {
|
||||
htmlfile: isDisplayOnly,
|
||||
requestJson: requestJson
|
||||
}, {
|
||||
responseType: 'json',
|
||||
withCredentials: true
|
||||
}).subscribe({
|
||||
next: (value) => {
|
||||
jsontarget = value;
|
||||
},
|
||||
error: (err) => {
|
||||
console.error('Error fetch json: ',err);
|
||||
}
|
||||
});
|
||||
return jsontarget;
|
||||
} else {
|
||||
this.httpClient.post(environment.api+"/dllog"+additionalParams, {
|
||||
htmlfile: isDisplayOnly,
|
||||
requestJson: requestJson
|
||||
},{
|
||||
responseType: 'blob',
|
||||
withCredentials: true,
|
||||
}).subscribe(
|
||||
{
|
||||
next: (value) => {
|
||||
const blob = new Blob([value], { type: 'application/octet-stream' });
|
||||
const url = window.URL.createObjectURL(blob);
|
||||
const a = document.createElement('a');
|
||||
a.href = url;
|
||||
a.download = 'logfile.log';
|
||||
a.innerText = "Click here to download as `.log` file";
|
||||
if(isDisplayOnly){
|
||||
blob.text().then(v => document.getElementById("log-disp-texts")!.innerHTML = v);
|
||||
} else {
|
||||
document.getElementById("log-dl")?.appendChild(a);
|
||||
document.getElementById("log-dl")!.className = "bg-yellow-500 rounded p-2 sticky top-0";
|
||||
}
|
||||
},
|
||||
error: (err) => {
|
||||
console.error('Error downloading log file: ',err);
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue