You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by mc...@apache.org on 2015/01/28 14:35:52 UTC
[1/2] incubator-nifi git commit: NIFI-250: - Adding parameters to the
update controller service endpoint.
Repository: incubator-nifi
Updated Branches:
refs/heads/NIFI-250 593afddaf -> 5d5cb8f10
NIFI-250:
- Adding parameters to the update controller service endpoint.
Project: http://git-wip-us.apache.org/repos/asf/incubator-nifi/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-nifi/commit/2303570e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-nifi/tree/2303570e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-nifi/diff/2303570e
Branch: refs/heads/NIFI-250
Commit: 2303570eb68da63ebbd3a438555e3f523ec7308d
Parents: 593afdd
Author: Matt Gilman <ma...@gmail.com>
Authored: Wed Jan 28 08:33:42 2015 -0500
Committer: Matt Gilman <ma...@gmail.com>
Committed: Wed Jan 28 08:33:42 2015 -0500
----------------------------------------------------------------------
.../nifi/web/api/ControllerServiceResource.java | 87 ++++++++++++++++----
1 file changed, 69 insertions(+), 18 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/2303570e/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ControllerServiceResource.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ControllerServiceResource.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ControllerServiceResource.java
index c0cc62a..4f33756 100644
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ControllerServiceResource.java
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ControllerServiceResource.java
@@ -19,6 +19,8 @@ package org.apache.nifi.web.api;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
@@ -38,19 +40,15 @@ import javax.ws.rs.QueryParam;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.Response;
import org.apache.nifi.cluster.manager.impl.WebClusterManager;
import org.apache.nifi.util.NiFiProperties;
import org.apache.nifi.web.ConfigurationSnapshot;
import org.apache.nifi.web.NiFiServiceFacade;
import org.apache.nifi.web.Revision;
-import org.apache.nifi.web.api.dto.FunnelDTO;
-import org.apache.nifi.web.api.dto.PositionDTO;
import org.apache.nifi.web.api.dto.RevisionDTO;
-import org.apache.nifi.web.api.entity.FunnelEntity;
-import org.apache.nifi.web.api.entity.FunnelsEntity;
import org.apache.nifi.web.api.request.ClientIdParameter;
-import org.apache.nifi.web.api.request.DoubleParameter;
import org.apache.nifi.web.api.request.LongParameter;
import org.apache.commons.lang3.StringUtils;
import org.apache.nifi.web.api.dto.ControllerServiceDTO;
@@ -62,7 +60,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.security.access.prepost.PreAuthorize;
/**
- * RESTful endpoint for managing a Funnel.
+ * RESTful endpoint for managing a Controller Service.
*/
public class ControllerServiceResource extends ApplicationResource {
@@ -130,7 +128,7 @@ public class ControllerServiceResource extends ApplicationResource {
}
/**
- * Creates a new funnel.
+ * Creates a new controller service.
*
* @param httpServletRequest
* @param version The revision is used to verify the client is working with
@@ -159,7 +157,6 @@ public class ControllerServiceResource extends ApplicationResource {
// create the revision
final RevisionDTO revision = new RevisionDTO();
revision.setClientId(clientId.getClientId());
-
if (version != null) {
revision.setVersion(version.getLong());
}
@@ -266,7 +263,7 @@ public class ControllerServiceResource extends ApplicationResource {
@Path("{id}")
@PreAuthorize("hasAnyRole('ROLE_MONITOR', 'ROLE_DFM', 'ROLE_ADMIN')")
@TypeHint(ControllerServiceEntity.class)
- public Response getFunnel(@QueryParam(CLIENT_ID) @DefaultValue(StringUtils.EMPTY) ClientIdParameter clientId, @PathParam("id") String id) {
+ public Response getControllerService(@QueryParam(CLIENT_ID) @DefaultValue(StringUtils.EMPTY) ClientIdParameter clientId, @PathParam("id") String id) {
// replicate if cluster manager
if (properties.isClusterManager()) {
@@ -274,7 +271,7 @@ public class ControllerServiceResource extends ApplicationResource {
}
// get the controller service
- final ControllerServiceDTO funnel = serviceFacade.getControllerService(id);
+ final ControllerServiceDTO controllerService = serviceFacade.getControllerService(id);
// create the revision
final RevisionDTO revision = new RevisionDTO();
@@ -283,7 +280,7 @@ public class ControllerServiceResource extends ApplicationResource {
// create the response entity
final ControllerServiceEntity entity = new ControllerServiceEntity();
entity.setRevision(revision);
- entity.setControllerService(populateRemainingControllerServiceContent(funnel));
+ entity.setControllerService(populateRemainingControllerServiceContent(controllerService));
return clusterContext(generateOkResponse(entity)).build();
}
@@ -298,6 +295,25 @@ public class ControllerServiceResource extends ApplicationResource {
* new one will be generated. This value (whether specified or generated) is
* included in the response.
* @param id The id of the controller service to update.
+ * @param name The name of the controller service
+ * @param annotationData The annotation data for the controller service
+ * @param comments The comments for the controller service
+ * @param enabled Whether this controller service is enabled or not
+ * @param markedForDeletion Array of property names whose value should be removed.
+ * @param formParams Additionally, the processor properties and styles are
+ * specified in the form parameters. Because the property names and styles
+ * differ from processor to processor they are specified in a map-like
+ * fashion:
+ * <br>
+ * <ul>
+ * <li>properties[required.file.path]=/path/to/file</li>
+ * <li>properties[required.hostname]=localhost</li>
+ * <li>properties[required.port]=80</li>
+ * <li>properties[optional.file.path]=/path/to/file</li>
+ * <li>properties[optional.hostname]=localhost</li>
+ * <li>properties[optional.port]=80</li>
+ * <li>properties[user.defined.pattern]=^.*?s.*$</li>
+ * </ul>
* @return A controllerServiceEntity.
*/
@PUT
@@ -310,16 +326,51 @@ public class ControllerServiceResource extends ApplicationResource {
@Context HttpServletRequest httpServletRequest,
@FormParam(VERSION) LongParameter version,
@FormParam(CLIENT_ID) @DefaultValue(StringUtils.EMPTY) ClientIdParameter clientId,
- @PathParam("id") String id) {
-
+ @PathParam("id") String id, @FormParam("name") String name,
+ @FormParam("annotationData") String annotationData, @FormParam("comments") String comments,
+ @FormParam("enabled") Boolean enabled, @FormParam("markedForDeletion[]") List<String> markedForDeletion,
+ MultivaluedMap<String, String> formParams) {
+
+ // create collections for holding the controller service properties
+ final Map<String, String> properties = new LinkedHashMap<>();
+
+ // go through each parameter and look for processor properties
+ for (String parameterName : formParams.keySet()) {
+ if (StringUtils.isNotBlank(parameterName)) {
+ // see if the parameter name starts with an expected parameter type...
+ // if so, store the parameter name and value in the corresponding collection
+ if (parameterName.startsWith("properties")) {
+ final int startIndex = StringUtils.indexOf(parameterName, "[");
+ final int endIndex = StringUtils.lastIndexOf(parameterName, "]");
+ if (startIndex != -1 && endIndex != -1) {
+ final String propertyName = StringUtils.substring(parameterName, startIndex + 1, endIndex);
+ properties.put(propertyName, formParams.getFirst(parameterName));
+ }
+ }
+ }
+ }
+
+ // set the properties to remove
+ for (String propertyToDelete : markedForDeletion) {
+ properties.put(propertyToDelete, null);
+ }
+
// create the controller service DTO
final ControllerServiceDTO controllerServiceDTO = new ControllerServiceDTO();
controllerServiceDTO.setId(id);
-
+ controllerServiceDTO.setName(name);
+ controllerServiceDTO.setAnnotationData(annotationData);
+ controllerServiceDTO.setComments(comments);
+ controllerServiceDTO.setEnabled(enabled);
+
+ // only set the properties when appropriate
+ if (!properties.isEmpty()) {
+ controllerServiceDTO.setProperties(properties);
+ }
+
// create the revision
final RevisionDTO revision = new RevisionDTO();
revision.setClientId(clientId.getClientId());
-
if (version != null) {
revision.setVersion(version.getLong());
}
@@ -330,7 +381,7 @@ public class ControllerServiceResource extends ApplicationResource {
controllerServiceEntity.setControllerService(controllerServiceDTO);
// update the controller service
- return updateFunnel(httpServletRequest, id, controllerServiceEntity);
+ return updateControllerService(httpServletRequest, id, controllerServiceEntity);
}
/**
@@ -347,7 +398,7 @@ public class ControllerServiceResource extends ApplicationResource {
@Path("{id}")
@PreAuthorize("hasRole('ROLE_DFM')")
@TypeHint(ControllerServiceEntity.class)
- public Response updateFunnel(
+ public Response updateControllerService(
@Context HttpServletRequest httpServletRequest,
@PathParam("id") String id,
ControllerServiceEntity controllerServiceEntity) {
@@ -447,7 +498,7 @@ public class ControllerServiceResource extends ApplicationResource {
clientVersion = version.getLong();
}
- // delete the specified funnel
+ // delete the specified controller service
final ConfigurationSnapshot<Void> controllerResponse = serviceFacade.deleteControllerService(new Revision(clientVersion, clientId.getClientId()), id);
// get the updated revision
[2/2] incubator-nifi git commit: NIFI-250: - Wiring up updating and
deleting controller services. - Ensuring the new property dialog is closed
when clearing the grid.
Posted by mc...@apache.org.
NIFI-250:
- Wiring up updating and deleting controller services.
- Ensuring the new property dialog is closed when clearing the grid.
Project: http://git-wip-us.apache.org/repos/asf/incubator-nifi/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-nifi/commit/5d5cb8f1
Tree: http://git-wip-us.apache.org/repos/asf/incubator-nifi/tree/5d5cb8f1
Diff: http://git-wip-us.apache.org/repos/asf/incubator-nifi/diff/5d5cb8f1
Branch: refs/heads/NIFI-250
Commit: 5d5cb8f106c630e92852cf0fdefdad1c602c4520
Parents: 2303570
Author: Matt Gilman <ma...@gmail.com>
Authored: Wed Jan 28 08:35:17 2015 -0500
Committer: Matt Gilman <ma...@gmail.com>
Committed: Wed Jan 28 08:35:17 2015 -0500
----------------------------------------------------------------------
.../css/new-controller-service-dialog.css | 5 +-
.../propertytable/jquery.propertytable.js | 3 +
.../nf-controller-service-configuration.js | 79 +++++++++++++-------
.../js/nf/canvas/nf-processor-configuration.js | 10 +--
.../src/main/webapp/js/nf/canvas/nf-settings.js | 52 +++++++++----
5 files changed, 98 insertions(+), 51 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/5d5cb8f1/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/css/new-controller-service-dialog.css
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/css/new-controller-service-dialog.css b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/css/new-controller-service-dialog.css
index 9a9a199..c28a253 100644
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/css/new-controller-service-dialog.css
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/css/new-controller-service-dialog.css
@@ -23,7 +23,7 @@
z-index: 1301;
display: none;
width: 800px;
- height: 500px;
+ height: 450px;
border: 1px solid #eee;
line-height: normal;
}
@@ -42,7 +42,7 @@
#controller-service-description-container {
width: 588px;
- height: 150px;
+ height: 100px;
margin-top: 10px;
}
@@ -57,7 +57,6 @@
#controller-service-type-description {
width: 588px;
height: 60px;
- margin-bottom: 8px;
}
#controller-service-types-table {
http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/5d5cb8f1/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/jquery/propertytable/jquery.propertytable.js
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/jquery/propertytable/jquery.propertytable.js b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/jquery/propertytable/jquery.propertytable.js
index 9b68f06..1e325f4 100644
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/jquery/propertytable/jquery.propertytable.js
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/jquery/propertytable/jquery.propertytable.js
@@ -1211,8 +1211,11 @@
var options = $(this).data('options');
if (options.readOnly === true) {
removeAllPropertyDetailDialogs();
+ } else {
+ $(this).find('div.new-property-dialog').hide();
}
+ // clean up data
var table = $(this).find('div.property-table');
table.removeData('descriptors history');
http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/5d5cb8f1/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-controller-service-configuration.js
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-controller-service-configuration.js b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-controller-service-configuration.js
index 79af834..5d6a496 100644
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-controller-service-configuration.js
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-controller-service-configuration.js
@@ -59,6 +59,12 @@ nf.ControllerServiceConfiguration = (function () {
if ($('#controller-service-comments').val() !== details.comments) {
return true;
}
+
+ if ($('#controller-service-enabled').hasClass('checkbox-checked') && details['enabled'] === false) {
+ return true;
+ } else if ($('#controller-service-enabled').hasClass('checkbox-unchecked') && details['enabled'] === true) {
+ return true;
+ }
// defer to the properties
return $('#controller-service-properties').propertytable('isSaveRequired');
@@ -107,6 +113,36 @@ nf.ControllerServiceConfiguration = (function () {
};
/**
+ * Reloads the specified controller service.
+ *
+ * @param {object} controllerService
+ */
+ var reloadControllerService = function (controllerService) {
+ return $.ajax({
+ type: 'GET',
+ url: controllerService.uri,
+ dataType: 'json'
+ }).done(function (response) {
+ renderControllerService(response.controllerService);
+ }).fail(nf.Common.handleAjaxError);
+ };
+
+ /**
+ * Reloads the specified controller service.
+ *
+ * @param {object} controllerService
+ */
+ var renderControllerService = function (controllerService) {
+ // get the table and update the row accordingly
+ var controllerServiceGrid = $('#controller-services-table').data('gridInstance');
+ var controllerServiceData = controllerServiceGrid.getData();
+ controllerServiceData.updateItem(controllerService.id, controllerService);
+
+ // reload the controller service references
+ reloadControllerServiceReferences(controllerService);
+ };
+
+ /**
* Reloads components that reference this controller service.
*
* @param {object} controllerService
@@ -135,7 +171,7 @@ nf.ControllerServiceConfiguration = (function () {
tabContentId: 'controller-service-comments-tab-content'
}],
select: function () {
- // update the processor property table size in case this is the first time its rendered
+ // update the property table size in case this is the first time its rendered
if ($(this).text() === 'Properties') {
$('#controller-service-properties').propertytable('resetTableSize');
}
@@ -151,7 +187,7 @@ nf.ControllerServiceConfiguration = (function () {
}
});
- // initialize the processor configuration dialog
+ // initialize the conroller service configuration dialog
$('#controller-service-configuration').modal({
headerText: 'Configure Controller Service',
overlayBackground: false,
@@ -160,9 +196,6 @@ nf.ControllerServiceConfiguration = (function () {
// // empty the relationship list
// $('#auto-terminate-relationship-names').css('border-width', '0').empty();
- // close the new property dialog if necessary
- $('#processor-property-dialog').hide();
-
// cancel any active edits
$('#controller-service-properties').propertytable('cancelEdit');
@@ -170,7 +203,7 @@ nf.ControllerServiceConfiguration = (function () {
$('#controller-service-properties').propertytable('clear');
// removed the cached controller service details
-// $('#controller-service-configuration').removeData('processorDetails');
+ $('#controller-service-configuration').removeData('controllerServiceDetails');
// $('#controller-service-configuration').removeData('processorHistory');
}
}
@@ -189,7 +222,7 @@ nf.ControllerServiceConfiguration = (function () {
* @argument {controllerService} controllerService The controller service
*/
showConfiguration: function (controllerService) {
- // record the processor details
+ // record the controller service details
$('#controller-service-configuration').data('controllerServiceDetails', controllerService);
// determine if the enabled checkbox is checked or not
@@ -198,7 +231,7 @@ nf.ControllerServiceConfiguration = (function () {
controllerServiceEnableStyle = 'checkbox-unchecked';
}
- // populate the processor settings
+ // populate the controller service settings
$('#controller-service-id').text(controllerService['id']);
$('#controller-service-type').text(nf.Common.substringAfterLast(controllerService['type'], '.'));
$('#controller-service-name').val(controllerService['name']);
@@ -229,19 +262,16 @@ nf.ControllerServiceConfiguration = (function () {
processData: false,
contentType: 'application/json'
}).done(function (response) {
-// if (nf.Common.isDefinedAndNotNull(response.processor)) {
-// // update the revision
-// nf.Client.setRevision(response.revision);
-//
-// // set the new processor state based on the response
-// nf.Processor.set(response.processor);
-//
-// // reload the processor's outgoing connections
-// reloadProcessorConnections(processor);
-//
-// // close the details panel
-// $('#processor-configuration').modal('hide');
-// }
+ if (nf.Common.isDefinedAndNotNull(response.controllerService)) {
+ // update the revision
+ nf.Client.setRevision(response.revision);
+
+ // reload the controller service
+ renderControllerService(response.controllerService);
+
+ // close the details panel
+ $('#controller-service-configuration').modal('hide');
+ }
}).fail(handleControllerServiceConfigurationError);
}
}
@@ -267,11 +297,8 @@ nf.ControllerServiceConfiguration = (function () {
// show the custom ui
nf.CustomProcessorUi.showCustomUi($('#controller-service-id').text(), controllerService.customUiUrl, true).done(function () {
-// // once the custom ui is closed, reload the processor
-// nf.Processor.reload(processor);
-//
-// // and reload the processor's outgoing connections
-// reloadProcessorConnections(processor);
+ // once the custom ui is closed, reload the controller service
+ reloadControllerService(controllerService);
});
};
http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/5d5cb8f1/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-processor-configuration.js
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-processor-configuration.js b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-processor-configuration.js
index 106542f..aa8980b 100644
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-processor-configuration.js
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-processor-configuration.js
@@ -426,14 +426,8 @@ nf.ProcessorConfiguration = (function () {
// empty the relationship list
$('#auto-terminate-relationship-names').css('border-width', '0').empty();
- // close the new property dialog if necessary
- $('#processor-property-dialog').hide();
-
- // cancel any active edits
- $('#processor-properties').propertytable('cancelEdit');
-
- // clear the tables
- $('#processor-properties').propertytable('clear');
+ // cancel any active edits and clear the table
+ $('#processor-properties').propertytable('cancelEdit').propertytable('clear');
// removed the cached processor details
$('#processor-configuration').removeData('processorDetails');
http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/5d5cb8f1/nifi/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/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-settings.js b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-settings.js
index f70ed72..37f218b 100644
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-settings.js
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-settings.js
@@ -369,12 +369,12 @@ nf.Settings = (function () {
},
dataType: 'json'
}).done(function (response) {
- var controllerService = response.controllerService;
- if (nf.Common.isDefinedAndNotNull(controllerService)) {
- var controllerServicesGrid = $('#controller-services-table').data('gridInstance');
- var controllerServicesData = controllerServicesGrid.getData();
- controllerServicesData.addItem(controllerService);
- }
+ // update the revision
+ nf.Client.setRevision(response.revision);
+
+ var controllerServicesGrid = $('#controller-services-table').data('gridInstance');
+ var controllerServicesData = controllerServicesGrid.getData();
+ controllerServicesData.addItem(response.controllerService);
});
// hide the dialog
@@ -497,12 +497,6 @@ nf.Settings = (function () {
controllerServiceTypesGrid.onClick.subscribe(function (e, args) {
var item = controllerServiceTypesData.getItem(args.row);
if (item && item.children.length > 0) {
- // determine if there are rows currectly selected
- var selectedIndex = controllerServiceTypesGrid.getSelectedRows();
- if ($.isArray(selectedIndex) && selectedIndex.length === 1) {
-
- }
-
// update the grid
item.collapsed = !item.collapsed;
controllerServiceTypesData.updateItem(item.id, item);
@@ -711,9 +705,39 @@ nf.Settings = (function () {
if (target.hasClass('edit-controller-service')) {
nf.ControllerServiceConfiguration.showConfiguration(controllerService);
} else if (target.hasClass('enable-controller-service')) {
-
+ var revision = nf.Client.getRevision();
+ return $.ajax({
+ type: 'PUT',
+ url: controllerService.uri,
+ data: {
+ clientId: revision.clientId,
+ version: revision.version,
+ enabled: true
+ },
+ dataType: 'json'
+ }).done(function (response) {
+ // update the revision
+ nf.Client.setRevision(response.revision);
+
+ // update the service
+ controllerServicesData.updateItem(controllerService.id, response.controllerService);
+ }).fail(nf.Common.handleAjaxError);
} else if (target.hasClass('delete-controller-service')) {
-
+ var revision = nf.Client.getRevision();
+ return $.ajax({
+ type: 'DELETE',
+ url: controllerService.uri + '?' + $.param({
+ version: revision.version,
+ clientId: revision.clientId
+ }),
+ dataType: 'json'
+ }).done(function (response) {
+ // update the revision
+ nf.Client.setRevision(response.revision);
+
+ // remove the service
+ controllerServicesData.deleteItem(controllerService.id);
+ }).fail(nf.Common.handleAjaxError);
}
} else if (controllerServicesGrid.getColumns()[args.cell].id === 'moreDetails') {
if (target.hasClass('view-controller-service')) {