diff options
Diffstat (limited to 'module/web')
| -rw-r--r-- | module/web/pyload_app.py | 2 | ||||
| -rw-r--r-- | module/web/static/css/default/dashboard.less | 10 | ||||
| -rw-r--r-- | module/web/static/js/default.js | 4 | ||||
| -rw-r--r-- | module/web/static/js/libs/jquery.peity-1.0.js | 246 | ||||
| -rw-r--r-- | module/web/static/js/models/ServerStatus.js | 22 | ||||
| -rw-r--r-- | module/web/static/js/views/packageView.js | 10 | ||||
| -rw-r--r-- | module/web/templates/default/dashboard.html | 1 | 
7 files changed, 23 insertions, 272 deletions
| diff --git a/module/web/pyload_app.py b/module/web/pyload_app.py index 8401e1778..147c31a92 100644 --- a/module/web/pyload_app.py +++ b/module/web/pyload_app.py @@ -39,7 +39,7 @@ def pre_processor():      if api is not None:          user = api.user -        status = api.statusServer() +        status = api.getServerStatus()      return {"user": user,              'server': status, diff --git a/module/web/static/css/default/dashboard.less b/module/web/static/css/default/dashboard.less index 4e056dc8d..ab62cc657 100644 --- a/module/web/static/css/default/dashboard.less +++ b/module/web/static/css/default/dashboard.less @@ -91,16 +91,6 @@    color: @light;
  }
 -.package-graph {
 -  display: inline;
 -  width: 20px;
 -  height: 20px;
 -
 -  canvas {
 -    margin-bottom: -3px;
 -  }
 -}
 -
  /*
    File view
  */
 diff --git a/module/web/static/js/default.js b/module/web/static/js/default.js index d7c9c4b4a..6e6e17a7b 100644 --- a/module/web/static/js/default.js +++ b/module/web/static/js/default.js @@ -8,8 +8,6 @@ require.config({          jquery: "libs/jquery-1.8.3",          jqueryui: "libs/jqueryui",          flot: "libs/jquery.flot-1.1", -        flotpie: "libs/jquery.flot.pie", -        peity: "libs/jquery.peity-1.0",          transit: "libs/jquery.transit-0.9.9",          omniwindow: "libs/jquery.omniwindow",          bootstrap: "libs/bootstrap-2.1.1", @@ -33,8 +31,6 @@ require.config({              exports: "Backbone"  //attaches "Backbone" to the window object          },          "flot": ["jquery"], -        "peity": ["jquery"], -        "flotpie": ["flot"],          "transit": ["jquery"],          "omniwindow": ["jquery"],          "bootstrap": ["jquery"] diff --git a/module/web/static/js/libs/jquery.peity-1.0.js b/module/web/static/js/libs/jquery.peity-1.0.js deleted file mode 100644 index 8c2abc236..000000000 --- a/module/web/static/js/libs/jquery.peity-1.0.js +++ /dev/null @@ -1,246 +0,0 @@ -// Peity jQuery plugin version 1.0.0 -// (c) 2012 Ben Pickles -// -// http://benpickles.github.com/peity -// -// Released under MIT license. -(function($, document, Math, devicePixelRatio) { -  var canvasSupported = document.createElement("canvas").getContext - -  var peity = $.fn.peity = function(type, options) { -    if (canvasSupported) { -      this.each(function() { -        var defaults = peity.defaults[type] -        var data = {} -        var $this = $(this) - -        $.each($this.data(), function(name, value) { -          if (name in defaults) data[name] = value -        }) - -        var opts = $.extend({}, defaults, data, options) -        var chart = new Peity($this, type, opts) -        chart.draw() - -        $this.change(function() { -          chart.draw() -        }) -      }); -    } - -    return this; -  }; - -  var Peity = function($elem, type, opts) { -    this.$elem = $elem -    this.type = type -    this.opts = opts -  } - -  var PeityPrototype = Peity.prototype - -  PeityPrototype.colours = function() { -    var colours = this.opts.colours -    var func = colours - -    if (!$.isFunction(func)) { -      func = function(_, i) { -        return colours[i % colours.length] -      } -    } - -    return func -  } - -  PeityPrototype.draw = function() { -    peity.graphers[this.type].call(this, this.opts) -  } - -  PeityPrototype.prepareCanvas = function(width, height) { -    var canvas = this.canvas - -    if (canvas) { -      this.context.clearRect(0, 0, canvas.width, canvas.height) -    } else { -      canvas = $("<canvas>").attr({ -        height: height * devicePixelRatio, -        width: width * devicePixelRatio -      }) - -      if (devicePixelRatio != 1) { -        canvas.css({ -          height: height, -          width: width -        }) -      } - -      this.canvas = canvas = canvas[0] -      this.context = canvas.getContext("2d") -      this.$elem.hide().before(canvas) -    } - -    return canvas -  } - -  PeityPrototype.values = function() { -    return $.map(this.$elem.text().split(this.opts.delimiter), function(value) { -      return parseFloat(value) -    }) -  } - -  peity.defaults = {} -  peity.graphers = {} - -  peity.register = function(type, defaults, grapher) { -    this.defaults[type] = defaults -    this.graphers[type] = grapher -  } - -  peity.register( -    'pie', -    { -      colours: ["#ff9900", "#fff4dd", "#ffc66e"], -      delimiter: null, -      diameter: 16 -    }, -    function(opts) { -      if (!opts.delimiter) { -        var delimiter = this.$elem.text().match(/[^0-9\.]/) -        opts.delimiter = delimiter ? delimiter[0] : "," -      } - -      var values = this.values() - -      if (opts.delimiter == "/") { -        var v1 = values[0] -        var v2 = values[1] -        values = [v1, v2 - v1] -      } - -      var i = 0 -      var length = values.length -      var sum = 0 - -      for (; i < length; i++) { -        sum += values[i] -      } - -      var canvas = this.prepareCanvas(opts.diameter, opts.diameter) -      var context = this.context -      var half = canvas.width / 2 -      var pi = Math.PI -      var colours = this.colours() - -      context.save() -      context.translate(half, half) -      context.rotate(-pi / 2) - -      for (i = 0; i < length; i++) { -        var value = values[i] -        var slice = (value / sum) * pi * 2 - -        context.beginPath() -        context.moveTo(0, 0) -        context.arc(0, 0, half, 0, slice, false) -        context.fillStyle = colours.call(this, value, i, values) -        context.fill() -        context.rotate(slice) -      } - -      context.restore() -    } -  ) - -  peity.register( -    "line", -    { -      colour: "#c6d9fd", -      strokeColour: "#4d89f9", -      strokeWidth: 1, -      delimiter: ",", -      height: 16, -      max: null, -      min: 0, -      width: 32 -    }, -    function(opts) { -      var values = this.values() -      if (values.length == 1) values.push(values[0]) -      var max = Math.max.apply(Math, values.concat([opts.max])); -      var min = Math.min.apply(Math, values.concat([opts.min])) - -      var canvas = this.prepareCanvas(opts.width, opts.height) -      var context = this.context -      var width = canvas.width -      var height = canvas.height -      var xQuotient = width / (values.length - 1) -      var yQuotient = height / (max - min) - -      var coords = []; -      var i; - -      context.beginPath(); -      context.moveTo(0, height + (min * yQuotient)) - -      for (i = 0; i < values.length; i++) { -        var x = i * xQuotient -        var y = height - (yQuotient * (values[i] - min)) - -        coords.push({ x: x, y: y }); -        context.lineTo(x, y); -      } - -      context.lineTo(width, height + (min * yQuotient)) -      context.fillStyle = opts.colour; -      context.fill(); - -      if (opts.strokeWidth) { -        context.beginPath(); -        context.moveTo(0, coords[0].y); -        for (i = 0; i < coords.length; i++) { -          context.lineTo(coords[i].x, coords[i].y); -        } -        context.lineWidth = opts.strokeWidth * devicePixelRatio; -        context.strokeStyle = opts.strokeColour; -        context.stroke(); -      } -    } -  ); - -  peity.register( -    'bar', -    { -      colours: ["#4D89F9"], -      delimiter: ",", -      height: 16, -      max: null, -      min: 0, -      spacing: devicePixelRatio, -      width: 32 -    }, -    function(opts) { -      var values = this.values() -      var max = Math.max.apply(Math, values.concat([opts.max])); -      var min = Math.min.apply(Math, values.concat([opts.min])) - -      var canvas = this.prepareCanvas(opts.width, opts.height) -      var context = this.context - -      var width = canvas.width -      var height = canvas.height -      var yQuotient = height / (max - min) -      var space = opts.spacing -      var xQuotient = (width + space) / values.length -      var colours = this.colours() - -      for (var i = 0; i < values.length; i++) { -        var value = values[i] -        var x = i * xQuotient -        var y = height - (yQuotient * (value - min)) - -        context.fillStyle = colours.call(this, value, i, values) -        context.fillRect(x, y, xQuotient - space, yQuotient * values[i]) -      } -    } -  ); -})(jQuery, document, Math, window.devicePixelRatio || 1); diff --git a/module/web/static/js/models/ServerStatus.js b/module/web/static/js/models/ServerStatus.js index f89282d8d..35257fcb1 100644 --- a/module/web/static/js/models/ServerStatus.js +++ b/module/web/static/js/models/ServerStatus.js @@ -1,4 +1,5 @@ -define(['jquery', 'backbone', 'underscore'], function($, Backbone, _) { +define(['jquery', 'backbone', 'underscore', 'collections/ProgressList'], +    function($, Backbone, _, ProgressList) {      return Backbone.Model.extend({ @@ -14,6 +15,25 @@ define(['jquery', 'backbone', 'underscore'], function($, Backbone, _) {          // Model Constructor          initialize: function() { +        }, + +        fetch: function() { +            options || (options = {}); +            options.url = 'api/getServerStatus'; + +            return Backbone.Model.prototype.fetch.call(this, options); +        }, + +        parse: function(resp, xhr) { +            // Package is loaded from tree collection +            if (_.has(resp, 'root')) { +                resp.root.files = new FileList(_.values(resp.files)); +                // circular dependencies needs to be avoided +                var PackageList = require('collections/PackageList'); +                resp.root.packs = new PackageList(_.values(resp.packages)); +                return resp.root; +            } +            return Backbone.model.prototype.fetch.call(this, resp, xhr);          }      }); diff --git a/module/web/static/js/views/packageView.js b/module/web/static/js/views/packageView.js index acf437cd8..7cccc9bf4 100644 --- a/module/web/static/js/views/packageView.js +++ b/module/web/static/js/views/packageView.js @@ -1,4 +1,4 @@ -define(['jquery', 'views/abstract/itemView', 'underscore', 'views/fileView', 'utils/lazyRequire', 'handlebars', 'peity'], +define(['jquery', 'views/abstract/itemView', 'underscore', 'views/fileView', 'utils/lazyRequire', 'handlebars'],      function($, itemView, _, fileView, lazyLoader, HB) {      // Renders a single package item @@ -33,14 +33,6 @@ define(['jquery', 'views/abstract/itemView', 'underscore', 'views/fileView', 'ut              // TODO: on expanding don't re-render              this.$el.html(this.template(this.model.toJSON())); -            var data = [ -             { label: "Series1", data: 30}, -             { label: "Series2", data: 90} -             ]; -            var pie = this.$('.package-graph'); -            pie.peity('pie'); -            this.$('canvas').addClass('pull-right'); -              if (this.model.isLoaded()) {                  var ul = $('<ul></ul>');                  this.model.get('files').each(function(file) { diff --git a/module/web/templates/default/dashboard.html b/module/web/templates/default/dashboard.html index 52b4dc82f..8275011f0 100644 --- a/module/web/templates/default/dashboard.html +++ b/module/web/templates/default/dashboard.html @@ -16,7 +16,6 @@          <div class="package-header">
              <div class="package-row first">
                  Package <%= pid %>: <%= name %>
 -                <div class="package-graph pull-right">3/5</div>
              </div>
              <div class="package-row second">
                  <span>
 | 
