ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From onechipore...@apache.org
Subject ambari git commit: AMBARI-8409. Alerts UI: Alert Definition details page throws exception on page reload (onechiporenko)
Date Fri, 21 Nov 2014 13:36:32 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk eeac84a52 -> 15ffd2ece


AMBARI-8409. Alerts UI: Alert Definition details page throws exception on page reload (onechiporenko)


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

Branch: refs/heads/trunk
Commit: 15ffd2ece6b20712ca505cd1f06361f224ac2c20
Parents: eeac84a
Author: Oleg Nechiporenko <onechiporenko@apache.org>
Authored: Fri Nov 21 14:22:58 2014 +0200
Committer: Oleg Nechiporenko <onechiporenko@apache.org>
Committed: Fri Nov 21 14:22:58 2014 +0200

----------------------------------------------------------------------
 .../alerts/definition_details_controller.js     | 10 +++++++
 .../app/mappers/alert_definitions_mapper.js     |  1 +
 ambari-web/app/routes/main.js                   | 11 ++++----
 .../main/alerts/definition_details.hbs          |  5 ++++
 .../main/alerts/definition_details_view.js      | 28 ++++++++++++++++++++
 5 files changed, 50 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/15ffd2ec/ambari-web/app/controllers/main/alerts/definition_details_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/alerts/definition_details_controller.js b/ambari-web/app/controllers/main/alerts/definition_details_controller.js
index 247c5d8..05d2ad0 100644
--- a/ambari-web/app/controllers/main/alerts/definition_details_controller.js
+++ b/ambari-web/app/controllers/main/alerts/definition_details_controller.js
@@ -60,6 +60,16 @@ App.MainAlertDefinitionDetailsController = Em.Controller.extend({
   }.observes('editing.description.value'),
 
   /**
+   * Load alert instances for current alertDefinition
+   * Start updating loaded data
+   * @method loadAlertInstances
+   */
+  loadAlertInstances: function() {
+    App.router.get('mainAlertInstancesController').loadAlertInstancesByAlertDefinition(this.get('content.id'));
+    App.router.set('mainAlertInstancesController.isUpdating', true);
+  },
+
+  /**
    * Edit button handler
    * @param event
    */

http://git-wip-us.apache.org/repos/asf/ambari/blob/15ffd2ec/ambari-web/app/mappers/alert_definitions_mapper.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mappers/alert_definitions_mapper.js b/ambari-web/app/mappers/alert_definitions_mapper.js
index 7ca8c41..7d38621 100644
--- a/ambari-web/app/mappers/alert_definitions_mapper.js
+++ b/ambari-web/app/mappers/alert_definitions_mapper.js
@@ -181,6 +181,7 @@ App.alertDefinitionsMapper = App.QuickDataMapper.create({
       if (App.router.get('mainAlertDefinitionsController')) {
         App.router.set('mainAlertDefinitionsController.mapperTimestamp', (new Date()).getTime());
       }
+      App.store.commit();
     }
   },
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/15ffd2ec/ambari-web/app/routes/main.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/routes/main.js b/ambari-web/app/routes/main.js
index 361312b..86c01eb 100644
--- a/ambari-web/app/routes/main.js
+++ b/ambari-web/app/routes/main.js
@@ -331,12 +331,13 @@ module.exports = Em.Route.extend({
     }),
 
     alertDetails: Em.Route.extend({
-      route: '/:alert_id',
-      connectOutlets: function (router, alert) {
-        router.get('mainAlertInstancesController').loadAlertInstancesByAlertDefinition(alert.get('id'));
-        router.set('mainAlertInstancesController.isUpdating', true);
-        router.get('mainController').connectOutlet('mainAlertDefinitionDetails', alert);
+
+      route: '/:alert_definition_id',
+
+      connectOutlets: function (router, alertDefinition) {
+        router.get('mainController').connectOutlet('mainAlertDefinitionDetails', alertDefinition);
       },
+
       exit: function(router) {
         router.set('mainAlertInstancesController.isUpdating', false);
       }

http://git-wip-us.apache.org/repos/asf/ambari/blob/15ffd2ec/ambari-web/app/templates/main/alerts/definition_details.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/main/alerts/definition_details.hbs b/ambari-web/app/templates/main/alerts/definition_details.hbs
index ab58561..298ea56 100644
--- a/ambari-web/app/templates/main/alerts/definition_details.hbs
+++ b/ambari-web/app/templates/main/alerts/definition_details.hbs
@@ -16,6 +16,8 @@
 * limitations under the License.
 }}
 
+{{#if view.isLoaded}}
+
 <div id="alert-definition-details">
   <div class="row-fluid">
     <div class="span9">
@@ -164,3 +166,6 @@
     </div>
   </div>
 </div>
+{{else}}
+  <div class="spinner"></div>
+{{/if}}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/15ffd2ec/ambari-web/app/views/main/alerts/definition_details_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/alerts/definition_details_view.js b/ambari-web/app/views/main/alerts/definition_details_view.js
index 4ad474f..8490755 100644
--- a/ambari-web/app/views/main/alerts/definition_details_view.js
+++ b/ambari-web/app/views/main/alerts/definition_details_view.js
@@ -22,6 +22,34 @@ App.MainAlertDefinitionDetailsView = App.TableView.extend({
 
   templateName: require('templates/main/alerts/definition_details'),
 
+  /**
+   * Determines if <code>controller.content</code> is loaded
+   * @type {bool}
+   */
+  isLoaded: false,
+
+  willInsertElement: function () {
+    var self = this,
+      updater = App.router.get('updateController');
+    if (self.get('controller.content.isLoaded')) {
+      self.set('isLoaded', true);
+      self.get('controller').loadAlertInstances();
+    }
+    else {
+      updater.updateAlertGroups(function () {
+        updater.updateAlertDefinitions(function () {
+          updater.updateAlertDefinitionSummary(function () {
+            self.set('isLoaded', true);
+            // App.AlertDefinition doesn't represents real models
+            // Real model (see AlertDefinition types) should be used
+            self.set('controller.content', App.AlertDefinition.getAllDefinitions().findProperty('id',
parseInt(self.get('controller.content.id'))));
+            self.get('controller').loadAlertInstances();
+          });
+        });
+      });
+    }
+  },
+
   didInsertElement: function () {
     this.filter();
   },


Mime
View raw message