Repository: nifi Updated Branches: refs/heads/master 8d4fe38bb -> b6117743d
http://git-wip-us.apache.org/repos/asf/nifi/blob/696d583b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/partials/canvas/new-remote-process-group-dialog.jsp ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/partials/canvas/new-remote-process-group-dialog.jsp b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/partials/canvas/new-remote-process-group-dialog.jsp index 4948001..524a824 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/partials/canvas/new-remote-process-group-dialog.jsp +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/partials/canvas/new-remote-process-group-dialog.jsp @@ -22,7 +22,7 @@ <div class="fa fa-question-circle" alt="Info" title="Specify the remote target NiFi URLs. Multiple URLs can be specified in comma-separated format. Different protocols cannot be mixed. If remote NiFi is a cluster, two or more node URLs are recommended for better connection establishment availability."></div> </div> <div class="setting-field"> - <input id="new-remote-process-group-uris" type="text" placeholder="https://remotehost:8080/nifi"/> + <input id="new-remote-process-group-uris" type="text" placeholder="https://remotehost:8443/nifi"/> </div> </div> <div class="setting"> http://git-wip-us.apache.org/repos/asf/nifi/blob/696d583b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/partials/canvas/registry-configuration-dialog.jsp ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/partials/canvas/registry-configuration-dialog.jsp b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/partials/canvas/registry-configuration-dialog.jsp index 7fa90f7..56a5fd8 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/partials/canvas/registry-configuration-dialog.jsp +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/partials/canvas/registry-configuration-dialog.jsp @@ -25,9 +25,9 @@ </div> </div> <div class="setting"> - <div class="setting-name">Location</div> + <div class="setting-name">URL</div> <div class="setting-field"> - <input type="text" id="registry-location" class="setting-input"/> + <input type="text" id="registry-location" class="setting-input" placeholder="https://remotehost:8443"/> </div> </div> <div class="setting"> http://git-wip-us.apache.org/repos/asf/nifi/blob/696d583b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/partials/canvas/save-flow-version-dialog.jsp ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/partials/canvas/save-flow-version-dialog.jsp b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/partials/canvas/save-flow-version-dialog.jsp index dfed409..5e653d2 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/partials/canvas/save-flow-version-dialog.jsp +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/partials/canvas/save-flow-version-dialog.jsp @@ -20,34 +20,36 @@ <div class="setting"> <div class="setting-name">Registry</div> <div class="setting-field"> - <div id="flow-version-registry-combo"></div> - <div id="flow-version-registry" class="hidden"></div> + <div id="save-flow-version-registry-combo" class="hidden"></div> + <div id="save-flow-version-registry" class="hidden"></div> </div> </div> <div class="setting"> <div class="setting-name">Location</div> <div class="setting-field"> - <div id="flow-version-bucket-combo"></div> - <div id="flow-version-bucket" class="hidden"></div> + <div id="save-flow-version-bucket-combo" class="hidden"></div> + <div id="save-flow-version-bucket" class="hidden"></div> </div> </div> <div class="setting"> <div class="setting-name">Name</div> <div class="setting-field"> - <span id="flow-version-process-group-id" class="hidden"></span> - <input type="text" id="flow-version-name" class="setting-input"/> + <span id="save-flow-version-process-group-id" class="hidden"></span> + <input type="text" id="save-flow-version-name-field" class="setting-input hidden"/> + <div id="save-flow-version-name" class="hidden"></div> </div> </div> <div class="setting"> <div class="setting-name">Description</div> <div class="setting-field"> - <textarea id="flow-version-description" class="setting-input"></textarea> + <textarea id="save-flow-version-description-field" class="setting-input hidden"></textarea> + <div id="save-flow-version-description" class="hidden"></div> </div> </div> <div class="setting"> - <div class="setting-name">Change Comments</div> + <div class="setting-name">Comments</div> <div class="setting-field"> - <textarea id="flow-version-change-comments" class="setting-input"></textarea> + <textarea id="save-flow-version-change-comments" class="setting-input"></textarea> </div> </div> </div> http://git-wip-us.apache.org/repos/asf/nifi/blob/696d583b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/css/dialog.css ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/css/dialog.css b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/css/dialog.css index 1c44e71..f8f5177 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/css/dialog.css +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/css/dialog.css @@ -213,14 +213,28 @@ div.progress-label { } /* - Flow Version + Save Flow Version */ -#flow-version-description, #flow-version-change-comments { +#save-flow-version-description-field, #save-flow-version-change-comments { height: 85px; } /* + Import Flow Version + */ + +#import-flow-version-table { + overflow: hidden; + position: absolute; + top: 202px; + left: 0px; + right: 0px; + bottom: 0px; + height: 225px; +} + +/* Variable Registry */ http://git-wip-us.apache.org/repos/asf/nifi/blob/696d583b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/header/components/nf-ng-group-component.js ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/header/components/nf-ng-group-component.js b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/header/components/nf-ng-group-component.js index fcd4aba..ae9e228 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/header/components/nf-ng-group-component.js +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/header/components/nf-ng-group-component.js @@ -24,9 +24,10 @@ 'nf.Birdseye', 'nf.Graph', 'nf.CanvasUtils', - 'nf.ErrorHandler'], - function ($, nfClient, nfBirdseye, nfGraph, nfCanvasUtils, nfErrorHandler) { - return (nf.ng.GroupComponent = factory($, nfClient, nfBirdseye, nfGraph, nfCanvasUtils, nfErrorHandler)); + 'nf.ErrorHandler', + 'nf.Common'], + function ($, nfClient, nfBirdseye, nfGraph, nfCanvasUtils, nfErrorHandler, nfCommon) { + return (nf.ng.GroupComponent = factory($, nfClient, nfBirdseye, nfGraph, nfCanvasUtils, nfErrorHandler, nfCommon)); }); } else if (typeof exports === 'object' && typeof module === 'object') { module.exports = (nf.ng.GroupComponent = @@ -35,16 +36,18 @@ require('nf.Birdseye'), require('nf.Graph'), require('nf.CanvasUtils'), - require('nf.ErrorHandler'))); + require('nf.ErrorHandler'), + require('nf.Common'))); } else { nf.ng.GroupComponent = factory(root.$, root.nf.Client, root.nf.Birdseye, root.nf.Graph, root.nf.CanvasUtils, - root.nf.ErrorHandler); + root.nf.ErrorHandler, + root.nf.Common); } -}(this, function ($, nfClient, nfBirdseye, nfGraph, nfCanvasUtils, nfErrorHandler) { +}(this, function ($, nfClient, nfBirdseye, nfGraph, nfCanvasUtils, nfErrorHandler, nfCommon) { 'use strict'; return function (serviceProvider) { @@ -126,6 +129,7 @@ handler: { close: function () { $('#new-process-group-name').val(''); + $('#new-process-group-dialog').removeData('pt'); } } }); @@ -145,10 +149,25 @@ * Show the modal. */ show: function () { + if (nfCommon.canVersionFlows()) { + $('#import-process-group-link').show(); + } else { + $('#import-process-group-link').hide(); + } + this.getElement().modal('show'); }, /** + * Stores the pt. + * + * @param pt + */ + storePt: function (pt) { + $('#new-process-group-dialog').data('pt', pt); + }, + + /** * Hide the modal. */ hide: function () { @@ -255,6 +274,7 @@ }]); // show the dialog + groupComponent.modal.storePt(pt); groupComponent.modal.show(); // set up the focus and key handlers http://git-wip-us.apache.org/repos/asf/nifi/blob/696d583b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-actions.js ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-actions.js b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-actions.js index ff09330..9dc20b1 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-actions.js +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-actions.js @@ -1254,14 +1254,14 @@ }, /** - * Reverts outstanding changes. + * Reverts local changes. */ - revertFlowChanges: function (selection) { + revertLocalChanges: function (selection) { if (selection.empty()) { - nfFlowVersion.revertFlowChanges(nfCanvasUtils.getGroupId()); + nfFlowVersion.revertLocalChanges(nfCanvasUtils.getGroupId()); } else if (selection.size() === 1) { var selectionData = selection.datum(); - nfFlowVersion.revertFlowChanges(selectionData.id); + nfFlowVersion.revertLocalChanges(selectionData.id); } }, @@ -1269,18 +1269,25 @@ * Changes the flow version. */ changeFlowVersion: function (selection) { - + if (selection.empty()) { + nfFlowVersion.showChangeFlowVersionDialog(nfCanvasUtils.getGroupId()); + } else if (selection.size() === 1) { + var selectionData = selection.datum(); + if (nfCanvasUtils.isProcessGroup(selection)) { + nfFlowVersion.showChangeFlowVersionDialog(selectionData.id); + } + } }, /** * Disconnects a Process Group from flow versioning. */ - disconnectFlowVersioning: function (selection) { + stopVersionControl: function (selection) { if (selection.empty()) { - nfFlowVersion.disconnectFlowVersioning(nfCanvasUtils.getGroupId()); + nfFlowVersion.stopVersionControl(nfCanvasUtils.getGroupId()); } else if (selection.size() === 1) { var selectionData = selection.datum(); - nfFlowVersion.disconnectFlowVersioning(selectionData.id); + nfFlowVersion.stopVersionControl(selectionData.id); } }, http://git-wip-us.apache.org/repos/asf/nifi/blob/696d583b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-canvas-bootstrap.js ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-canvas-bootstrap.js b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-canvas-bootstrap.js index 6e17b27..536f87b 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-canvas-bootstrap.js +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-canvas-bootstrap.js @@ -337,7 +337,6 @@ nfCanvas.setManagedAuthorizer(configDetails.supportsManagedAuthorizer); nfCanvas.setConfigurableAuthorizer(configDetails.supportsConfigurableAuthorizer); nfCanvas.setConfigurableUsersAndGroups(configDetails.supportsConfigurableUsersAndGroups); - nfCanvas.setSupportsFlowVersioning(configDetails.supportsFlowVersioning); // init nfStorage nfStorage.init(); @@ -356,7 +355,7 @@ nfQueueListing.init(); nfVariableRegistry.init(); nfComponentState.init(); - nfFlowVersion.init(); + nfFlowVersion.init(configDetails.timeOffset); nfComponentVersion.init(nfSettings); // initialize the component behaviors http://git-wip-us.apache.org/repos/asf/nifi/blob/696d583b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-canvas-utils.js ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-canvas-utils.js b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-canvas-utils.js index 9506fef..213b572 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-canvas-utils.js +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-canvas-utils.js @@ -1820,13 +1820,6 @@ }, /** - * Returns whether this NiFi supports flow versioning. - */ - supportsFlowVersioning: function () { - return nfCanvas.supportsFlowVersioning(); - }, - - /** * Returns whether the authorizer is managed. */ isManagedAuthorizer: function () { http://git-wip-us.apache.org/repos/asf/nifi/blob/696d583b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-canvas.js ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-canvas.js b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-canvas.js index d0ad4ee..49ded8c 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-canvas.js +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-canvas.js @@ -85,7 +85,6 @@ var permissions = null; var parentGroupId = null; var managedAuthorizer = false; - var supportsFlowVersioning = false; var configurableAuthorizer = false; var configurableUsersAndGroups = false; var svg = null; @@ -910,23 +909,6 @@ }, /** - * Set whether this NiFi supports flow versioning. - * - * @param bool Whether this NiFi supports flow versioning - */ - setSupportsFlowVersioning: function (bool) { - supportsFlowVersioning = bool; - }, - - /** - * - * @returns {boolean} - */ - supportsFlowVersioning: function () { - return supportsFlowVersioning; - }, - - /** * Set whether the authorizer is configurable. * * @param bool The boolean value representing whether the authorizer is configurable. http://git-wip-us.apache.org/repos/asf/nifi/blob/696d583b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-context-menu.js ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-context-menu.js b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-context-menu.js index f128086..8656035 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-context-menu.js +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-context-menu.js @@ -375,11 +375,17 @@ * @param selection */ var supportsFlowVersioning = function (selection) { - if (nfCanvasUtils.supportsFlowVersioning() === false) { + if (nfCommon.canVersionFlows() === false) { return false; } if (selection.empty()) { + // prevent versioning of the root group + if (nfCanvasUtils.getParentGroupId() === null) { + return false; + } + + // if not root group, ensure adequate permissions return nfCanvasUtils.canReadCurrentGroup() && nfCanvasUtils.canWriteCurrentGroup(); } @@ -632,13 +638,13 @@ {id: 'variable-registry-menu-item', condition: hasVariables, menuItem: {clazz: 'fa', text: 'Variables', action: 'openVariableRegistry'}}, {separator: true}, {id: 'version-menu-item', groupMenuItem: {clazz: 'fa', text: 'Version'}, menuItems: [ - {id: 'start-version-control-menu-item', condition: supportsStartFlowVersioning, menuItem: {clazz: 'fa fa-floppy-o', text: 'Start version control', action: 'saveFlowVersion'}}, + {id: 'start-version-control-menu-item', condition: supportsStartFlowVersioning, menuItem: {clazz: 'fa fa-upload', text: 'Start version control', action: 'saveFlowVersion'}}, {separator: true}, - {id: 'commit-menu-item', condition: supportsStopFlowVersioning, menuItem: {clazz: 'fa fa-floppy-o', text: 'Commit local changes', action: 'saveFlowVersion'}}, - {id: 'revert-menu-item', condition: supportsStopFlowVersioning, menuItem: {clazz: 'fa', text: 'Revert local changes', action: 'revertFlowChanges'}}, + {id: 'commit-menu-item', condition: supportsStopFlowVersioning, menuItem: {clazz: 'fa fa-upload', text: 'Commit local changes', action: 'saveFlowVersion'}}, + {id: 'revert-menu-item', condition: supportsStopFlowVersioning, menuItem: {clazz: 'fa fa-undo', text: 'Revert local changes', action: 'revertLocalChanges'}}, {id: 'change-version-menu-item', condition: supportsStopFlowVersioning, menuItem: {clazz: 'fa', text: 'Change version', action: 'changeFlowVersion'}}, {separator: true}, - {id: 'stop-version-control-menu-item', condition: supportsStopFlowVersioning, menuItem: {clazz: 'fa', text: 'Stop version control', action: 'disconnectFlowVersioning'}} + {id: 'stop-version-control-menu-item', condition: supportsStopFlowVersioning, menuItem: {clazz: 'fa', text: 'Stop version control', action: 'stopVersionControl'}} ]}, {separator: true}, {id: 'enter-group-menu-item', condition: isProcessGroup, menuItem: {clazz: 'fa fa-sign-in', text: 'Enter group', action: 'enterGroup'}}, http://git-wip-us.apache.org/repos/asf/nifi/blob/696d583b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-flow-version.js ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-flow-version.js b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-flow-version.js index 6315d30..1652624 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-flow-version.js +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-flow-version.js @@ -30,9 +30,10 @@ 'nf.Client', 'nf.CanvasUtils', 'nf.ProcessGroup', - 'nf.Graph'], - function ($, nfNgBridge, nfErrorHandler, nfDialog, nfCommon, nfClient, nfCanvasUtils, nfProcessGroup, nfGraph) { - return (nf.FlowVersion = factory($, nfNgBridge, nfErrorHandler, nfDialog, nfCommon, nfClient, nfCanvasUtils, nfProcessGroup, nfGraph)); + 'nf.Graph', + 'nf.Birdseye'], + function ($, nfNgBridge, nfErrorHandler, nfDialog, nfCommon, nfClient, nfCanvasUtils, nfProcessGroup, nfGraph, nfBirdseye) { + return (nf.FlowVersion = factory($, nfNgBridge, nfErrorHandler, nfDialog, nfCommon, nfClient, nfCanvasUtils, nfProcessGroup, nfGraph, nfBirdseye)); }); } else if (typeof exports === 'object' && typeof module === 'object') { module.exports = (nf.FlowVerison = @@ -44,7 +45,8 @@ require('nf.Client'), require('nf.CanvasUtils'), require('nf.ProcessGroup'), - require('nf.Graph'))); + require('nf.Graph'), + require('nf.Birdseye'))); } else { nf.FlowVersion = factory(root.$, root.nf.ng.Bridge, @@ -54,35 +56,121 @@ root.nf.Client, root.nf.CanvasUtils, root.nf.ProcessGroup, - root.nf.Graph); + root.nf.Graph, + root.nf.Birdseye); } -}(this, function ($, nfNgBridge, nfErrorHandler, nfDialog, nfCommon, nfClient, nfCanvasUtils, nfProcessGroup, nfGraph) { +}(this, function ($, nfNgBridge, nfErrorHandler, nfDialog, nfCommon, nfClient, nfCanvasUtils, nfProcessGroup, nfGraph, nfBirdseye) { 'use strict'; + var serverTimeOffset = null; + + var gridOptions = { + forceFitColumns: true, + enableTextSelectionOnCells: true, + enableCellNavigation: true, + enableColumnReorder: false, + autoEdit: false, + multiSelect: false, + rowHeight: 24 + }; + + /** + * Reset the save flow version dialog. + */ + var resetSaveFlowVersionDialog = function () { + $('#save-flow-version-registry-combo').combo('destroy').hide(); + $('#save-flow-version-bucket-combo').combo('destroy').hide(); + + $('#save-flow-version-registry').text('').hide(); + $('#save-flow-version-bucket').text('').hide(); + + $('#save-flow-version-name').text('').hide(); + $('#save-flow-version-description').text('').hide(); + + $('#save-flow-version-name-field').val('').hide(); + $('#save-flow-version-description-field').val('').hide(); + $('#save-flow-version-change-comments').val(''); + + $('#save-flow-version-process-group-id').removeData('versionControlInformation').removeData('revision').text(''); + }; + /** - * Reset the dialog. + * Reset the import flow version dialog. */ - var resetDialog = function () { - $('#flow-version-registry-combo').combo('destroy').hide(); - $('#flow-version-bucket-combo').combo('destroy').hide(); + var resetImportFlowVersionDialog = function () { + $('#import-flow-version-registry-combo').combo('destroy').hide(); + $('#import-flow-version-bucket-combo').combo('destroy').hide(); + $('#import-flow-version-name-combo').combo('destroy').hide(); - $('#flow-version-registry').text('').hide(); - $('#flow-version-bucket').text('').hide(); + $('#import-flow-version-registry').text('').hide(); + $('#import-flow-version-bucket').text('').hide(); + $('#import-flow-version-name').text('').hide(); - $('#flow-version-name').val(''); - $('#flow-version-description').val(''); - $('#flow-version-change-comments').val(''); + var importFlowVersionGrid = $('#import-flow-version-table').data('gridInstance'); + if (nfCommon.isDefinedAndNotNull(importFlowVersionGrid)) { + var importFlowVersionData = importFlowVersionGrid.getData(); + importFlowVersionData.setItems([]); + } - $('#flow-version-process-group-id').removeData('versionControlInformation').removeData('revision').text(''); + $('#import-flow-version-process-group-id').removeData('versionControlInformation').removeData('revision').text(''); + }; + + /** + * Loads the registries into the specified registry combo. + * + * @param dialog + * @param registryCombo + * @param bucketCombo + * @returns {deferred} + */ + var loadRegistries = function (dialog, registryCombo, bucketCombo, selectBucket) { + return $.ajax({ + type: 'GET', + url: '../nifi-api/flow/registries', + dataType: 'json' + }).done(function (registriesResponse) { + var registries = []; + + if (nfCommon.isDefinedAndNotNull(registriesResponse.registries) && registriesResponse.registries.length > 0) { + registriesResponse.registries.sort(function (a, b) { + return a.component.name > b.component.name; + }); + + $.each(registriesResponse.registries, function (_, registryEntity) { + var registry = registryEntity.component; + registries.push({ + text: registry.name, + value: registry.id, + description: nfCommon.escapeHtml(registry.description) + }); + }); + } else { + registries.push({ + text: 'No available registries', + value: null, + optionClass: 'unset', + disabled: true + }); + } + + // load the registries + registryCombo.combo({ + options: registries, + select: function (selectedOption) { + selectRegistry(dialog, selectedOption, bucketCombo, selectBucket) + } + }); + }).fail(nfErrorHandler.handleAjaxError); }; /** * Loads the buckets for the specified registryIdentifier for the current user. * * @param registryIdentifier + * @param bucketCombo * @returns {*} */ - var loadBuckets = function (registryIdentifier) { + var loadBuckets = function (registryIdentifier, bucketCombo, selectBucket) { return $.ajax({ type: 'GET', url: '../nifi-api/flow/registries/' + encodeURIComponent(registryIdentifier) + '/buckets', @@ -113,23 +201,24 @@ } // load the buckets - $('#flow-version-bucket-combo').combo('destroy').combo({ + bucketCombo.combo('destroy').combo({ options: buckets, select: selectBucket }); - }).fail(function () { - $('#save-flow-version-dialog').modal('refreshButtons'); }).fail(nfErrorHandler.handleAjaxError); }; /** * Select handler for the registries combo. * + * @param dialog * @param selectedOption + * @param bucketCombo + * @param selectBucket */ - var selectRegistry = function (selectedOption) { - if (selectedOption.disabled === true) { - $('#flow-version-bucket-combo').combo('destroy').combo({ + var selectRegistry = function (dialog, selectedOption, bucketCombo, selectBucket) { + var showNoBucketsAvailable = function () { + bucketCombo.combo('destroy').combo({ options: [{ text: 'No available buckets', value: null, @@ -138,9 +227,15 @@ }] }); - $('#save-flow-version-dialog').modal('refreshButtons'); + dialog.modal('refreshButtons'); + }; + + if (selectedOption.disabled === true) { + showNoBucketsAvailable(); } else { - loadBuckets(selectedOption.value); + loadBuckets(selectedOption.value, bucketCombo, selectBucket).fail(function () { + showNoBucketsAvailable(); + }); } }; @@ -149,7 +244,7 @@ * * @param selectedOption */ - var selectBucket = function (selectedOption) { + var selectBucketSaveFlowVersion = function (selectedOption) { $('#save-flow-version-dialog').modal('refreshButtons'); }; @@ -159,8 +254,8 @@ * @returns {*} */ var saveFlowVersion = function () { - var processGroupId = $('#flow-version-process-group-id').text(); - var processGroupRevision = $('#flow-version-process-group-id').data('revision'); + var processGroupId = $('#save-flow-version-process-group-id').text(); + var processGroupRevision = $('#save-flow-version-process-group-id').data('revision'); var saveFlowVersionRequest = { processGroupRevision: nfClient.getRevision({ @@ -170,27 +265,27 @@ }) }; - var versionControlInformation = $('#flow-version-process-group-id').data('versionControlInformation'); + var versionControlInformation = $('#save-flow-version-process-group-id').data('versionControlInformation'); if (nfCommon.isDefinedAndNotNull(versionControlInformation)) { saveFlowVersionRequest['versionedFlow'] = { registryId: versionControlInformation.registryId, bucketId: versionControlInformation.bucketId, flowId: versionControlInformation.flowId, - flowName: $('#flow-version-name').val(), - description: $('#flow-version-description').val(), - comments: $('#flow-version-change-comments').val() + flowName: $('#save-flow-version-name').text(), + description: $('#save-flow-version-description').text(), + comments: $('#save-flow-version-change-comments').val() } } else { - var selectedRegistry = $('#flow-version-registry-combo').combo('getSelectedOption'); - var selectedBucket = $('#flow-version-bucket-combo').combo('getSelectedOption'); + var selectedRegistry = $('#save-flow-version-registry-combo').combo('getSelectedOption'); + var selectedBucket = $('#save-flow-version-bucket-combo').combo('getSelectedOption'); saveFlowVersionRequest['versionedFlow'] = { registryId: selectedRegistry.value, bucketId: selectedBucket.value, - flowName: $('#flow-version-name').val(), - description: $('#flow-version-description').val(), - comments: $('#flow-version-change-comments').val() - } + flowName: $('#save-flow-version-name-field').val(), + description: $('#save-flow-version-description-field').val(), + comments: $('#save-flow-version-change-comments').val() + }; } return $.ajax({ @@ -202,8 +297,555 @@ }).fail(nfErrorHandler.handleAjaxError); }; + /** + * Sorts the specified data using the specified sort details. + * + * @param {object} sortDetails + * @param {object} data + */ + var sort = function (sortDetails, data) { + // defines a function for sorting + var comparer = function (a, b) { + var aString = nfCommon.isDefinedAndNotNull(a[sortDetails.columnId]) ? a[sortDetails.columnId] : ''; + var bString = nfCommon.isDefinedAndNotNull(b[sortDetails.columnId]) ? b[sortDetails.columnId] : ''; + return aString === bString ? 0 : aString > bString ? 1 : -1; + }; + + // perform the sort + data.sort(comparer, sortDetails.sortAsc); + }; + + var initImportFlowVersionTable = function () { + var importFlowVersionTable = $('#import-flow-version-table'); + + var valueFormatter = function (row, cell, value, columnDef, dataContext) { + return nfCommon.escapeHtml(value); + }; + + var timestampFormatter = function (row, cell, value, columnDef, dataContext) { + // get the current user time to properly convert the server time + var now = new Date(); + + // convert the user offset to millis + var userTimeOffset = now.getTimezoneOffset() * 60 * 1000; + + // create the proper date by adjusting by the offsets + var date = new Date(dataContext.timestamp + userTimeOffset + serverTimeOffset); + return nfCommon.formatDateTime(date); + }; + + // define the column model for the controller services table + var importFlowVersionColumns = [ + { + id: 'version', + name: 'Version', + field: 'version', + formatter: valueFormatter, + sortable: true, + resizable: true, + width: 75, + maxWidth: 75 + }, + { + id: 'timestamp', + name: 'Created', + field: 'timestamp', + formatter: timestampFormatter, + sortable: true, + resizable: true, + width: 175, + maxWidth: 175 + }, + { + id: 'changeComments', + name: 'Comments', + field: 'comments', + sortable: true, + resizable: true, + formatter: valueFormatter + } + ]; + + // initialize the dataview + var importFlowVersionData = new Slick.Data.DataView({ + inlineFilters: false + }); + + // initialize the sort + sort({ + columnId: 'version', + sortAsc: false + }, importFlowVersionData); + + // initialize the grid + var importFlowVersionGrid = new Slick.Grid(importFlowVersionTable, importFlowVersionData, importFlowVersionColumns, gridOptions); + importFlowVersionGrid.setSelectionModel(new Slick.RowSelectionModel()); + importFlowVersionGrid.registerPlugin(new Slick.AutoTooltips()); + importFlowVersionGrid.setSortColumn('version', false); + importFlowVersionGrid.onSort.subscribe(function (e, args) { + sort({ + columnId: args.sortCol.id, + sortAsc: args.sortAsc + }, importFlowVersionData); + }); + importFlowVersionGrid.onSelectedRowsChanged.subscribe(function (e, args) { + $('#import-flow-version-dialog').modal('refreshButtons'); + }); + importFlowVersionGrid.onDblClick.subscribe(function (e, args) { + changeFlowVersion().done(function () { + $('#import-flow-version-dialog').modal('hide'); + }); + }); + + // wire up the dataview to the grid + importFlowVersionData.onRowCountChanged.subscribe(function (e, args) { + importFlowVersionGrid.updateRowCount(); + importFlowVersionGrid.render(); + }); + importFlowVersionData.onRowsChanged.subscribe(function (e, args) { + importFlowVersionGrid.invalidateRows(args.rows); + importFlowVersionGrid.render(); + }); + importFlowVersionData.syncGridSelection(importFlowVersionGrid, true); + + // hold onto an instance of the grid + importFlowVersionTable.data('gridInstance', importFlowVersionGrid); + }; + + /** + * Shows the import flow version dialog. + */ + var showImportFlowVersionDialog = function () { + var pt = $('#new-process-group-dialog').data('pt'); + + // update the registry and bucket visibility + var registryCombo = $('#import-flow-version-registry-combo').show(); + var bucketCombo = $('#import-flow-version-bucket-combo').show(); + $('#import-flow-version-name-combo').show(); + + loadRegistries($('#import-flow-version-dialog'), registryCombo, bucketCombo, selectBucketImportVersion).done(function () { + // reposition the version table + $('#import-flow-version-table').css({ + 'top': '202px', + 'height': '225px' + }); + + // show the import dialog + $('#import-flow-version-dialog').modal('setHeaderText', 'Import Version').modal('setButtonModel', [{ + buttonText: 'Import', + color: { + base: '#728E9B', + hover: '#004849', + text: '#ffffff' + }, + disabled: disableImportOrChangeButton, + handler: { + click: function () { + importFlowVersion(pt).always(function (response) { + // close the dialog + $('#import-flow-version-dialog').modal('hide'); + }); + } + } + }, { + buttonText: 'Cancel', + color: { + base: '#E3E8EB', + hover: '#C7D2D7', + text: '#004849' + }, + handler: { + click: function () { + $(this).modal('hide'); + } + } + }]).modal('show'); + + // hide the new process group dialog + $('#new-process-group-dialog').modal('hide'); + }); + }; + + /** + * Loads the flow versions for the specified registry, bucket, and flow. + * + * @param registryIdentifier + * @param bucketIdentifier + * @param flowIdentifier + * @returns deferred + */ + var loadFlowVersions = function (registryIdentifier, bucketIdentifier, flowIdentifier) { + var importFlowVersionGrid = $('#import-flow-version-table').data('gridInstance'); + var importFlowVersionData = importFlowVersionGrid.getData(); + + // begin the update + importFlowVersionData.beginUpdate(); + + // remove the current versions + importFlowVersionGrid.setSelectedRows([]); + importFlowVersionGrid.resetActiveCell(); + importFlowVersionData.setItems([]); + + return $.ajax({ + type: 'GET', + url: '../nifi-api/flow/registries/' + encodeURIComponent(registryIdentifier) + '/buckets/' + encodeURIComponent(bucketIdentifier) + '/flows/' + encodeURIComponent(flowIdentifier) + '/versions', + dataType: 'json' + }).done(function (response) { + if (nfCommon.isDefinedAndNotNull(response.versionedFlowSnapshotMetadataSet) && response.versionedFlowSnapshotMetadataSet.length > 0) { + $.each(response.versionedFlowSnapshotMetadataSet, function (_, entity) { + importFlowVersionData.addItem($.extend({ + id: entity.versionedFlowSnapshotMetadata.version + }, entity.versionedFlowSnapshotMetadata)); + }); + } else { + nfDialog.showOkDialog({ + headerText: 'Flow Versions', + dialogContent: 'This flow does not have any versions available.' + }); + } + }).fail(nfErrorHandler.handleAjaxError).always(function () { + // end the update + importFlowVersionData.endUpdate(); + + // resort + importFlowVersionData.reSort(); + importFlowVersionGrid.invalidate(); + }); + }; + + /** + * Loads the versioned flows from the specified registry and bucket. + * + * @param registryIdentifier + * @param bucketIdentifier + * @param selectFlow + * @returns deferred + */ + var loadFlows = function (registryIdentifier, bucketIdentifier, selectFlow) { + return $.ajax({ + type: 'GET', + url: '../nifi-api/flow/registries/' + encodeURIComponent(registryIdentifier) + '/buckets/' + encodeURIComponent(bucketIdentifier) + '/flows', + dataType: 'json' + }).done(function (response) { + var versionedFlows = []; + + if (nfCommon.isDefinedAndNotNull(response.versionedFlows) && response.versionedFlows.length > 0) { + response.versionedFlows.sort(function (a, b) { + return a.versionedFlow.flowName > b.versionedFlow.flowName; + }); + + $.each(response.versionedFlows, function (_, versionedFlowEntity) { + var versionedFlow = versionedFlowEntity.versionedFlow; + versionedFlows.push({ + text: versionedFlow.flowName, + value: versionedFlow.flowId, + description: nfCommon.escapeHtml(versionedFlow.description) + }); + }); + } else { + versionedFlows.push({ + text: 'No available flows', + value: null, + optionClass: 'unset', + disabled: true + }); + } + + // load the buckets + $('#import-flow-version-name-combo').combo('destroy').combo({ + options: versionedFlows, + select: function (selectedFlow) { + if (nfCommon.isDefinedAndNotNull(selectedFlow.value)) { + selectFlow(registryIdentifier, bucketIdentifier, selectedFlow.value) + } else { + var importFlowVersionGrid = $('#import-flow-version-table').data('gridInstance'); + var importFlowVersionData = importFlowVersionGrid.getData(); + + // clear the current values + importFlowVersionData.beginUpdate(); + importFlowVersionData.setItems([]); + importFlowVersionData.endUpdate(); + } + } + }); + }).fail(nfErrorHandler.handleAjaxError); + }; + + /** + * Handler when a versioned flow is selected. + * + * @param registryIdentifier + * @param bucketIdentifier + * @param flowIdentifier + */ + var selectVersionedFlow = function (registryIdentifier, bucketIdentifier, flowIdentifier) { + loadFlowVersions(registryIdentifier, bucketIdentifier, flowIdentifier).done(function () { + $('#import-flow-version-dialog').modal('refreshButtons'); + }); + }; + + /** + * Handler when a bucket is selected. + * + * @param selectedBucket + */ + var selectBucketImportVersion = function (selectedBucket) { + var selectedRegistry = $('#import-flow-version-registry-combo').combo('getSelectedOption'); + + // load the flows for the currently selected registry and bucket + loadFlows(selectedRegistry.value, selectedBucket.value, selectVersionedFlow); + }; + + /** + * Imports the selected flow version. + */ + var importFlowVersion = function (pt) { + var selectedRegistry = $('#import-flow-version-registry-combo').combo('getSelectedOption'); + var selectedBucket = $('#import-flow-version-bucket-combo').combo('getSelectedOption'); + var selectedFlow = $('#import-flow-version-name-combo').combo('getSelectedOption'); + + var importFlowVersionGrid = $('#import-flow-version-table').data('gridInstance'); + var selectedVersionIndex = importFlowVersionGrid.getSelectedRows(); + var selectedVersion = importFlowVersionGrid.getDataItem(selectedVersionIndex[0]); + + var processGroupEntity = { + 'revision': nfClient.getRevision({ + 'revision': { + 'version': 0 + } + }), + 'component': { + 'name': selectedFlow.text, // TODO - name from versioned PG? + 'position': { + 'x': pt.x, + 'y': pt.y + }, + 'versionControlInformation': { + 'registryId': selectedRegistry.value, + 'bucketId': selectedBucket.value, + 'flowId': selectedFlow.value, + 'version': selectedVersion.version + } + } + }; + + return $.ajax({ + type: 'POST', + data: JSON.stringify(processGroupEntity), + url: '../nifi-api/process-groups/' + encodeURIComponent(nfCanvasUtils.getGroupId()) + '/process-groups', + dataType: 'json', + contentType: 'application/json' + }).done(function (response) { + // add the process group to the graph + nfGraph.add({ + 'processGroups': [response] + }, { + 'selectAll': true + }); + + // update component visibility + nfGraph.updateVisibility(); + + // update the birdseye + nfBirdseye.refresh(); + }).fail(nfErrorHandler.handleAjaxError); + }; + + /** + * Determines whether the import/change button is disabled. + * + * @returns {boolean} + */ + var disableImportOrChangeButton = function () { + var importFlowVersionGrid = $('#import-flow-version-table').data('gridInstance'); + if (nfCommon.isDefinedAndNotNull(importFlowVersionGrid)) { + var selected = importFlowVersionGrid.getSelectedRows(); + return selected.length !== 1; + } else { + return true; + } + }; + + /** + * Changes the flow version for the currently selected Process Group. + * + * @returns {deferred} + */ + var changeFlowVersion = function () { + var changeTimer = null; + + var processGroupId = $('#import-flow-version-process-group-id').text(); + var processGroupRevision = $('#import-flow-version-process-group-id').data('revision'); + var versionControlInformation = $('#import-flow-version-process-group-id').data('versionControlInformation'); + + var importFlowVersionGrid = $('#import-flow-version-table').data('gridInstance'); + var selectedVersionIndex = importFlowVersionGrid.getSelectedRows(); + var selectedVersion = importFlowVersionGrid.getDataItem(selectedVersionIndex[0]); + + // TODO - introduce dialog to show current state with option to cancel once available + + var submitChangeRequest = function () { + var changeVersionRequest = { + 'processGroupRevision': nfClient.getRevision({ + 'revision': { + 'version': processGroupRevision.version + } + }), + 'versionControlInformation': { + 'groupId': processGroupId, + 'registryId': versionControlInformation.registryId, + 'bucketId': versionControlInformation.bucketId, + 'flowId': versionControlInformation.flowId, + 'version': selectedVersion.version + } + }; + + return $.ajax({ + type: 'POST', + data: JSON.stringify(changeVersionRequest), + url: '../nifi-api/versions/update-requests/process-groups/' + encodeURIComponent(processGroupId), + dataType: 'json', + contentType: 'application/json' + }).done(function (response) { + console.log(response); + }).fail(nfErrorHandler.handleAjaxError); + }; + + var pollChangeRequest = function (changeRequest) { + getChangeRequest(changeRequest).done(function (response) { + processChangeResponse(response); + }) + }; + + var getChangeRequest = function (changeRequest) { + return $.ajax({ + type: 'GET', + url: changeRequest.uri, + dataType: 'json' + }).fail(nfErrorHandler.handleAjaxError); + }; + + var deleteChangeRequest = function (changeRequest) { + var deleteXhr = $.ajax({ + type: 'DELETE', + url: changeRequest.uri, + dataType: 'json' + }).fail(nfErrorHandler.handleAjaxError); + + updateProcessGroup(processGroupId); + + nfDialog.showOkDialog({ + headerText: 'Change Version', + dialogContent: 'This Process Group version has changed.' + }); + + return deleteXhr; + }; + + var processChangeResponse = function (response) { + var changeRequest = response.request; + + if (nfCommon.isDefinedAndNotNull(changeRequest.failureReason)) { + nfDialog.showOkDialog({ + headerText: 'Change Version', + dialogContent: nfCommon.escapeHtml(changeRequest.failureReason) + }); + } + + if (changeRequest.complete === true) { + deleteChangeRequest(changeRequest); + } else { + changeTimer = setTimeout(function () { + // clear the timer since we've been invoked + changeTimer = null; + + // poll revert request + pollChangeRequest(changeRequest); + }, 2000); + } + }; + + submitChangeRequest().done(function (response) { + processChangeResponse(response); + }); + + }; + + /** + * Gets the version control information for the specified process group id. + * + * @param processGroupId + * @return {deferred} + */ + var getVersionControlInformation = function (processGroupId) { + return $.Deferred(function (deferred) { + if (processGroupId === nfCanvasUtils.getGroupId()) { + $.ajax({ + type: 'GET', + url: '../nifi-api/versions/process-groups/' + encodeURIComponent(processGroupId), + dataType: 'json' + }).done(function (response) { + deferred.resolve(response); + }).fail(function () { + deferred.reject(); + }); + } else { + var processGroup = nfProcessGroup.get(processGroupId); + if (processGroup.permissions.canRead === true && processGroup.permissions.canWrite === true) { + deferred.resolve({ + 'processGroupRevision': processGroup.revision, + 'versionControlInformation': processGroup.component.versionControlInformation + }); + } else { + deferred.reject(); + } + } + }).promise(); + }; + + /** + * Updates the specified process group with the specified version control information. + * + * @param processGroupId + * @param versionControlInformation + */ + var updateVersionControlInformation = function (processGroupId, versionControlInformation) { + // refresh either selected PG or bread crumb to reflect connected/tracking status + if (nfCanvasUtils.getGroupId() === processGroupId) { + nfNgBridge.injector.get('breadcrumbsCtrl').updateVersionControlInformation(processGroupId, versionControlInformation); + nfNgBridge.digest(); + } else { + nfProcessGroup.reload(processGroupId); + } + }; + + /** + * Updates the specified process group following an operation that may change it's contents. + * + * @param processGroupId + */ + var updateProcessGroup = function (processGroupId) { + if (nfCanvasUtils.getGroupId() === processGroupId) { + // if reverting current PG... reload/refresh this group/canvas + + // TODO consider implementing this differently + $.ajax({ + type: 'GET', + url: '../nifi-api/flow/process-groups/' + encodeURIComponent(processGroupId), + dataType: 'json' + }).done(function (response) { + nfGraph.set(response.processGroupFlow.flow); + }).fail(nfErrorHandler.handleAjaxError); + } else { + // if reverting selected PG... reload selected PG to update counts, etc + nfProcessGroup.reload(processGroupId); + } + }; + return { - init: function () { + init: function (timeOffset) { + serverTimeOffset = timeOffset; + // initialize the flow version dialog $('#save-flow-version-dialog').modal({ scrollableContentStyle: 'scrollable', @@ -216,9 +858,9 @@ text: '#ffffff' }, disabled: function () { - if ($('#flow-version-registry-combo').is(':visible')) { - var selectedRegistry = $('#flow-version-registry-combo').combo('getSelectedOption'); - var selectedBucket = $('#flow-version-bucket-combo').combo('getSelectedOption'); + if ($('#save-flow-version-registry-combo').is(':visible')) { + var selectedRegistry = $('#save-flow-version-registry-combo').combo('getSelectedOption'); + var selectedBucket = $('#save-flow-version-bucket-combo').combo('getSelectedOption'); if (nfCommon.isDefinedAndNotNull(selectedRegistry) && nfCommon.isDefinedAndNotNull(selectedBucket)) { return selectedRegistry.disabled === true || selectedBucket.disabled === true; @@ -231,16 +873,10 @@ }, handler: { click: function () { - var processGroupId = $('#flow-version-process-group-id').text(); + var processGroupId = $('#save-flow-version-process-group-id').text(); saveFlowVersion().done(function (response) { - // refresh either selected PG or bread crumb to reflect connected/tracking status - if (nfCanvasUtils.getGroupId() === processGroupId) { - nfNgBridge.injector.get('breadcrumbsCtrl').updateVersionControlInformation(processGroupId, response.versionControlInformation); - nfNgBridge.digest(); - } else { - nfProcessGroup.reload(processGroupId); - } + updateVersionControlInformation(processGroupId, response.versionControlInformation); // close the dialog $('#save-flow-version-dialog').modal('hide'); @@ -262,10 +898,28 @@ }], handler: { close: function () { - resetDialog(); + resetSaveFlowVersionDialog(); } } }); + + // initialize the import flow version dialog + $('#import-flow-version-dialog').modal({ + scrollableContentStyle: 'scrollable', + handler: { + close: function () { + resetImportFlowVersionDialog(); + } + } + }); + + // handle the click for the process group import + $('#import-process-group-link').on('click', function() { + showImportFlowVersionDialog(); + }); + + // initialize the import flow version table + initImportFlowVersionTable(); }, /** @@ -274,88 +928,64 @@ * @param processGroupId */ showFlowVersionDialog: function (processGroupId) { + var focusName = true; + return $.Deferred(function (deferred) { - $.ajax({ - type: 'GET', - url: '../nifi-api/versions/process-groups/' + encodeURIComponent(processGroupId), - dataType: 'json' - }).done(function (response) { + getVersionControlInformation(processGroupId).done(function (groupVersionControlInformation) { // record the revision - $('#flow-version-process-group-id').data('revision', response.processGroupRevision).text(processGroupId); + $('#save-flow-version-process-group-id').data('revision', groupVersionControlInformation.processGroupRevision).text(processGroupId); - if (nfCommon.isDefinedAndNotNull(response.versionControlInformation)) { - var versionControlInformation = response.versionControlInformation; + if (nfCommon.isDefinedAndNotNull(groupVersionControlInformation.versionControlInformation)) { + var versionControlInformation = groupVersionControlInformation.versionControlInformation; // update the registry and bucket visibility - $('#flow-version-registry').text(versionControlInformation.registryId).show(); - $('#flow-version-bucket').text(versionControlInformation.bucketId).show(); + $('#save-flow-version-registry').text(versionControlInformation.registryId).show(); + $('#save-flow-version-bucket').text(versionControlInformation.bucketId).show(); - $('#flow-version-name').val(''); - $('#flow-version-description').val(''); + $('#save-flow-version-name').text(versionControlInformation.flowName).show(); + $('#save-flow-version-description').text('Flow description goes here').show(); // record the versionControlInformation - $('#flow-version-process-group-id').data('versionControlInformation', versionControlInformation) + $('#save-flow-version-process-group-id').data('versionControlInformation', versionControlInformation); + focusName = false; deferred.resolve(); } else { // update the registry and bucket visibility - $('#flow-version-registry-combo').show(); - $('#flow-version-bucket-combo').show(); - - $.ajax({ - type: 'GET', - url: '../nifi-api/flow/registries', - dataType: 'json' - }).done(function (registriesResponse) { - var registries = []; - - if (nfCommon.isDefinedAndNotNull(registriesResponse.registries) && registriesResponse.registries.length > 0) { - registriesResponse.registries.sort(function (a, b) { - return a.component.name > b.component.name; - }); - - $.each(registriesResponse.registries, function (_, registryEntity) { - var registry = registryEntity.component; - registries.push({ - text: registry.name, - value: registry.id, - description: nfCommon.escapeHtml(registry.description) - }); - }); - } else { - registries.push({ - text: 'No available registries', - value: null, - optionClass: 'unset', - disabled: true - }); - } + $('#save-flow-version-registry-combo').show(); + $('#save-flow-version-bucket-combo').show(); - // load the registries - $('#flow-version-registry-combo').combo({ - options: registries, - select: selectRegistry - }); + $('#save-flow-version-name-field').show(); + $('#save-flow-version-description-field').show(); + loadRegistries($('#save-flow-version-dialog'), $('#save-flow-version-registry-combo'), $('#save-flow-version-bucket-combo'), selectBucketSaveFlowVersion).done(function () { deferred.resolve(); }).fail(function () { deferred.reject(); - }).fail(nfErrorHandler.handleAjaxError); + }); } }).fail(nfErrorHandler.handleAjaxError); }).done(function () { $('#save-flow-version-dialog').modal('show'); + + if (focusName) { + $('#save-flow-version-name-field').focus(); + } else { + $('#save-flow-version-change-comments').focus(); + } }).fail(function () { $('#save-flow-version-dialog').modal('refreshButtons'); }).promise(); }, /** - * Reverts changes for the specified Process Group. + * Reverts local changes for the specified Process Group. * * @param processGroupId */ - revertFlowChanges: function (processGroupId) { + revertLocalChanges: function (processGroupId) { + // TODO update to show user the ramifications of reverting for confirmation + // prompt the user before reverting nfDialog.showYesNoDialog({ headerText: 'Revert Changes', @@ -363,50 +993,88 @@ noText: 'Cancel', yesText: 'Revert', yesHandler: function () { - $.ajax({ - type: 'GET', - url: '../nifi-api/versions/process-groups/' + encodeURIComponent(processGroupId), - dataType: 'json' - }).done(function (response) { + getVersionControlInformation(processGroupId).done(function (response) { if (nfCommon.isDefinedAndNotNull(response.versionControlInformation)) { - var revertFlowVersionRequest = { - processGroupRevision: nfClient.getRevision({ - revision: { - version: response.processGroupRevision.version - } - }), - versionControlInformation: response.versionControlInformation + var revertTimer = null; + + // TODO - introduce dialog to show current state once available + + var submitRevertRequest = function () { + var revertFlowVersionRequest = { + 'processGroupRevision': nfClient.getRevision({ + 'revision': { + 'version': response.processGroupRevision.version + } + }), + 'versionControlInformation': response.versionControlInformation + }; + + return $.ajax({ + type: 'POST', + data: JSON.stringify(revertFlowVersionRequest), + url: '../nifi-api/versions/revert-requests/process-groups/' + encodeURIComponent(processGroupId), + dataType: 'json', + contentType: 'application/json' + }).fail(nfErrorHandler.handleAjaxError); }; - $.ajax({ - type: 'POST', - data: JSON.stringify(revertFlowVersionRequest), - url: '../nifi-api/versions/revert-requests/process-groups/' + encodeURIComponent(processGroupId), - dataType: 'json', - contentType: 'application/json' - }).done(function (response) { - // TODO update multi step to show user the ramifications of reverting for confirmation - - if (nfCanvasUtils.getGroupId() === processGroupId) { - // if reverting current PG... reload/refresh this group/canvas - // TODO consider implementing this differently - $.ajax({ - type: 'GET', - url: '../nifi-api/flow/process-groups/' + encodeURIComponent(processGroupId), - dataType: 'json' - }).done(function (response) { - nfGraph.set(response.processGroupFlow.flow); - }).fail(nfErrorHandler.handleAjaxError); - } else { - // if reverting selected PG... reload selected PG to update counts, etc - nfProcessGroup.reload(processGroupId); - } + var pollRevertRequest = function (revertRequest) { + getRevertRequest(revertRequest).done(function (response) { + processRevertResponse(response); + }) + }; + + var getRevertRequest = function (revertRequest) { + return $.ajax({ + type: 'GET', + url: revertRequest.uri, + dataType: 'json' + }).fail(nfErrorHandler.handleAjaxError); + }; + + var deleteRevertRequest = function (revertRequest) { + var deleteXhr = $.ajax({ + type: 'DELETE', + url: revertRequest.uri, + dataType: 'json' + }).fail(nfErrorHandler.handleAjaxError); + + updateProcessGroup(processGroupId); nfDialog.showOkDialog({ headerText: 'Revert Changes', dialogContent: 'This Process Group has been reverted.' }); - }).fail(nfErrorHandler.handleAjaxError); + + return deleteXhr; + }; + + var processRevertResponse = function (response) { + var revertRequest = response.request; + + if (nfCommon.isDefinedAndNotNull(revertRequest.failureReason)) { + nfDialog.showOkDialog({ + headerText: 'Revert Changes', + dialogContent: nfCommon.escapeHtml(revertRequest.failureReason) + }); + } + + if (revertRequest.complete === true) { + deleteRevertRequest(revertRequest); + } else { + revertTimer = setTimeout(function () { + // clear the timer since we've been invoked + revertTimer = null; + + // poll revert request + pollRevertRequest(revertRequest); + }, 2000); + } + }; + + submitRevertRequest().done(function (response) { + processRevertResponse(response); + }); } else { nfDialog.showOkDialog({ headerText: 'Revert Changes', @@ -419,11 +1087,89 @@ }, /** - * Disconnects the specified Process Group from flow versioning. + * Shows the change flow version dialog. * * @param processGroupId */ - disconnectFlowVersioning: function (processGroupId) { + showChangeFlowVersionDialog: function (processGroupId) { + return $.Deferred(function (deferred) { + getVersionControlInformation(processGroupId).done(function (groupVersionControlInformation) { + if (nfCommon.isDefinedAndNotNull(groupVersionControlInformation.versionControlInformation)) { + var versionControlInformation = groupVersionControlInformation.versionControlInformation; + + // update the registry and bucket visibility + $('#import-flow-version-registry').text(versionControlInformation.registryId).show(); + $('#import-flow-version-bucket').text(versionControlInformation.bucketId).show(); + $('#import-flow-version-name').text(versionControlInformation.flowId).show(); + + // record the versionControlInformation + $('#import-flow-version-process-group-id').data('versionControlInformation', versionControlInformation).data('revision', groupVersionControlInformation.processGroupRevision).text(processGroupId); + + // load the flow versions + loadFlowVersions(versionControlInformation.registryId, versionControlInformation.bucketId, versionControlInformation.flowId).done(function () { + deferred.resolve(); + }).fail(function () { + nfDialog.showOkDialog({ + headerText: 'Change Version', + dialogContent: 'Unable to load available versions for this Process Group.' + }); + + deferred.reject(); + }); + } else { + nfDialog.showOkDialog({ + headerText: 'Change Version', + dialogContent: 'This Process Group is not currently under version control.' + }); + + deferred.reject(); + } + }).fail(nfErrorHandler.handleAjaxError); + }).done(function () { + // reposition the version table + $('#import-flow-version-table').css({ + 'top': '150px', + 'height': '277px' + }); + + // show the dialog + $('#import-flow-version-dialog').modal('setHeaderText', 'Change Version').modal('setButtonModel', [{ + buttonText: 'Change', + color: { + base: '#728E9B', + hover: '#004849', + text: '#ffffff' + }, + disabled: disableImportOrChangeButton, + handler: { + click: function () { + changeFlowVersion().done(function () { + $('#import-flow-version-dialog').modal('hide'); + }); + } + } + }, { + buttonText: 'Cancel', + color: { + base: '#E3E8EB', + hover: '#C7D2D7', + text: '#004849' + }, + handler: { + click: function () { + $(this).modal('hide'); + } + } + }]).modal('show'); + }).promise(); + }, + + /** + * Stops version control for the specified Process Group. + * + * @param processGroupId + */ + stopVersionControl: function (processGroupId) { // prompt the user before disconnecting nfDialog.showYesNoDialog({ headerText: 'Disconnect', @@ -449,13 +1195,7 @@ dataType: 'json', contentType: 'application/json' }).done(function (response) { - // refresh either selected PG or bread crumb to reflect disconnected status - if (nfCanvasUtils.getGroupId() === processGroupId) { - nfNgBridge.injector.get('breadcrumbsCtrl').updateVersionControlInformation(processGroupId, undefined); - nfNgBridge.digest(); - } else { - nfProcessGroup.reload(processGroupId); - } + updateVersionControlInformation(processGroupId, undefined); nfDialog.showOkDialog({ headerText: 'Disconnect', http://git-wip-us.apache.org/repos/asf/nifi/blob/696d583b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-settings.js ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-settings.js b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-settings.js index 0e5a2d7..d3289c7 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-settings.js +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-settings.js @@ -82,8 +82,7 @@ reportingTaskTypes: '../nifi-api/flow/reporting-task-types', createReportingTask: '../nifi-api/controller/reporting-tasks', reportingTasks: '../nifi-api/flow/reporting-tasks', - createRegistry: '../nifi-api/controller/registries', - registries: '../nifi-api/flow/registries' + registries: '../nifi-api/controller/registry-clients' } }; @@ -486,7 +485,7 @@ // add the new registry var addRegistry = $.ajax({ type: 'POST', - url: config.urls.createRegistry, + url: config.urls.registries, data: JSON.stringify(registryEntity), dataType: 'json', contentType: 'application/json' @@ -877,7 +876,6 @@ // initialize the registry configuration dialog $('#registry-configuration-dialog').modal({ scrollableContentStyle: 'scrollable', - headerText: 'Add Registry', handler: { close: function () { $('#registry-id').text(''); @@ -1351,7 +1349,7 @@ $('#registry-description').val(registryEntity.component.description); // show the dialog - $('#registry-configuration-dialog').modal('setButtonModel', [{ + $('#registry-configuration-dialog').modal('setHeaderText', 'Edit Registry Client').modal('setButtonModel', [{ buttonText: 'Update', color: { base: '#728E9B', @@ -1597,7 +1595,7 @@ name: 'Reporting Tasks', tabContentId: 'reporting-tasks-tab-content' }, { - name: 'Registries', + name: 'Registry Clients', tabContentId: 'registries-tab-content' }], select: function () { @@ -1625,9 +1623,9 @@ } else if (tab === 'Reporting Tasks') { $('#settings-save').hide(); return 'Create a new reporting task'; - } else if (tab === 'Registries') { + } else if (tab === 'Registry Clients') { $('#settings-save').hide(); - return 'Register a new registry'; + return 'Register a new registry client'; } }); } else { @@ -1637,7 +1635,7 @@ if (tab === 'Reporting Task Controller Services') { $('#controller-cs-availability').show(); - } else if (tab === 'Reporting Tasks' || tab === 'Registries') { + } else if (tab === 'Reporting Tasks' || tab === 'Registry Clients') { $('#controller-cs-availability').hide(); } @@ -1676,8 +1674,8 @@ // set the initial focus $('#reporting-task-type-filter').focus(); - } else if (selectedTab === 'Registries') { - $('#registry-configuration-dialog').modal('setButtonModel', [{ + } else if (selectedTab === 'Registry Clients') { + $('#registry-configuration-dialog').modal('setHeaderText', 'Add Registry Client').modal('setButtonModel', [{ buttonText: 'Add', color: { base: '#728E9B', @@ -1702,6 +1700,9 @@ } } }]).modal('show'); + + // set the initial focus + $('#registry-name').focus(); } }); http://git-wip-us.apache.org/repos/asf/nifi/blob/696d583b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/nf-common.js ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/nf-common.js b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/nf-common.js index 0d55b27..5619bc3 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/nf-common.js +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/nf-common.js @@ -557,6 +557,17 @@ }, /** + * Determines whether the current user can version flows. + */ + canVersionFlows: function () { + if (nfCommon.isDefinedAndNotNull(nfCommon.currentUser)) { + return nfCommon.currentUser.canVersionFlows === true; + } else { + return false; + } + }, + + /** * Determines whether the current user can access provenance. * * @returns {boolean}
