diff options
author | RaNaN <Mast3rRaNaN@hotmail.de> | 2013-03-23 21:56:42 +0100 |
---|---|---|
committer | RaNaN <Mast3rRaNaN@hotmail.de> | 2013-03-23 21:56:42 +0100 |
commit | 6e8a0f79f5ad7182a0bc35308ae06c63222667ed (patch) | |
tree | 0026179d34f19b64bc689c63af85b949ce57fb83 /module/web/static/js/views | |
parent | show button when files are selected (diff) | |
download | pyload-6e8a0f79f5ad7182a0bc35308ae06c63222667ed.tar.xz |
implemented interactions for multi user, show waiting queries on webui
Diffstat (limited to 'module/web/static/js/views')
-rw-r--r-- | module/web/static/js/views/headerView.js | 18 | ||||
-rw-r--r-- | module/web/static/js/views/notificationView.js | 65 |
2 files changed, 76 insertions, 7 deletions
diff --git a/module/web/static/js/views/headerView.js b/module/web/static/js/views/headerView.js index 9e18734d4..b5b4a9d24 100644 --- a/module/web/static/js/views/headerView.js +++ b/module/web/static/js/views/headerView.js @@ -1,6 +1,6 @@ define(['jquery', 'underscore', 'backbone', 'app', 'models/ServerStatus', 'collections/ProgressList', - 'views/progressView', 'helpers/formatSize', 'flot'], - function($, _, Backbone, App, ServerStatus, ProgressList, ProgressView, formatSize) { + 'views/progressView', 'views/notificationView', 'helpers/formatSize', 'flot'], + function($, _, Backbone, App, ServerStatus, ProgressList, ProgressView, notificationView, formatSize) { // Renders the header with all information return Backbone.View.extend({ @@ -18,7 +18,6 @@ define(['jquery', 'underscore', 'backbone', 'app', 'models/ServerStatus', 'colle // html elements grabber: null, - notifications: null, header: null, progress: null, speedgraph: null, @@ -29,12 +28,15 @@ define(['jquery', 'underscore', 'backbone', 'app', 'models/ServerStatus', 'colle progressList: null, speeds: null, + // sub view + notificationView: null, + // save if last progress was empty wasEmpty: false, initialize: function() { var self = this; - this.notifications = this.$('#notification-area').calculateHeight().height(0); + this.notificationView = new notificationView(); this.status = new ServerStatus(); this.listenTo(this.status, 'change', this.render); @@ -98,7 +100,9 @@ define(['jquery', 'underscore', 'backbone', 'app', 'models/ServerStatus', 'colle // queue/processing size? var status = this.status.toJSON(); - status.maxspeed = _.max(this.speeds, function(speed) {return speed[1];})[1] * 1024; + status.maxspeed = _.max(this.speeds, function(speed) { + return speed[1]; + })[1] * 1024; this.$('.status-block').html( this.templateStatus(status) ); @@ -152,8 +156,8 @@ define(['jquery', 'underscore', 'backbone', 'app', 'models/ServerStatus', 'colle if (data === null) return; if (data['@class'] === "ServerStatus") { + // TODO: load interaction when none available this.status.set(data); - this.speeds = this.speeds.slice(1); this.speeds.push([this.speeds[this.speeds.length - 1][0] + 1, Math.floor(data.speed / 1024)]); @@ -169,7 +173,7 @@ define(['jquery', 'underscore', 'backbone', 'app', 'models/ServerStatus', 'colle else if (data['@class'] === 'EventInfo') this.onEvent(data.eventname, data.event_args); else - console.log('Unknown Async input'); + console.log('Unknown Async input', data); }, diff --git a/module/web/static/js/views/notificationView.js b/module/web/static/js/views/notificationView.js new file mode 100644 index 000000000..22c727304 --- /dev/null +++ b/module/web/static/js/views/notificationView.js @@ -0,0 +1,65 @@ +define(['jquery', 'backbone', 'underscore', 'app', 'collections/InteractionList'], + function($, Backbone, _, App, InteractionList) { + + // Renders context actions for selection packages and files + return Backbone.View.extend({ + el: '#notification-area', + template: _.compile($("#template-notification").html()), + + events: { + 'click .btn-query': 'openQuery', + 'click .btn-notification': 'openNotifications' + }, + + tasks: null, + // current open task + current: null, + // area is slided out + visible: false, + + initialize: function() { + this.tasks = new InteractionList(); + + this.$el.calculateHeight().height(0); + + App.vent.on('interaction:added', _.bind(this.onAdd, this)); + App.vent.on('interaction:deleted', _.bind(this.onDelete, this)); + + var render = _.bind(this.render, this); + this.listenTo(this.tasks, 'add', render); + this.listenTo(this.tasks, 'remove', render); + + }, + + onAdd: function(task) { + this.tasks.add(task); + }, + + onDelete: function(task) { + this.tasks.remove(task); + }, + + render: function() { + this.$el.html(this.template(this.tasks.toJSON())); + + if (this.tasks.length > 0 && !this.visible) { + this.$el.slideOut(); + this.visible = true; + } + else if (this.tasks.length === 0 && this.visible) { + this.$el.slideIn(); + this.visible = false; + } + + return this; + }, + + openQuery: function() { + + }, + + openNotifications: function() { + + } + }); + });
\ No newline at end of file |