From ea13e330ea0d2de62d9d4f81ab84718f22fd46af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adolfo=20G=C3=B3mez=20Garc=C3=ADa?= Date: Wed, 7 Apr 2021 14:05:55 +0200 Subject: [PATCH] fixed all eslint "complains" --- .eslintrc.js | 37 --- .vscode/settings.json | 6 +- angular.json | 11 - e2e/{tsconfig.e2e.json => tsconfig.json} | 0 package.json | 4 +- src/app/app.component.ts | 24 +- .../gui/components/filter/filter.component.ts | 2 +- .../components/service/service.component.ts | 88 ++++--- src/app/gui/modal/modal.component.ts | 13 +- src/app/gui/uds-gui.service.ts | 8 +- src/app/helpers/plugin.ts | 215 ++++++++++-------- .../client-download.component.ts | 2 +- src/app/pages/error/error.component.ts | 6 +- src/app/pages/login/login.component.ts | 33 +-- src/app/pages/services/services.component.ts | 77 ++++--- src/app/translate.directive.ts | 2 +- src/app/types/config.ts | 1 + src/app/types/services.ts | 1 + src/app/uds-api.service.ts | 3 +- src/typings.d.ts | 3 +- 20 files changed, 279 insertions(+), 257 deletions(-) delete mode 100644 .eslintrc.js rename e2e/{tsconfig.e2e.json => tsconfig.json} (100%) diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index fbc9d77..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1,37 +0,0 @@ -/* I prefer to use JavaScript file because i can write comment and other can understand it. -if you wish to use .eslintrc without js extension,then you need to remove all the comments and -its looks just like { ..eslint config as below} without module.export -*/ - -module.exports={ - "root": true, - "parser": "@typescript-eslint/parser", // we are changing default parser - "parserOptions": { - "ecmaVersion": 2018, - "sourceType": "module", - "project": "./tsconfig.json" // path to tsconfig - }, - -/* A plugin provides you with a set of rules that you can -individually apply depending on your need. -Just having a plugin does not enforce any rule. -You have to choose which rules you need. -A plugin may provide you with zero, one, or more configuration files. -If the plugin provides a configuration file, then you can load -that in your extends section after adding the plugin in the plugins section. -*/ - "plugins": ["@typescript-eslint"], - -/* extends uses a config file which applies set of rules -when you add that to the extends options. */ - "extends": [ - "eslint:recommended", - "plugin:@typescript-eslint/eslint-recommended", - "plugin:@typescript-eslint/recommended", - ], - "rules": { - }, - "overrides": [ - ] -} - diff --git a/.vscode/settings.json b/.vscode/settings.json index 11915f4..14dd45a 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,4 +1,6 @@ { "python.linting.enabled": true, - "python.pythonPath": "/usr/bin/python3" -} \ No newline at end of file + "python.pythonPath": "/usr/bin/python3", + "prettier.singleQuote": true, + "typescript.preferences.quoteStyle": "single" +} diff --git a/angular.json b/angular.json index 2747f4f..e91cbd2 100644 --- a/angular.json +++ b/angular.json @@ -124,17 +124,6 @@ "protractorConfig": "./protractor.conf.js", "devServerTarget": "uds:serve" } - }, - "lint": { - "builder": "@angular-devkit/build-angular:tslint", - "options": { - "tsConfig": [ - "e2e/tsconfig.e2e.json" - ], - "exclude": [ - "**/node_modules/**" - ] - } } } } diff --git a/e2e/tsconfig.e2e.json b/e2e/tsconfig.json similarity index 100% rename from e2e/tsconfig.e2e.json rename to e2e/tsconfig.json diff --git a/package.json b/package.json index d22e6b6..36b039d 100644 --- a/package.json +++ b/package.json @@ -5,9 +5,9 @@ "scripts": { "ng": "ng", "f4xstart": "ng serve --host 0.0.0.0 --port 9000 --proxy-config proxy.conf.json", - "f4xbuild": "ng build --prod --output-hashing=none --aot=false --deleteOutputPath --build-optimizer=false --deploy-url /uds/res/modern/ --base-href /uds/page && yarn postbuild", + "f4xbuild": "ng build --prod --output-hashing=none --aot=false --delete-output-path --build-optimizer=false --deploy-url /uds/res/modern/ --base-href /uds/page && yarn postbuild", "start": "ng serve --host 0.0.0.0 --port 9000 --proxy-config proxy.conf.json", - "build": "ng build --prod --output-hashing=none --aot --deleteOutputPath --build-optimizer --deploy-url /uds/res/modern/ --base-href /uds/page", + "build": "ng build --prod --output-hashing=none --aot --delete-output-path --build-optimizer --deploy-url /uds/res/modern/ --base-href /uds/page", "postbuild": "python3 toUDS.py", "test": "ng test", "lint": "ng lint", diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 1b607a9..210959d 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -1,8 +1,8 @@ import { Component, OnInit } from '@angular/core'; // External -declare var django: any; -declare var cookieconsent: any; +declare const django: any; +declare const cookieconsent: any; @Component({ @@ -15,19 +15,19 @@ export class AppComponent implements OnInit { ngOnInit() { cookieconsent.initialise({ - 'palette': { - 'popup': { - 'background': '#343c66', - 'text': '#cfcfe8' + palette: { + popup: { + background: '#343c66', + text: '#cfcfe8' }, - 'button': { - 'background': '#f71559' + button: { + background: '#f71559' } }, - 'content': { - 'message': django.gettext('We use cookies to track usage and preferences'), - 'dismiss': django.gettext('I Understand'), - 'link': django.gettext('Learn more') + content: { + message: django.gettext('We use cookies to track usage and preferences'), + dismiss: django.gettext('I Understand'), + link: django.gettext('Learn more') } }); } diff --git a/src/app/gui/components/filter/filter.component.ts b/src/app/gui/components/filter/filter.component.ts index 7008204..dcf0a70 100644 --- a/src/app/gui/components/filter/filter.component.ts +++ b/src/app/gui/components/filter/filter.component.ts @@ -22,7 +22,7 @@ export class FilterComponent implements AfterViewInit { filter(Boolean), debounceTime(600), distinctUntilChanged(), - tap(() => { this.update(this.input.nativeElement.value); }) + tap(() => this.update(this.input.nativeElement.value)) ).subscribe(); } diff --git a/src/app/gui/components/service/service.component.ts b/src/app/gui/components/service/service.component.ts index 82a28fd..b4091db 100644 --- a/src/app/gui/components/service/service.component.ts +++ b/src/app/gui/components/service/service.component.ts @@ -2,23 +2,21 @@ import { Component, OnInit, Input } from '@angular/core'; import { JSONService, JSONTransport } from '../../../types/services'; import { UDSApiService } from '../../../uds-api.service'; -declare var django: any; +declare const django: any; const MAX_NAME_LENGTH = 32; @Component({ selector: 'uds-service', templateUrl: './service.component.html', - styleUrls: ['./service.component.css'] + styleUrls: ['./service.component.css'], }) export class ServiceComponent implements OnInit { - - constructor(private api: UDSApiService) { } - @Input() service: JSONService; - ngOnInit() { - } + constructor(private api: UDSApiService) {} + + ngOnInit() {} get serviceImage() { return this.api.galleryImageURL(this.service.imageId); @@ -66,7 +64,10 @@ export class ServiceComponent implements OnInit { get serviceNameClass() { const klass = []; - const len = Math.min(Math.floor((this.service.visual_name.length - 1) / 4) * 4, 28); + const len = Math.min( + Math.floor((this.service.visual_name.length - 1) / 4) * 4, + 28 + ); if (len >= 16) { klass.push('small-' + len.toString()); } @@ -86,27 +87,39 @@ export class ServiceComponent implements OnInit { } hasMenu() { - return this.service.maintenance === false && + return ( + this.service.maintenance === false && this.service.not_accesible === false && (this.hasActions() || this.showTransportsMenu()) - ; + ); } notifyNotLaunching(message: string) { - this.api.gui.alert('

' + django.gettext('Launcher') + '

', message); + this.api.gui.alert( + '

' + django.gettext('Launcher') + '

', + message + ); } launch(transport: JSONTransport) { if (this.service.maintenance) { - this.notifyNotLaunching(django.gettext('Service is in maintenance and cannot be launched')); + this.notifyNotLaunching( + django.gettext('Service is in maintenance and cannot be launched') + ); } else if (this.service.not_accesible) { - const calendarDeniedText = this.service.custom_calendar_text || this.api.config.messages.calendarDenied; + const calendarDeniedText = + this.service.custom_calendar_text || + this.api.config.messages.calendarDenied; - this.notifyNotLaunching('

' + - django.gettext('This service is currently not accesible due to schedule restrictions.') + - '

' + calendarDeniedText + - '

' + - '

' + this.notifyNotLaunching( + '

' + + django.gettext( + 'This service is currently not accesible due to schedule restrictions.' + ) + + '

' + + calendarDeniedText + + '

' + + '

' ); } else { if (transport === null || this.service.show_transports === false) { @@ -118,23 +131,26 @@ export class ServiceComponent implements OnInit { } action(type: string) { - const title = (type === 'release' ? django.gettext('Release service: ') : django.gettext('Reset service: ')) + ' ' + this.serviceName; - const action = type === 'release' ? django.gettext('Service released') : django.gettext('Service reseted'); - this.api.gui.yesno( - title, - django.gettext('Are you sure?') - ).subscribe((val) => { - if (val) { - this.api.action(type, this.service.id).subscribe((service) => { - if (service) { - this.api.gui.alert( - title, - action - ); - } - }); - } - }); - + const title = + (type === 'release' + ? django.gettext('Release service: ') + : django.gettext('Reset service: ')) + + ' ' + + this.serviceName; + const action = + type === 'release' + ? django.gettext('Service released') + : django.gettext('Service reseted'); + this.api.gui + .yesno(title, django.gettext('Are you sure?')) + .subscribe((val) => { + if (val) { + this.api.action(type, this.service.id).subscribe((service) => { + if (service) { + this.api.gui.alert(title, action); + } + }); + } + }); } } diff --git a/src/app/gui/modal/modal.component.ts b/src/app/gui/modal/modal.component.ts index cbcce72..e529235 100644 --- a/src/app/gui/modal/modal.component.ts +++ b/src/app/gui/modal/modal.component.ts @@ -1,8 +1,9 @@ +/* eslint-disable no-shadow */ import { Component, OnInit, Inject } from '@angular/core'; import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog'; import { interval, Subscription, Observable } from 'rxjs'; -declare var django: any; +declare const django: any; export enum DialogType { alert = 0, @@ -49,16 +50,13 @@ export class ModalComponent implements OnInit { observer.complete(); }; const self = this; - return {unsubscribe() { - self.resetCallbacks(); - }}; + return {unsubscribe: () => self.resetCallbacks()}; }); - } resetCallbacks() { - this.yes = this.no = () => { this.close(); }; - this.close = () => { this.doClose(); }; + this.yes = this.no = () => this.close(); + this.close = () => this.doClose(); } /** @@ -77,6 +75,7 @@ export class ModalComponent implements OnInit { /** * Sets extra information on close button + * * @param miliseconds miliseconds to inform (will be converted to seconds) */ setExtra(miliseconds: number) { diff --git a/src/app/gui/uds-gui.service.ts b/src/app/gui/uds-gui.service.ts index a8c7716..394c0ec 100644 --- a/src/app/gui/uds-gui.service.ts +++ b/src/app/gui/uds-gui.service.ts @@ -11,8 +11,8 @@ export class UDSGuiService { alert(title: string, message: string, autoclose = 0 ) { const width = window.innerWidth < 800 ? '80%' : '40%'; const dialogRef = this.dialog.open(ModalComponent, { - width: width, - data: { title: title, body: message, autoclose: autoclose, type: DialogType.alert }, + width, + data: { title, body: message, autoclose, type: DialogType.alert }, disableClose: true, }); return dialogRef; @@ -21,8 +21,8 @@ export class UDSGuiService { yesno(title: string, message: string) { const width = window.innerWidth < 800 ? '80%' : '40%'; const dialogRef = this.dialog.open(ModalComponent, { - width: width, - data: { title: title, body: message, type: DialogType.yesno }, + width, + data: { title, body: message, type: DialogType.yesno }, disableClose: true, }); diff --git a/src/app/helpers/plugin.ts b/src/app/helpers/plugin.ts index f29ecb6..4b77241 100644 --- a/src/app/helpers/plugin.ts +++ b/src/app/helpers/plugin.ts @@ -1,108 +1,135 @@ import { UDSApiServiceType } from '../uds-api.service-type'; -declare const django: { gettext: (arg0: string) => string; }; +declare const django: any; /** * Plugin manipulation class */ export class Plugin { - static transportsWindow = {}; - delay: number; + static transportsWindow = {}; + delay: number; - constructor(private api: UDSApiServiceType) { - this.delay = api.config.launcher_wait_time; - } + constructor(private api: UDSApiServiceType) { + this.delay = api.config.launcher_wait_time; + } - private showAlert(text: string, info: string, waitTime: number) { - return this.api.gui.alert( - django.gettext('Launching service'), - '

' + text + '

' + - info + '

', - waitTime - ); - } - - /** - * Launches an UDS related url - * @param url uds url to be lauhcned - * - */ - private doLaunch(url: string) { - let elem: HTMLIFrameElement = document.getElementById('hiddenUdsLauncherIFrame') as HTMLIFrameElement; - if (elem === null) { - const i = document.createElement('div'); - i.id = 'testID'; - i.innerHTML = ''; - document.body.appendChild(i); - elem = document.getElementById('hiddenUdsLauncherIFrame') as HTMLIFrameElement; - } - elem.contentWindow.location.href = url; - } - - launchURL(url: string): void { - // If uds url... - if (url.substring(0, 7) === 'udsa://') { - this.showAlert( - django.gettext('Please wait until the service is launched.'), - django.gettext('Remember that you will need the UDS client on your platform to access the service.'), - this.delay - ); - const params = url.split('//')[1].split('/'); - this.api.enabler(params[0], params[1]).subscribe(data => { - if (data.error) { - // TODO: show the error correctly - this.api.gui.alert(django.gettext('Error launching service'), data.error); - } else { - // Is HTTP access the service returned, or for UDS client? - if (data.url.startsWith('/')) { - this.launchURL(data.url); - return; - } - if (window.location.protocol === 'https:') { - // Ensures that protocol is https also for plugin, fixing if needed UDS provided info - data.url = data.url.replace('uds://', 'udss://'); - } - this.doLaunch(data.url); - } - }); + launchURL(url: string): void { + // If uds url... + if (url.substring(0, 7) === 'udsa://') { + this.showAlert( + django.gettext('Please wait until the service is launched.'), + django.gettext( + 'Remember that you will need the UDS client on your platform to access the service.' + ), + this.delay + ); + const params = url.split('//')[1].split('/'); + this.api.enabler(params[0], params[1]).subscribe((data) => { + if (data.error) { + // TODO: show the error correctly + this.api.gui.alert( + django.gettext('Error launching service'), + data.error + ); } else { - // Custom url, http/https - const alert = this.showAlert( - django.gettext('Please wait until the service is launched.'), - django.gettext('Your connection is being prepared. It will open on a new window when ready.'), - this.delay * 2 - ); - this.api.transportUrl(url).subscribe(data => { - alert.close(); - if (data.url) { - if (data.url.indexOf('o_s_w=') !== -1) { - window.location.href = data.url; - } else { - // If the url contains "o_n_w", will open the url on a new window ALWAYS - let name = 'global'; - if (data.url.indexOf('o_n_w=') !== -1) { - // Extract window name from o_n_w parameter if present - const onw = /.*o_n_w=([a-zA-Z0-9._-]*)/.exec(data.url); - if (onw) { - name = onw[1]; - } - } - if (Plugin.transportsWindow[name]) { - Plugin.transportsWindow[name].close(); - } - Plugin.transportsWindow[name] = window.open(data.url, 'uds_trans_' + name); - } - } else if (data.running) { // Already preparing, show some info and request wait a bit to user - this.showAlert( - django.gettext('The service is now being prepared. (It is at #).'.replace('#', '' + data.running + '%')), - django.gettext('Please, try again in a few moments.'), - this.delay - ); - } else { // error - this.api.gui.alert(django.gettext('Error launching service'), data.error); - } - }); + // Is HTTP access the service returned, or for UDS client? + if (data.url.startsWith('/')) { + this.launchURL(data.url); + return; + } + if (window.location.protocol === 'https:') { + // Ensures that protocol is https also for plugin, fixing if needed UDS provided info + data.url = data.url.replace('uds://', 'udss://'); + } + this.doLaunch(data.url); } + }); + } else { + // Custom url, http/https + const alert = this.showAlert( + django.gettext('Please wait until the service is launched.'), + django.gettext( + 'Your connection is being prepared. It will open on a new window when ready.' + ), + this.delay * 2 + ); + this.api.transportUrl(url).subscribe((data) => { + alert.close(); + if (data.url) { + if (data.url.indexOf('o_s_w=') !== -1) { + window.location.href = data.url; + } else { + // If the url contains "o_n_w", will open the url on a new window ALWAYS + let name = 'global'; + if (data.url.indexOf('o_n_w=') !== -1) { + // Extract window name from o_n_w parameter if present + const onw = /.*o_n_w=([a-zA-Z0-9._-]*)/.exec(data.url); + if (onw) { + name = onw[1]; + } + } + if (Plugin.transportsWindow[name]) { + Plugin.transportsWindow[name].close(); + } + Plugin.transportsWindow[name] = window.open( + data.url, + 'uds_trans_' + name + ); + } + } else if (data.running) { + // Already preparing, show some info and request wait a bit to user + this.showAlert( + django.gettext( + 'The service is now being prepared. (It is at #).'.replace( + '#', + '' + data.running + '%' + ) + ), + django.gettext('Please, try again in a few moments.'), + this.delay + ); + } else { + // error + this.api.gui.alert( + django.gettext('Error launching service'), + data.error + ); + } + }); } + } + private showAlert(text: string, info: string, waitTime: number) { + return this.api.gui.alert( + django.gettext('Launching service'), + '

' + + text + + '

' + + info + + '

', + waitTime + ); + } + + /** + * Launches an UDS related url + * + * @param url uds url to be lauhcned + */ + private doLaunch(url: string) { + let elem: HTMLIFrameElement = document.getElementById( + 'hiddenUdsLauncherIFrame' + ) as HTMLIFrameElement; + if (elem === null) { + const i = document.createElement('div'); + i.id = 'testID'; + i.innerHTML = + ''; + document.body.appendChild(i); + elem = document.getElementById( + 'hiddenUdsLauncherIFrame' + ) as HTMLIFrameElement; + } + elem.contentWindow.location.href = url; + } } diff --git a/src/app/pages/client-download/client-download.component.ts b/src/app/pages/client-download/client-download.component.ts index 4ed731d..05d2f58 100644 --- a/src/app/pages/client-download/client-download.component.ts +++ b/src/app/pages/client-download/client-download.component.ts @@ -2,7 +2,7 @@ import { Component, OnInit } from '@angular/core'; import { UDSApiService } from '../../uds-api.service'; import { Downloadable } from '../../types/config'; -declare var django: any; +declare const django: any; @Component({ selector: 'uds-client-download', diff --git a/src/app/pages/error/error.component.ts b/src/app/pages/error/error.component.ts index b308561..f650f2b 100644 --- a/src/app/pages/error/error.component.ts +++ b/src/app/pages/error/error.component.ts @@ -1,8 +1,8 @@ import { Component, OnInit } from '@angular/core'; import { ActivatedRoute } from '@angular/router'; -declare var django: any; -declare var udsData: any; +declare const django: any; +declare const udsData: any; @Component({ selector: 'uds-error', @@ -21,7 +21,7 @@ export class ErrorComponent implements OnInit { getError(): void { const id = this.route.snapshot.paramMap.get('id'); try { - this.error = new TextDecoder().decode(Uint8Array.from(window.atob(id), c => (c).charCodeAt(c))).replace('\n', '
'); + this.error = new TextDecoder().decode(Uint8Array.from(window.atob(id), c => (c as any).charCodeAt(c))).replace('\n', '
'); console.log(this.error); udsData.error = this.error; } catch (e) { diff --git a/src/app/pages/login/login.component.ts b/src/app/pages/login/login.component.ts index 3e28d45..cb188bb 100644 --- a/src/app/pages/login/login.component.ts +++ b/src/app/pages/login/login.component.ts @@ -1,19 +1,19 @@ +// eslint-disable-next-line @typescript-eslint/quotes import { Component, OnInit } from '@angular/core'; import { UDSApiService } from '../../uds-api.service'; import { Authenticator } from '../../types/config'; -declare var django: any; +declare const django: any; @Component({ selector: 'uds-login', templateUrl: './login.component.html', - styleUrls: ['./login.component.css'] + styleUrls: ['./login.component.css'], }) export class LoginComponent implements OnInit { auths: Authenticator[]; auth: HTMLInputElement; title = 'UDS Enterprise'; - constructor(public api: UDSApiService) { this.title = api.config.site_name; @@ -25,22 +25,24 @@ export class LoginComponent implements OnInit { ngOnInit() { // We want to keep compatibility right now with previous UDS templates, so we // adapt form to post the correct values the correct way - const form = document.getElementById('loginform'); + const form = document.getElementById('loginform') as HTMLFormElement; form.action = this.api.config.urls.login; - const input = (document.getElementById('token')); + const input = document.getElementById('token') as HTMLInputElement; input.name = this.api.config.csrf_field; input.value = this.api.config.csrf; - this.auth = (document.getElementById('authenticator')); + this.auth = document.getElementById('authenticator') as HTMLInputElement; if (this.auths.length > 0) { this.auth.value = this.auths[0].id; this.changeAuth(this.auth.value); } if (this.api.errors.length > 0) { - this.api.gui.alert(django.gettext('Errors found'), '
' + this.api.errors.join('
') + '
' ); + this.api.gui.alert( + django.gettext('Errors found'), + '
' + this.api.errors.join('
') + '
' + ); } - } changeAuth(auth: string) { @@ -53,20 +55,23 @@ export class LoginComponent implements OnInit { for (const l of this.auths) { if (l.id === auth) { - if (l.is_custom) { // If is custom, we should get the code from server to authentication + if (l.is_custom) { + // If is custom, we should get the code from server to authentication // Instant hide form - document.getElementsByClassName('login-form')[0].setAttribute('style', 'display: none;'); - this.api.getAuthCustomHtml(l.id) - .subscribe(result => doCustomAuth(result)); + document + .getElementsByClassName('login-form')[0] + .setAttribute('style', 'display: none;'); + this.api + .getAuthCustomHtml(l.id) + .subscribe((result) => doCustomAuth(result)); } } } } launch(): boolean { - const form = document.getElementById('loginform'); + const form = document.getElementById('loginform') as HTMLFormElement; form.submit(); return true; } - } diff --git a/src/app/pages/services/services.component.ts b/src/app/pages/services/services.component.ts index 1dca996..1f9d36d 100644 --- a/src/app/pages/services/services.component.ts +++ b/src/app/pages/services/services.component.ts @@ -1,8 +1,12 @@ import { Component, OnInit } from '@angular/core'; import { UDSApiService } from '../../uds-api.service'; -import { JSONServicesInformation, JSONGroup, JSONService } from '../../types/services'; +import { + JSONServicesInformation, + JSONGroup, + JSONService, +} from '../../types/services'; -declare var django: any; +declare const django: any; class GroupedServices { services: JSONService[]; @@ -15,13 +19,24 @@ class GroupedServices { @Component({ selector: 'uds-services-page', templateUrl: './services.component.html', - styleUrls: ['./services.component.css'] + styleUrls: ['./services.component.css'], }) export class ServicesComponent implements OnInit { servicesInformation: JSONServicesInformation; group: GroupedServices[]; - constructor(public api: UDSApiService) { + constructor(public api: UDSApiService) {} + + update(filter: string) { + this.updateServices(filter); + } + + ngOnInit() { + if (this.api.config.urls.launch) { + this.api.logout(); + } else { + this.loadServices(); // Loads service related data + } } /** @@ -29,14 +44,22 @@ export class ServicesComponent implements OnInit { */ private autorun(): boolean { // If autorun, and there is only one service, launch it - if (this.servicesInformation.autorun && this.servicesInformation.services.length === 1) { + if ( + this.servicesInformation.autorun && + this.servicesInformation.services.length === 1 + ) { if (!this.servicesInformation.services[0].maintenance) { this.api.executeCustomJSForServiceLaunch(); // Launch url - this.api.launchURL(this.servicesInformation.services[0].transports[0].link); + this.api.launchURL( + this.servicesInformation.services[0].transports[0].link + ); return true; } else { - this.api.gui.alert(django.gettext('Warning'), django.gettext('Service is in maintenance and cannot be executed')); + this.api.gui.alert( + django.gettext('Warning'), + django.gettext('Service is in maintenance and cannot be executed') + ); } } @@ -52,12 +75,14 @@ export class ServicesComponent implements OnInit { } // Obtain services list - this.api.getServicesInformation().subscribe((result: JSONServicesInformation) => { - this.servicesInformation = result; - this.autorun(); + this.api + .getServicesInformation() + .subscribe((result: JSONServicesInformation) => { + this.servicesInformation = result; + this.autorun(); - this.updateServices(); - }); + this.updateServices(); + }); } private updateServices(filter: string = '') { @@ -65,10 +90,14 @@ export class ServicesComponent implements OnInit { this.group = []; let current: GroupedServices = null; - this.servicesInformation.services.filter( - (value) => !filter || value.visual_name.toLowerCase().includes(filter) || value.group.name.toLowerCase().includes(filter) - ).sort( - (a, b) => { + this.servicesInformation.services + .filter( + (value) => + !filter || + value.visual_name.toLowerCase().includes(filter) || + value.group.name.toLowerCase().includes(filter) + ) + .sort((a, b) => { if (a.group.priority !== b.group.priority) { return a.group.priority - b.group.priority; } else { @@ -79,7 +108,8 @@ export class ServicesComponent implements OnInit { } } return 0; - }).forEach(element => { + }) + .forEach((element) => { if (current === null || element.group.id !== current.group.id) { if (current !== null) { this.group.push(current); @@ -92,17 +122,4 @@ export class ServicesComponent implements OnInit { this.group.push(current); } } - - update(filter: string) { - this.updateServices(filter); - } - - ngOnInit() { - if (this.api.config.urls.launch) { - this.api.logout(); - } else { - this.loadServices(); // Loads service related data - } - } - } diff --git a/src/app/translate.directive.ts b/src/app/translate.directive.ts index 5e2a7d2..4904a40 100644 --- a/src/app/translate.directive.ts +++ b/src/app/translate.directive.ts @@ -1,6 +1,6 @@ import { Directive, OnInit, ElementRef } from '@angular/core'; -declare var django: any; +declare const django: any; @Directive({ // eslint-disable-next-line @angular-eslint/directive-selector diff --git a/src/app/types/config.ts b/src/app/types/config.ts index 430560d..3e6144f 100644 --- a/src/app/types/config.ts +++ b/src/app/types/config.ts @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/naming-convention */ // Types definition for configuration from js export interface Lang { diff --git a/src/app/types/services.ts b/src/app/types/services.ts index e00cf74..8bb0331 100644 --- a/src/app/types/services.ts +++ b/src/app/types/services.ts @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/naming-convention */ // Types definition for services json export interface JSONGroup { diff --git a/src/app/uds-api.service.ts b/src/app/uds-api.service.ts index 4a23f9d..61f4205 100644 --- a/src/app/uds-api.service.ts +++ b/src/app/uds-api.service.ts @@ -11,7 +11,7 @@ import { UDSApiServiceType } from './uds-api.service-type'; import { environment } from '../environments/environment'; -declare var udsData: any; +declare const udsData: any; @Injectable() @@ -131,6 +131,7 @@ export class UDSApiService implements UDSApiServiceType { /** * Gets auth custom html code + * * @param authId if of the authenticator * @returns Observable */ diff --git a/src/typings.d.ts b/src/typings.d.ts index 1a147a3..c1c411a 100644 --- a/src/typings.d.ts +++ b/src/typings.d.ts @@ -1,9 +1,10 @@ /* SystemJS module definition */ +// eslint-disable-next-line no-var declare var module: NodeModule; interface NodeModule { id: string; } /* UDS injected modules */ -// declare var django: any; +// declare const django: any; // declare var udsData: any;