Skip to content

Commit

Permalink
PoC for Mobile App: Revert back app files
Browse files Browse the repository at this point in the history
Signed-off-by: Leonty Chudinov <[email protected]>
  • Loading branch information
Leonty Chudinov committed Jun 22, 2020
1 parent 62d0a15 commit d23b61d
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 43 deletions.
67 changes: 28 additions & 39 deletions webClient/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ export class AppComponent {
} catch (e) {
//this.parameters was not JSON
}
if (this.targetAppId) {
let message = '';
/*
With ZLUX, there's a global called ZoweZLUX which holds useful tools. So, a site
Expand All @@ -201,49 +202,37 @@ export class AppComponent {
*/
let dispatcher = ZoweZLUX.dispatcher;
let pluginManager = ZoweZLUX.pluginManager;
if (this.targetAppId) {
const plugin = pluginManager.getPlugin(this.targetAppId);
if (!plugin) {
this.popupManager.reportError(
ZluxErrorSeverity.WARNING,
this.translation.translate('invalid_plugin_identifier'),
`${this.translation.translate('no_plugin_found_for_identifier')} ${this.targetAppId}`, popupOptions);
let plugin = pluginManager.getPlugin(this.targetAppId);
if (plugin) {
let type = dispatcher.constants.ActionType[this.actionType];
let mode = dispatcher.constants.ActionTargetMode[this.targetMode];

if (type != undefined && mode != undefined) {
let actionTitle = 'Launch app from sample app';
let actionID = 'org.zowe.zlux.sample.launch';
let argumentFormatter = {data: {op:'deref',source:'event',path:['data']}};
/*Actions can be made ahead of time, stored and registered at startup, but for example purposes we are making one on-the-fly.
Actions are also typically associated with Recognizers, which execute an Action when a certain pattern is seen in the running App.
*/
let action = dispatcher.makeAction(actionID, actionTitle, mode,type,this.targetAppId,argumentFormatter);
let argumentData = {'data':(parameters ? parameters : this.parameters)};
this.log.info((message = this.translation.translate('request_succeeded'))); // App request succeeded
this.callStatus = message;
/*Just because the Action is invoked does not mean the target App will accept it. We've made an Action on the fly,
So the data could be in any shape under the "data" attribute and it is up to the target App to take action or ignore this request*/
dispatcher.invokeAction(action,argumentData);
} else {
this.log.warn((message = 'Invalid target mode or action type specified'));
}
}
let type = dispatcher.constants.ActionType[this.actionType];
let mode = dispatcher.constants.ActionTargetMode[this.targetMode];
if (type != undefined && mode != undefined) {
let actionTitle = 'Launch app from sample app';
let actionID = 'org.zowe.zlux.sample.launch';
let argumentFormatter = {data: {op:'deref',source:'event',path:['data']}};
/*Actions can be made ahead of time, stored and registered at startup, but for example purposes we are making one on-the-fly.
Actions are also typically associated with Recognizers, which execute an Action when a certain pattern is seen in the running App.
*/
let action = dispatcher.makeAction(actionID, actionTitle, mode,type,this.targetAppId,argumentFormatter);
let argumentData = this.targetAppId ? {'data':(parameters ? parameters : this.parameters)} : (parameters ? parameters : this.parameters);
this.log.info((message = this.translation.translate('request_succeeded'))); // App request succeeded
this.callStatus = message;
/*Just because the Action is invoked does not mean the target App will accept it. We've made an Action on the fly,
So the data could be in any shape under the "data" attribute and it is up to the target App to take action or ignore this request*/
dispatcher.invokeAction(action,argumentData).catch(
e => {
let message: string;
if (typeof e === 'string') {
message = e;
} else if (e instanceof Error) {
message = e.message;
} else {
message = JSON.stringify(e);
}
this.popupManager.reportError(
ZluxErrorSeverity.WARNING, 'Unable to launch app', message, popupOptions
);
}
);
} else {
this.log.warn((message = 'Invalid target mode or action type specified'));
this.popupManager.reportError(
ZluxErrorSeverity.WARNING,
this.translation.translate('invalid_plugin_identifier'), //
`${this.translation.translate('no_plugin_found_for_identifier')} ${this.targetAppId}`, popupOptions);
}

this.callStatus = message;
}
}

generateTestMenuItems(translator: TranslationService): void {
Expand Down
5 changes: 1 addition & 4 deletions webClient/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
{
"extends": "../../zlux-app-manager/virtual-desktop/plugin-config/tsconfig.strict.json",
"include": [
"./src/**/*.ts"
]
"extends": "../../zlux-app-manager/virtual-desktop/plugin-config/tsconfig.strict.json"
}

0 comments on commit d23b61d

Please sign in to comment.