Started on web front end
This commit is contained in:
parent
05eb182419
commit
a1ced419c0
@ -15,6 +15,38 @@
|
||||
</head>
|
||||
<body>
|
||||
<script id="tMain" type="text/ractive">
|
||||
{{#if view == "projects"}}
|
||||
{{>projects}}
|
||||
{{elseif view == "project"}}
|
||||
{{elseif view == "version"}}
|
||||
{{elseif view == "stage"}}
|
||||
{{/if}}
|
||||
|
||||
|
||||
{{#partial projects}}
|
||||
<table class="pure-table pure-table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Project</th>
|
||||
<th>Status</th>
|
||||
<th>Stage</th>
|
||||
<th>Last Release</th>
|
||||
<th>Last Version</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{#projects:i}}
|
||||
<tr>
|
||||
<td>{{.name}}</td>
|
||||
<td>{{.status}}</td>
|
||||
<td>{{.stage}}</td>
|
||||
<td>{{.releaseVersion}}</td>
|
||||
<td>{{.lastVersion}}</td>
|
||||
</tr>
|
||||
{{/projects}}
|
||||
</tbody>
|
||||
</table>
|
||||
{{/partial}}
|
||||
|
||||
</script>
|
||||
<script src="/js/ractive.min.js"></script>
|
||||
|
@ -6,14 +6,66 @@
|
||||
(function() {
|
||||
"use strict";
|
||||
|
||||
var r = new Ractive({
|
||||
var r = new Ractive({
|
||||
el: "body",
|
||||
template: "#tMain",
|
||||
data: function() {
|
||||
return {
|
||||
data: function() {
|
||||
return {
|
||||
view: "projects",
|
||||
projects: [],
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
};
|
||||
},
|
||||
});
|
||||
getProjects();
|
||||
|
||||
|
||||
function getProjects() {
|
||||
get("/log/",
|
||||
function(result) {
|
||||
r.set("projects", result.data);
|
||||
},
|
||||
function(result) {
|
||||
console.log("error", result);
|
||||
});
|
||||
}
|
||||
|
||||
})();
|
||||
|
||||
function ajax(type, url, data, success, error) {
|
||||
"use strict";
|
||||
var req = new XMLHttpRequest();
|
||||
req.open(type, url);
|
||||
|
||||
if (success || error) {
|
||||
req.onload = function() {
|
||||
if (req.status >= 200 && req.status < 400) {
|
||||
if (success && typeof success === 'function') {
|
||||
success(JSON.parse(req.responseText));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
//failed
|
||||
if (error && typeof error === 'function') {
|
||||
error(req);
|
||||
}
|
||||
};
|
||||
req.onerror = function() {
|
||||
if (error && typeof error === 'function') {
|
||||
error(req);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
if (type != "get") {
|
||||
req.setRequestHeader("Content-Type", "application/json");
|
||||
}
|
||||
|
||||
req.send(data);
|
||||
}
|
||||
|
||||
function get(url, success, error) {
|
||||
"use strict";
|
||||
ajax("GET", url, null, success, error);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user