mirror of
https://github.com/cwinfo/powerdns-admin.git
synced 2025-06-15 04:26:05 +00:00
Initial commit
This commit is contained in:
56
app/static/global/plugins/morris/spec/viz/examples.js
Normal file
56
app/static/global/plugins/morris/spec/viz/examples.js
Normal file
@ -0,0 +1,56 @@
|
||||
var webpage = require("webpage"),
|
||||
fs = require("fs");
|
||||
|
||||
var html_path = fs.absolute("test.html");
|
||||
var examples = [];
|
||||
|
||||
function run_example(example_index) {
|
||||
if (example_index >= examples.length) {
|
||||
phantom.exit(0);
|
||||
return;
|
||||
}
|
||||
|
||||
var example = examples[example_index];
|
||||
var snapshot_index = 0;
|
||||
var page = webpage.create();
|
||||
|
||||
page.viewportSize = { width: 500, height: 300 };
|
||||
page.clipRect = { width: 500, height: 300 };
|
||||
page.onAlert = function (msg) {
|
||||
var e = JSON.parse(msg);
|
||||
if (e.fn == "snapshot") {
|
||||
page.render("output/" + example.name + snapshot_index + ".png");
|
||||
snapshot_index += 1;
|
||||
} else if (e.fn == "mousemove") {
|
||||
page.sendEvent("mousemove", e.x, e.y);
|
||||
}
|
||||
};
|
||||
|
||||
page.open(html_path, function (status) {
|
||||
if (status == "fail") {
|
||||
console.log("Failed to load test page: " + example.name);
|
||||
phantom.exit(1);
|
||||
} else {
|
||||
page.evaluate(example.runner);
|
||||
}
|
||||
page.close();
|
||||
run_example(example_index + 1);
|
||||
});
|
||||
}
|
||||
|
||||
exports.def = function (name, runner) {
|
||||
examples.push({ name: name, runner: runner });
|
||||
};
|
||||
|
||||
exports.run = function () {
|
||||
if (fs.isDirectory("output")) {
|
||||
fs.list("output").forEach(function (path) {
|
||||
if (path != "." && path != "..") {
|
||||
fs.remove("output/" + path);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
fs.makeDirectory("output");
|
||||
}
|
||||
run_example(0);
|
||||
};
|
BIN
app/static/global/plugins/morris/spec/viz/exemplary/area0.png
Normal file
BIN
app/static/global/plugins/morris/spec/viz/exemplary/area0.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 18 KiB |
BIN
app/static/global/plugins/morris/spec/viz/exemplary/bar0.png
Normal file
BIN
app/static/global/plugins/morris/spec/viz/exemplary/bar0.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.8 KiB |
BIN
app/static/global/plugins/morris/spec/viz/exemplary/line0.png
Normal file
BIN
app/static/global/plugins/morris/spec/viz/exemplary/line0.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 22 KiB |
Binary file not shown.
After Width: | Height: | Size: 5.7 KiB |
32
app/static/global/plugins/morris/spec/viz/run.sh
Normal file
32
app/static/global/plugins/morris/spec/viz/run.sh
Normal file
@ -0,0 +1,32 @@
|
||||
#!/bin/sh
|
||||
|
||||
# visual_specs.js creates output in output/XXX.png
|
||||
phantomjs visual_specs.js
|
||||
|
||||
# clear out old diffs
|
||||
mkdir -p diff
|
||||
rm -f diff/*
|
||||
|
||||
# generate diffs
|
||||
PASS=1
|
||||
for i in exemplary/*.png
|
||||
do
|
||||
FN=`basename $i`
|
||||
perceptualdiff $i output/$FN -output diff/$FN
|
||||
if [ $? -eq 0 ]
|
||||
then
|
||||
echo "OK: $FN"
|
||||
else
|
||||
echo "FAIL: $FN"
|
||||
PASS=0
|
||||
fi
|
||||
done
|
||||
|
||||
# pass / fail
|
||||
if [ $PASS -eq 1 ]
|
||||
then
|
||||
echo "Success."
|
||||
else
|
||||
echo "Failed."
|
||||
exit 1
|
||||
fi
|
34
app/static/global/plugins/morris/spec/viz/test.html
Normal file
34
app/static/global/plugins/morris/spec/viz/test.html
Normal file
@ -0,0 +1,34 @@
|
||||
<!doctype html>
|
||||
<head>
|
||||
<!-- jQuery packaging changed for 2.1.0, so try to load both paths, one will work. -->
|
||||
<script src="../../bower_components/jquery/dist/jquery.js"></script>
|
||||
<script src="../../bower_components/jquery/jquery.js"></script>
|
||||
<script src="../../bower_components/raphael/raphael-min.js"></script>
|
||||
<script src="../../morris.js"></script>
|
||||
<link rel="stylesheet" href="../../morris.css">
|
||||
<style>
|
||||
body {
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
background-color: white;
|
||||
}
|
||||
#chart {
|
||||
width: 500px;
|
||||
height: 300px;
|
||||
}
|
||||
</style>
|
||||
<script>
|
||||
function bridge(e) {
|
||||
window.alert(JSON.stringify(e));
|
||||
}
|
||||
window.snapshot = function () {
|
||||
bridge({ fn: "snapshot" });
|
||||
};
|
||||
window.mousemove = function (x, y) {
|
||||
bridge({ fn: "mousemove", x: x, y: y });
|
||||
};
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="chart"></div>
|
||||
</body>
|
66
app/static/global/plugins/morris/spec/viz/visual_specs.js
Normal file
66
app/static/global/plugins/morris/spec/viz/visual_specs.js
Normal file
@ -0,0 +1,66 @@
|
||||
var examples = require('./examples');
|
||||
|
||||
examples.def('line', function () {
|
||||
Morris.Line({
|
||||
element: 'chart',
|
||||
data: [
|
||||
{ x: 0, y: 10, z: 30 }, { x: 1, y: 20, z: 20 },
|
||||
{ x: 2, y: 30, z: 10 }, { x: 3, y: 30, z: 10 },
|
||||
{ x: 4, y: 20, z: 20 }, { x: 5, y: 10, z: 30 }
|
||||
],
|
||||
xkey: 'x',
|
||||
ykeys: ['y', 'z'],
|
||||
labels: ['y', 'z'],
|
||||
parseTime: false
|
||||
});
|
||||
window.snapshot();
|
||||
});
|
||||
|
||||
examples.def('area', function () {
|
||||
Morris.Area({
|
||||
element: 'chart',
|
||||
data: [
|
||||
{ x: 0, y: 1, z: 1 }, { x: 1, y: 2, z: 1 },
|
||||
{ x: 2, y: 3, z: 1 }, { x: 3, y: 3, z: 1 },
|
||||
{ x: 4, y: 2, z: 1 }, { x: 5, y: 1, z: 1 }
|
||||
],
|
||||
xkey: 'x',
|
||||
ykeys: ['y', 'z'],
|
||||
labels: ['y', 'z'],
|
||||
parseTime: false
|
||||
});
|
||||
window.snapshot();
|
||||
});
|
||||
|
||||
examples.def('bar', function () {
|
||||
Morris.Bar({
|
||||
element: 'chart',
|
||||
data: [
|
||||
{ x: 0, y: 1, z: 3 }, { x: 1, y: 2, z: 2 },
|
||||
{ x: 2, y: 3, z: 1 }, { x: 3, y: 3, z: 1 },
|
||||
{ x: 4, y: 2, z: 2 }, { x: 5, y: 1, z: 3 }
|
||||
],
|
||||
xkey: 'x',
|
||||
ykeys: ['y', 'z'],
|
||||
labels: ['y', 'z']
|
||||
});
|
||||
window.snapshot();
|
||||
});
|
||||
|
||||
examples.def('stacked_bar', function () {
|
||||
Morris.Bar({
|
||||
element: 'chart',
|
||||
data: [
|
||||
{ x: 0, y: 1, z: 1 }, { x: 1, y: 2, z: 1 },
|
||||
{ x: 2, y: 3, z: 1 }, { x: 3, y: 3, z: 1 },
|
||||
{ x: 4, y: 2, z: 1 }, { x: 5, y: 1, z: 1 }
|
||||
],
|
||||
xkey: 'x',
|
||||
ykeys: ['y', 'z'],
|
||||
labels: ['y', 'z'],
|
||||
stacked: true
|
||||
});
|
||||
window.snapshot();
|
||||
});
|
||||
|
||||
examples.run();
|
Reference in New Issue
Block a user