stratos-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From im...@apache.org
Subject [4/4] stratos git commit: Adding force undeployment button for UI
Date Mon, 22 Jun 2015 06:09:52 GMT
Adding force undeployment button for UI


Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/efbd8652
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/efbd8652
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/efbd8652

Branch: refs/heads/master
Commit: efbd86522d71355c3e9d8864ab006a25e590dfa2
Parents: 444954e
Author: anuruddhal <anuruddha789@gmail.com>
Authored: Wed Jun 17 19:34:47 2015 +0530
Committer: Imesh Gunaratne <imesh@apache.org>
Committed: Mon Jun 22 11:39:42 2015 +0530

----------------------------------------------------------------------
 .../applications/pojo/ApplicationContext.java   |  1 +
 .../services/impl/AutoscalerServiceImpl.java    |  2 +-
 .../console/applications_form.jag               |  1 +
 .../applications/application_requests.jag       |  3 ++
 .../console/controllers/rest/rest_calls.jag     |  4 ++
 .../console/themes/theme0/css/custom.css        |  4 ++
 .../theme0/partials/applications_form.hbs       | 52 +++++++++++++-------
 .../theme0/partials/applications_topology.hbs   | 52 ++++++++++++++++++++
 .../theme0/renderers/applications_form.js       |  1 +
 .../rest/endpoint/api/StratosApiV41.java        |  2 +-
 10 files changed, 102 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/efbd8652/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/pojo/ApplicationContext.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/pojo/ApplicationContext.java
