Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create Auto Save Event #250

Merged
merged 47 commits into from
Aug 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
981533a
Adding app generator first version
1000TurquoisePogs Mar 7, 2020
4451c5e
Make dev plugins folder devPlugins not pluginFolders
1000TurquoisePogs Mar 10, 2020
c04def6
Un-hardcoded plugin id references
1000TurquoisePogs Mar 13, 2020
1395667
Update to validate the ID
1000TurquoisePogs Jun 9, 2020
f8b16b5
Version 1
DivergentEuropeans Jun 25, 2020
90b84a2
Version 2
DivergentEuropeans Jun 25, 2020
23b3428
Clean-up
DivergentEuropeans Jun 25, 2020
f732b5b
session expire storage evnt,renew session on login
Jun 25, 2020
c0d6bf7
unique session value using timestamp
Jun 26, 2020
60d6bf1
storage key removal, and subscription management
Jun 30, 2020
42af102
fixed storage sub and unsub
Jul 1, 2020
d9c2071
clean up messages
Jul 1, 2020
288dc99
updated changelog for 1.12,1.13, *1.14
Jul 1, 2020
31e2fe4
Remove double slash for unix api in case it is accidentally done
1000TurquoisePogs Jul 2, 2020
4653f2e
Fix implicit "any"
Jul 3, 2020
10b019b
Prototype for actions + recog's by plugin definition
DivergentEuropeans Jul 6, 2020
3c39c7a
Make idle check only happen if session is renewable
Jul 9, 2020
53e2502
Fixed get logic for recognizers & actions for config location
DivergentEuropeans Jul 9, 2020
861e8d5
Updated CHANGELOG (retroactive changes too)
DivergentEuropeans Jul 10, 2020
99b4f71
Made more accurate comment
DivergentEuropeans Jul 10, 2020
c14ae57
Update to staging
DivergentEuropeans Jul 10, 2020
1476de2
Newline/OCD
DivergentEuropeans Jul 10, 2020
e5eadf6
Added snackbar service to display pop-up for too large images
DivergentEuropeans Jul 10, 2020
409df35
Made pop-up adjust based on desktop size
DivergentEuropeans Jul 10, 2020
ea38a8f
Forgot a small thing
DivergentEuropeans Jul 10, 2020
3da4c50
Reuse Capabilities declared in zlux-platform
Jul 13, 2020
112f984
Change to use Notification framework
DivergentEuropeans Jul 13, 2020
2dd5379
Little hack for expirations that are only seen in testing
1000TurquoisePogs Jul 14, 2020
3d7d305
Add server-framework.d.ts into tsconfig.ngx-i18n.json
Jul 15, 2020
54cf1d6
& --> &&
DivergentEuropeans Jul 15, 2020
ad9440f
Remove unused styles
DivergentEuropeans Jul 15, 2020
361a4a6
Updated log messages
DivergentEuropeans Jul 20, 2020
8596376
Fixed case in which the URI broker for unixfile would allow 3 or more…
1000TurquoisePogs Jul 20, 2020
762d574
appgen fixes
1000TurquoisePogs Jul 24, 2020
a763dcb
Update package lock
1000TurquoisePogs Jul 24, 2020
91d0397
Updating app gen icon and angular template icon
1000TurquoisePogs Jul 24, 2020
040a56c
Add AutoSave Event
miteshgoplani Jul 2, 2020
20c72ad
Fix AutoSave Behavior due to WindowId
miteshgoplani Jul 4, 2020
dc1ce2f
Add AutoSave for Single View App
miteshgoplani Jul 9, 2020
d19e04a
Handle Multiple Desktop Windows
miteshgoplani Jul 10, 2020
db508ca
Retrieve data for Single Page Apps
miteshgoplani Jul 12, 2020
2362177
Clean AutoSaveData only when first save happens
miteshgoplani Jul 13, 2020
1849743
Minor Fix
miteshgoplani Jul 14, 2020
9aa12fa
Solve Data-Overwrite issue
miteshgoplani Jul 14, 2020
8fe2548
Check autosave property of plugin before deleting autosave file on wi…
miteshgoplani Jul 26, 2020
1bbd47a
Merge branch 'staging' into AutoSave
1000TurquoisePogs Jul 30, 2020
74c39c1
small cleanup
miteshgoplani Jul 30, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions bootstrap/web/iframe-adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ let messageHandler = function(message) {
let sessionExpire = new CustomEvent('ZoweZLUX.sessionEvents', {detail: {event:'sessionExpire'}});
window.dispatchEvent(sessionExpire);
return;
case 'sessionEvents.autosaveEmitter':
let autosaveEmitter = new CustomEvent('ZoweZLUX.sessionEvents', {detail: {event:'autosaveEmitter'}});
window.dispatchEvent(autosaveEmitter);
return;
default:
return;
}
Expand Down
11 changes: 11 additions & 0 deletions virtual-desktop/pluginDefinition.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,17 @@
"aggregationPolicy": "none"
}
}
},
"pluginData": {
"aggregationPolicy": "override",
"subResources": {
"app": {
"aggregationPolicy": "override"
},
"singleApp": {
"aggregationPolicy": "override"
}
}
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { StartURLManager } from '../start-url-manager';
import { StorageService } from './storage.service';
import { Subscription } from 'rxjs/Subscription';


class ClearZoweZLUX implements MVDHosting.LogoutActionInterface {
onLogout(username: string | null): boolean {
ZoweZLUX.notificationManager.removeAll()
Expand Down Expand Up @@ -161,6 +162,7 @@ export class AuthenticationManager {
const windowManager: MVDWindowManagement.WindowManagerServiceInterface =
this.injector.get(MVDWindowManagement.Tokens.WindowManagerToken);
if (reason == MVDHosting.LoginScreenChangeReason.UserLogout) {
windowManager.autoSaveFileAllowDelete = false;
windowManager.closeAllWindows();
}

Expand Down Expand Up @@ -205,6 +207,9 @@ export class AuthenticationManager {
}).catch((err:any)=> {
observer.error(err);
});

const windowManager: MVDWindowManagement.WindowManagerServiceInterface = this.injector.get(MVDWindowManagement.Tokens.WindowManagerToken);
windowManager.launchDesktopAutoSavedApplications();
});
}

