From ee18b69fa2830f9c3a1901f2b7c61841cee10817 Mon Sep 17 00:00:00 2001 From: miteshgoplani Date: Thu, 2 Jul 2020 15:58:46 +0530 Subject: [PATCH 1/2] Add AutoSave Example --- webClient/src/app/app.component.ts | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/webClient/src/app/app.component.ts b/webClient/src/app/app.component.ts index c054acf..1a85697 100644 --- a/webClient/src/app/app.component.ts +++ b/webClient/src/app/app.component.ts @@ -11,7 +11,7 @@ */ import { Component, Inject, Optional } from '@angular/core'; -import { Angular2InjectionTokens, ContextMenuItem, Angular2PluginWindowActions } from 'pluginlib/inject-resources'; +import { Angular2InjectionTokens, ContextMenuItem, Angular2PluginWindowActions, Angular2PluginSessionEvents } from 'pluginlib/inject-resources'; import { ZluxPopupManagerService, ZluxErrorSeverity } from '@zlux/widgets'; @@ -56,6 +56,8 @@ export class AppComponent { serverResponseMessage: string; private menuItems: ContextMenuItem[]; + autoSaveEvent:any; + constructor( public locale: LocaleService, public translation: TranslationService, @@ -63,6 +65,7 @@ export class AppComponent { @Inject(Angular2InjectionTokens.LOGGER) private log: ZLUX.ComponentLogger, @Inject(Angular2InjectionTokens.LAUNCH_METADATA) private launchMetadata: any, @Optional() @Inject(Angular2InjectionTokens.WINDOW_ACTIONS) private windowActions: Angular2PluginWindowActions, + @Inject(Angular2InjectionTokens.SESSION_EVENTS) private sessionEvents: Angular2PluginSessionEvents, private popupManager: ZluxPopupManagerService, private helloService: HelloService, private settingsService: SettingsService) { @@ -73,6 +76,12 @@ export class AppComponent { if (this.launchMetadata != null && this.launchMetadata.data != null && this.launchMetadata.data.type != null) { this.handleLaunchOrMessageObject(this.launchMetadata.data); } + + this.autoSaveEvent = this.sessionEvents.autosaveEmitter.subscribe((saveThis: any)=> { + if (saveThis) { + saveThis({'appData':{'requestText':this.parameters,'targetAppId':this.targetAppId}}); + } + }); } handleLaunchOrMessageObject(data: any) { @@ -85,8 +94,8 @@ export class AppComponent { if (mode == 'PluginCreate' || mode == 'PluginFindAnyOrCreate') { this.actionType = actionType; this.targetMode = mode; - this.targetAppId = data.targetAppId; - this.parameters = data.requestText; + this.targetAppId = data.appData.targetAppId; + this.parameters = data.appData.requestText; } else { msg = `Invalid target mode given (${mode})`; this.log.warn(msg); @@ -353,7 +362,10 @@ export class AppComponent { } return false; } - + + ngOnDestroy(){ + this.autoSaveEvent.unsubscribe(); + } } From d5d3f7cc83835e6e845e018ca90888df28043fb0 Mon Sep 17 00:00:00 2001 From: Mitesh Date: Mon, 27 Jul 2020 02:24:37 +0530 Subject: [PATCH 2/2] Add autosave property to pluginDefinition Signed-off-by: Mitesh --- pluginDefinition.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pluginDefinition.json b/pluginDefinition.json index 6db1180..eda790a 100644 --- a/pluginDefinition.json +++ b/pluginDefinition.json @@ -16,7 +16,8 @@ "defaultWindowStyle": { "width": 850, "height": 450 - } + }, + "autosave": true }, "dataServices": [ {