b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/pojo/ApplicationContext.java
index 7ab87ce..ec79fcf 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/pojo/ApplicationContext.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/pojo/ApplicationContext.java
@@ -29,6 +29,7 @@ public class ApplicationContext implements Serializable {
 
     public static final String STATUS_CREATED = "Created";
     public static final String STATUS_DEPLOYED = "Deployed";
+    public static final String STATUS_UNDEPLOYING = "Undeploying";
 
     private String applicationId;
     private String alias;

http://git-wip-us.apache.org/repos/asf/stratos/blob/efbd8652/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/services/impl/AutoscalerServiceImpl.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/services/impl/AutoscalerServiceImpl.java
b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/services/impl/AutoscalerServiceImpl.java
index bcf4763..e6baf1e 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/services/impl/AutoscalerServiceImpl.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/services/impl/AutoscalerServiceImpl.java
@@ -554,7 +554,7 @@ public class AutoscalerServiceImpl implements AutoscalerService {
                 log.error(message);
                 throw new RuntimeException(message);
             }
-
+            applicationContext.setStatus(ApplicationContext.STATUS_UNDEPLOYING);
             // Remove application signup(s) in stratos manager
             removeApplicationSignUp(applicationContext);
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/efbd8652/components/org.apache.stratos.manager.console/console/applications_form.jag
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager.console/console/applications_form.jag b/components/org.apache.stratos.manager.console/console/applications_form.jag
index 0c52785..ad1745c 100644
--- a/components/org.apache.stratos.manager.console/console/applications_form.jag
+++ b/components/org.apache.stratos.manager.console/console/applications_form.jag
@@ -123,6 +123,7 @@ var caramelData = {
     applicationAlias:applicationAlias,
     applicationName:applicationName,
     applicationJSON:JSON.stringify(applicationJSON),
+    applicationStatus: applicationJSON.status,
     formTitle: formTitle,
     formDataRaw: JSON.stringify(formDataRaw),
     formtype:elements.formtype,

http://git-wip-us.apache.org/repos/asf/stratos/blob/efbd8652/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 7867505..2e51c7b 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
@@ -43,6 +43,9 @@ try {
         case "undeployapplication":
             formSubmit = util.RESTCalls.undeployApplication(applicationId);
             break;
+        case "forceundeployapplication":
+            formSubmit = util.RESTCalls.forceUndeployApplication(applicationId);
+            break;
         default:
             session.put("deploy-status", { "message": "Sorry Endpoint Error", "status": "error"
});
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/efbd8652/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 ed5d42a..7b020fa 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
@@ -140,6 +140,10 @@ RESTCalls = new function(){
         return this.send("POST","/applications/"+applicationId+"/undeploy",{});
     };
 
+    this.forceUndeployApplication = function(applicationId){
+        return this.send("POST","/applications/"+applicationId+"/undeploy?force=true",{});
+    };
+
     this.deleteGroup = function(groupName){
         return this.send("DELETE","/cartridgeGroups/" + groupName,{});
     };

http://git-wip-us.apache.org/repos/asf/stratos/blob/efbd8652/components/org.apache.stratos.manager.console/console/themes/theme0/css/custom.css
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager.console/console/themes/theme0/css/custom.css
b/components/org.apache.stratos.manager.console/console/themes/theme0/css/custom.css
index 10d3788..a8b1b3a 100644
--- a/components/org.apache.stratos.manager.console/console/themes/theme0/css/custom.css
+++ b/components/org.apache.stratos.manager.console/console/themes/theme0/css/custom.css
@@ -218,6 +218,10 @@ button.hover-undeploy{
     margin-top: .7em;
 }
 
+button.hover-force-undeploy{
+    margin-top: .7em;
+}
+
 div#textform>div>h3 {
     display: none;
 }

http://git-wip-us.apache.org/repos/asf/stratos/blob/efbd8652/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 0042071..0c72fb9 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
@@ -115,25 +115,41 @@
 
                             <div class="toggle-menu-description">{{description}} {{status}}</div>
                             {{#ifCond status "!=" "Created"}}
-                            <div class="list-button" style="display: none;">
-                                <button class="btn btn-danger btn-lg hover-undeploy" type="button"
-                                        id="{{applicationId}}"> Undeploy</button>
-                                <button class="btn btn-info btn-lg hover-details" type="button"
-                                        id="details_list_{{applicationId}}"
-                                        data-url="{{url ""}}/applications/{{applicationId}}/"
> View
-                                </button>
-                            </div>
-                            <div class="bottom-bar-wrapper">
-                                <div class="bottom-bar">
-                                    <button class="btn btn-danger btn-lg hover-undeploy"
type="button"
-                                            id="{{applicationId}}"> Undeploy</button>
-                                    <button class="btn btn-info btn-lg hover-details"
type="button"
-                                            id="details_{{applicationId}}"
-                                            data-url="{{url ""}}/applications/{{applicationId}}/"
> View
-                                    </button>
-
+                                {{#ifCond status "==" "Deployed"}}
+                                    <div class="list-button" style="display: none;">
+                                        <button class="btn btn-danger btn-lg hover-undeploy"
type="button"
+                                                id="{{applicationId}}"> Undeploy</button>
+                                        <button class="btn btn-info btn-lg hover-details"
type="button"
+                                                id="details_list_{{applicationId}}"
+                                                data-url="{{url ""}}/applications/{{applicationId}}/"
> View
+                                        </button>
+                                    </div>
+                                    <div class="bottom-bar-wrapper">
+                                        <div class="bottom-bar">
+                                            <button class="btn btn-danger btn-lg hover-undeploy"
type="button"
+                                                    id="{{applicationId}}"> Undeploy</button>
+                                            <button class="btn btn-info btn-lg hover-details"
type="button"
+                                                    id="details_{{applicationId}}"
+                                                    data-url="{{url ""}}/applications/{{applicationId}}/"
> View
+                                            </button>
+
+                                        </div>
+                                {{else}}
+                                    <div class="list-button" style="display: none;">
+                                        <button class="btn btn-info btn-lg hover-details"
type="button"
+                                                id="details_list_{{applicationId}}"
+                                                data-url="{{url ""}}/applications/{{applicationId}}/"
> View
+                                        </button>
+                                    </div>
+                                    <div class="bottom-bar-wrapper">
+                                    <div class="bottom-bar">
+                                        <button class="btn btn-info btn-lg hover-details"
type="button"
+                                                id="details_{{applicationId}}"
+                                                data-url="{{url ""}}/applications/{{applicationId}}/"
> View
+                                        </button>
+                                    </div>
+                                {{/ifCond}}
                                 </div>
-                            </div>
                             {{else}}
                                 <div class="list-button" style="display: none;">
                                     <button class="btn btn-danger btn-lg hover-delete"
type="button"

http://git-wip-us.apache.org/repos/asf/stratos/blob/efbd8652/components/org.apache.stratos.manager.console/console/themes/theme0/partials/applications_topology.hbs
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager.console/console/themes/theme0/partials/applications_topology.hbs
b/components/org.apache.stratos.manager.console/console/themes/theme0/partials/applications_topology.hbs
index 3627b31..0deb7c9 100644
--- a/components/org.apache.stratos.manager.console/console/themes/theme0/partials/applications_topology.hbs
+++ b/components/org.apache.stratos.manager.console/console/themes/theme0/partials/applications_topology.hbs
@@ -32,7 +32,13 @@
                 <div class='col-md-1'>
                     <button class='btn btn-default btn-lg' type='button' style="margin-left:
-15px; "
                             onclick='window.location.replace(document.referrer)'> Back</button>
+                    </div>
+        {{#ifCond applicationStatus "==" "Undeploying"}}
+                <div class='col-md-1'>
+                    <button class="btn btn-danger btn-lg" type="button" style="..."
+                            value="{{appName}}" id="force_undeploy">Force Undeploy</button>
                 </div>
+        {{/ifCond}}
             </div>
         </div>
         <!-- Nav tabs -->
@@ -142,6 +148,52 @@ $(window).load(function() {
         downloadCanvas(this, 'canvasOriginal', '{{{appName}}}.png');
     });
 
+$( "#force_undeploy" ).click(function() {
+var payload =$(this).attr("value");
+  noty({
+            layout: 'bottomRight',
+            type: 'warning',
+            text: 'Are you sure you want to <strong>forcefully undeploy</strong>
application: <strong>'
+            +$(this).attr("value") + "</strong> ?",
+            buttons: [
+                {addClass: 'btn btn-primary', text: 'Yes', onClick: function($noty) {
+                    var formtype = 'forceundeployapplication';
+                    $noty.close();
+
+                    $.ajax({
+                        type: "POST",
+                        url: caramel.context + "/controllers/applications/application_requests.jag",
+                        dataType: 'json',
+                        data: { "applicationId": 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();
+                }
+                }
+            ]
+        });
+    });
 });
+
+
+
+
+
 </script>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/efbd8652/components/org.apache.stratos.manager.console/console/themes/theme0/renderers/applications_form.js
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager.console/console/themes/theme0/renderers/applications_form.js
b/components/org.apache.stratos.manager.console/console/themes/theme0/renderers/applications_form.js
index 85bac5e..80d9dad 100644
--- a/components/org.apache.stratos.manager.console/console/themes/theme0/renderers/applications_form.js
+++ b/components/org.apache.stratos.manager.console/console/themes/theme0/renderers/applications_form.js
@@ -135,6 +135,7 @@ var render = function (theme, data, meta, require) {
                                 appName: data.appName,
                                 topologyData: data.topologyData,
                                 applicationJSON:data.applicationJSON,
+                                applicationStatus: data.applicationStatus,
                                 form_action: data.form_action,
                                 formHtml: data.formHtml,
                                 formData: data.formData,

http://git-wip-us.apache.org/repos/asf/stratos/blob/efbd8652/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java
b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java
index c319873..11ecb30 100644
--- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java
@@ -1254,7 +1254,7 @@ public class StratosApiV41 extends AbstractApi {
         }
         StratosApiV41Utils.undeployApplication(applicationId, force);
         return Response.accepted().entity(new ResponseMessageBean(ResponseMessageBean.SUCCESS,
-                String.format("Application undeployed successfully: [application-id] %s",
applicationId))).build();
+                String.format("Application undeploy process started successfully: [application-id]
%s", applicationId))).build();
     }
 
     /**


Mime
View raw message