Expand Down Expand Up @@ -307,6 +312,9 @@ export class AuthenticationManager {
this.injector.get(MVDWindowManagement.Tokens.WindowManagerToken);
windowManager.closeAllWindows();
}
const windowManager: MVDWindowManagement.WindowManagerServiceInterface =
this.injector.get(MVDWindowManagement.Tokens.WindowManagerToken);
windowManager.autoSaveFileAllowDelete = true;
return this.http.post(ZoweZLUX.uriBroker.serverRootUri('auth'), { username: username, password: password })
.map(result => {
let jsonMessage = result.json();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,16 @@ export class IFramePluginComponent {
});
this.themeEvents.colorChanged.subscribe(() => {
this.postWindowEvent('themeEvents.colorChanged')
})
});
this.themeEvents.sizeChanged.subscribe(() => {
this.postWindowEvent('themeEvents.sizeChanged')
})
});
this.themeEvents.wallpaperChanged.subscribe(() => {
this.postWindowEvent('themeEvents.wallpaperChanged')
})
});
this.sessionEvents.autosaveEmitter.subscribe(() => {
this.postWindowEvent('sessionEvents.saveData')
});
return;
}
if(data.request.instanceId === this.instanceId){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import { ContextMenuItem, Angular2PluginWindowActions, Angular2PluginSessionEven
import { KeybindingService } from './keybinding.service';
import { KeyCode } from './keycode-enum';
import { ThemeEmitterService } from '../services/theme-emitter.service';
import { HttpClient } from '@angular/common/http';

type PluginIdentifier = string;
const DEFAULT_DESKTOP_SHORT_TITLE = 'Zowe';
Expand Down Expand Up @@ -58,6 +59,10 @@ export class WindowManagerService implements MVDWindowManagement.WindowManagerSe
private _lastScreenshotPluginId: string = '';
private _lastScreenshotWindowId: number = -1;
public showPersonalizationPanel: boolean = false;
private autoSaveInterval : number = 60000;
public autoSaveFiles : {[key:string]:number} = {};
public autoSaveFileAllowDelete : boolean = true;
public autoSaveDataClean : boolean = false;
/*
* NOTES:
* 1. We ignore the width and height here (I am reluctant to make a new data type just for this,
Expand All @@ -81,7 +86,8 @@ export class WindowManagerService implements MVDWindowManagement.WindowManagerSe
private windowMonitor: WindowMonitor,
private componentFactoryResolver: ComponentFactoryResolver,
private appKeyboard: KeybindingService,
private themeService: ThemeEmitterService
private themeService: ThemeEmitterService,
private http: HttpClient
) {
// Workaround for AoT problem with namespaces (see angular/angular#15613)
this.applicationManager = this.injector.get(MVDHosting.Tokens.ApplicationManagerToken);
Expand Down Expand Up @@ -429,12 +435,58 @@ export class WindowManagerService implements MVDWindowManagement.WindowManagerSe
};
}

public launchDesktopAutoSavedApplications(){
this.http.get<any>(ZoweZLUX.uriBroker.pluginConfigUri(ZoweZLUX.pluginManager.getDesktopPlugin(),'pluginData/app', undefined)).subscribe(res => {
if(res){
for (let pluginWindow in res.contents){
let pluginName = pluginWindow.split('-')[0]
this.applicationManager.spawnApplication(new DesktopPluginDefinitionImpl(ZoweZLUX.pluginManager.getPlugin(pluginName)),{"data":{"type":"setAppRequest","actionType":"Launch","targetMode":"PluginCreate","appData":res.contents[pluginWindow].data.appData}})

this.autoSaveDataClean = true;
}
}
});
}

private savePluginData(plugin:ZLUX.Plugin,windowId:number,data:any){
let pathToSave : any = 'pluginData' + '/' + 'app'
let fileNameToSave : string = plugin.getIdentifier() + '-' + windowId
miteshgoplani marked this conversation as resolved.
Show resolved Hide resolved
if(this.autoSaveDataClean){
this.http.delete(ZoweZLUX.uriBroker.pluginConfigUri(ZoweZLUX.pluginManager.getDesktopPlugin(),'pluginData/app',undefined)).subscribe(()=>
this.logger.info('Deleted AutoSaveData for Desktop Plugins')
)
this.autoSaveDataClean = false;
}
if(this.autoSaveFiles[fileNameToSave] !== undefined){
this.http.put<any>(ZoweZLUX.uriBroker.pluginConfigUri(ZoweZLUX.pluginManager.getDesktopPlugin(),pathToSave,fileNameToSave+'&lastmod='+this.autoSaveFiles[fileNameToSave]), data).subscribe(res => {
this.autoSaveFiles[fileNameToSave] = res.maccessms
this.logger.info('Saved data for plugin:',plugin.getIdentifier())
})
}else{
this.http.put<any>(ZoweZLUX.uriBroker.pluginConfigUri(ZoweZLUX.pluginManager.getDesktopPlugin(),pathToSave,fileNameToSave), data).subscribe(res => {
this.autoSaveFiles[fileNameToSave] = res.maccessms
this.logger.info('Saved data for plugin:',plugin.getIdentifier())
})
}
};

private generateSessionEventsProvider(windowId: MVDWindowManagement.WindowId): Angular2PluginSessionEvents {
const login = new Subject<void>();
const sessionExpire = new Subject<void>();
const autosaveEmitter = new Subject<any>();
let desktopWin: DesktopWindow|undefined = this.windowMap.get(windowId);
if (desktopWin) {
let plugin: ZLUX.Plugin = desktopWin.plugin;
setInterval(()=> {
autosaveEmitter.next((data:any)=> {
this.savePluginData(plugin,windowId,data)
});
},this.autoSaveInterval);
}
const sessionEvents: Angular2PluginSessionEvents = {
login,
sessionExpire
sessionExpire,
autosaveEmitter
}
this.sessionSubscriptions.set(windowId, sessionEvents)
return sessionEvents
Expand Down Expand Up @@ -578,6 +630,13 @@ export class WindowManagerService implements MVDWindowManagement.WindowManagerSe
const closeViewports = ()=> {
desktopWindow.closeViewports(this.viewportManager).then(()=> {
if (appId!=null) {
let filePath : any = 'pluginData' + '/' + 'app'
let fileNameToDelete : string = desktopWindow.plugin.getIdentifier() + '-' + appId
if(this.autoSaveFileAllowDelete && desktopWindow.plugin.getWebContent().autosave == true){
this.http.delete(ZoweZLUX.uriBroker.pluginConfigUri(ZoweZLUX.pluginManager.getDesktopPlugin(),filePath,fileNameToDelete)).subscribe(()=>
this.logger.info('Deleted AutoSaveData for plugin:',desktopWindow.plugin.getIdentifier())
);
}
this.applicationManager.killApplication(desktopWindow.plugin, appId);
}
this.destroyWindow(windowId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,29 @@ import { Injectable, Injector, EventEmitter } from '@angular/core';
// import { DesktopPluginDefinition } from 'app/plugin-manager/shared/desktop-plugin-definition';
import { ViewportManager } from 'app/application-manager/viewport-manager/viewport-manager.service';
import { ContextMenuItem, Angular2InjectionTokens, Angular2PluginViewportEvents, Angular2PluginSessionEvents } from 'pluginlib/inject-resources';
//import { BaseLogger } from 'virtual-desktop-logger';
import { BaseLogger } from 'virtual-desktop-logger';
import { Subject } from 'rxjs';
import { HttpClient } from '@angular/common/http';

@Injectable()
export class SimpleWindowManagerService implements MVDWindowManagement.WindowManagerServiceInterface {
//private readonly logger: ZLUX.ComponentLogger = BaseLogger;
private readonly logger: ZLUX.ComponentLogger = BaseLogger;
private theViewportId: MVDHosting.ViewportId;
readonly windowResized: EventEmitter<{ width: number, height: number }>;
private applicationManager: MVDHosting.ApplicationManagerInterface;
private pluginDef: MVDHosting.DesktopPluginDefinition;
private authenticationManager: MVDHosting.AuthenticationManagerInterface;

contextMenuRequested: Subject<{xPos: number, yPos: number, items: ContextMenuItem[]}>;
private autoSaveInterval : number = 60000;
public autoSaveFiles : {[key:string]:number} = {};
public autoSaveFileAllowDelete : boolean = true;
public autoSaveDataClean : boolean = false;

constructor(
private viewportManager: ViewportManager,
private injector: Injector
private injector: Injector,
private http: HttpClient
) {
this.applicationManager = this.injector.get(MVDHosting.Tokens.ApplicationManagerToken);
this.authenticationManager = this.injector.get(MVDHosting.Tokens.AuthenticationManagerToken)
Expand Down Expand Up @@ -90,9 +96,30 @@ export class SimpleWindowManagerService implements MVDWindowManagement.WindowMan
return providers;
}

public launchDesktopAutoSavedApplications(){
return 1;
}

private savePluginData(plugin:ZLUX.Plugin,data:any){
let pathToSave : any = 'pluginData' + '/' + 'singleApp'
let fileNameToSave : string = plugin.getIdentifier()
if(this.autoSaveFiles[fileNameToSave] !== undefined){
this.http.put<any>(ZoweZLUX.uriBroker.pluginConfigUri(ZoweZLUX.pluginManager.getDesktopPlugin(),pathToSave,fileNameToSave+'&lastmod='+this.autoSaveFiles[fileNameToSave]), data).subscribe(res => {
this.autoSaveFiles[fileNameToSave] = res.maccessms
this.logger.info('Saved data for plugin:',plugin.getIdentifier())
})
}else{
this.http.put<any>(ZoweZLUX.uriBroker.pluginConfigUri(ZoweZLUX.pluginManager.getDesktopPlugin(),pathToSave,fileNameToSave), data).subscribe(res => {
this.autoSaveFiles[fileNameToSave] = res.maccessms
this.logger.info('Saved data for plugin:',plugin.getIdentifier())
})
}
};

private generateSessionEventsProvider(): Angular2PluginSessionEvents {
const loginSubject = new Subject<void>();
const sessionExpireSubject = new Subject<void>();
const autosaveEmitter = new Subject<any>();
miteshgoplani marked this conversation as resolved.
Show resolved Hide resolved
this.authenticationManager.loginScreenVisibilityChanged.subscribe((eventReason: MVDHosting.LoginScreenChangeReason) => {
switch (eventReason) {
case MVDHosting.LoginScreenChangeReason.UserLogin:
Expand All @@ -104,9 +131,18 @@ export class SimpleWindowManagerService implements MVDWindowManagement.WindowMan
default:
}
});
let plugin: ZLUX.Plugin = this.pluginDef.getBasePlugin();
if (plugin) {
setInterval(()=> {
autosaveEmitter.next((data:any)=> {
this.savePluginData(plugin,data)
});
},this.autoSaveInterval);
}
return {
login: loginSubject,
sessionExpire: sessionExpireSubject
sessionExpire: sessionExpireSubject,
autosaveEmitter: autosaveEmitter
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { DesktopPluginDefinitionImpl } from "app/plugin-manager/shared/desktop-p
import { SimpleWindowManagerService } from "./simple-window-manager.service";
import { ContextMenuItem } from 'pluginlib/inject-resources';
import { BaseLogger } from 'virtual-desktop-logger';
import { HttpClient } from '@angular/common/http';

@Component({
selector: 'rs-com-root',
Expand All @@ -35,6 +36,7 @@ export class SimpleComponent implements OnInit {
private applicationManager: ApplicationManager,
private pluginManager: PluginManager,
private injector: Injector,
private HTTP:HttpClient
) {
// Workaround for AoT problem with namespaces (see angular/angular#15613)
this.windowManager = this.injector.get(MVDWindowManagement.Tokens.WindowManagerToken);
Expand Down Expand Up @@ -73,12 +75,17 @@ export class SimpleComponent implements OnInit {
link.href = imageUrl;
document.getElementsByTagName('head')[0].appendChild(link);
}
const launchMetadata = {
const launchMetadata : {[key: string]: any}= {
singleAppMode: true,
arguments: this.parseUriArguments()
};
this.applicationManager.spawnApplication(plugin as DesktopPluginDefinitionImpl, launchMetadata);
this.viewportId = this.windowManager.getViewportId(1);
this.HTTP.get<any>(ZoweZLUX.uriBroker.pluginConfigUri(ZoweZLUX.pluginManager.getDesktopPlugin(),'pluginData/singleApp',plugin.getIdentifier())).subscribe(res => {
if(res){
launchMetadata["data"] = {"appData" : res.contents.appData,"type":"setAppRequest","actionType":"Launch","targetMode":"PluginCreate"}
}
this.applicationManager.spawnApplication(plugin as DesktopPluginDefinitionImpl, launchMetadata);
this.viewportId = this.windowManager.getViewportId(1);
});
} else {
let message = "Cannot find plugin with ID="+pluginID;
this.logger.severe("ZWED5144E", pluginID); //this.logger.severe(message);
Expand Down
1 change: 1 addition & 0 deletions virtual-desktop/src/pluginlib/inject-resources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export interface Angular2PluginWindowActions {
export interface Angular2PluginSessionEvents {
readonly login: Subject<void>;
readonly sessionExpire: Subject<void>;
readonly autosaveEmitter: Subject<any>;
}

export interface Angular2PluginThemeEvents {
Expand Down