mirror of
https://github.com/internetarchive/brozzler.git
synced 2025-02-24 08:39:59 -05:00
more stubby stuff
This commit is contained in:
parent
2e1601ac81
commit
5868192e0a
@ -12,12 +12,25 @@ app = flask.Flask(__name__)
|
|||||||
r = rethinkstuff.Rethinker(["wbgrp-svc020", "wbgrp-svc035", "wbgrp-svc036"],
|
r = rethinkstuff.Rethinker(["wbgrp-svc020", "wbgrp-svc035", "wbgrp-svc036"],
|
||||||
db="archiveit_brozzler")
|
db="archiveit_brozzler")
|
||||||
|
|
||||||
|
@app.route("/api/sites/<site_id>")
|
||||||
|
@app.route("/api/site/<site_id>")
|
||||||
|
def site(site_id):
|
||||||
|
site_ = r.table("sites").get(site_id).run()
|
||||||
|
return flask.jsonify(site_)
|
||||||
|
|
||||||
|
@app.route("/api/stats/<bucket>")
|
||||||
|
def stats(bucket):
|
||||||
|
stats_ = r.table("stats").get(bucket).run()
|
||||||
|
return flask.jsonify(stats_)
|
||||||
|
|
||||||
@app.route("/api/jobs/<int:job_id>/sites")
|
@app.route("/api/jobs/<int:job_id>/sites")
|
||||||
|
@app.route("/api/job/<int:job_id>/sites")
|
||||||
def sites(job_id):
|
def sites(job_id):
|
||||||
sites_ = r.table("sites").get_all(job_id, index="job_id").run()
|
sites_ = r.table("sites").get_all(job_id, index="job_id").run()
|
||||||
return flask.jsonify(sites=sites_)
|
return flask.jsonify(sites=list(sites_))
|
||||||
|
|
||||||
@app.route("/api/jobs/<int:job_id>")
|
@app.route("/api/jobs/<int:job_id>")
|
||||||
|
@app.route("/api/job/<int:job_id>")
|
||||||
def job(job_id):
|
def job(job_id):
|
||||||
job_ = r.table("jobs").get(job_id).run()
|
job_ = r.table("jobs").get(job_id).run()
|
||||||
return flask.jsonify(job_)
|
return flask.jsonify(job_)
|
||||||
@ -32,7 +45,6 @@ def jobs():
|
|||||||
def root(path):
|
def root(path):
|
||||||
return app.send_static_file("index.html")
|
return app.send_static_file("index.html")
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
app.run(host="0.0.0.0", port=8081, debug=True)
|
app.run(host="0.0.0.0", port=8081, debug=True)
|
||||||
|
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
|
|
||||||
<body role="document">
|
<body role="document">
|
||||||
<div class="container" role="main">
|
<div class="container" role="main">
|
||||||
<a href="/jobs">jobs</a>
|
|
||||||
<div ng-view></div>
|
<div ng-view></div>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
|
@ -15,14 +15,32 @@ brozzlerConsoleApp.config(["$routeProvider", "$locationProvider",
|
|||||||
when("/jobs/:id", {
|
when("/jobs/:id", {
|
||||||
templateUrl: "/static/partials/job.html",
|
templateUrl: "/static/partials/job.html",
|
||||||
controller: "JobController"
|
controller: "JobController"
|
||||||
|
}).
|
||||||
|
when("/sites/:id", {
|
||||||
|
templateUrl: "/static/partials/site.html",
|
||||||
|
controller: "SiteController"
|
||||||
|
}).
|
||||||
|
otherwise({
|
||||||
|
template: '<div> <div class="page-header"> <h1>Not Found</h1> </div> <div class="row"> <div class="col-sm-12"> How the heck did you get here? </div> </div> </div> ',
|
||||||
});
|
});
|
||||||
// .
|
|
||||||
// otherwise({
|
|
||||||
// redirectTo: "/jobs"
|
|
||||||
// });
|
|
||||||
|
|
||||||
$locationProvider.html5Mode({
|
$locationProvider.html5Mode({
|
||||||
enabled: true,
|
enabled: true,
|
||||||
requireBase: false,
|
requireBase: false,
|
||||||
});
|
});
|
||||||
}]);
|
}]);
|
||||||
|
|
||||||
|
// copied from https://bitbucket.org/webarchive/ait5/src/master/archiveit/static/app/js/filters/ByteFormat.js
|
||||||
|
brozzlerConsoleApp.filter("byteformat", function() {
|
||||||
|
return function(bytes, precision) {
|
||||||
|
var bytes_f = parseFloat(bytes);
|
||||||
|
if (bytes_f == 0 || isNaN(bytes_f) || !isFinite(bytes_f)) return "0";
|
||||||
|
if (bytes_f < 1024) return bytes_f.toFixed(0) + " bytes";
|
||||||
|
if (typeof precision === "undefined") precision = 1;
|
||||||
|
var units = ["bytes", "kB", "MB", "GB", "TB", "PB"];
|
||||||
|
var number = Math.floor(Math.log(bytes_f) / Math.log(1024));
|
||||||
|
var result = (bytes_f / Math.pow(1024, Math.floor(number))).toFixed(precision) + " " + units[number];
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
@ -5,7 +5,6 @@ var brozzlerControllers = angular.module("brozzlerControllers", []);
|
|||||||
brozzlerControllers.controller("JobsListController", ["$scope", "$http",
|
brozzlerControllers.controller("JobsListController", ["$scope", "$http",
|
||||||
function($scope, $http) {
|
function($scope, $http) {
|
||||||
$http.get("/api/jobs").success(function(data) {
|
$http.get("/api/jobs").success(function(data) {
|
||||||
console.log(data);
|
|
||||||
$scope.jobs = data.jobs;
|
$scope.jobs = data.jobs;
|
||||||
});
|
});
|
||||||
}]);
|
}]);
|
||||||
@ -14,8 +13,44 @@ brozzlerControllers.controller("JobController", ["$scope", "$routeParams", "$htt
|
|||||||
function($scope, $routeParams, $http) {
|
function($scope, $routeParams, $http) {
|
||||||
$scope.phoneId = $routeParams.phoneId;
|
$scope.phoneId = $routeParams.phoneId;
|
||||||
$http.get("/api/jobs/" + $routeParams.id).success(function(data) {
|
$http.get("/api/jobs/" + $routeParams.id).success(function(data) {
|
||||||
console.log(data);
|
|
||||||
$scope.job = data;
|
$scope.job = data;
|
||||||
|
console.log("job=", $scope.job);
|
||||||
|
});
|
||||||
|
|
||||||
|
$http.get("/api/jobs/" + $routeParams.id + "/sites").success(function(data) {
|
||||||
|
$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 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) {
|
||||||
|
console.log("warcprox_meta.stats.buckets[" + j + "]=" + warcprox_meta.stats.buckets[j]);
|
||||||
|
var bucket = warcprox_meta.stats.buckets[j];
|
||||||
|
$http.get("/api/stats/" + warcprox_meta.stats.buckets[j]).success(function(data) {
|
||||||
|
console.log("/api/stats/" + bucket + "=", data);
|
||||||
|
site.stats = data;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}]);
|
}]);
|
||||||
|
|
||||||
|
brozzlerControllers.controller("SiteController", ["$scope", "$routeParams", "$http",
|
||||||
|
function($scope, $routeParams, $http) {
|
||||||
|
$http.get("/api/site/" + $routeParams.id).success(function(data) {
|
||||||
|
$scope.site = data;
|
||||||
|
});
|
||||||
|
}]);
|
||||||
|
|
||||||
|
/*
|
||||||
|
$http.get(...)
|
||||||
|
.then(function(response){
|
||||||
|
// successHandler
|
||||||
|
// do some stuff
|
||||||
|
return $http.get('/somethingelse') // get more data
|
||||||
|
})
|
||||||
|
.then(anotherSuccessHandler)
|
||||||
|
.catch(errorHandler)
|
||||||
|
*/
|
||||||
|
@ -5,7 +5,38 @@
|
|||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-sm-12">
|
<div class="col-sm-12">
|
||||||
Job {{job.id}}
|
<ul>
|
||||||
|
<li> started {{job.started}} </li>
|
||||||
|
<li> finished {{job.finished}} </li>
|
||||||
|
<li> status {{job.status}} </li>
|
||||||
|
<li> sites={{sites}} </li>
|
||||||
|
</ul>
|
||||||
|
<ul>
|
||||||
|
<li ng-repeat="site in sites">
|
||||||
|
{{site}}
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<table class="table table-striped">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>id</th>
|
||||||
|
<th>seed</th>
|
||||||
|
<!-- <th>pages</th> -->
|
||||||
|
<th>urls</th>
|
||||||
|
<th>new data</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr ng-repeat="site in sites">
|
||||||
|
<td><a href="/sites/{{site.id}}">{{site.id}}</a></td>
|
||||||
|
<td>{{site.seed}}</td>
|
||||||
|
<td>{{site.stats.total.urls}}</td>
|
||||||
|
<td>{{site.stats.new.wire_bytes | byteformat}}</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
11
webconsole/static/partials/site.html
Normal file
11
webconsole/static/partials/site.html
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<div>
|
||||||
|
<div class="page-header">
|
||||||
|
<h1>Site {{site.seed}} (Job <a href="/jobs/{{site.job_id}}">{{site.job_id}}</a>)</h1>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-sm-12">
|
||||||
|
site={{site}}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
Loading…
x
Reference in New Issue
Block a user