123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313 |
- "use strict";
- /**
- * Licensed Materials - Property of IBM
- *
- * IBM Cognos Products: ADMIN
- *
- * Copyright IBM Corp. 2017, 2022
- *
- * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
- */
- define(['jquery', 'underscore', 'bi/glass/app/ContentView', 'bi/admin/nls/StringResource', 'react', 'react-dom', 'ba-react-admin/ba-react-admin.min', 'bacontentnav/ui/dialogs/OpenDialog', 'bi/admin/account/slideout/SecurityObjectSelectorPane', 'bi/content_apps/PromptValuesView'], function ($, _, ContentView, StringResource, React, ReactDOM, AdminReact, OpenDialog, SecurityObjectSelectorPane, PromptValuesView) {
- var view = ContentView.extend({
- selectableItems: _.keys(AdminReact.JobStepObjects),
- init: function init(options) {
- view.inherited('init', this, arguments);
- this.objectInfo = {};
- if (this.objRef) {
- this.objectInfo.id = this.objRef;
- }
- $.extend(this, options);
- },
- updateContent: function updateContent(options) {
- if (AdminReact.JobUIStore.isOpen) {
- if (options) {
- AdminReact.JobObjectStore.updateWithNewContent(this.glassContext, options);
- if (options.objectInfo && options.objectInfo.id) {
- this.objectInfo.id = options.objectInfo.id;
- }
- this.trigger("change:state");
- }
- }
- },
- deactivate: function deactivate() {
- return Promise.resolve();
- },
- activate: function activate(options) {
- if (options.setFocus) {
- return Promise.resolve();
- }
- AdminReact.JobObjectStore.updateWithNewContent(this.glassContext, options);
- if (options.objectInfo && options.objectInfo.id) {
- this.objectInfo.id = options.objectInfo.id;
- }
- this.trigger("change:state");
- return Promise.resolve();
- },
- getTitle: function getTitle() {
- var jobStore = AdminReact.JobObjectStore;
- if (jobStore.isNew) {
- return StringResource.get("newJob");
- } else {
- return jobStore.defaultName;
- }
- },
- getContent: function getContent() {
- if (AdminReact.JobObjectStore.isNew) {
- return {
- objRef: ""
- };
- }
- if (this.objectInfo && this.objectInfo.id) {
- return {
- objRef: this.objectInfo.id
- };
- }
- },
- isDirty: function isDirty() {
- var jobStore = AdminReact.JobObjectStore;
- if (jobStore.isNew) {
- return true;
- } else {
- return jobStore.isDirty;
- }
- },
- getIcon: function getIcon() {
- return 'common-open-tab';
- },
- setTitle: function setTitle() {
- this.trigger("change:title", {
- value: this.getTitle()
- });
- },
- updateAfterSave: function updateAfterSave() {
- this.setTitle();
- this.trigger("change:dirty");
- this.objectInfo.id = AdminReact.JobObjectStore.id;
- this.trigger("change:state");
- },
- renderAccountSelector: function renderAccountSelector(rootEl) {
- var anEl = $(rootEl);
- var defaultTypes = ['account'];
- var aPane = new SecurityObjectSelectorPane({
- glassContext: this.glassContext,
- 'parentView': this,
- 'objectInfo': [{}],
- 'allowedSelectionTypes': defaultTypes,
- 'targetType': [],
- '$el': anEl
- });
- aPane.renderBody(anEl);
- },
- _openScheduleSlideout: function _openScheduleSlideout(objectInformation) {
- var objIn = JSON.parse(JSON.stringify(objectInformation));
- this.glassContext.appController.showSlideOut({
- content: {
- module: 'bi/schedule/views/SchedulesView',
- glassContext: this.glassContext,
- objectInfo: objIn
- },
- width: '390px',
- enableTabLooping: true,
- label: "Schedule",
- position: 'left'
- });
- },
- _showOptionsSlideout: function _showOptionsSlideout(objectInformation, selectedStep) {
- this.glassContext.appController.showSlideOut({
- content: {
- module: 'bi/admin/job/RunOptionsView',
- glassContext: this.glassContext,
- objectInformation: objectInformation,
- selectedStep: selectedStep
- },
- width: '390px',
- enableTabLooping: true,
- label: StringResource.get("options"),
- position: 'left',
- onHide: function onHide() {
- this.contentView.onHide();
- }
- });
- },
- openRelinkDialog: function openRelinkDialog() {
- var dialog = new OpenDialog({
- glassContext: this.glassContext,
- typesToOpen: this.selectableItems,
- multiSelect: false,
- primaryBtnText: StringResource.get('ok'),
- onOpenCallback: AdminReact.JobUIStore.relinkDialogClosed.bind(AdminReact.JobUIStore, this.glassContext),
- dataManipulationCallback: this._filterOutNoExecute.bind(this),
- extraUrlParameters: ['options']
- });
- dialog.title = StringResource.get('relinkAsset');
- dialog.primaryBtnText = StringResource.get('ok');
- dialog.open();
- },
- openOptionsSlideout: function openOptionsSlideout(selectedStep, descriptor) {
- var runnable = selectedStep;
- if (selectedStep.stepObject && selectedStep.stepObject.length > 0) {
- runnable = selectedStep.stepObject[0];
- }
- if (runnable.type === 'reportView') {
- AdminReact.JobAccess.getPropertiesForReportView(this.glassContext, runnable.id).then(function (result) {
- var objectInformation = result.data.data[0];
- objectInformation.descriptor = descriptor;
- this._showOptionsSlideout(objectInformation, selectedStep);
- }.bind(this));
- } else {
- this._showOptionsSlideout({
- id: runnable.id,
- type: runnable.type,
- canBurst: selectedStep.canBurst,
- descriptor: descriptor
- }, selectedStep);
- }
- },
- openDeploymentSelection: function openDeploymentSelection(addFunction) {
- var jobAccess = AdminReact.JobAccess;
- jobAccess.getAdminFolderID(this.glassContext).then(function (adminFolderID) {
- var rootObject = {
- id: adminFolderID,
- defaultName: 'Directory',
- type: 'adminFolder',
- _meta: {
- links: {
- items: {
- mimeType: 'application/json',
- url: 'v1/objects/' + adminFolderID + '/items'
- },
- self: {
- mimeType: 'application/json',
- url: 'v1/objects/' + adminFolderID
- }
- }
- }
- };
- var dialog = new OpenDialog({
- glassContext: this.glassContext,
- typesToOpen: ['importDeployment', 'exportDeployment'],
- multiSelect: true,
- ancestors: [rootObject],
- rootObjects: [rootObject],
- onOpenCallback: addFunction,
- extraUrlParameters: ['options']
- });
- dialog.title = StringResource.get("addJobSteps");
- dialog.primaryBtnText = StringResource.get("jobStepsToAdd");
- dialog.open();
- }.bind(this));
- },
- renderPromptSelector: function renderPromptSelector(rootEl, obj) {
- var anEl = $(rootEl);
- this.objectInfo = {
- id: obj.stepObject[0].id,
- type: obj.type
- };
- var anEl = $(rootEl);
- var defaultTypes = ['account'];
- var aPane = new PromptValuesView({
- glassContext: this.glassContext,
- 'parentView': this,
- 'promptDisplayValues': [],
- 'parameters': [],
- 'objectInformation': {
- id: obj.id,
- type: obj.type
- },
- 'hasPermission': true,
- 'clearCallback': function clearCallback() {
- console.log('weeeeee');
- },
- 'editCallback': function editCallback() {
- console.log('weeeeee');
- },
- '$el': anEl,
- slideout: this
- });
- aPane.render();
- },
- _filterOutNoExecute: function _filterOutNoExecute(response) {
- response.data = _.filter(response.data, function (result) {
- if (this.selectableItems.indexOf(result.type) === -1) {
- return true;
- }
- return result.permissions.indexOf("execute") !== -1;
- }.bind(this));
- },
- openContentSelection: function openContentSelection(addFunction) {
- var dialog = new OpenDialog({
- glassContext: this.glassContext,
- typesToOpen: this.selectableItems,
- multiSelect: true,
- primaryBtnText: StringResource.get("addJobSteps"),
- filesToOpenTitle: StringResource.get("jobStepsToAdd"),
- onOpenCallback: addFunction,
- dataManipulationCallback: this._filterOutNoExecute.bind(this),
- extraUrlParameters: ['options']
- });
- dialog.title = StringResource.get("addJobSteps");
- dialog.primaryBtnText = StringResource.get("jobStepsToAdd");
- dialog.open();
- },
- remove: function remove() {
- AdminReact.JobUIStore.setIsOpen(false);
- view.inherited('remove', this, arguments);
- ReactDOM.unmountComponentAtNode(this.$el[0]);
- },
- render: function render() {
- AdminReact.JobUIStore.setIsOpen(true);
- this.$el.addClass("jobmgt");
- this.$el.css("width", "100%");
- this.$el.css("height", "100%");
- ReactDOM.unmountComponentAtNode(this.$el[0]);
- var jobPane = React.createElement(AdminReact.JobPane, {
- glassContext: this.glassContext,
- StringResource: StringResource,
- objectInfo: this.objectInfo,
- dialog: this,
- selectedJobSteps: this.selectedSteps
- });
- AdminReact.JobObjectStore.setOptionDefault(this.glassContext);
- ReactDOM.render(jobPane, this.$el[0]);
- return Promise.resolve();
- }
- });
- view.openJobPane = function (glassContext, content) {
- var perspective = glassContext.appController.currentAppView.perspective;
- var context = {
- id: "123",
- content: content
- };
- if (perspective === 'job_mgt' && content.setFocus) return;
- if (content.addToJob === true) {
- glassContext.appController.openAppView('job_mgt', context);
- return;
- }
- glassContext.appController.closeAppView('job_mgt', '123').then(function () {
- setTimeout(function () {
- glassContext.appController.openAppView('job_mgt', context);
- }, 1);
- });
- };
- return view;
- });
|