NIFI-2534: - Refreshing using component IDs. - Code clean up.

This closes #874.

Signed-off-by: Bryan Bende <bbende@apache.org>
This commit is contained in:
Matt Gilman 2016-08-16 15:29:29 -04:00 committed by Bryan Bende
parent 2fd39676a8
commit b3f36489ad
No known key found for this signature in database
GPG Key ID: A0DDA9ED50711C39
13 changed files with 52 additions and 67 deletions

View File

@ -143,7 +143,7 @@ nf.Actions = (function () {
var connections = nf.Connection.getComponentConnections(remoteProcessGroup.id);
$.each(connections, function (_, connection) {
if (connection.permissions.canRead) {
nf.Connection.reload(connection.component);
nf.Connection.reload(connection.id);
}
});
}
@ -519,7 +519,7 @@ nf.Actions = (function () {
startRequests.push(updateResource(uri, entity).done(function (response) {
if (nf.CanvasUtils.isProcessGroup(selected)) {
nf.ProcessGroup.reload(d.component);
nf.ProcessGroup.reload(d.id);
} else {
nf[d.type].set(response);
}
@ -589,7 +589,7 @@ nf.Actions = (function () {
stopRequests.push(updateResource(uri, entity).done(function (response) {
if (nf.CanvasUtils.isProcessGroup(selected)) {
nf.ProcessGroup.reload(d.component);
nf.ProcessGroup.reload(d.id);
} else {
nf[d.type].set(response);
}

View File

@ -1194,11 +1194,11 @@ nf.CanvasUtils = (function () {
if (sourceData.permissions.canRead) {
// update the source status if necessary
if (nf.CanvasUtils.isProcessor(source)) {
nf.Processor.reload(sourceData.component);
nf.Processor.reload(sourceData.id);
} else if (nf.CanvasUtils.isInputPort(source)) {
nf.Port.reload(sourceData.component);
nf.Port.reload(sourceData.id);
} else if (nf.CanvasUtils.isRemoteProcessGroup(source)) {
nf.RemoteProcessGroup.reload(sourceData.component);
nf.RemoteProcessGroup.reload(sourceData.id);
}
}
}
@ -1212,9 +1212,9 @@ nf.CanvasUtils = (function () {
if (destinationData.permissions.canRead) {
// update the destination component accordingly
if (nf.CanvasUtils.isProcessor(destination)) {
nf.Processor.reload(destinationData.component);
nf.Processor.reload(destinationData.id);
} else if (nf.CanvasUtils.isRemoteProcessGroup(destination)) {
nf.RemoteProcessGroup.reload(destinationData.component);
nf.RemoteProcessGroup.reload(destinationData.id);
}
}
}
@ -1371,7 +1371,7 @@ nf.CanvasUtils = (function () {
// move the components into the destination and...
moveComponents(components, groupData.id).done(function () {
// reload the target group
nf.ProcessGroup.reload(groupData.component);
nf.ProcessGroup.reload(groupData.id);
});
},

View File

@ -1676,11 +1676,11 @@ nf.Connection = (function () {
/**
* Reloads the connection state from the server and refreshes the UI.
*
* @param {object} connection The connection to reload
* @param {string} id The connection id
*/
reload: function (connection) {
if (connectionMap.has(connection.id)) {
var connectionEntity = connectionMap.get(connection.id);
reload: function (id) {
if (connectionMap.has(id)) {
var connectionEntity = connectionMap.get(id);
return $.ajax({
type: 'GET',
url: connectionEntity.uri,

View File

@ -188,8 +188,7 @@ nf.ControllerService = (function () {
if (reference.referenceType === 'Processor') {
// reload the processor on the canvas if appropriate
if (nf.Canvas.getGroupId() === reference.groupId) {
var processor = nf.Processor.get(reference.id);
nf.Processor.reload(processor.component);
nf.Processor.reload(reference.id);
}
// update the current active thread count

View File

@ -277,11 +277,11 @@ nf.Funnel = (function () {
* Reloads the funnel state from the server and refreshes the UI.
* If the funnel is currently unknown, this function just returns.
*
* @param {object} funnel The funnel to reload
* @param {string} id The funnel id
*/
reload: function (funnel) {
if (funnelMap.has(funnel.id)) {
var funnelEntity = funnelMap.get(funnel.id);
reload: function (id) {
if (funnelMap.has(id)) {
var funnelEntity = funnelMap.get(id);
return $.ajax({
type: 'GET',
url: funnelEntity.uri,

View File

@ -457,11 +457,11 @@ nf.Label = (function () {
* Reloads the label state from the server and refreshes the UI.
* If the label is currently unknown, this function just returns.
*
* @param {object} label The label to reload
* @param {string} id The label id
*/
reload: function (label) {
if (labelMap.has(label.id)) {
var labelEntity = labelMap.get(label.id);
reload: function (id) {
if (labelMap.has(id)) {
var labelEntity = labelMap.get(id);
return $.ajax({
type: 'GET',
url: labelEntity.uri,

View File

@ -948,15 +948,11 @@ nf.PolicyManagement = (function () {
resetPolicy();
loadPolicy();
}
nf.Canvas.reload({
'transition': true
});
}).fail(function (xhr, status, error) {
nf.Common.handleAjaxError(xhr, status, error);
resetPolicy();
loadPolicy();
}).always(function () {
nf.Canvas.reload({
'transition': true
});

View File

@ -602,21 +602,17 @@ nf.Port = (function () {
* Reloads the port state from the server and refreshes the UI.
* If the port is currently unknown, this function just returns.
*
* @param {object} port The port to reload
* @param {string} id The port id
*/
reload: function (port) {
if (portMap.has(port.id)) {
var portEntity = portMap.get(port.id);
reload: function (id) {
if (portMap.has(id)) {
var portEntity = portMap.get(id);
return $.ajax({
type: 'GET',
url: portEntity.uri,
dataType: 'json'
}).done(function (response) {
if (nf.Common.isDefinedAndNotNull(response.inputPort)) {
nf.Port.set(response);
} else {
nf.Port.set(response);
}
});
}
},

View File

@ -1084,12 +1084,11 @@ nf.ProcessGroup = (function () {
* Reloads the process group state from the server and refreshes the UI.
* If the process group is currently unknown, this function reloads the canvas.
*
* @param {object} processGroup The process group to reload
* @param {string} id The process group id
*/
reload: function (processGroup) {
if(nf.Common.isDefinedAndNotNull(processGroup)) {
if (processGroupMap.has(processGroup.id)) {
var processGroupEntity = processGroupMap.get(processGroup.id);
reload: function (id) {
if (processGroupMap.has(id)) {
var processGroupEntity = processGroupMap.get(id);
return $.ajax({
type: 'GET',
url: processGroupEntity.uri,
@ -1098,11 +1097,6 @@ nf.ProcessGroup = (function () {
nf.ProcessGroup.set(response);
});
}
} else {
nf.Canvas.reload({
'transition': true
});
}
},
/**

View File

@ -376,7 +376,7 @@ nf.ProcessorConfiguration = (function () {
$.each(connections, function (_, connection) {
if (connection.permissions.canRead) {
if (connection.sourceId === processor.id) {
nf.Connection.reload(connection.component);
nf.Connection.reload(connection.id);
}
}
});
@ -577,7 +577,7 @@ nf.ProcessorConfiguration = (function () {
var requests = [];
// reload the processor in case an property descriptors have updated
requests.push(nf.Processor.reload(processor));
requests.push(nf.Processor.reload(processor.id));
// get the processor history
requests.push($.ajax({
@ -764,7 +764,7 @@ nf.ProcessorConfiguration = (function () {
// show the custom ui
nf.CustomUi.showCustomUi(processorResponse, processor.config.customUiUrl, true).done(function () {
// once the custom ui is closed, reload the processor
nf.Processor.reload(processor);
nf.Processor.reload(processor.id);
// and reload the processor's outgoing connections
reloadProcessorConnections(processor);

View File

@ -859,11 +859,11 @@ nf.Processor = (function () {
* Reloads the processor state from the server and refreshes the UI.
* If the processor is currently unknown, this function just returns.
*
* @param {object} processor The processor to reload
* @param {string} id The processor id
*/
reload: function (processor) {
if (processorMap.has(processor.id)) {
var processorEntity = processorMap.get(processor.id);
reload: function (id) {
if (processorMap.has(id)) {
var processorEntity = processorMap.get(id);
return $.ajax({
type: 'GET',
url: processorEntity.uri,

View File

@ -166,7 +166,7 @@ nf.RemoteProcessGroupPorts = (function () {
// if can modify, the over status of this node may have changed
if (nf.CanvasUtils.canModify(remoteProcessGroup)) {
// reload the remote process group
nf.RemoteProcessGroup.reload(remoteProcessGroupData.component);
nf.RemoteProcessGroup.reload(remoteProcessGroupData.id);
}
// hide the dialog

View File

@ -930,11 +930,11 @@ nf.RemoteProcessGroup = (function () {
* Reloads the remote process group state from the server and refreshes the UI.
* If the remote process group is currently unknown, this function just returns.
*
* @param {object} remoteProcessGroup The remote process group to reload
* @param {string} id The remote process group id
*/
reload: function (remoteProcessGroup) {
if (remoteProcessGroupMap.has(remoteProcessGroup.id)) {
var remoteProcessGroupEntity = remoteProcessGroupMap.get(remoteProcessGroup.id);
reload: function (id) {
if (remoteProcessGroupMap.has(id)) {
var remoteProcessGroupEntity = remoteProcessGroupMap.get(id);
return $.ajax({
type: 'GET',
url: remoteProcessGroupEntity.uri,
@ -943,10 +943,10 @@ nf.RemoteProcessGroup = (function () {
nf.RemoteProcessGroup.set(response);
// reload the group's connections
var connections = nf.Connection.getComponentConnections(remoteProcessGroup.id);
var connections = nf.Connection.getComponentConnections(id);
$.each(connections, function (_, connection) {
if (connection.permissions.canRead) {
nf.Connection.reload(connection.component);
nf.Connection.reload(connection.id);
}
});
});