Commit d2b03bfc by Tuukka Kivilahti

ng lint and fixed errors

1 parent 00da62d3
Pipeline #157 failed
in 0 seconds
import { NgModule } from '@angular/core'; import { NgModule } from '@angular/core';
import {Routes, RouterModule, PreloadAllModules, NoPreloading} from '@angular/router'; import {Routes, RouterModule, PreloadAllModules, NoPreloading} from '@angular/router';
import {FrontpageComponent} from './components/frontpage/frontpage.component'; import {FrontpageComponent} from './components/frontpage/frontpage.component';
import {LoginPageComponent} from "./modules/login/login-page/login-page.component"; import {LoginPageComponent} from './modules/login/login-page/login-page.component';
const APP_ROUTES: Routes = [ const APP_ROUTES: Routes = [
//{ path: 'login', component: LoginPageComponent },
{ path: 'viplist', loadChildren: 'app/modules/viplist/viplist.module#ViplistModule' }, { path: 'viplist', loadChildren: 'app/modules/viplist/viplist.module#ViplistModule' },
{ path: 'old', loadChildren: 'app/modules/old-moya/old-moya.module#OldMoyaModule' }, { path: 'old', loadChildren: 'app/modules/old-moya/old-moya.module#OldMoyaModule' },
{ path: 'index', component: FrontpageComponent }, { path: 'index', component: FrontpageComponent },
......
import {Component, NgZone} from '@angular/core'; import {Component, NgZone} from '@angular/core';
import {Router} from '@angular/router'; import {Router} from '@angular/router';
import {MatDialog, MatDialogConfig} from "@angular/material"; import {MatDialog, MatDialogConfig} from '@angular/material';
import {LoginComponent} from "./modules/login/login-component/login.component"; import {LoginComponent} from './modules/login/login-component/login.component';
declare var window: any; declare var window: any;
......
...@@ -19,8 +19,8 @@ import { FrontpageComponent } from './components/frontpage/frontpage.component'; ...@@ -19,8 +19,8 @@ import { FrontpageComponent } from './components/frontpage/frontpage.component';
import {HttpLink, HttpLinkModule} from 'apollo-angular-link-http'; import {HttpLink, HttpLinkModule} from 'apollo-angular-link-http';
import {APOLLO_OPTIONS, ApolloModule} from 'apollo-angular'; import {APOLLO_OPTIONS, ApolloModule} from 'apollo-angular';
import {createApollo} from './shared/config/moya.config'; import {createApollo} from './shared/config/moya.config';
import {MatButtonModule} from "@angular/material"; import {MatButtonModule} from '@angular/material';
import {LoginComponent} from "./modules/login/login-component/login.component"; import {LoginComponent} from './modules/login/login-component/login.component';
@NgModule({ @NgModule({
declarations: [ declarations: [
......
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import {MatDialog, MatDialogConfig} from "@angular/material"; import {MatDialog, MatDialogConfig} from '@angular/material';
import {LoginComponent} from "../login-component/login.component"; import {LoginComponent} from '../login-component/login.component';
import {Router} from "@angular/router"; import {Router} from '@angular/router';
import {SessionServiceService} from "../../../shared/services/session-service.service"; import {SessionServiceService} from '../../../shared/services/session-service.service';
import {EventUser} from "../../../shared/models/event-user.model"; import {EventUser} from '../../../shared/models/event-user.model';
import {User} from "../../../shared/models/user.model"; import {User} from '../../../shared/models/user.model';
@Component({ @Component({
selector: 'moya-login-button', selector: 'moya-login-button',
...@@ -32,20 +32,20 @@ export class LoginButtonComponent implements OnInit { ...@@ -32,20 +32,20 @@ export class LoginButtonComponent implements OnInit {
openLoginDialog(): void { openLoginDialog(): void {
let conf = new MatDialogConfig(); const conf = new MatDialogConfig();
conf.autoFocus = true; conf.autoFocus = true;
/*conf.height = "800px"; /*conf.height = "800px";
conf.width = "500px";*/ conf.width = "500px";*/
let dialogRef = this.dialog.open(LoginComponent, conf); const dialogRef = this.dialog.open(LoginComponent, conf);
dialogRef.componentInstance.loginEvent.subscribe((success) => { dialogRef.componentInstance.loginEvent.subscribe((success) => {
if(success) { if (success) {
dialogRef.close(); dialogRef.close();
} else { } else {
dialogRef.close(); dialogRef.close();
this.router.navigateByUrl("/login"); this.router.navigateByUrl('/login');
} }
}); });
} }
......
import {Component, EventEmitter, OnInit, Output} from '@angular/core'; import {Component, EventEmitter, OnInit, Output} from '@angular/core';
import {TranslatePipe} from '@ngx-translate/core'; import {TranslatePipe} from '@ngx-translate/core';
import {SessionServiceService} from '../../../shared/services/session-service.service'; import {SessionServiceService} from '../../../shared/services/session-service.service';
import {FormGroup, NgForm} from "@angular/forms"; import {FormGroup, NgForm} from '@angular/forms';
......
import {Component, NgZone, OnInit} from '@angular/core'; import {Component, NgZone, OnInit} from '@angular/core';
import {MatDialog, MatDialogConfig} from "@angular/material"; import {MatDialog, MatDialogConfig} from '@angular/material';
import {LoginComponent} from "../login-component/login.component"; import {LoginComponent} from '../login-component/login.component';
import {Router} from "@angular/router"; import {Router} from '@angular/router';
@Component({ @Component({
selector: 'moya-login-dialog', selector: 'moya-login-dialog',
......
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import {Router} from "@angular/router"; import {Router} from '@angular/router';
@Component({ @Component({
selector: 'moya-login-page', selector: 'moya-login-page',
...@@ -13,9 +13,9 @@ export class LoginPageComponent implements OnInit { ...@@ -13,9 +13,9 @@ export class LoginPageComponent implements OnInit {
ngOnInit() { ngOnInit() {
} }
onLoginEvent(success: boolean):void { onLoginEvent(success: boolean): void {
if(success) { if (success) {
this.router.navigateByUrl("/"); this.router.navigateByUrl('/');
} }
} }
......
...@@ -57,17 +57,19 @@ export class User { ...@@ -57,17 +57,19 @@ export class User {
zip: string; zip: string;
town: string; town: string;
public isAnonymous(): boolean {
return !this.login || this.login === "anonymous";
}
public static NewUser(user) { public static NewUser(user) {
if(user === null) if (user === null) {
return new User(); return new User();
}
return Object.assign(new User(), user); return Object.assign(new User(), user);
} }
public isAnonymous(): boolean {
return !this.login || this.login === 'anonymous';
}
} }
...@@ -6,9 +6,9 @@ import {BehaviorSubject, Observable, Observer, Subject} from 'rxjs'; ...@@ -6,9 +6,9 @@ import {BehaviorSubject, Observable, Observer, Subject} from 'rxjs';
import {MOYA_BASE_URL, MOYA_REST_URL} from '../config/moya.config'; import {MOYA_BASE_URL, MOYA_REST_URL} from '../config/moya.config';
import {map, share} from 'rxjs/operators'; import {map, share} from 'rxjs/operators';
import {HttpClient, HttpHeaders, HttpParams} from '@angular/common/http'; import {HttpClient, HttpHeaders, HttpParams} from '@angular/common/http';
import {EventUser} from "../models/event-user.model"; import {EventUser} from '../models/event-user.model';
import {User} from "../models/user.model"; import {User} from '../models/user.model';
import {Router} from "@angular/router"; import {Router} from '@angular/router';
...@@ -83,6 +83,8 @@ export class SessionServiceService { ...@@ -83,6 +83,8 @@ export class SessionServiceService {
* Returns observable with current user. If we are not logged in, current user is Anonymous. * Returns observable with current user. If we are not logged in, current user is Anonymous.
* *
* If there is any change of user status, new user is automatically pushed into this observable. * If there is any change of user status, new user is automatically pushed into this observable.
*
* TODO: Change User to EventUser, and use prober currentUser -api
*/ */
public getCurrentUser(): Observable<User> { public getCurrentUser(): Observable<User> {
return this.currentuserSubject.pipe(map(user => User.NewUser(user))); return this.currentuserSubject.pipe(map(user => User.NewUser(user)));
...@@ -94,7 +96,7 @@ export class SessionServiceService { ...@@ -94,7 +96,7 @@ export class SessionServiceService {
* This will push currently logged in user into currentUser -observable. * This will push currently logged in user into currentUser -observable.
*/ */
public updateCurrentUser() { public updateCurrentUser() {
this.http.get<User>(MOYA_REST_URL + "/v2/user/current").subscribe( this.http.get<User>(MOYA_REST_URL + '/v2/user/current').subscribe(
(currentUser) => { (currentUser) => {
this.currentuserSubject.next(currentUser); this.currentuserSubject.next(currentUser);
}); });
...@@ -135,8 +137,8 @@ export class SessionServiceService { ...@@ -135,8 +137,8 @@ export class SessionServiceService {
// Do login with unexiting user and password, this does also logout // Do login with unexiting user and password, this does also logout
let params = new HttpParams(); let params = new HttpParams();
params = params.set('username', "anonymous"); params = params.set('username', 'anonymous');
params = params.set('password', "notValidPassword"); params = params.set('password', 'notValidPassword');
const apolloObservable = this.http.post(MOYA_REST_URL + '/user/auth', params, { const apolloObservable = this.http.post(MOYA_REST_URL + '/user/auth', params, {
...@@ -146,7 +148,7 @@ export class SessionServiceService { ...@@ -146,7 +148,7 @@ export class SessionServiceService {
}).subscribe(x => x, x => x, () => { }).subscribe(x => x, x => x, () => {
this.permissionsApollo.refetch(); this.permissionsApollo.refetch();
this.updateCurrentUser(); this.updateCurrentUser();
this.router.navigateByUrl("/"); this.router.navigateByUrl('/');
}); });
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!