You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by db...@apache.org on 2016/03/02 13:06:31 UTC
ambari git commit: AMBARI-15219. New Files View: Show error/success
message count over the message button. (dipayanb)
Repository: ambari
Updated Branches:
refs/heads/trunk 1c8d7b968 -> c3c723e7a
AMBARI-15219. New Files View: Show error/success message count over the message button. (dipayanb)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/c3c723e7
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/c3c723e7
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/c3c723e7
Branch: refs/heads/trunk
Commit: c3c723e7a78b74ba35c46cda86bb33ee6e06eb66
Parents: 1c8d7b9
Author: Dipayan Bhowmick <di...@gmail.com>
Authored: Wed Mar 2 17:36:04 2016 +0530
Committer: Dipayan Bhowmick <di...@gmail.com>
Committed: Wed Mar 2 17:36:04 2016 +0530
----------------------------------------------------------------------
.../main/resources/ui/app/controllers/files.js | 3 +++
.../src/main/resources/ui/app/models/alert.js | 3 ++-
.../main/resources/ui/app/routes/messages.js | 1 +
.../resources/ui/app/services/alert-messages.js | 20 +++++++++++++++++++-
.../src/main/resources/ui/app/styles/app.less | 10 ++++++++++
.../main/resources/ui/app/templates/files.hbs | 2 +-
6 files changed, 36 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/c3c723e7/contrib/views/files/src/main/resources/ui/app/controllers/files.js
----------------------------------------------------------------------
diff --git a/contrib/views/files/src/main/resources/ui/app/controllers/files.js b/contrib/views/files/src/main/resources/ui/app/controllers/files.js
index 4b60ab3..9fc11b6 100644
--- a/contrib/views/files/src/main/resources/ui/app/controllers/files.js
+++ b/contrib/views/files/src/main/resources/ui/app/controllers/files.js
@@ -20,6 +20,7 @@ import Ember from 'ember';
import columnConfig from '../config/files-columns';
export default Ember.Controller.extend({
+ logger: Ember.inject.service('alert-messages'),
fileSelectionService: Ember.inject.service('files-selection'),
lastSelectedFile: Ember.computed.oneWay('fileSelectionService.lastFileSelected'),
selectedFilesCount: Ember.computed.oneWay('fileSelectionService.filesCount'),
@@ -32,6 +33,8 @@ export default Ember.Controller.extend({
path: '/',
columns: columnConfig,
+ currentMessagesCount: Ember.computed.alias('logger.currentMessagesCount'),
+
hasHomePath: false,
hasTrashPath: false,
http://git-wip-us.apache.org/repos/asf/ambari/blob/c3c723e7/contrib/views/files/src/main/resources/ui/app/models/alert.js
----------------------------------------------------------------------
diff --git a/contrib/views/files/src/main/resources/ui/app/models/alert.js b/contrib/views/files/src/main/resources/ui/app/models/alert.js
index 74b07f9..f7d30a3 100644
--- a/contrib/views/files/src/main/resources/ui/app/models/alert.js
+++ b/contrib/views/files/src/main/resources/ui/app/models/alert.js
@@ -23,5 +23,6 @@ export default DS.Model.extend({
message: DS.attr('string'),
responseMessage: DS.attr('string'),
status: DS.attr('number'),
- trace: DS.attr('string')
+ trace: DS.attr('string'),
+ read: DS.attr('string', {defaultValue: false})
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/c3c723e7/contrib/views/files/src/main/resources/ui/app/routes/messages.js
----------------------------------------------------------------------
diff --git a/contrib/views/files/src/main/resources/ui/app/routes/messages.js b/contrib/views/files/src/main/resources/ui/app/routes/messages.js
index 2d94782..1e413ed 100644
--- a/contrib/views/files/src/main/resources/ui/app/routes/messages.js
+++ b/contrib/views/files/src/main/resources/ui/app/routes/messages.js
@@ -26,6 +26,7 @@ export default Ember.Route.extend({
setupController: function(controller, model) {
this._super(controller, model);
this.get('logger').clearMessages();
+ this.get('logger').setUnreadMessagesToRead();
controller.set('isExpanded', true);
}
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/c3c723e7/contrib/views/files/src/main/resources/ui/app/services/alert-messages.js
----------------------------------------------------------------------
diff --git a/contrib/views/files/src/main/resources/ui/app/services/alert-messages.js b/contrib/views/files/src/main/resources/ui/app/services/alert-messages.js
index 1a9c06d..ed4cff1 100644
--- a/contrib/views/files/src/main/resources/ui/app/services/alert-messages.js
+++ b/contrib/views/files/src/main/resources/ui/app/services/alert-messages.js
@@ -34,6 +34,24 @@ import Ember from 'ember';
export default Ember.Service.extend({
flashMessages: Ember.inject.service('flash-messages'),
store: Ember.inject.service('store'),
+ alertsChanged: false,
+
+ currentUnreadMessages: function() {
+ return this.get('store').peekAll('alert').filter((entry) => {
+ return entry.get('read') === false;
+ });
+ },
+
+ setUnreadMessagesToRead: function() {
+ this.currentUnreadMessages().forEach((entry) => {
+ entry.set('read', true);
+ });
+ this.toggleProperty('alertsChanged');
+ },
+
+ currentMessagesCount: Ember.computed('alertsChanged', function() {
+ return this.currentUnreadMessages().get('length');
+ }),
success: function(message, options = {}, alertOptions = {}) {
this._processMessage('success', message, options, alertOptions);
@@ -59,6 +77,7 @@ export default Ember.Service.extend({
this._clearMessagesIfRequired(alertOptions);
let alertRecord = this._createAlert(message, type, options, alertOptions);
if(alertRecord) {
+ this.toggleProperty('alertsChanged');
message = this._addDetailsToMessage(message, alertRecord);
}
switch (type) {
@@ -96,7 +115,6 @@ export default Ember.Service.extend({
if(alertOptions.flashOnly === true) {
return;
}
-
return this.get('store').createRecord('alert', data);
},
http://git-wip-us.apache.org/repos/asf/ambari/blob/c3c723e7/contrib/views/files/src/main/resources/ui/app/styles/app.less
----------------------------------------------------------------------
diff --git a/contrib/views/files/src/main/resources/ui/app/styles/app.less b/contrib/views/files/src/main/resources/ui/app/styles/app.less
index 564ebe6..a0355c7 100644
--- a/contrib/views/files/src/main/resources/ui/app/styles/app.less
+++ b/contrib/views/files/src/main/resources/ui/app/styles/app.less
@@ -127,6 +127,16 @@ body {
}
+.message-count-button {
+ position: relative;
+ .badge {
+ position: absolute;
+ top: -5px;
+ right: -10px;
+ background-color: @brand-danger;
+ }
+}
+
.spinner-wrap {
http://git-wip-us.apache.org/repos/asf/ambari/blob/c3c723e7/contrib/views/files/src/main/resources/ui/app/templates/files.hbs
----------------------------------------------------------------------
diff --git a/contrib/views/files/src/main/resources/ui/app/templates/files.hbs b/contrib/views/files/src/main/resources/ui/app/templates/files.hbs
index 769f0c8..3e178bc 100644
--- a/contrib/views/files/src/main/resources/ui/app/templates/files.hbs
+++ b/contrib/views/files/src/main/resources/ui/app/templates/files.hbs
@@ -57,7 +57,7 @@
</button>
{{new-directory path=path refreshAction="refreshCurrentRoute" currentPathIsTrash=currentPathIsTrash}}
{{upload-file path=path refreshAction="refreshCurrentRoute" currentPathIsTrash=currentPathIsTrash}}
- {{#link-to 'messages' class="btn btn-sm btn-default"}}{{fa-icon "comment-o"}}{{/link-to}}
+ {{#link-to 'messages' class="btn btn-sm btn-default message-count-button"}}{{fa-icon "comment-o"}}<span class="badge">{{currentMessagesCount}}</span>{{/link-to}}
</p>
</div>
</div>