Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
hpc-team
strudelv2_spa
Commits
4595a001
Commit
4595a001
authored
Sep 25, 2019
by
Chris Hines
Browse files
make cloudcmd authentication almost work
parent
1dbee646
Pipeline
#7904
passed with stages
in 4 minutes and 32 seconds
Changes
1
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
src/app/tes.service.ts
View file @
4595a001
import
{
Injectable
,
EventEmitter
}
from
'
@angular/core
'
;
import
{
HttpClientModule
,
HttpClient
,
HttpHeaders
,
HttpErrorResponse
}
from
'
@angular/common/http
'
;
import
{
Observable
,
Subject
,
BehaviorSubject
,
of
,
from
}
from
'
rxjs
'
;
import
{
Observable
,
Subject
,
BehaviorSubject
,
of
,
from
,
interval
}
from
'
rxjs
'
;
import
{
fromEvent
,
throwError
,
Subscription
,
merge
}
from
'
rxjs
'
;
import
{
catchError
,
map
,
tap
,
filter
}
from
'
rxjs/operators
'
;
import
{
Job
}
from
'
./job
'
;
...
...
@@ -12,7 +12,7 @@ import { BatchInterface } from './batchinterface';
import
{
ComputesitesService
}
from
'
./computesites.service
'
;
import
{
StrudelappsService
}
from
'
./strudelapps.service
'
;
import
{
timer
}
from
'
rxjs/observable/timer
'
;
import
{
repeat
,
takeUntil
}
from
'
rxjs/operators
'
;
import
{
repeat
,
takeUntil
,
take
}
from
'
rxjs/operators
'
;
import
{
LocationStrategy
,
Location
}
from
'
@angular/common
'
;
import
{
ActivatedRoute
,
Router
}
from
'
@angular/router
'
;
import
{
ModaldialogComponent
}
from
'
./modaldialog/modaldialog.component
'
;
...
...
@@ -53,6 +53,7 @@ private cancelRequests$: Subject<boolean>;
public
identitySubject
:
BehaviorSubject
<
Identity
>
;
public
appSubject
:
BehaviorSubject
<
Strudelapp
>
;
private
openapps
:
any
[];
private
authdone$
:
Subject
<
boolean
>
;
// public batchinterface: {[id: string] : BatchInterface};
...
...
@@ -71,6 +72,7 @@ private openapps: any[];
this
.
apiserver
=
new
BehaviorSubject
<
APIServer
>
(
null
);
this
.
apiservers
=
new
BehaviorSubject
<
APIServer
[]
>
([]);
this
.
cancelRequests$
=
new
Subject
<
boolean
>
();
this
.
authdone$
=
new
Subject
<
boolean
>
();
this
.
openapps
=
[];
//this.identitySubject = new BehaviorSubject<Identity>(null);
//this.appSubject = new BehaviorSubject<Strudelapp>(null);
...
...
@@ -463,24 +465,40 @@ addUserHealth(identity,resp) {
this
.
getAppInstance
(
job
,
action
);
}
private
windowLoaded
(
window
:
any
,
location
:
string
):
boolean
{
console
.
log
(
'
in windowloaded testing
'
);
console
.
log
(
window
.
location
);
try
{
if
(
window
.
location
.
toString
()
==
location
)
{
console
.
log
(
'
location match
'
);
return
true
;
}
console
.
log
(
'
location not match
'
);
return
false
;
}
catch
{
return
true
;
}
}
public
openAppWindow
(
url
:
any
,
job
:
Job
,
action
:
AppAction
)
{
var
re
=
/^https:
\/\/([
a-z0-9
\.
-
]
+
)\/?
/
;
let
twshost
=
this
.
twsproxy
.
replace
(
re
,
"
$1
"
);
console
.
log
(
'
in openappwindow url is
'
,
url
);
let
windowloc
=
url
.
replace
(
/
\{
twsproxy
\}
/g
,
this
.
twsproxy
).
replace
(
/twshost/g
,
twshost
);
console
.
log
(
'
window loc is
'
,
windowloc
);
let
user
=
'
chines
'
;
let
pass
=
'
pass
'
;
var
authwindow
=
null
;
if
(
action
.
client
.
usebasicauth
)
{
let
authwindowloc
=
windowloc
.
replace
(
/^https:
\/\/
/
,
'
https://
'
+
job
.
appinst
.
username
+
'
:
'
+
job
.
appinst
.
password
+
'
@
'
);
console
.
log
(
'
authwindowloc is
'
,
authwindowloc
);
console
.
log
(
job
.
appinst
);
authwindow
=
window
.
open
(
authwindowloc
);
//windowloc = authwindowloc;
this
.
authdone$
.
pipe
(
take
(
1
)).
subscribe
(
()
=>
{
authwindow
.
close
()
;
this
.
finishAppWindow
(
windowloc
,
job
)
});
interval
(
500
).
pipe
(
takeUntil
(
this
.
authdone$
),
filter
((
v
)
=>
this
.
windowLoaded
(
authwindow
,
authwindowloc
))).
subscribe
(
()
=>
this
.
authdone$
.
next
(
true
));
}
else
{
this
.
finishAppWindow
(
windowloc
,
job
);
}
}
public
finishAppWindow
(
windowloc
:
any
,
job
:
Job
)
{
let
appwindow
=
window
.
open
(
windowloc
);
if
(
appwindow
==
null
)
{
this
.
statusMsg
.
next
(
'
It looks like a window failed to open. Please check your popup blocker settings (Strudel 2 needs to be able to open a window to your application
'
);
...
...
@@ -490,10 +508,6 @@ addUserHealth(identity,resp) {
return
}
this
.
openapps
.
push
({
'
window
'
:
appwindow
,
'
job
'
:
job
})
if
(
authwindow
!==
null
)
{
authwindow
.
close
();
}
}
public
connect
(
job
:
Job
,
action
:
AppAction
,
appinst
?:
any
)
{
...
...
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