From 05915488615a40fb902065cf8a39433bfdc7029e Mon Sep 17 00:00:00 2001 From: Noah Levitt Date: Fri, 9 Oct 2015 20:12:40 +0000 Subject: [PATCH] more incremental progress on web console --- webconsole/brozzler-webconsole.py | 7 ++++++- webconsole/static/index.html | 3 +++ webconsole/static/js/controllers.js | 17 ++++++++++++----- webconsole/static/partials/job.html | 25 ++++++++++++++++++++++++- webconsole/static/partials/site.html | 25 +++++++++++++++++++++---- 5 files changed, 66 insertions(+), 11 deletions(-) diff --git a/webconsole/brozzler-webconsole.py b/webconsole/brozzler-webconsole.py index 80d9d3d..c7671b7 100644 --- a/webconsole/brozzler-webconsole.py +++ b/webconsole/brozzler-webconsole.py @@ -73,8 +73,13 @@ def jobs(): jobs_ = list(r.table("jobs").run()) return flask.jsonify(jobs=jobs_) +@app.route("/api/") +@app.route("/api", defaults={"path":""}) +def api404(path): + flask.abort(404) + @app.route("/", defaults={"path": ""}) -@app.route('/') +@app.route("/") def root(path): return app.send_static_file("index.html") diff --git a/webconsole/static/index.html b/webconsole/static/index.html index a5505eb..bb2aa1c 100644 --- a/webconsole/static/index.html +++ b/webconsole/static/index.html @@ -17,6 +17,9 @@ .thumbnail:focus, .thumbnail:hover { text-decoration: none; } .thumbnail { word-wrap: break-word; } /* .glyphicon { color: #563d7c; } */ + .bigstats { font-size:125% } + .bigstats .fa { font-size:150% } + .bigstats .stat { padding:2rem } diff --git a/webconsole/static/js/controllers.js b/webconsole/static/js/controllers.js index 8c118c5..c4a5db2 100644 --- a/webconsole/static/js/controllers.js +++ b/webconsole/static/js/controllers.js @@ -11,10 +11,14 @@ brozzlerControllers.controller("JobsListController", ["$scope", "$http", brozzlerControllers.controller("JobController", ["$scope", "$routeParams", "$http", function($scope, $routeParams, $http) { - $scope.phoneId = $routeParams.phoneId; $http.get("/api/jobs/" + $routeParams.id).success(function(data) { $scope.job = data; - // console.log("job=", $scope.job); + $scope.job.page_count = $scope.job.queued_count = 0; + console.log("job=", $scope.job); + $http.get("/api/stats/" + $scope.job.conf.warcprox_meta.stats.buckets[0]).success(function(data) { + $scope.job.stats = data; + // console.log("job stats=", $scope.job.stats); + }); }); function statsSuccessCallback(site, bucket) { @@ -30,14 +34,16 @@ brozzlerControllers.controller("JobController", ["$scope", "$routeParams", "$htt // console.log("site = ", site); // console.log("/api/sites/" + site.id + "/page_count = ", data); site.page_count = data.count; + $scope.job.page_count += data.count; } } function queuedCountSuccessCallback(site, bucket) { return function(data) { - console.log("site = ", site); - console.log("/api/sites/" + site.id + "/queued_count = ", data); + // console.log("site = ", site); + // console.log("/api/sites/" + site.id + "/queued_count = ", data); site.queued_count = data.count; + $scope.job.queued_count += data.count; } } @@ -45,10 +51,11 @@ brozzlerControllers.controller("JobController", ["$scope", "$routeParams", "$htt $scope.sites = data.sites; // console.log("sites=", $scope.sites); for (var i = 0; i < $scope.sites.length; i++) { - var site = $scope.sites[i]; // parse Warcprox-Meta to find stats bucket + var site = $scope.sites[i]; $http.get("/api/sites/" + site.id + "/page_count").success(pageCountSuccessCallback(site, bucket)); $http.get("/api/sites/" + site.id + "/queued_count").success(queuedCountSuccessCallback(site, bucket)); + // parse Warcprox-Meta to find stats bucket var warcprox_meta = angular.fromJson(site.extra_headers["Warcprox-Meta"]); for (var j = 0; j < warcprox_meta.stats.buckets.length; j++) { if (warcprox_meta.stats.buckets[j].indexOf("seed") >= 0) { diff --git a/webconsole/static/partials/job.html b/webconsole/static/partials/job.html index 9783f82..790435f 100644 --- a/webconsole/static/partials/job.html +++ b/webconsole/static/partials/job.html @@ -10,7 +10,30 @@
-

Job {{job.id}}

+

Job {{job.id}} {{job.started}}-{{job.finished}} {{job.status}}

+ +
+
+
+ {{job.page_count}} pages crawled +
+
+
+
+ {{job.stats.total.urls}} urls crawled +
+
+
+
+ {{job.stats.total.wire_bytes | byteformat}} crawled +
+
+
+
+ {{job.queued_count}} pages queued +
+
+
diff --git a/webconsole/static/partials/site.html b/webconsole/static/partials/site.html index 4523196..9b7dbfa 100644 --- a/webconsole/static/partials/site.html +++ b/webconsole/static/partials/site.html @@ -13,11 +13,28 @@

Site {{site.seed}} (Job {{site.job_id}})

-
-
- site={{site}} +
+
+
+ {{site.page_count}} pages crawled +
+
+
+
+ {{site.stats.total.urls}} urls crawled +
+
+
+
+ {{site.stats.total.wire_bytes | byteformat}} crawled +
+
+
+
+ {{site.queued_count}} pages queued +
+
-