diff options
Diffstat (limited to 'module/web/static')
| -rw-r--r-- | module/web/static/css/default/style.less | 10 | ||||
| -rw-r--r-- | module/web/static/js/collections/InteractionList.js | 47 | ||||
| -rw-r--r-- | module/web/static/js/models/InteractionTask.js | 27 | ||||
| -rw-r--r-- | module/web/static/js/utils/apitypes.js | 4 | ||||
| -rw-r--r-- | module/web/static/js/views/headerView.js | 18 | ||||
| -rw-r--r-- | module/web/static/js/views/notificationView.js | 65 | 
6 files changed, 161 insertions, 10 deletions
| diff --git a/module/web/static/css/default/style.less b/module/web/static/css/default/style.less index b3020d30f..f48aff9fd 100644 --- a/module/web/static/css/default/style.less +++ b/module/web/static/css/default/style.less @@ -326,6 +326,7 @@ header .logo {  .header-area {
    display: none; // hidden by default
    position: absolute;
 +  bottom: -28px;
    line-height: 18px;
    top: @header-height;
    padding: 4px 10px 6px 10px;
 @@ -339,12 +340,19 @@ header .logo {  #notification-area {
    .header-area;
    left: 140px;
 +
 +  .badge {
 +    vertical-align: top;
 +  }
 +
 +  .btn-query, .btn-notification {
 +    cursor: pointer;
 +  }
  }
  #selection-area {
    .header-area;
    left: 50%;
 -  bottom: -28px;
    min-width: 15%;
    i {
 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 diff --git a/module/web/static/js/models/InteractionTask.js b/module/web/static/js/models/InteractionTask.js new file mode 100644 index 000000000..4ba88a539 --- /dev/null +++ b/module/web/static/js/models/InteractionTask.js @@ -0,0 +1,27 @@ +define(['jquery', 'backbone', 'underscore', 'utils/apitypes'], +    function($, Backbone, _, Api) { + +        return Backbone.Model.extend({ + +            idAttribute: 'iid', + +            defaults: { +                iid: -1, +                type: null, +                input: null, +                default_value: null, +                title: "", +                description: "", +                plugin: "" +            }, + +            // Model Constructor +            initialize: function() { + +            }, + +            isNotification: function() { +                return this.get('type') === Api.Interaction.Notification; +            } +        }); +    });
\ No newline at end of file diff --git a/module/web/static/js/utils/apitypes.js b/module/web/static/js/utils/apitypes.js index c9fca48d6..28620250e 100644 --- a/module/web/static/js/utils/apitypes.js +++ b/module/web/static/js/utils/apitypes.js @@ -4,9 +4,9 @@ define([], function() {  		DownloadState: {'Failed': 3, 'All': 0, 'Unmanaged': 4, 'Finished': 1, 'Unfinished': 2},  		DownloadStatus: {'Downloading': 10, 'NA': 0, 'Processing': 14, 'Waiting': 9, 'Decrypting': 13, 'Paused': 4, 'Failed': 7, 'Finished': 5, 'Skipped': 6, 'Unknown': 16, 'Aborted': 12, 'Online': 2, 'TempOffline': 11, 'Offline': 1, 'Custom': 15, 'Starting': 8, 'Queued': 3},  		FileStatus: {'Remote': 2, 'Ok': 0, 'Missing': 1}, -		Input: {'Multiple': 10, 'Int': 2, 'NA': 0, 'List': 11, 'Bool': 7, 'File': 3, 'Text': 1, 'Table': 12, 'Folder': 4, 'Password': 6, 'Click': 8, 'Select': 9, 'Textbox': 5}, +		InputType: {'Multiple': 10, 'Int': 2, 'NA': 0, 'List': 11, 'Bool': 7, 'File': 3, 'Text': 1, 'Table': 12, 'Folder': 4, 'Password': 6, 'Click': 8, 'Select': 9, 'Textbox': 5}, +		Interaction: {'Captcha': 2, 'All': 0, 'Query': 4, 'Notification': 1},  		MediaType: {'All': 0, 'Audio': 2, 'Image': 4, 'Other': 1, 'Video': 8, 'Document': 16, 'Archive': 32}, -		Output: {'Captcha': 2, 'All': 0, 'Query': 4, 'Notification': 1},  		PackageStatus: {'Paused': 1, 'Remote': 3, 'Folder': 2, 'Ok': 0},  		Permission: {'All': 0, 'Interaction': 32, 'Modify': 4, 'Add': 1, 'Accounts': 16, 'Plugins': 64, 'Download': 8, 'Delete': 2},  		Role: {'Admin': 0, 'User': 1}, 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 | 
