Skip to content

Commit

Permalink
Zowe Suite v1.13.0
Browse files Browse the repository at this point in the history
  • Loading branch information
zowe-robot authored Jun 22, 2020
2 parents 0bf96ac + 4a6c02d commit 33b1737
Show file tree
Hide file tree
Showing 18 changed files with 933 additions and 142 deletions.
22 changes: 0 additions & 22 deletions virtual-desktop/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion virtual-desktop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
"jquery": "~3.5.0",
"json-loader": "~0.5.7",
"ngx-i18nsupport": "~0.17.1",
"ngx-color": "~5.0.3",
"ngx-file-drop": "~6.0.1",
"moment": "~2.25.3",
"popper.js": "~1.14.3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,17 @@ import { HttpModule } from '@angular/http';
import { ZluxPopupManagerModule } from '@zlux/widgets';
import { LoginComponent } from './login/login.component';
import { AuthenticationManager } from './authentication-manager.service';
import { StartURLManagerModule } from '../start-url-manager';
import { StorageService } from './storage.service';
import { IdleWarnService } from './idleWarn.service';

@NgModule({
imports: [
CommonModule,
FormsModule,
HttpModule,
ZluxPopupManagerModule
ZluxPopupManagerModule,
StartURLManagerModule,
],
declarations: [
LoginComponent
Expand All @@ -34,7 +38,9 @@ import { AuthenticationManager } from './authentication-manager.service';
providers: [
AuthenticationManager,
/* Expose authentication manager to window managers */
{ provide: MVDHosting.Tokens.AuthenticationManagerToken, useExisting: AuthenticationManager }
{ provide: MVDHosting.Tokens.AuthenticationManagerToken, useExisting: AuthenticationManager },
StorageService,
IdleWarnService
]
})
export class AuthenticationModule {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { Observable } from 'rxjs/Observable';
import { ErrorObservable } from 'rxjs/observable/ErrorObservable';
import { BaseLogger } from 'virtual-desktop-logger';
import { PluginManager } from 'app/plugin-manager/shared/plugin-manager';
import { StartURLManager } from '../start-url-manager';

class ClearZoweZLUX implements MVDHosting.LogoutActionInterface {
onLogout(username: string | null): boolean {
Expand Down Expand Up @@ -59,14 +60,16 @@ export class AuthenticationManager {
constructor(
public http: Http,
private injector: Injector,
private pluginManager: PluginManager
private pluginManager: PluginManager,
private startURLManager: StartURLManager
) {
this.username = null;
this.postLoginActions = new Array<MVDHosting.LoginActionInterface>();
this.preLogoutActions = new Array<MVDHosting.LogoutActionInterface>();
this.registerPreLogoutAction(new ClearZoweZLUX());
this.registerPreLogoutAction(this.pluginManager)
this.registerPostLoginAction(new initializeNotificationManager());
this.registerPostLoginAction(this.startURLManager);
this.loginScreenVisibilityChanged = new EventEmitter();
this.loginExpirationIdleCheck = new EventEmitter();
this.log = BaseLogger.makeSublogger("auth");
Expand Down
118 changes: 118 additions & 0 deletions virtual-desktop/src/app/authentication-manager/idleWarn.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
import * as moment from 'moment';
import { Injectable } from '@angular/core';
import { ZluxPopupManagerService, ZluxErrorSeverity } from '@zlux/widgets';
import { TranslationService } from 'angular-l10n';
import { BaseLogger } from 'virtual-desktop-logger';
import { Subscription } from 'rxjs/Subscription';
import { StorageService } from './storage.service';

@Injectable()
export class IdleWarnService {

private report: any;
private readonly logger: ZLUX.ComponentLogger = BaseLogger;

constructor(private popupManager: ZluxPopupManagerService,
public translation: TranslationService,
private storageService: StorageService
) {
}

public createRetryErrorReport(renewSession: any, isIdle: any) {
this.removeErrorReport();
this.report = this.popupManager.createErrorReport(
ZluxErrorSeverity.WARNING,
this.translation.translate('Session Renewal Error'),
this.translation.translate('Session could not be renewed. Logout will occur unless renewed. Click here to retry.'),
{
blocking: false,
buttons: [this.translation.translate('Retry'), this.translation.translate('Dismiss')]
}
);

this.report.subscription = new Subscription();
this.onUserActionSubscribe(renewSession,'Retry');
this.onActivitySubscribe(renewSession, isIdle);
}

onUserActionSubscribe(renewSession: any, action: string) {
if(this.report) {
this.report.subscription.add(this.report.subject.subscribe((buttonName:any)=> {
if (buttonName == this.translation.translate(action)) {
renewSession();
}
}));
}
}

public createContinueErrorReport(renewSession: any, isIdle: any, expirationInMS: number, desktopSize: any) {
this.removeErrorReport();
let popupStyle;

/* According to the size of the desktop, we move the expiration prompt to align with the app bar */
switch (desktopSize) {
case 3: {
popupStyle = {
'margin-bottom': '70px',
'margin-right': '-5px'
};
break;
}
case 1: {
popupStyle = {
'margin-bottom': '15px',
'margin-right': '-10px'
};
break;
}
default: {
popupStyle = {
'margin-bottom': '35px',
'margin-right': '-5px'
};
break;
}
}

this.report = this.popupManager.createErrorReport(
ZluxErrorSeverity.WARNING,
this.translation.translate('Session Expiring Soon'),
//TODO: Add translation
//this.translation.translate('You will be logged out at ', { expirationInMS: moment().add(expirationInMS/1000, 'seconds').format('LT') }),
this.translation.translate('You will be logged out at ' + moment().add(expirationInMS/1000, 'seconds').format('LT')),
{
blocking: false,
buttons: [this.translation.translate('Continue session')],
timestamp: false,
theme: "dark",
style: popupStyle,
callToAction: true
});

this.report.subscription = new Subscription();
this.onUserActionSubscribe(renewSession, 'Continue session');
this.onActivitySubscribe(renewSession, isIdle);
}


onActivitySubscribe(renewSession: any, isIdle: any) {
if(this.report) {
this.report.subscription.add(this.storageService.lastActive.subscribe(()=> {
if (!isIdle()) {
this.logger.info('ZWED5047I', 'renew on activity'); /*this.logger.info('Near session expiration, but renewing session due to activity');*/
renewSession();
this.removeErrorReport();
}
}));
}
}

removeErrorReport() {
if (this.report) {
this.popupManager.removeReport(this.report.id);
this.report.subscription.unsubscribe();
this.report = undefined;
}
}

}
Loading

0 comments on commit 33b1737

Please sign in to comment.