X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=plugins%2Ffilter_status%2Fstatic%2Fjs%2Ffilter_status.js;h=7a30100509905c6ab7902bd244759ea1cb4507d8;hb=d035a1f93e4acbeee79b7c8200264687d940ccc2;hp=9c3fe4fe4673aaf6f81bda144b9c577b35877cb4;hpb=6eb1d8c9d03d2b10b514c317b6fff11172097346;p=myslice.git diff --git a/plugins/filter_status/static/js/filter_status.js b/plugins/filter_status/static/js/filter_status.js index 9c3fe4fe..7a301005 100644 --- a/plugins/filter_status/static/js/filter_status.js +++ b/plugins/filter_status/static/js/filter_status.js @@ -28,11 +28,16 @@ /* Setup query and record handlers */ this.listen_query(options.query_uuid); + this.listen_query(options.query_lease_uuid, 'leases'); /* Setup click handlers */ this.elts('list-group-item').click({'instance': this}, this._on_click); this.prev_filter_status = null; + + /* Initialize tooltips */ + $("[rel='tooltip']").tooltip(); + }, /************************************************************************** @@ -52,14 +57,50 @@ // These functions are here to react on external filters, which we don't // use at the moment - on_filter_added: function(filter) { + on_filter_added: function(filter) + { // XXX }, - on_filter_removed: function(filter) { + on_filter_removed: function(filter) + { // XXX }, + on_leases_field_state_changed: function(data) + { + console.log('leases_field_state_changed'); + this.on_field_state_changed(data); + }, + on_field_state_changed: function(data) + { + var query_ext; + + switch (data.state) { + case STATE_SET: + case STATE_WARNINGS: + /* Get the number of pending / unconfigured resources */ + /* Let's store it in query_ext */ + query_ext = manifold.query_store.find_analyzed_query_ext(this.options.query_uuid); + + $('#badge-pending').text(query_ext.num_pending); + if (query_ext.num_pending > 0) { + $('#badge-pending').show(); + } else { + $('#badge-pending').hide(); + } + + $('#badge-unconfigured').text(query_ext.num_unconfigured); + if (query_ext.num_unconfigured > 0) { + $('#badge-unconfigured').show(); + } else { + $('#badge-unconfigured').hide(); + } + default: + break; + } + }, + /************************************************************************** * PRIVATE METHODS * **************************************************************************/ @@ -82,15 +123,17 @@ // ... and communicate the appropriate filters to the manager // NOTE: we use the manifold namespace for internal filters - if (self.prev_filter_status) - manifold.raise_event(self.options.query_uuid, FILTER_REMOVED, self.prev_filter_status); - - // XXX The datatables will be refreshed twice ! - if (filter_status != 'all') { - // No filter for 'all' - var filter = ['manifold:status', '==', filter_status]; - manifold.raise_event(self.options.query_uuid, FILTER_ADDED, filter); + if (self.prev_filter_status) { + var filter = ['manifold:status', '==', self.prev_filter_status]; + manifold.raise_event(self.options.query_uuid, FILTER_REMOVED, filter); } + // XXX The datatables will be refreshed twice ! + //if (filter_status != 'all') { + // No filter for 'all' + // Changed since we have available/unavailable status + var filter = ['manifold:status', '==', filter_status]; + manifold.raise_event(self.options.query_uuid, FILTER_ADDED, filter); + //} self.prev_filter_status = filter_status; },