Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
feudal
feudalWebpage
Commits
c2ffa9b7
Commit
c2ffa9b7
authored
May 16, 2018
by
Lukas Burgey
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Some restructuring
parent
2ce5f255
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
63 additions
and
63 deletions
+63
-63
src/app/user.service.ts
src/app/user.service.ts
+63
-63
No files found.
src/app/user.service.ts
View file @
c2ffa9b7
import
{
of
as
observableOf
,
Observable
}
from
'
rxjs
'
;
import
{
catchError
,
map
}
from
'
rxjs/operators
'
;
import
{
Injectable
}
from
'
@angular/core
'
;
import
{
Injectable
}
from
'
@angular/core
'
;
import
{
HttpClient
,
HttpErrorResponse
}
from
'
@angular/common/http
'
;
import
{
HttpClient
,
HttpErrorResponse
}
from
'
@angular/common/http
'
;
import
{
Observable
}
from
'
rxjs/Observable
'
;
import
'
rxjs/add/operator/map
'
;
import
'
rxjs/add/operator/catch
'
;
import
'
rxjs/add/observable/of
'
;
import
{
CookieService
}
from
'
ngx-cookie-service
'
;
import
{
CookieService
}
from
'
ngx-cookie-service
'
;
import
{
MatTableDataSource
}
from
'
@angular/material
'
;
import
{
MatTableDataSource
}
from
'
@angular/material
'
;
...
@@ -52,7 +49,7 @@ export class UserService {
...
@@ -52,7 +49,7 @@ export class UserService {
public
getIdPPreference
():
Observable
<
AllAuthInfo
>
{
public
getIdPPreference
():
Observable
<
AllAuthInfo
>
{
let
idpID
=
Number
(
this
.
cookieService
.
get
(
environment
.
idpCookieName
));
let
idpID
=
Number
(
this
.
cookieService
.
get
(
environment
.
idpCookieName
));
return
this
.
http
.
get
(
'
/backend/auth/v1/info/
'
).
pipe
(
map
(
return
this
.
http
.
get
(
'
/backend/auth/v1/info/
'
).
map
(
(
authInfo
:
AuthInfo
)
=>
{
(
authInfo
:
AuthInfo
)
=>
{
let
selected
=
authInfo
.
idps
[
1
];
let
selected
=
authInfo
.
idps
[
1
];
...
@@ -69,12 +66,15 @@ export class UserService {
...
@@ -69,12 +66,15 @@ export class UserService {
selected
:
selected
,
selected
:
selected
,
};
};
}
}
)
,
catch
Error
(
)
.
catch
(
(
error
:
any
)
=>
{
(
error
:
any
)
=>
{
this
.
errorHandler
(
error
);
this
.
errorHandler
(
error
);
return
o
bservable
O
f
(
null
);
return
O
bservable
.
o
f
(
null
);
}
}
),);
);
}
private
_handleValueChange
(
newData
:
any
)
{
}
}
private
_updateUserValues
(
newUser
:
any
)
{
private
_updateUserValues
(
newUser
:
any
)
{
...
@@ -152,58 +152,6 @@ export class UserService {
...
@@ -152,58 +152,6 @@ export class UserService {
this
.
updateState
();
this
.
updateState
();
}
}
private
initStomp
()
{
// handle with care
let
login
=
this
.
user
.
id
let
passcode
=
this
.
cookieService
.
get
(
'
sessionid
'
);
const
stompConfig
:
StompConfig
=
{
// Which server?
url
:
'
wss://hdf-portal.data.kit.edu/ws
'
,
// Headers
// Typical keys: login, passcode, host
headers
:
{
login
:
'
webpage-client:
'
+
login
,
passcode
:
passcode
,
},
// How often to heartbeat?
// Interval in milliseconds, set to 0 to disable
heartbeat_in
:
0
,
// Typical value 0 - disabled
heartbeat_out
:
20000
,
// Typical value 20000 - every 20 seconds
// Wait in milliseconds before attempting auto reconnect
// Set to 0 to disable
// Typical value 5000 (5 seconds)
reconnect_delay
:
5000
,
// Will log diagnostics on console
debug
:
false
,
};
this
.
_stompService
.
config
=
stompConfig
;
this
.
_stompService
.
initAndConnect
();
}
private
connectLiveUpdates
()
{
this
.
initStomp
();
let
subscription
=
this
.
_stompService
.
subscribe
(
'
/exchange/update/
'
+
this
.
user
.
id
.
toString
()
);
subscription
.
pipe
(
map
((
message
:
Message
)
=>
{
return
message
.
body
;
})).
subscribe
((
body
:
any
)
=>
{
let
json
=
JSON
.
parse
(
body
);
if
(
json
.
message
&&
json
.
message
!=
''
)
{
this
.
snackBar
.
open
(
json
.
message
);
this
.
messages
.
push
(
json
.
message
);
}
if
(
json
.
user_state
)
{
this
.
_updateUserValues
(
json
.
user_state
);
}
});
}
public
login
(
idp
:
IdP
)
{
public
login
(
idp
:
IdP
)
{
this
.
setIdPPreference
(
idp
);
this
.
setIdPPreference
(
idp
);
window
.
location
.
href
=
'
https://hdf-portal.data.kit.edu/backend/auth/v1/request/
'
;
window
.
location
.
href
=
'
https://hdf-portal.data.kit.edu/backend/auth/v1/request/
'
;
...
@@ -304,6 +252,58 @@ export class UserService {
...
@@ -304,6 +252,58 @@ export class UserService {
);
);
}
}
public
initStomp
()
{
// handle with care
let
login
=
this
.
user
.
id
let
passcode
=
this
.
cookieService
.
get
(
'
sessionid
'
);
const
stompConfig
:
StompConfig
=
{
// Which server?
url
:
'
wss://hdf-portal.data.kit.edu/ws
'
,
// Headers
// Typical keys: login, passcode, host
headers
:
{
login
:
'
webpage-client:
'
+
login
,
passcode
:
passcode
,
},
// How often to heartbeat?
// Interval in milliseconds, set to 0 to disable
heartbeat_in
:
0
,
// Typical value 0 - disabled
heartbeat_out
:
20000
,
// Typical value 20000 - every 20 seconds
// Wait in milliseconds before attempting auto reconnect
// Set to 0 to disable
// Typical value 5000 (5 seconds)
reconnect_delay
:
5000
,
// Will log diagnostics on console
debug
:
false
,
};
this
.
_stompService
.
config
=
stompConfig
;
this
.
_stompService
.
initAndConnect
();
}
public
connectLiveUpdates
()
{
this
.
initStomp
();
let
subscription
=
this
.
_stompService
.
subscribe
(
'
/exchange/update/
'
+
this
.
user
.
id
.
toString
()
);
subscription
.
map
((
message
:
Message
)
=>
{
return
message
.
body
;
}).
subscribe
((
body
:
any
)
=>
{
let
json
=
JSON
.
parse
(
body
);
if
(
json
.
message
&&
json
.
message
!=
''
)
{
this
.
snackBar
.
open
(
json
.
message
);
this
.
messages
.
push
(
json
.
message
);
}
if
(
json
.
user_state
)
{
this
.
_updateUserValues
(
json
.
user_state
);
}
});
}
public
taskInProgress
(
site
,
service
):
boolean
{
public
taskInProgress
(
site
,
service
):
boolean
{
if
(
site
&&
service
)
{
if
(
site
&&
service
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
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 comment