fix application policy delete feature
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/044da421 Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/044da421 Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/044da421 Branch: refs/heads/master Commit: 044da42104dba1ae4ba4116186caeef621e8eaf7 Parents: b75179e Author: Dakshika Jayathilaka <[email protected]> Authored: Sun Mar 8 10:43:04 2015 +0530 Committer: Imesh Gunaratne <[email protected]> Committed: Sun Mar 8 12:02:56 2015 +0530 ---------------------------------------------------------------------- .../applications/application_requests.jag | 3 ++ .../console/controllers/rest/rest_calls.jag | 4 ++ .../console/themes/theme0/css/custom/style.css | 4 ++ .../theme0/partials/applications_form.hbs | 47 +++++++++++++++++++- 4 files changed, 56 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/stratos/blob/044da421/components/org.apache.stratos.manager.console/console/controllers/applications/application_requests.jag ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.manager.console/console/controllers/applications/application_requests.jag b/components/org.apache.stratos.manager.console/console/controllers/applications/application_requests.jag index f26e214..516ba3e 100644 --- a/components/org.apache.stratos.manager.console/console/controllers/applications/application_requests.jag +++ b/components/org.apache.stratos.manager.console/console/controllers/applications/application_requests.jag @@ -40,6 +40,9 @@ try { case "applicationpolicies": formSubmit = util.RESTCalls.deployApplicationPolicyDefinition(formPayload); break; + case "deleteapppolicy": + formSubmit = util.RESTCalls.deleteApplicationPolicyDefinition(formPayload); + break; case "applications": formSubmit = util.RESTCalls.deployApplicationDefinition(formPayload); break; http://git-wip-us.apache.org/repos/asf/stratos/blob/044da421/components/org.apache.stratos.manager.console/console/controllers/rest/rest_calls.jag ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.manager.console/console/controllers/rest/rest_calls.jag b/components/org.apache.stratos.manager.console/console/controllers/rest/rest_calls.jag index 84e96bc..d062389 100644 --- a/components/org.apache.stratos.manager.console/console/controllers/rest/rest_calls.jag +++ b/components/org.apache.stratos.manager.console/console/controllers/rest/rest_calls.jag @@ -104,6 +104,10 @@ RESTCalls = new function(){ return this.send("DELETE","/applications/" + applicationId,{}); }; + this.deleteApplicationPolicyDefinition = function(applicationPolicyId){ + return this.send("DELETE","/applicationPolicies/" + applicationPolicyId,{}); + }; + this.undeployApplication = function(applicationId){ return this.send("POST","/applications/"+applicationId+"/undeploy",{}); }; http://git-wip-us.apache.org/repos/asf/stratos/blob/044da421/components/org.apache.stratos.manager.console/console/themes/theme0/css/custom/style.css ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.manager.console/console/themes/theme0/css/custom/style.css b/components/org.apache.stratos.manager.console/console/themes/theme0/css/custom/style.css index ee66998..78fb4b2 100644 --- a/components/org.apache.stratos.manager.console/console/themes/theme0/css/custom/style.css +++ b/components/org.apache.stratos.manager.console/console/themes/theme0/css/custom/style.css @@ -252,4 +252,8 @@ button.hover-delete-autoscale{ background-color: rgb(255, 252, 196); padding: 2px 10px; border-radius: 4px; +} + +button.hover-delete-app-policy{ + margin-top: .7em; } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/stratos/blob/044da421/components/org.apache.stratos.manager.console/console/themes/theme0/partials/applications_form.hbs ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.manager.console/console/themes/theme0/partials/applications_form.hbs b/components/org.apache.stratos.manager.console/console/themes/theme0/partials/applications_form.hbs index dbe107f..14ec016 100644 --- a/components/org.apache.stratos.manager.console/console/themes/theme0/partials/applications_form.hbs +++ b/components/org.apache.stratos.manager.console/console/themes/theme0/partials/applications_form.hbs @@ -184,7 +184,7 @@ <div class="toggle-menu-description">{{description}} </div> <div class="list-button" style="display: none;"> - <button class="btn btn-danger btn-lg hover-delete-group" type="button" + <button class="btn btn-danger btn-lg hover-delete-app-policy" type="button" id="{{id}}"> Delete</button> <button class="btn btn-info btn-lg hover-details" type="button" id="details_list_{{id}}" data-url="{{url ""}}/applications/applicationpolicies{{id}}/" > Details @@ -192,7 +192,7 @@ </div> <div class="bottom-bar-wrapper"> <div class="bottom-bar"> - <button class="btn btn-danger btn-lg hover-delete-group" type="button" + <button class="btn btn-danger btn-lg hover-delete-app-policy" type="button" id="{{id}}"> Delete</button> <button class="btn btn-info btn-lg hover-details" type="button" id="details_{{id}}" data-url="{{url ""}}/applications/applicationpolicies/{{id}}/" > Details @@ -466,6 +466,49 @@ }); }); + $('.general-table').on('click', '.hover-delete-app-policy', function (event) { + + var payload =$(this).attr("id"); + noty({ + layout: 'bottomRight', + type: 'warning', + text: 'Are you sure you want to delete Application Policy: <strong>'+$(this).attr("id") + "</strong> ?", + buttons: [ + {addClass: 'btn btn-primary', text: 'Yes', onClick: function($noty) { + var formtype = 'deleteapppolicy'; + $noty.close(); + + $.ajax({ + type: "POST", + url: caramel.context + "/controllers/applications/application_requests.jag", + dataType: 'json', + data: { "formPayload": payload, "formtype": formtype }, + success: function (data) { + if (data.status == 'error') { + var n = noty({text: data.message, layout: 'bottomRight', type: 'error'}); + } else if (data.status == 'warning') { + var n = noty({text: data.message, layout: 'bottomRight', type: 'warning'}); + } else { + var n = noty({text: data.message, layout: 'bottomRight', type: 'success'}); + } + window.setTimeout(function(){ + location.reload(); + }, 1000); + } + }).always(function () { + + }); + + } + }, + {addClass: 'btn btn-danger', text: 'No', onClick: function($noty) { + $noty.close(); + } + } + ] + }); + }); + $('.general-table').on('click', '.hover-undeploy', function (event) { var payload =$(this).attr("id");
