success box
authorScott Baker <smbaker@gmail.com>
Wed, 29 Oct 2014 04:40:20 +0000 (21:40 -0700)
committerScott Baker <smbaker@gmail.com>
Wed, 29 Oct 2014 04:40:20 +0000 (21:40 -0700)
planetstack/core/xoslib/dashboards/test.html
planetstack/core/xoslib/static/css/test.css
planetstack/core/xoslib/static/js/test.js

index b15f4fd..5326b76 100644 (file)
@@ -53,6 +53,8 @@
 </div>
 
 <div id="rightSide">
+<div id="successBox">
+</div>
 <div id="errorBox">
 </div>
 
   </table>
 </script>
 
+<script type="text/template" id="test-success-template">
+  <button id="close-success-box">Close Success Message</button>
+  <h3>Success!</h3>
+  <table class="test-success-table">
+  <tr><td>Code:</td><td><%= status %></td></tr>
+  <tr><td>Message:</td><td><%= statusText %></td></tr>
+  </table>
+</script>
+
 <!-- Deployment -->
 
 <script type="text/template" id="test-deployment-list-template">
index 51b7407..e5b1b80 100644 (file)
@@ -12,7 +12,7 @@
     padding: 10px;
     border: 2px solid;
     background-color: #f0f0f0;
-    margin-bottom:50px;
+    margin-bottom:30px;
     display:none;
 }
 
     padding: 10px;
     border: 2px solid;
     background-color: #f00000;
-    margin-bottom:50px;
+    margin-bottom:30px;
+    display:none;
+}
+
+#successBox {
+    padding: 10px;
+    border: 2px solid;
+    background-color: #00f000;
+    margin-bottom:30px;
     display:none;
 }
 
index fff0df3..ff681e8 100644 (file)
@@ -34,6 +34,15 @@ TestApp.DeploymentListView = Marionette.CompositeView.extend({
 
 TestApp.hideError = function(result) {
     $("#errorBox").hide();
+    $("#successBox").hide();
+};
+
+TestApp.showSuccess = function(result) {
+     $("#successBox").show();
+     $("#successBox").html(_.template($("#test-success-template").html())(result));
+     $('#close-success-box').unbind().bind('click', function() {
+         $('#successBox').hide();
+     });
 };
 
 TestApp.showError = function(result) {
@@ -75,12 +84,17 @@ TestApp.on("start", function() {
                 TestApp.showError(result);\r
             },\r
 \r
+            saveSuccess: function(model, result, xhr) {\r
+                TestApp.showSuccess({status: xhr.xhr.status, statusText: xhr.xhr.statusText});\r
+            },\r
+\r
             submitClicked: function(e) {\r
                 TestApp.hideError();\r
                 e.preventDefault();\r
                 var data = Backbone.Syphon.serialize(this);\r
                 var thisView = this;\r
-                this.model.save(data, {error: function(model, result, xhr) { thisView.saveError(model, result, xhr); }});\r
+                this.model.save(data, {error: function(model, result, xhr) { thisView.saveError(model, result, xhr); },\r
+                                       success: function(model, result, xhr) { thisView.saveSuccess(model, result, xhr); }});\r
                 this.dirty = false;\r
             },\r
          });
@@ -120,7 +134,7 @@ TestApp.on("start", function() {
          var listView = new listViewClass();
 
          TestApp[region_name].show(listView);
-         xos[collection_name].startPolling();
+         xos[collection_name].fetch(); //startPolling();
      }
 
      $('#close-detail-view').unbind().bind('click', function() {