Commit 67096fbf by Ali Arshad

TSLint fixes

parent 6d835fb6
<div [class]="'form-control-wrapper ' + class" *ngIf='fcn' [ngClass]="{ 'has-error': isHighlighted }">
<ng-content></ng-content>
<span class="error-msg" *ngIf='isHighlighted'>{{ getError() }}</span>
</div>
div([class]="'form-control-wrapper ' + class", *ngIf='fcn', [ngClass]="{ 'has-error': isHighlighted }")
ng-content
span.error-msg(*ngIf='isHighlighted') {{ getError() }}
......@@ -5,7 +5,7 @@ import { FocusBlurDirective } from '../../directives/focus-blur.directive';
@Component({
selector: 'app-form-control',
templateUrl: './form-control.component.pug'
templateUrl: './form-control.component.html'
})
export class FormControlComponent {
......
......@@ -11,7 +11,7 @@ export class TruncatePipe implements PipeTransform {
}
let newValue = '';
if (value.length > length) {
newValue = `${value.substring(0, length - 3)} ...` ;
newValue = `${value.substring(0, length - 3)} ...`;
}
return newValue;
......
/* tslint:disable */
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Router } from '@angular/router';
import { Subject } from 'rxjs';
import { map, share } from 'rxjs/operators';
import { Observable, Subject } from 'rxjs';
import { map } from 'rxjs/operators';
@Injectable()
......@@ -13,7 +12,7 @@ export class HttpService {
private headers;
private api;
private sendAuthMsg;
private logoutNotification = new Subject();
private logoutNotification: Subject<string> = new Subject();
constructor(
private http: HttpClient,
......@@ -22,40 +21,42 @@ export class HttpService {
this.sendAuthMsg = true;
}
setAPIURL(url) {
setAPIURL(url): void {
this.api = url;
}
setTokken(value) {
setTokken(value): void {
this.accessTokken = value;
}
getToken() {
getToken(): string {
return this.accessTokken;
}
getAPIURL() {
getAPIURL(): string {
return this.api;
}
onLogout() {
onLogout(): Observable<string> {
return this.logoutNotification.asObservable();
}
createHeader(extraHeaders = {}) {
createHeader(extraHeaders = {}): void {
const headers = {
'Content-Type': 'application/json', ...extraHeaders};
Authorization: '',
'Content-Type': 'application/json', ...extraHeaders
};
if (extraHeaders['Content-Type'] === null) {
delete headers['Content-Type'];
}
if (this.accessTokken) {
headers[`Authorization`] = 'Bearer ' + this.accessTokken;
headers.Authorization = `Bearer ${this.accessTokken}`;
}
this.headers = new HttpHeaders(headers);
}
sendUnAuthorizedMessage(message) {
message = message || 'You need to login first.';
sendUnAuthorizedMessage(msg): void {
const message = msg || 'You need to login first.';
this.sendAuthMsg = false;
// this.toastr.error(message, null, {showCloseButton: true});
setTimeout(() => {
......@@ -64,54 +65,58 @@ export class HttpService {
this.logoutNotification.next('user_logout');
}
mapResponse(resp, returnHeaders = false) {
mapResponse(resp, returnHeaders = false): {} {
if (returnHeaders === false) {
return resp.body;
} else {
}
return {
body: resp.body,
headers: resp.headers
};
}
}
get(method, value = '', showErrors = {}, returnHeaders = false, absoluteUrl = false, extraHeaders = {}) {
get(method, value = '', showErrors = {}, returnHeaders = false, absoluteUrl = false, extraHeaders = {}): Observable<{}> {
this.createHeader(extraHeaders);
const url = (absoluteUrl ? '' : this.api) + method + value;
return this.http.get(url, {
headers: this.headers,
observe: 'response'
}).pipe(map(resp => this.mapResponse(resp, returnHeaders)));
})
.pipe(map(resp => this.mapResponse(resp, returnHeaders)));
}
post(method, value, showErrors = {}, returnHeaders = false, absoluteUrl = false, extraHeaders = {}) {
post(method, value, showErrors = {}, returnHeaders = false, absoluteUrl = false, extraHeaders = {}): Observable<{}> {
this.createHeader(extraHeaders);
const url = (absoluteUrl ? '' : this.api) + method;
return this.http.post(url, value, {
headers: this.headers,
observe: 'response'
}).pipe(map(resp => this.mapResponse(resp, returnHeaders)));
})
.pipe(map(resp => this.mapResponse(resp, returnHeaders)));
}
put(method, value, showErrors = {}, returnHeaders = false) {
put(method, value, showErrors = {}, returnHeaders = false): Observable<{}> {
this.createHeader();
const url = this.api + method;
return this.http.put(url, value, {
headers: this.headers,
observe: 'response'
}).pipe(map(resp => this.mapResponse(resp, returnHeaders)));
})
.pipe(map(resp => this.mapResponse(resp, returnHeaders)));
}
delete(method, value = '', showErrors = {}, returnHeaders = false) {
delete(method, value = '', showErrors = {}, returnHeaders = false): Observable<{}> {
this.createHeader();
const url = this.api + method + value;
return this.http.delete(url, {
headers: this.headers,
observe: 'response'
}).pipe(map(resp => this.mapResponse(resp, returnHeaders)));
})
.pipe(map(resp => this.mapResponse(resp, returnHeaders)));
}
}
import { Injectable } from '@angular/core';
import { SvgIconRegistryService } from 'angular-svg-icon';
import { forkJoin } from 'rxjs';
import { retry } from 'rxjs/operators';
import { ICONS } from '../../config/icon-list';
@Injectable()
export class IconsService {
icons = ICONS;
constructor(
private iconReg: SvgIconRegistryService
) {
}
async loadSvgIcons(): Promise<any> {
return new Promise<any>(resolve => {
forkJoin(this.icons.map(icon => this.iconReg.loadSvg(icon.url, icon.name).pipe(retry(3))))
.subscribe(() => {
resolve();
});
});
}
}
import { HttpErrorResponse } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { FormArray, FormControl, FormGroup } from '@angular/forms';
import { SHOW_ERRORS } from '../config';
@Injectable()
......@@ -13,13 +11,13 @@ export class UtilsService {
.forEach(field => {
const control = formGroup.get(field);
if (control instanceof FormControl) {
control.markAsDirty({ onlySelf: true });
control.markAsDirty({onlySelf: true});
} else if (control instanceof FormGroup) {
this.validateAllFormFields(control);
} else if (control instanceof FormArray) {
control.controls.forEach(ctrl => {
if (ctrl instanceof FormControl) {
ctrl.markAsDirty({ onlySelf: true });
ctrl.markAsDirty({onlySelf: true});
} else if (ctrl instanceof FormGroup) {
this.validateAllFormFields(ctrl);
}
......@@ -27,40 +25,4 @@ export class UtilsService {
}
});
}
handleHttpError(error: HttpErrorResponse): any {
switch (error.status) {
case 401:
if (SHOW_ERRORS.e401) {
console.log(`Error ${error.status}`);
}
break;
case 400:
if (SHOW_ERRORS.e400) {
console.log(`Error ${error.status}`);
}
break;
case 500:
if (SHOW_ERRORS.e500) {
console.log(`Error ${error.status}`);
}
break;
case 404:
if (SHOW_ERRORS.e404) {
console.log(`Error ${error.status}`);
}
break;
case 422:
if (SHOW_ERRORS.e422) {
console.log(`Error ${error.status}`);
}
break;
case 403:
if (SHOW_ERRORS.e403) {
console.log(`Error ${error.status}`);
}
break;
default:
}
}
}
......@@ -18,7 +18,7 @@ export class ConfirmPasswordValidator {
const fieldValue = c.value;
const isValid = (fieldValue.length >= 8 && /[A-Z]/.test(fieldValue) && /[a-z]/.test(fieldValue) && /[0-9]/.test(fieldValue));
return isValid ? null : {invalidPassword: true};
return isValid ? undefined : {invalidPassword: true};
};
}
......
import { CommonModule } from '@angular/common';
import { HttpClientModule } from '@angular/common/http';
import { NgModule } from '@angular/core';
import { AngularSvgIconModule } from 'angular-svg-icon';
import { FormControlComponent } from './components/form-control/form-control.component';
import { FocusBlurDirective } from './directives/focus-blur.directive';
import { PasswordDirective } from './directives/password.directive';
import { TruncatePipe } from './pipes/truncate.pipe';
import { HttpService } from './services/http.service';
import { IconsService } from './services/icons.service';
import { UtilsService } from './services/utils.service';
const PIPES = [
......@@ -25,12 +23,10 @@ const DIRECTIVES = [
const PROVIDERS = [
HttpService,
UtilsService,
IconsService
UtilsService
];
const MODULES = [
AngularSvgIconModule,
HttpClientModule
];
......@@ -48,4 +44,5 @@ const MODULES = [
...DIRECTIVES
]
})
export class VqodeModule { }
export class VqodeModule {
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment