Prettied, Linted and updated angular.json according to the latest schematic of Angular CLI.

Now all that is needed is to make it ready for strict compiling.
Removed eslint-plugin-prettier as it is not recommended and causes errors for both eslint and prettier

Bumped to v8.0.0
This commit is contained in:
2020-10-10 08:45:05 +05:30
parent 438a98334d
commit 5ea09df272
320 changed files with 2233 additions and 2268 deletions

View File

@ -1,7 +1,8 @@
import { Injectable } from '@angular/core';
import { catchError } from 'rxjs/operators';
import { Observable } from 'rxjs/internal/Observable';
import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs/internal/Observable';
import { catchError } from 'rxjs/operators';
import { ErrorLoggerService } from './error-logger.service';
import { Voucher } from './voucher';
@ -18,6 +19,21 @@ const serviceName = 'VoucherService';
export class VoucherService {
constructor(private http: HttpClient, private log: ErrorLoggerService) {}
static dataURLtoBlob(dataURL) {
const re = /^data:([\w/\-.]+);\w+,(.*)$/;
const m = dataURL.match(re);
const mimeString = m[1];
const byteString = atob(m[2]);
const ab = new ArrayBuffer(byteString.length);
const dw = new DataView(ab);
let i;
for (i = 0; i < byteString.length; i += 1) {
dw.setUint8(i, byteString.charCodeAt(i));
}
return new Blob([ab], { type: mimeString });
}
get(id: string, type: string): Observable<Voucher> {
const endpoint = type.replace(/ /g, '-').toLowerCase();
return <Observable<Voucher>>(
@ -31,6 +47,7 @@ export class VoucherService {
const endpoint = type.replace(/ /g, '-').toLowerCase();
const options = {};
if (account !== undefined && account !== null) {
// eslint-disable-next-line @typescript-eslint/dot-notation
options['params'] = new HttpParams().set('a', account);
}
return <Observable<Voucher>>(
@ -69,9 +86,8 @@ export class VoucherService {
const endpoint = voucher.type.replace(/ /g, '-').toLowerCase();
if (!voucher.id) {
return this.save(voucher, endpoint);
} else {
return this.update(voucher, endpoint);
}
return this.update(voucher, endpoint);
}
save(voucher: Voucher, endpoint: string): Observable<Voucher> {
@ -79,8 +95,8 @@ export class VoucherService {
voucher.files
.filter((x) => !x.id)
.forEach((file) => {
fd.append('i', this.dataURLtoBlob(file.resized));
fd.append('t', this.dataURLtoBlob(file.thumbnail));
fd.append('i', VoucherService.dataURLtoBlob(file.resized));
fd.append('t', VoucherService.dataURLtoBlob(file.thumbnail));
});
voucher.files = voucher.files.filter((x) => x.id);
fd.append('data', JSON.stringify(voucher));
@ -96,8 +112,8 @@ export class VoucherService {
voucher.files
.filter((x) => !x.id)
.forEach((file) => {
fd.append('i', this.dataURLtoBlob(file.resized));
fd.append('t', this.dataURLtoBlob(file.thumbnail));
fd.append('i', VoucherService.dataURLtoBlob(file.resized));
fd.append('t', VoucherService.dataURLtoBlob(file.thumbnail));
});
voucher.files = voucher.files.filter((x) => x.id);
fd.append('data', JSON.stringify(voucher));
@ -107,19 +123,4 @@ export class VoucherService {
.pipe(catchError(this.log.handleError(serviceName, 'Update Voucher')))
);
}
dataURLtoBlob(dataURL) {
const re = /^data:([\w/\-\.]+);\w+,(.*)$/;
const m = dataURL.match(re);
const mimeString = m[1];
const byteString = atob(m[2]);
const ab = new ArrayBuffer(byteString.length);
const dw = new DataView(ab);
let i;
for (i = 0; i < byteString.length; i++) {
dw.setUint8(i, byteString.charCodeAt(i));
}
return new Blob([ab], { type: mimeString });
}
}