mirror of https://github.com/Ombi-app/Ombi
parent
ac1266bf6e
commit
b6c53a69fa
@ -0,0 +1,35 @@
|
|||||||
|
|
||||||
|
import { APP_BASE_HREF } from "@angular/common";
|
||||||
|
import { Injectable, Inject } from "@angular/core";
|
||||||
|
|
||||||
|
import { HttpClient } from "@angular/common/http";
|
||||||
|
|
||||||
|
import { ServiceHelpers } from "./service.helpers";
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class FileDownloadService extends ServiceHelpers {
|
||||||
|
constructor(http: HttpClient, @Inject(APP_BASE_HREF) href:string) {
|
||||||
|
super(http, "/api/v2/system/", href);
|
||||||
|
}
|
||||||
|
|
||||||
|
downloadFile(url: string, contentType: string): void {
|
||||||
|
this.http.get(url).subscribe((response: any) => {
|
||||||
|
|
||||||
|
// It is necessary to create a new blob object with mime-type explicitly set
|
||||||
|
// otherwise only Chrome works like it should
|
||||||
|
const newBlob = new Blob([(response)], { type: contentType });
|
||||||
|
|
||||||
|
// IE doesn't allow using a blob object directly as link href
|
||||||
|
// instead it is necessary to use msSaveOrOpenBlob
|
||||||
|
if (window.navigator && window.navigator.msSaveOrOpenBlob) {
|
||||||
|
window.navigator.msSaveOrOpenBlob(newBlob);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// For other browsers:
|
||||||
|
// Create a link pointing to the ObjectURL containing the blob.
|
||||||
|
const downloadURL = URL.createObjectURL(response);
|
||||||
|
window.open(downloadURL);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,21 @@
|
|||||||
|
|
||||||
|
import { APP_BASE_HREF } from "@angular/common";
|
||||||
|
import { Injectable, Inject } from "@angular/core";
|
||||||
|
|
||||||
|
import { HttpClient, HttpHeaders } from "@angular/common/http";
|
||||||
|
import { Observable } from "rxjs";
|
||||||
|
|
||||||
|
import { ServiceHelpers } from "./service.helpers";
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class SystemService extends ServiceHelpers {
|
||||||
|
constructor(http: HttpClient, @Inject(APP_BASE_HREF) href:string) {
|
||||||
|
super(http, "/api/v2/system/", href);
|
||||||
|
}
|
||||||
|
public getAvailableLogs(): Observable<string[]> {
|
||||||
|
return this.http.get<string[]>(`${this.url}logs/`, {headers: this.headers});
|
||||||
|
}
|
||||||
|
public getLog(logName: string): Observable<string> {
|
||||||
|
return this.http.get(`${this.url}logs/${logName}`, {responseType: 'text'});
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,8 @@
|
|||||||
|
.small-middle-container{
|
||||||
|
margin: auto;
|
||||||
|
width: 80%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.code-block {
|
||||||
|
font-size: 10px;
|
||||||
|
}
|
Loading…
Reference in new issue