Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Codecrew
/
Moya
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
30
Merge Requests
2
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit d2b03bfc
authored
Oct 15, 2018
by
Tuukka Kivilahti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ng lint and fixed errors
1 parent
00da62d3
Pipeline
#157
failed
in 0 seconds
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
39 additions
and
36 deletions
code/moya-angular/src/app/app-routing.module.ts
code/moya-angular/src/app/app.component.ts
code/moya-angular/src/app/app.module.ts
code/moya-angular/src/app/modules/login/login-button/login-button.component.ts
code/moya-angular/src/app/modules/login/login-component/login.component.ts
code/moya-angular/src/app/modules/login/login-dialog/login-dialog.component.ts
code/moya-angular/src/app/modules/login/login-page/login-page.component.ts
code/moya-angular/src/app/shared/models/user.model.ts
code/moya-angular/src/app/shared/services/session-service.service.ts
code/moya-angular/src/app/app-routing.module.ts
View file @
d2b03bf
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
},
...
...
code/moya-angular/src/app/app.component.ts
View file @
d2b03bf
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
;
...
...
code/moya-angular/src/app/app.module.ts
View file @
d2b03bf
...
@@ -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
:
[
...
...
code/moya-angular/src/app/modules/login/login-button/login-button.component.ts
View file @
d2b03bf
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
{
le
t
conf
=
new
MatDialogConfig
();
cons
t
conf
=
new
MatDialogConfig
();
conf
.
autoFocus
=
true
;
conf
.
autoFocus
=
true
;
/*conf.height = "800px";
/*conf.height = "800px";
conf.width = "500px";*/
conf.width = "500px";*/
le
t
dialogRef
=
this
.
dialog
.
open
(
LoginComponent
,
conf
);
cons
t
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'
);
}
}
});
});
}
}
...
...
code/moya-angular/src/app/modules/login/login-component/login.component.ts
View file @
d2b03bf
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'
;
...
...
code/moya-angular/src/app/modules/login/login-dialog/login-dialog.component.ts
View file @
d2b03bf
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'
,
...
...
code/moya-angular/src/app/modules/login/login-page/login-page.component.ts
View file @
d2b03bf
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
(
'/'
);
}
}
}
}
...
...
code/moya-angular/src/app/shared/models/user.model.ts
View file @
d2b03bf
...
@@ -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'
;
}
}
}
code/moya-angular/src/app/shared/services/session-service.service.ts
View file @
d2b03bf
...
@@ -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
(
'/'
);
});
});
}
}
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment