From 1603543e3ecad16f8ac0f36aa62e40fd46b4486d Mon Sep 17 00:00:00 2001 From: Scott Baker Date: Tue, 28 Oct 2014 14:46:13 -0700 Subject: [PATCH] error box --- planetstack/core/xoslib/dashboards/test.html | 14 +++++++++++ planetstack/core/xoslib/static/css/test.css | 18 ++++++++++++-- planetstack/core/xoslib/static/js/test.js | 26 +++++++++++++++++--- 3 files changed, 53 insertions(+), 5 deletions(-) diff --git a/planetstack/core/xoslib/dashboards/test.html b/planetstack/core/xoslib/dashboards/test.html index 9eb005a..98cc0c1 100644 --- a/planetstack/core/xoslib/dashboards/test.html +++ b/planetstack/core/xoslib/dashboards/test.html @@ -48,12 +48,26 @@
+
+
+
+
+
+ + diff --git a/planetstack/core/xoslib/static/css/test.css b/planetstack/core/xoslib/static/css/test.css index 157f2a8..51b7407 100644 --- a/planetstack/core/xoslib/static/css/test.css +++ b/planetstack/core/xoslib/static/css/test.css @@ -2,11 +2,25 @@ border: 1px solid black; } -#detailBox { +#rightSide { position: fixed; top: 1em; right: 1em; - border: 1px; +} + +#detailBox { + padding: 10px; + border: 2px solid; background-color: #f0f0f0; + margin-bottom:50px; + display:none; +} + +#errorBox { + padding: 10px; + border: 2px solid; + background-color: #f00000; + margin-bottom:50px; + display:none; } diff --git a/planetstack/core/xoslib/static/js/test.js b/planetstack/core/xoslib/static/js/test.js index 7a1106c..10626d7 100644 --- a/planetstack/core/xoslib/static/js/test.js +++ b/planetstack/core/xoslib/static/js/test.js @@ -32,6 +32,18 @@ TestApp.DeploymentListView = Marionette.CompositeView.extend({ }, }); +TestApp.hideError = function(result) { + $("#errorBox").hide(); +}; + +TestApp.showError = function(result) { + $("#errorBox").show(); + $("#errorBox").html(_.template($("#test-error-template").html())(result)); + $('#close-error-box').unbind().bind('click', function() { + $('#errorBox').hide(); + }); +}; + TestApp.on("start", function() { var objs = ['deployment', 'image', 'networkTemplate', 'network', 'node', 'service', 'site', 'slice', 'sliver']; @@ -59,10 +71,16 @@ TestApp.on("start", function() { this.dirty = true; }, + saveError: function(model, result, xhr) { + TestApp.showError(result); + }, + submitClicked: function(e) { + TestApp.hideError(); e.preventDefault(); var data = Backbone.Syphon.serialize(this); - this.model.save(data); + var thisView = this; + this.model.save(data, {error: function(model, result, xhr) { thisView.saveError(model, result, xhr); }}); this.dirty = false; }, }); @@ -76,6 +94,7 @@ TestApp.on("start", function() { events: {"click": "changeItem"}, changeItem: function(e) { + TestApp.hideError(); e.preventDefault(); e.stopPropagation(); @@ -104,11 +123,12 @@ TestApp.on("start", function() { xos[collection_name].startPolling(); } - $('#close-detail-view').bind('click', function() { + $('#close-detail-view').unbind().bind('click', function() { $('#detailBox').hide(); }); - $('#detailBox').hide(); +// $('#detailBox').hide(); +// $('#errorBox').hide(); }); $(document).ready(function(){ -- 2.47.0