From 67c4c19e5aa19c09d5dbefdc8077cda3941713c7 Mon Sep 17 00:00:00 2001
From: RaNaN <Mast3rRaNaN@hotmail.de>
Date: Thu, 21 Mar 2013 11:39:16 +0100
Subject: render package stats, speedgraph

---
 module/web/static/js/models/Package.js  | 7 +++++++
 module/web/static/js/models/Progress.js | 5 +----
 2 files changed, 8 insertions(+), 4 deletions(-)

(limited to 'module/web/static/js/models')

diff --git a/module/web/static/js/models/Package.js b/module/web/static/js/models/Package.js
index 0b9efca10..1b050d735 100644
--- a/module/web/static/js/models/Package.js
+++ b/module/web/static/js/models/Package.js
@@ -32,6 +32,13 @@ define(['jquery', 'backbone', 'underscore', 'app', 'collections/FileList', 'requ
             initialize: function() {
             },
 
+            toJSON: function(options) {
+                var obj = Backbone.Model.prototype.toJSON.call(this, options);
+                obj.percent = Math.round(obj.stats.linksdone * 100 / obj.stats.linkstotal);
+
+                return obj;
+            },
+
             // Changes url + method and delegates call to super class
             fetch: function(options) {
                 options = App.apiRequest(
diff --git a/module/web/static/js/models/Progress.js b/module/web/static/js/models/Progress.js
index 87e7b350b..96beb0198 100644
--- a/module/web/static/js/models/Progress.js
+++ b/module/web/static/js/models/Progress.js
@@ -35,10 +35,7 @@ define(['jquery', 'backbone', 'underscore', 'utils/apitypes'], function($, Backb
         toJSON: function(options) {
             var obj = Backbone.Model.prototype.toJSON.call(this, options);
             obj.percent = this.getPercent();
-            if (this.isDownload() && this.get('download').status === Api.DownloadStatus.Downloading)
-                obj.downloading = true;
-            else
-                obj.downloading = false;
+            obj.downloading = this.isDownload() && this.get('download').status === Api.DownloadStatus.Downloading;
 
             return obj;
         },
-- 
cgit v1.2.3