diff options
Diffstat (limited to 'module/web/static/js/collections')
-rw-r--r-- | module/web/static/js/collections/AccountList.js | 23 | ||||
-rw-r--r-- | module/web/static/js/collections/FileList.js | 17 | ||||
-rw-r--r-- | module/web/static/js/collections/InteractionList.js | 48 | ||||
-rw-r--r-- | module/web/static/js/collections/PackageList.js | 15 | ||||
-rw-r--r-- | module/web/static/js/collections/ProgressList.js | 17 |
5 files changed, 120 insertions, 0 deletions
diff --git a/module/web/static/js/collections/AccountList.js b/module/web/static/js/collections/AccountList.js new file mode 100644 index 000000000..1bcf87c1e --- /dev/null +++ b/module/web/static/js/collections/AccountList.js @@ -0,0 +1,23 @@ +define(['jquery', 'backbone', 'underscore', 'app', 'models/Account'], function($, Backbone, _, App, Account) { + + return Backbone.Collection.extend({ + + model: Account, + + comparator: function(account) { + return account.get('plugin'); + }, + + initialize: function() { + + }, + + fetch: function(options) { + // TODO: refresh options? + options = App.apiRequest('getAccounts/false', null, options); + return Backbone.Collection.prototype.fetch.call(this, options); + } + + }); + +});
\ No newline at end of file diff --git a/module/web/static/js/collections/FileList.js b/module/web/static/js/collections/FileList.js new file mode 100644 index 000000000..e91088867 --- /dev/null +++ b/module/web/static/js/collections/FileList.js @@ -0,0 +1,17 @@ +define(['jquery', 'backbone', 'underscore', 'models/File'], function($, Backbone, _, File) { + + return Backbone.Collection.extend({ + + model: File, + + comparator: function(file) { + return file.get('fileorder'); + }, + + initialize: function() { + + } + + }); + +});
\ No newline at end of file diff --git a/module/web/static/js/collections/InteractionList.js b/module/web/static/js/collections/InteractionList.js new file mode 100644 index 000000000..9ec175892 --- /dev/null +++ b/module/web/static/js/collections/InteractionList.js @@ -0,0 +1,48 @@ +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', null, options); + var self = this; + options.success = function(data) { + self.update(data); + }; + + return $.ajax(options); + }, + + toJSON: function() { + var data = {queries: 0, notifications: 0}; + + this.map(function(task) { + if (task.isNotification()) + data.notifications++; + else + data.queries++; + }); + + 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 diff --git a/module/web/static/js/collections/PackageList.js b/module/web/static/js/collections/PackageList.js new file mode 100644 index 000000000..a36f8bcdc --- /dev/null +++ b/module/web/static/js/collections/PackageList.js @@ -0,0 +1,15 @@ +define(['jquery', 'backbone', 'underscore', 'models/Package'], function($, Backbone, _, Package) { + + return Backbone.Collection.extend({ + + model: Package, + + comparator: function(pack) { + return pack.get('packageorder'); + }, + + initialize: function() { + } + + }); +});
\ No newline at end of file diff --git a/module/web/static/js/collections/ProgressList.js b/module/web/static/js/collections/ProgressList.js new file mode 100644 index 000000000..1706d5f16 --- /dev/null +++ b/module/web/static/js/collections/ProgressList.js @@ -0,0 +1,17 @@ +define(['jquery', 'backbone', 'underscore', 'models/Progress'], function($, Backbone, _, Progress) { + + return Backbone.Collection.extend({ + + model: Progress, + + comparator: function(progress) { + return progress.get('eta'); + }, + + initialize: function() { + + } + + }); + +});
\ No newline at end of file |