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 51e7e8e6
authored
Sep 22, 2018
by
Tuukka Kivilahti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
session intialization
1 parent
5ec07a05
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
78 additions
and
1 deletions
code/moya-angular/src/app/shared/models/permissions.model.ts
code/moya-angular/src/app/shared/services/session-service.service.spec.ts
code/moya-angular/src/app/shared/services/session-service.service.ts
code/moya-angular/src/app/shared/services/user.service.ts
code/moya-angular/tsconfig.json
code/moya-angular/src/app/shared/models/permissions.model.ts
0 → 100644
View file @
51e7e8e
/**
* Created by tuukka on 15/02/17.
*/
import
gql
from
'graphql-tag'
;
class
PermissionFields
{
USER
:
boolean
;
INFO
:
boolean
;
ADMIN
:
boolean
;
}
export
class
Permissions
{
static
fragments
=
gql
`
fragment permissionPrimitives on Permission {
VIPLIST: {USER, INFO, ADMIN},
BILLING: {USER, INFO, ADMIN},
}
`
;
VIPLIST
:
PermissionFields
;
BILLING
:
PermissionFields
;
constructor
()
{
}
}
code/moya-angular/src/app/shared/services/session-service.service.spec.ts
0 → 100644
View file @
51e7e8e
import
{
TestBed
,
inject
}
from
'@angular/core/testing'
;
import
{
SessionServiceService
}
from
'./session-service.service'
;
describe
(
'SessionServiceService'
,
()
=>
{
beforeEach
(()
=>
{
TestBed
.
configureTestingModule
({
providers
:
[
SessionServiceService
]
});
});
it
(
'should be created'
,
inject
([
SessionServiceService
],
(
service
:
SessionServiceService
)
=>
{
expect
(
service
).
toBeTruthy
();
}));
});
code/moya-angular/src/app/shared/services/session-service.service.ts
0 → 100644
View file @
51e7e8e
import
{
Injectable
}
from
'@angular/core'
;
import
gql
from
'graphql-tag'
;
import
{
Permission
,
Permissions
}
from
"../models/permissions.model"
;
import
{
Apollo
}
from
"apollo-angular"
;
import
{
map
}
from
"rxjs/operators"
;
import
{
Q_VIPS_N_DATA
}
from
"../../modules/viplist/viplist.service"
;
import
{
Observable
}
from
"rxjs"
;
const
__REFRESH_TIME_MINUTES
=
5
;
export
const
Q_USER_PERMISSIONS
=
gql
`
{
}
`
;
@
Injectable
({
providedIn
:
'root'
})
export
class
SessionServiceService
{
private
permissionsObservable
:
Observable
<
Permissions
>
;
public
getPermissions
():
Observable
<
Permissions
>
{
return
this
.
permissionsObservable
;
}
constructor
(
private
apollo
:
Apollo
)
{
this
.
permissionsObservable
=
this
.
apollo
.
watchQuery
<
Permissions
>
({
query
:
Q_USER_PERMISSIONS
,
pollInterval
:
__REFRESH_TIME_MINUTES
*
60000
});
}
}
code/moya-angular/src/app/shared/services/user.service.ts
View file @
51e7e8e
...
...
@@ -23,5 +23,4 @@ export class UserService {
return
this
.
cacheService
.
cacheObservable
(
'moya:UserService'
,
path
,
this
.
http
.
get
<
User
>
(
path
).
pipe
(
tap
(
v
=>
{
console
.
log
(
'getting user outside of cache'
,
path
);
})));
}
}
code/moya-angular/tsconfig.json
View file @
51e7e8e
...
...
@@ -13,6 +13,7 @@
],
"lib"
:
[
"es2018"
,
"es2016"
,
"dom"
,
"esnext.asynciterable"
],
...
...
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