1
0
mirror of https://github.com/xuthus83/pigallery2.git synced 2024-11-03 21:04:03 +08:00

update indentation

This commit is contained in:
Patrik J. Braun 2023-10-08 00:59:14 +02:00
parent 07c827ec1b
commit 7efcaed733

View File

@ -7,7 +7,7 @@ import {Config} from '../../../../common/config/public/Config';
import {Utils} from '../../../../common/Utils'; import {Utils} from '../../../../common/Utils';
import {CustomHeaders} from '../../../../common/CustomHeaders'; import {CustomHeaders} from '../../../../common/CustomHeaders';
import {VersionService} from '../version.service'; import {VersionService} from '../version.service';
import { lastValueFrom } from 'rxjs'; import {lastValueFrom} from 'rxjs';
@Injectable() @Injectable()
export class NetworkService { export class NetworkService {
@ -15,9 +15,9 @@ export class NetworkService {
private globalErrorHandlers: Array<(error: ErrorDTO) => boolean> = []; private globalErrorHandlers: Array<(error: ErrorDTO) => boolean> = [];
constructor( constructor(
private http: HttpClient, private http: HttpClient,
private loadingBarService: LoadingBarService, private loadingBarService: LoadingBarService,
private versionService: VersionService private versionService: VersionService
) { ) {
} }
@ -52,9 +52,9 @@ export class NetworkService {
}; };
return lastValueFrom(this.http return lastValueFrom(this.http
.get(this.apiBaseUrl + url, {responseType: 'text'})) .get(this.apiBaseUrl + url, {responseType: 'text'}))
.then(process) .then(process)
.catch(err); .catch(err);
} }
public getText(url: string): Promise<string> { public getText(url: string): Promise<string> {
@ -71,9 +71,9 @@ export class NetworkService {
}; };
return lastValueFrom(this.http return lastValueFrom(this.http
.get(this.apiBaseUrl + url, {responseType: 'text'})) .get(this.apiBaseUrl + url, {responseType: 'text'}))
.then(process) .then(process)
.catch(err); .catch(err);
} }
public postJson<T>(url: string, data = {}): Promise<T> { public postJson<T>(url: string, data = {}): Promise<T> {
@ -97,9 +97,9 @@ export class NetworkService {
} }
private callJson<T>( private callJson<T>(
method: 'get' | 'post' | 'delete' | 'put', method: 'get' | 'post' | 'delete' | 'put',
url: string, url: string,
data = {} data = {}
): Promise<T> { ): Promise<T> {
const body = data; const body = data;
@ -110,7 +110,7 @@ export class NetworkService {
const msg = res.body; const msg = res.body;
if (res.headers.has(CustomHeaders.dataVersion)) { if (res.headers.has(CustomHeaders.dataVersion)) {
this.versionService.onNewVersion( this.versionService.onNewVersion(
res.headers.get(CustomHeaders.dataVersion) res.headers.get(CustomHeaders.dataVersion)
); );
} }
if (msg.error) { if (msg.error) {
@ -130,26 +130,26 @@ export class NetworkService {
switch (method) { switch (method) {
case 'get': case 'get':
return lastValueFrom(this.http return lastValueFrom(this.http
.get<Message<T>>(this.apiBaseUrl + url, {observe: 'response'})) .get<Message<T>>(this.apiBaseUrl + url, {observe: 'response'}))
.then(process) .then(process)
.catch(err); .catch(err);
case 'delete': case 'delete':
return lastValueFrom(this.http return lastValueFrom(this.http
.delete<Message<T>>(this.apiBaseUrl + url, {observe: 'response'})) .delete<Message<T>>(this.apiBaseUrl + url, {observe: 'response'}))
.then(process) .then(process)
.catch(err); .catch(err);
case 'post': case 'post':
return lastValueFrom(this.http return lastValueFrom(this.http
.post<Message<T>>(this.apiBaseUrl + url, body, { .post<Message<T>>(this.apiBaseUrl + url, body, {
observe: 'response', observe: 'response',
})) }))
.then(process) .then(process)
.catch(err); .catch(err);
case 'put': case 'put':
return lastValueFrom(this.http return lastValueFrom(this.http
.put<Message<T>>(this.apiBaseUrl + url, body, {observe: 'response'})) .put<Message<T>>(this.apiBaseUrl + url, body, {observe: 'response'}))
.then(process) .then(process)
.catch(err); .catch(err);
default: default:
throw new Error('Unknown method'); throw new Error('Unknown method');
} }