2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
17 * Modifications to the original nifi code for the ONAP project are made
18 * available under the Apache License, Version 2.0
21 /* global define, module, require, exports */
23 (function (root, factory) {
24 if (typeof define === 'function' && define.amd) {
29 'nf.PolicyManagement',
34 function ($, nfCommon, nfQueueListing, nfShell, nfPolicyManagement, nfClusterSummary, nfErrorHandler, nfSettings, nfCanvasUtils) {
35 return (nf.ng.Canvas.GlobalMenuCtrl = factory($, nfCommon, nfQueueListing, nfShell, nfPolicyManagement, nfClusterSummary, nfErrorHandler, nfSettings, nfCanvasUtils));
37 } else if (typeof exports === 'object' && typeof module === 'object') {
38 module.exports = (nf.ng.Canvas.GlobalMenuCtrl =
39 factory(require('jquery'),
41 require('nf.QueueListing'),
43 require('nf.PolicyManagement'),
44 require('nf.ClusterSummary'),
45 require('nf.ErrorHandler'),
46 require('nf.Settings'),
47 require('nf.CanvasUtils')));
49 nf.ng.Canvas.GlobalMenuCtrl = factory(root.$,
53 root.nf.PolicyManagement,
54 root.nf.ClusterSummary,
59 }(this, function ($, nfCommon, nfQueueListing, nfShell, nfPolicyManagement, nfClusterSummary, nfErrorHandler, nfSettings, nfCanvasUtils) {
62 return function (serviceProvider) {
67 helpDocument: '../nifi-docs/documentation',
68 controllerAbout: '../nifi-api/flow/about'
72 function GlobalMenuCtrl(serviceProvider) {
75 * The summary menu item controller.
80 * The summary menu item's shell controller.
85 * Launch the summary shell.
88 nfShell.showPage('summary');
94 * The counters menu item controller.
99 * The counters menu item's shell controller.
104 * Launch the counters shell.
106 launch: function () {
107 if (nfCommon.canAccessCounters()) {
108 nfShell.showPage('counters');
115 * The bulletin board menu item controller.
117 this.bulletinBoard = {
120 * The bulletin board menu item's shell controller.
125 * Launch the bulletin board shell.
127 launch: function () {
128 nfShell.showPage('bulletin-board');
134 * The data provenance menu item controller.
136 this.dataProvenance = {
139 * The data provenance menu item's shell controller.
144 * Launch the data provenance shell.
146 launch: function () {
147 if (nfCommon.canAccessProvenance()) {
148 nfShell.showPage('provenance');
155 * The controller settings menu item controller.
157 this.controllerSettings = {
160 * The controller settings menu item's shell controller.
165 * Launch the settings shell.
167 launch: function () {
168 nfSettings.showSettings();
174 * The cluster menu item controller.
179 * Determines if the cluster menu item is enabled.
181 * @returns {*|boolean}
183 visible: function () {
184 return nfClusterSummary.isConnectedToCluster();
188 * The cluster menu item's shell controller.
193 * Launch the cluster shell.
195 launch: function () {
196 if (nfCommon.canAccessController()) {
197 nfShell.showPage('cluster');
204 * The flow config history menu item controller.
206 this.flowConfigHistory = {
209 * The flow config history menu item's shell controller.
214 * Launch the history shell.
216 launch: function () {
217 nfShell.showPage('history');
223 * The users menu item controller.
228 * The users menu item's shell controller.
233 * Launch the users shell.
235 launch: function () {
236 if (nfCommon.canAccessTenants()) {
237 nfShell.showPage('users');
244 * The policies menu item controller.
249 * The policies menu item's shell controller.
254 * Launch the policies shell.
256 launch: function () {
257 if (nfCommon.canModifyPolicies() && nfCommon.canAccessTenants()) {
258 nfPolicyManagement.showGlobalPolicies();
265 * The templates menu item controller.
270 * The templates menu item's shell controller.
275 * Launch the templates shell.
277 launch: function () {
278 nfShell.showPage('templates?' + $.param({
279 groupId: nfCanvasUtils.getGroupId()
286 * The help menu item controller.
291 * The help menu item's shell controller.
296 * Launch the help documentation shell.
298 launch: function () {
299 nfShell.showPage(config.urls.helpDocument);
305 * The about menu item controller.
310 * Initialize the about details.
313 // get the about details
316 url: config.urls.controllerAbout,
318 }).done(function (response) {
319 var aboutDetails = response.about;
320 // set the document title and the about title
321 document.title = aboutDetails.title;
322 $('#nf-version').text(aboutDetails.version);
323 var showVersionDetail = false;
324 if (aboutDetails.buildTag && aboutDetails.buildTag !== 'HEAD') {
325 $('#nf-about-build-tag').text(aboutDetails.buildTag);
326 $('#nf-version-detail-tag').show();
327 showVersionDetail = true;
329 if (aboutDetails.buildRevision) {
330 $('#nf-about-build-revision').text(aboutDetails.buildRevision);
331 $('#nf-about-build-branch').text(aboutDetails.buildBranch);
332 $('#nf-version-detail-commit').show();
333 showVersionDetail = true
335 if (aboutDetails.buildTimestamp) {
336 $('#nf-about-build-timestamp').text(aboutDetails.buildTimestamp);
337 $('#nf-version-detail-timestamp').show();
338 showVersionDetail = true;
340 if (showVersionDetail) {
341 $('#nf-version-detail').show();
344 // store the content viewer url if available
345 if (!nfCommon.isBlank(aboutDetails.contentViewerUrl)) {
346 $('#nifi-content-viewer-url').text(aboutDetails.contentViewerUrl);
347 nfQueueListing.initFlowFileDetailsDialog();
349 }).fail(nfErrorHandler.handleAjaxError);
355 * The about menu item's modal controller.
360 * Gets the modal element.
362 * @returns {*|jQuery|HTMLElement}
364 getElement: function () {
365 return $('#nf-about');
369 * Initialize the modal.
372 var aboutModal = this;
374 var resizeAbout = function () {
375 var dialog = $(this);
376 var top = $('#nf-about-pic-container').height() + $('.dialog-header').height() + 10; //10 for padding-top
377 dialog.find('.dialog-content').css('top', top);
380 this.getElement().modal({
381 scrollableContentStyle: 'scrollable',
382 headerText: 'About Apache NiFi',
403 * Updates the modal config.
405 * @param {string} name The name of the property to update.
406 * @param {object|array} config The config for the `name`.
408 update: function (name, config) {
409 this.getElement().modal(name, config);
416 this.getElement().modal('show');
423 this.getElement().modal('hide');
429 * The import model menu item controller.
434 * The import model menu item's shell controller.
439 * Launch the import model shell.
441 launch: function () {
442 $("#model-type").val("-");
443 nfShell.showContent('#import-model');
449 * The import component specificaton menu item controller.
451 this.importComponent = {
454 * The import component specification menu item's shell controller.
459 * Launch the import component shell.
461 launch: function () {
462 nfShell.showContent('#import-component');
468 * The import data format menu item controller.
470 this.importDataFormat = {
473 * The import data format menu item's shell controller.
478 * Launch the import data format shell.
480 launch: function () {
481 nfShell.showContent('#import-data-format');
487 GlobalMenuCtrl.prototype = {
488 constructor: GlobalMenuCtrl,
491 * Initialize the global menu controls.
498 var globalMenuCtrl = new GlobalMenuCtrl();
499 return globalMenuCtrl;