summaryrefslogtreecommitdiffstats
path: root/module/web/static/js/collections
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2013-03-23 21:56:42 +0100
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2013-03-23 21:56:42 +0100
commit6e8a0f79f5ad7182a0bc35308ae06c63222667ed (patch)
tree0026179d34f19b64bc689c63af85b949ce57fb83 /module/web/static/js/collections
parentshow button when files are selected (diff)
downloadpyload-6e8a0f79f5ad7182a0bc35308ae06c63222667ed.tar.xz
implemented interactions for multi user, show waiting queries on webui
Diffstat (limited to 'module/web/static/js/collections')
-rw-r--r--module/web/static/js/collections/InteractionList.js47
1 files changed, 47 insertions, 0 deletions
diff --git a/module/web/static/js/collections/InteractionList.js b/module/web/static/js/collections/InteractionList.js
new file mode 100644
index 000000000..88651970e
--- /dev/null
+++ b/module/web/static/js/collections/InteractionList.js
@@ -0,0 +1,47 @@
+define(['jquery', 'backbone', 'underscore', 'app', 'models/InteractionTask'],
+ function($, Backbone, _, App, InteractionTask) {
+
+ return Backbone.Collection.extend({
+
+ model: InteractionTask,
+
+ comparator: function(task) {
+ return task.get('iid');
+ },
+
+ fetch: function(options) {
+ options = App.apiRequest('getInteractionTasks/0');
+
+ return Backbone.Collection.prototype.fetch.apply(this, options);
+ },
+
+ toJSON: function() {
+ var data = {queries: 0, notifications: 0, empty: false};
+
+ this.map(function(task) {
+ if (task.isNotification())
+ data.notifications++;
+ else
+ data.queries++;
+ });
+
+ if (!data.queries && !data.notifications)
+ data.empty = true;
+
+ return data;
+ },
+
+ // a task is waiting for attention (no notification)
+ hasTaskWaiting: function() {
+ var tasks = 0;
+ this.map(function(task) {
+ if (!task.isNotification())
+ tasks++;
+ });
+
+ return tasks > 0;
+ }
+
+ });
+
+ }); \ No newline at end of file