Commit 8f3b6f0b authored by Lukas Burgey's avatar Lukas Burgey
Browse files

Lint all ts files

parent 1fedc25e
......@@ -12,7 +12,7 @@ import { ProfileDialogService } from '../dialogues/profile-dialog.service';
export class AccountComponent implements OnInit {
// account deletion form
sure: boolean = false;
sure = false;
constructor(
......
......@@ -3,7 +3,7 @@ import { Component, OnInit, Input } from '@angular/core';
import { Observable } from 'rxjs';
import { UserService } from '../user.service';
import { Deployment, VO, Service } from '../types/types.module'
import { Deployment, VO, Service } from '../types/types.module';
@Component({
selector: '[deployment-action-row]',
......@@ -24,13 +24,13 @@ export class DeploymentActionRowComponent implements OnInit {
}
public changeDeployment(stateTarget: string): void {
if (this.vo != undefined) {
if (this.vo !== undefined) {
this.userService.patchDeployment('vo', stateTarget, this.vo.id);
return
return;
}
if (this.service != undefined) {
if (this.service !== undefined) {
this.userService.patchDeployment('service', stateTarget, this.service.id);
return
return;
}
}
}
......@@ -13,7 +13,7 @@ import { User } from '../../types/types.module';
export class AccountComponent {
// account deletion form
public sure: boolean = false;
public sure = false;
constructor(
public userService: UserService,
......
......@@ -15,8 +15,8 @@ import { DeploymentState, Service, CredentialState } from '../../types/types.mod
})
export class CredentialsComponent implements OnInit {
public columns = ["name", "value"];
public credentialCount: number = 0;
public columns = ['name', 'value'];
public credentialCount = 0;
public table: MatTableDataSource<any>;
constructor(
......
......@@ -26,7 +26,7 @@ export class DialogService {
return {
panelClass: 'scrolling-dialog',
data: data,
}
};
}
public openAccount() {
......
......@@ -15,7 +15,7 @@ import { AccountComponent } from './account/account.component';
import { CredentialsComponent } from './credentials/credentials.component';
import { MessageComponent } from './message/message.component';
//providers
// providers
import { DialogService } from './dialog.service';
import { ProfileDialogService } from './profile-dialog.service';
......
import { Component, OnInit, Inject } from '@angular/core';
import { MAT_DIALOG_DATA } from '@angular/material/dialog';
import { MatTableDataSource } from '@angular/material/table';
import {} from '@angular/material';
import { User } from '../../types/types.module';
......
......@@ -13,7 +13,7 @@ import { JSONObject, DeploymentState } from '../../types/types.module';
})
export class QuestionnaireComponent implements OnInit {
public answers$ = <BehaviorSubject<JSONObject>> new BehaviorSubject(undefined);;
public answers$ = <BehaviorSubject<JSONObject>> new BehaviorSubject(undefined);
constructor(
public userService: UserService,
......@@ -22,15 +22,15 @@ export class QuestionnaireComponent implements OnInit {
state$.subscribe(
(state: DeploymentState) => {
let answers = undefined;
let answers;
// initialize the answers if needed
if (state.answers == undefined) {
if (state.answers === undefined) {
answers = state.questionnaire;
Object.keys(state.questionnaire).forEach(
(key: string) => {
answers[key] = "";
answers[key] = '';
}
);
......
......@@ -32,6 +32,6 @@ export class HeaderComponent implements OnInit {
}
idpCompare(a: IdP, b: IdP): boolean {
return a != undefined && b != undefined && a.id == b.id;
return a !== undefined && b !== undefined && a.id === b.id;
}
}
......@@ -10,22 +10,22 @@ export class LanguageService {
public printState(state: string) {
switch (state) {
case "not_deployed":
return "Not deployed";
case "deployed":
return "Deployed";
case "deployment_pending":
return "Deployment pending";
case "removal_pending":
return "Removal pending";
case "failed":
return "Failed";
case "rejected":
return "Rejected";
case "questionnaire":
return "Questionnaire";
case 'not_deployed':
return 'Not deployed';
case 'deployed':
return 'Deployed';
case 'deployment_pending':
return 'Deployment pending';
case 'removal_pending':
return 'Removal pending';
case 'failed':
return 'Failed';
case 'rejected':
return 'Rejected';
case 'questionnaire':
return 'Questionnaire';
default:
return "Not deployed";
return 'Not deployed';
}
}
}
......@@ -3,12 +3,12 @@ import { BehaviorSubject, Observable } from 'rxjs';
import { IdP } from '../types/types.module';
export const prefsKey = "feudalPrefs";
export const prefsKey = 'feudalPrefs';
export interface Prefs {
showEmptyVOs?: boolean;
preferredIdP?: IdP;
};
}
@Injectable({
providedIn: 'root'
......@@ -24,7 +24,7 @@ export class PreferencesService {
public save(prefs: Prefs): void {
localStorage.setItem(prefsKey, JSON.stringify(prefs));
console.log("Saved preferences:", prefs);
console.log('Saved preferences:', prefs);
}
public load(): void {
......@@ -32,9 +32,9 @@ export class PreferencesService {
if (loaded != null) {
this.prefs = loaded;
this.prefs$.next(loaded);
console.log("Loaded preferences:", this.prefs);
console.log('Loaded preferences:', this.prefs);
} else {
console.log("No preferences to load");
console.log('No preferences to load');
}
}
......
......@@ -28,7 +28,7 @@ export class ServiceComponent implements OnInit {
ngOnInit() {
this.deploymentState$ = this.userService.subscribeStateFor(this.service);
this.deployment$ = this.userService.subscribeDeployment(
(dep: Deployment) => dep.service ? dep.service.id == this.service.id : false
(dep: Deployment) => dep.service ? dep.service.id === this.service.id : false
);
}
}
......@@ -4,7 +4,7 @@ import { Pipe, PipeTransform } from '@angular/core';
@Pipe({ name: 'ObjKeys', pure: false })
export class ObjKeysPipe implements PipeTransform {
transform(value: any, args: any[] = null): any {
const transformation = Object.keys(value);//.map(key => value[key]);
const transformation = Object.keys(value); // .map(key => value[key]);
return transformation;
}
}
......@@ -4,7 +4,7 @@ import { MatSnackBar, MatSnackBarConfig } from '@angular/material/snack-bar';
@Injectable()
export class SnackBarService {
config = new MatSnackBarConfig()
config = new MatSnackBarConfig();
constructor(
public snackBar: MatSnackBar,
......
import { CollectionViewer, DataSource } from "@angular/cdk/collections";
import { CollectionViewer, DataSource } from '@angular/cdk/collections';
import { Observable } from 'rxjs';
import { UserService } from '../user.service';
......
......@@ -41,7 +41,7 @@ export class SshkeysComponent implements OnInit {
this.formKey = {
name: '',
key: '',
}
};
}
uploadKey() {
......@@ -50,7 +50,7 @@ export class SshkeysComponent implements OnInit {
}
keyDeleteable(key: SSHKey): boolean {
return key.name !== "unity_key";
return key.name !== 'unity_key';
}
addFiles(): void {
......@@ -60,8 +60,8 @@ export class SshkeysComponent implements OnInit {
onFilesAdded(): void {
const files: { [key: string]: File } = this.file.nativeElement.files;
for (let key in files) {
if (!isNaN(parseInt(key))) {
for (const key in files) {
if (!isNaN(parseInt(key, 10))) {
this.files.add(files[key]);
}
}
......
......@@ -28,27 +28,27 @@ export class StateComponent implements OnInit {
ngOnInit() {
this.state$ = this.userService.subscribeStateFor(this.service);
this.stateTooltip = "foo";
this.stateTooltip = 'foo';
}
public tooltip(state: DeploymentState): string {
switch(state.state) {
case "not_deployed":
switch (state.state) {
case 'not_deployed':
return `The credentials are not deployed for the service ${ this.service.name }.`;
case "deployed":
case 'deployed':
return `The credentials are deployed for the service ${ this.service.name }. Click to see details.`;
case "deployment_pending":
case 'deployment_pending':
return `Waiting for the deployment of the credentials to the site ${ this.service.site.name }`;
case "removal_pending":
case 'removal_pending':
return `Waiting for the removal of the credentials from the site ${ this.service.site.name }`;
case "questionnaire":
case 'questionnaire':
return `Site ${ this.service.site.name } needs more data to deploy the keys. Please click to submit the data.`;
case "failed":
case 'failed':
return `Site ${ this.service.site.name } failed to deploy the credentials. The deployment will be retried. Click for details.`;
case "rejected":
case 'rejected':
return `Site ${ this.service.site.name } rejected the deployment of the credentials. Click for details.`;
default:
return "Access to this service was never requested.";
return 'Access to this service was never requested.';
}
}
......
......@@ -88,8 +88,8 @@ export interface Deployment {
id: number;
service?: Service; // only for ServiceDeployment
services?: Service[]; // only for VODeployment
state: string
state_target: string
state: string;
state_target: string;
states: DeploymentState[];
vo?: VO; // only for VODeployment
}
......
......@@ -35,7 +35,7 @@ export class UserService {
private user: User;
private user$: BehaviorSubject<User> = new BehaviorSubject(undefined);
private userEmissions: number = 0;
private userEmissions = 0;
private sshKeys: Map<number, SSHKey> = new Map([]);
private sshKeys$ = new BehaviorSubject<SSHKey[]>([]);
......@@ -66,7 +66,7 @@ export class UserService {
this.userSrc().subscribe(
(newUser: User) => {
if (newUser == undefined || newUser == null) {
if (newUser === undefined || newUser == null) {
// LOGGED OUT
// show the logout to the user
if (this.loggedIn) {
......@@ -110,7 +110,7 @@ export class UserService {
if (newUser.states) {
newUser.states.forEach((state: DeploymentState) => {
this.deploymentStates.set(state.id, state)
this.deploymentStates.set(state.id, state);
});
this.deploymentStates$.next(Array.from(this.deploymentStates.values()));
}
......@@ -126,11 +126,11 @@ export class UserService {
private connectLiveUpdates(userID: number): void {
// handle with care
const login = userID
const login = userID;
const passcode = this.cookieService.get('sessionid');
const stompConfig: StompConfig = {
// Which server?
url: 'wss://'+window.location.host+'/ws',
url: 'wss://' + window.location.host + '/ws',
// Headers
// Typical keys: login, passcode, host
......@@ -161,11 +161,11 @@ export class UserService {
subscription.subscribe(
(message: Message) => {
let update: Update = JSON.parse(message.body);
const update: Update = JSON.parse(message.body);
console.log('update:', update);
// TODO rename error to msg
if (update.error && update.error != '') {
if (update.error && update.error !== '') {
this.snackBar.open(update.error);
}
......@@ -182,7 +182,7 @@ export class UserService {
}
private updateDeployment(dep: Deployment): void {
if (dep != undefined && dep != null) {
if (dep !== undefined && dep !== null) {
dep.states.forEach((state: DeploymentState) => this.updateDeploymentState(state),
);
this.deployments.set(dep.id, dep);
......@@ -191,7 +191,7 @@ export class UserService {
}
private updateDeploymentState(ds: DeploymentState): void {
if (ds != undefined && ds != null) {
if (ds !== undefined && ds !== null) {
this.deploymentStates.set(ds.id, ds);
this.deploymentStates$.next(Array.from(this.deploymentStates.values()));
}
......@@ -231,7 +231,7 @@ export class UserService {
return (error: any) => {
if (error.status === 403 && this.autoReLogin) {
this.login();
return
return;
}
if (msg) {
......@@ -241,8 +241,8 @@ export class UserService {
if (fetch) {
this.fetch();
}
return EMPTY
}
return EMPTY;
};
}
private logErrorAndFetch(error: any) {
......@@ -266,7 +266,7 @@ export class UserService {
console.log(name, e);
}
}
}
};
}
private fetchIdPInfo(): void {
......@@ -286,7 +286,7 @@ export class UserService {
(authInfo, prefs) => {
const defaultIdP: IdP = authInfo.idps.find((idp: IdP) => idp.id === authInfo.default);
if (prefs != undefined && prefs.preferredIdP != undefined) {
if (prefs !== undefined && prefs.preferredIdP !== undefined) {
authInfo.selectedIdP = prefs.preferredIdP;
} else if (defaultIdP) {
authInfo.selectedIdP = defaultIdP;
......@@ -303,21 +303,21 @@ export class UserService {
public login(idp?: IdP): void {
const redirect = (idp: IdP) => {
window.location.href = '/?idphint=' + encodeURIComponent(idp.issuer_uri);
const redirect = (arg: IdP) => {
window.location.href = '/?idphint=' + encodeURIComponent(arg.issuer_uri);
};
if (idp != undefined) {
if (idp !== undefined) {
this.prefs.setPreferredIdP(idp);
redirect(idp);
} else {
this.prefs.connect().subscribe(
prefs => {
if (prefs.preferredIdP != undefined) {
if (prefs.preferredIdP !== undefined) {
redirect(prefs.preferredIdP);
}
}
)
);
}
console.log('Unable to login: No IdP');
......@@ -334,7 +334,7 @@ export class UserService {
public deleteUser() {
return this.http.delete('/rest/user').pipe(
catchError(this.handleError(true, "Error deleting user")),
catchError(this.handleError(true, 'Error deleting user')),
).subscribe(
_ => {
this.user$.next(undefined);
......@@ -349,7 +349,7 @@ export class UserService {
'/rest/ssh-keys',
{'name': name, 'key': key},
).pipe(
catchError(this.handleError(true, "Error changing deployment")),
catchError(this.handleError(true, 'Error changing deployment')),
).subscribe(
(newKey: SSHKey) => {
this.sshKeys.set(newKey.id, newKey);
......@@ -364,7 +364,7 @@ export class UserService {
return this.http.delete(
`/rest/ssh-key/${ key.id.toString() }`,
).pipe(
catchError(this.handleError(true, "Error changing deployment")),
catchError(this.handleError(true, 'Error changing deployment')),
).subscribe(
_ => {
this.sshKeys.delete(key.id);
......@@ -379,7 +379,7 @@ export class UserService {
`/rest/deployment/${ depType }/${ id.toString() }`,
{'state_target': stateTarget},
).pipe(
catchError(this.handleError(true, "Error changing deployment")),
catchError(this.handleError(true, 'Error changing deployment')),
).subscribe(
(dep: Deployment) => this.updateDeployment(dep),
);
......@@ -390,7 +390,7 @@ export class UserService {
`/rest/state/${ stateItemID }`,
{'answers': answers},
).pipe(
catchError(this.handleError(true, "Error submitting answers")),
catchError(this.handleError(true, 'Error submitting answers')),
).subscribe(
(state: DeploymentState) => this.updateDeploymentState(state),
this.logErrorAndFetch,
......@@ -445,7 +445,7 @@ export class UserService {
public subscribeStateFor(service: Service): Observable<DeploymentState> {
return this.deploymentStates$.asObservable().pipe(
map((states: DeploymentState[]) => states.find(
(dsi: DeploymentState) => dsi.service.id == service.id,
(dsi: DeploymentState) => dsi.service.id === service.id,
)),
tap(this.tapLogger('subscribeStateFor')),
);
......
......@@ -6,7 +6,7 @@ import { map, tap, filter, flatMap, groupBy, toArray } from 'rxjs/operators';
import { UserService } from '../user.service';
import { LanguageService } from '../language.service';
import { DialogService } from '../dialogues/dialog.service';
import { User, VO, Site, Service, Deployment, DeploymentState } from '../types/types.module';
import { User, VO, Site, Service, Deployment, DeploymentState } from '../types/types.module';
@Component({
selector: 'app-vo-data',
......@@ -32,14 +32,14 @@ export class VoDataComponent implements OnInit {
ngOnInit(): void {
this.deployment$ = this.userService.subscribeDeployment(
(dep: Deployment) => dep.vo ? dep.vo.id == this.vo.id : false
(dep: Deployment) => dep.vo ? dep.vo.id === this.vo.id : false
);
this.groupedServices$ = this.userService.userSrc().pipe(
map(user => {
if (user != undefined && user.services != undefined) {
if (user !== undefined && user.services !== undefined) {
const voServices = user.services.filter(
service => service.vos.some(svo => svo.id == this.vo.id),
service => service.vos.some(svo => svo.id === this.vo.id),
);
const groupedServices = voServices.sort(service => service.site.id);
return groupedServices;
......
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