From 2cf160d497e501bf254bd8be054c0f5880ab90ca Mon Sep 17 00:00:00 2001 From: RaNaN Date: Sat, 8 Jun 2013 17:37:43 +0200 Subject: restructured webui to single-page-app, removed jinja --- module/web/app/scripts/collections/AccountList.js | 23 +++++++++++ module/web/app/scripts/collections/FileList.js | 17 ++++++++ .../web/app/scripts/collections/InteractionList.js | 48 ++++++++++++++++++++++ module/web/app/scripts/collections/PackageList.js | 15 +++++++ module/web/app/scripts/collections/ProgressList.js | 17 ++++++++ 5 files changed, 120 insertions(+) create mode 100644 module/web/app/scripts/collections/AccountList.js create mode 100644 module/web/app/scripts/collections/FileList.js create mode 100644 module/web/app/scripts/collections/InteractionList.js create mode 100644 module/web/app/scripts/collections/PackageList.js create mode 100644 module/web/app/scripts/collections/ProgressList.js (limited to 'module/web/app/scripts/collections') diff --git a/module/web/app/scripts/collections/AccountList.js b/module/web/app/scripts/collections/AccountList.js new file mode 100644 index 000000000..1bcf87c1e --- /dev/null +++ b/module/web/app/scripts/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/app/scripts/collections/FileList.js b/module/web/app/scripts/collections/FileList.js new file mode 100644 index 000000000..e91088867 --- /dev/null +++ b/module/web/app/scripts/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/app/scripts/collections/InteractionList.js b/module/web/app/scripts/collections/InteractionList.js new file mode 100644 index 000000000..57622a075 --- /dev/null +++ b/module/web/app/scripts/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.set(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/app/scripts/collections/PackageList.js b/module/web/app/scripts/collections/PackageList.js new file mode 100644 index 000000000..a36f8bcdc --- /dev/null +++ b/module/web/app/scripts/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/app/scripts/collections/ProgressList.js b/module/web/app/scripts/collections/ProgressList.js new file mode 100644 index 000000000..1706d5f16 --- /dev/null +++ b/module/web/app/scripts/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 -- cgit v1.2.3