Skip to content

Added code for WRC managed variables and archive entries #126

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

Merged
merged 6 commits into from
Apr 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 6 additions & 6 deletions webui/package-lock.json

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

32 changes: 27 additions & 5 deletions webui/src/js/viewModels/model-design-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
* Licensed under The Universal Permissive License (UPL), Version 1.0 as shown at https://oss.oracle.com/licenses/upl/
*/
define(['accUtils', 'utils/i18n', 'knockout', 'models/wkt-project', 'utils/url-catalog', 'utils/view-helper',
'utils/wkt-logger', 'js-yaml', 'wrc-frontend/integration/viewModels/utils', 'wdt-model-designer/loader',
'utils/wkt-logger', 'wrc-frontend/integration/viewModels/utils', 'wdt-model-designer/loader',
'ojs/ojinputtext', 'ojs/ojlabel', 'ojs/ojbutton', 'ojs/ojformlayout'],
function(accUtils, i18n, ko, project, urlCatalog, viewHelper, wktLogger, jsYaml, ViewModelUtils) {
function(accUtils, i18n, ko, project, urlCatalog, viewHelper, wktLogger, ViewModelUtils) {
function ModelDesignViewModel() {

let subscriptions = [];
Expand Down Expand Up @@ -47,6 +47,7 @@ function(accUtils, i18n, ko, project, urlCatalog, viewHelper, wktLogger, jsYaml,
if (this.designer) {
viewHelper.componentReady(this.designer).then(() => {
this.showWdtModelDesigner(port, this.designer);
this.designer.addEventListener('archiveUpdated', this.archiveUpdated);
});
}
}
Expand All @@ -62,6 +63,7 @@ function(accUtils, i18n, ko, project, urlCatalog, viewHelper, wktLogger, jsYaml,
if (this.designer) {
wktLogger.debug('disconnected() dataProvider = %s', JSON.stringify(this.dataProvider));
this.designer.deactivateProvider(this.dataProvider);
this.designer.removeEventListener('archiveUpdated', this.archiveUpdated);
}

viewHelper.removeEventListenerFromRootElement('searchModel', this.handleSearchModelEvent);
Expand Down Expand Up @@ -127,12 +129,19 @@ function(accUtils, i18n, ko, project, urlCatalog, viewHelper, wktLogger, jsYaml,

if (!providerOptions.fileContents) {
const modelTemplates = this.designer.getProperty('modelTemplate');
providerOptions.fileContents = modelTemplates.sparse;
providerOptions.fileContents = modelTemplates.domain;
}

// A name is needed to create a WDT Model File provider.
//
providerOptions['name'] = this.project.wdtModel.getDefaultModelFile();

// Set model properties provider option
providerOptions['modelProperties'] = [...this.project.wdtModel.getModelPropertiesObject().observable()];

// Set model archive provider option
providerOptions['modelArchive'] = this.project.wdtModel.archiveRoots;

return providerOptions;
};

Expand All @@ -147,8 +156,7 @@ function(accUtils, i18n, ko, project, urlCatalog, viewHelper, wktLogger, jsYaml,

const providerOptions = this.getRemoteConsoleProviderOptions();
try {
const data = jsYaml.load(providerOptions.fileContents);
wdtModelDesigner.createProvider(providerOptions.name, data);
wdtModelDesigner.createProvider(providerOptions);
} catch (err) {
ViewModelUtils.failureResponseDefaultHandling(err);
}
Expand All @@ -168,6 +176,20 @@ function(accUtils, i18n, ko, project, urlCatalog, viewHelper, wktLogger, jsYaml,
wktLogger.debug('Received changesAutoDownloaded event with modelContent = %s', event.detail.value);
this.wrcBackendTriggerChange = true;
this.project.wdtModel.modelContent(event.detail.value);
if (event.detail.properties) this.project.wdtModel.getModelPropertiesObject().observable(event.detail.properties);
};

this.archiveUpdated = (event) => {
const options = event.detail.options;
wktLogger.debug('Received archiveUpdated event with options = %s', JSON.stringify(event.detail.options));
switch (options.operation) {
case 'add':
this.project.wdtModel.addArchiveUpdate(options.operation, options.archivePath, options.filePath);
break;
case 'remove':
this.project.wdtModel.addArchiveUpdate(options.operation, options.path);
break;
}
};

// Triggered when WDT Model File provider has been deactivated with the WRC backend.
Expand Down
4 changes: 2 additions & 2 deletions webui/src/js/viewModels/model-page-impl.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ define([],
// Setup for Design / Code tab selection.

let navData = [
{path: '', redirect: 'model-code-view'},
{path: '', redirect: 'model-design-view'},
{path: 'model-design-view', detail: {label: i18n.t('page-design-view')}},
{path: 'model-code-view', detail: {label: i18n.t('page-code-view')}}
];
Expand All @@ -33,7 +33,7 @@ define([],
preparer.startPrepareModel().then();
};

this.selectedItem = ko.observable('model-code-view');
this.selectedItem = ko.observable('model-design-view');
this.inDesignView = ko.computed(() => {
return this.selectedItem() === 'model-design-view';
});
Expand Down