More front end work, stages and log entries

This commit is contained in:
Tim Shannon 2016-04-18 19:45:16 +00:00
parent 5f26454adf
commit e0bc90e954
2 changed files with 108 additions and 22 deletions

View File

@ -68,7 +68,29 @@
font-weight: bold;
font-size: 2em;
}
.pull-left {
float: left;
}
.pull-right {
float: right;
}
.timestamp {
font-size: .75em;
color: #777;
margin-left: 10px;
}
.log {
margin-left: 15px;
margin-right: 15px;
}
.log > pre {
margin-left: 15px;
}
</style>
</head>
<body>
@ -102,12 +124,12 @@
<a href="/project/{{project.id}}/{{version}}" class="pure-menu-link">{{version}}</a>
</li>
{{/if}}
{{#if project && version && stage}}
{{#if project && version && currentStage}}
<li class="pure-menu-item">
<span class="breadcrumb-separator">/</span>
</li>
<li class="pure-menu-item">
<a href="/project/{{project.id}}/{{version}}/{{stage}}" class="pure-menu-link">{{stage}}</a>
<a href="/project/{{project.id}}/{{version}}/{{currentStage}}" class="pure-menu-link">{{currentStage}}</a>
</li>
{{/if}}
</ul>
@ -116,10 +138,8 @@
{{>projects}}
{{elseif !version}}
{{>project}}
{{elseif !stage}}
{{>version}}
{{else}}
{{>stage}}
{{>version}}
{{/if}}
</div>
</div>
@ -141,7 +161,7 @@
</thead>
<tbody>
{{#projects:i}}
<tr>
<tr title="{{formatDate(.lastLog.when)}}">
<td><a href="/project/{{.id}}/">{{.name}}</a></td>
<td>{{.status}}</td>
<td>{{.stage}}</td>
@ -149,7 +169,11 @@
<a href="/project/{{.id}}/{{.releaseVersion}}">{{.releaseVersion}}</a>
</td>
<td>
<a href="/release/{{.id}}?file">Download</a>
{{#if releases[.id]}}
<a href="/release/{{.id}}?file">{{releases[id].fileName}}</a>
{{else}}
No release file available
{{/if}}
</td>
<td>
<a href="/project/{{.id}}/{{.lastLog.version}}">{{.lastLog.version}}</a>
@ -175,15 +199,15 @@
</thead>
<tbody>
{{#project.versions:i}}
<tr>
<tr title="{{formatDate(.when)}}">
<td>
<a href="/project/{{project.id}}/{{.version}}">{{.version}}</a>
</td>
<td>{{.stage}}</td>
<td title="{{.log}}">{{#if .log}}{{.log.substring(0,100) + " ..."}}{{/if}}</td>
<td>
{{#if .stage == "released"}}
<a href="/release/{{project.id}}/{{.version}}?file">Download</a>
{{#if releases[project.id + .version]}}
<a href="/release/{{project.id}}/{{.version}}?file">{{releases[project.id + .version].fileName}}</a>
{{/if}}
</td>
</tr>
@ -195,13 +219,41 @@
{{/partial}}
{{#partial version}}
<hr>
{{#if releases[project.id + .version]}}
<a href="/release/{{project.id}}/{{.version}}?file" class="pull-right pure-button pure-button-primary">Download Release</a>
{{/if}}
<div class="pure-menu pure-menu-horizontal">
<ul class="pure-menu-list">
<li class="pure-menu-item {{#if !currentStage}}pure-menu-selected{{/if}}">
<a href="/project/{{project.id}}/{{.version}}/" class="pure-menu-link">All</a>
</li>
{{#stages:i}}
<li class="pure-menu-item {{#if currentStage && currentStage == .stage}}pure-menu-selected{{/if}}">
<a href="/project/{{project.id}}/{{version}}/{{.stage}}" class="pure-menu-link">{{.stage}}</a>
</li>
{{/stages}}
</ul>
</div>
<hr>
<div class="log">
{{#if currentStage}}
<h3>{{currentStage}}<small class="timestamp">{{formatDate(logs.when)}}</small></h3>
<pre><samp>
{{logs.log}}
</samp></pre>
{{else}}
{{#stages:i}}
<h3>{{.stage}}<small class="timestamp">{{formatDate(.when)}}</small></h3>
<pre><samp>
{{.log}}
</samp></pre>
{{/stages}}
{{/if}}
</div>
{{/partial}}
{{#partial stage}}
{{/partial}}
</script>
<script src="/js/ractive.min.js"></script>
<script src="/js/index.js"></script>

View File

@ -15,10 +15,13 @@ Ractive.DEBUG = false;
return {
project: null,
version: null,
stages: null,
stage: null,
stages: null,
currentStage: null,
logs: null,
projects: [],
error: null,
formatDate: formatDate,
releases: {},
};
},
});
@ -40,13 +43,13 @@ Ractive.DEBUG = false;
if (paths[1] == "project") {
if (paths[2]) {
getProject(paths[2]);
if (paths[3]) {
getVersion(paths[2], paths[3]);
if (paths[4]) {
getStage(paths[2], paths[3], paths[4]);
}
getVersion(paths[2], paths[3]);
}
getProject(paths[2]);
}
getProjects();
return;
@ -61,8 +64,8 @@ Ractive.DEBUG = false;
function(result) {
for (var i = 0; i < result.data.length; i++) {
setStatus(result.data[i]);
hasRelease(result.data[i].id, "");
}
r.set("projects", result.data);
},
function(result) {
@ -74,6 +77,11 @@ Ractive.DEBUG = false;
get("/log/" + id,
function(result) {
r.set("project", result.data);
if (result.data.versions) {
for (var i = 0; i < result.data.versions.length; i++) {
hasRelease(result.data.id, result.data.versions[i].version);
}
}
},
function(result) {
r.set("error", err(result).message);
@ -81,9 +89,9 @@ Ractive.DEBUG = false;
}
function getVersion(id, version) {
r.set("version", version);
get("/log/" + id + "/" + version,
function(result) {
r.set("version", version);
r.set("stages", result.data);
},
function(result) {
@ -94,13 +102,27 @@ Ractive.DEBUG = false;
function getStage(id, version, stage) {
get("/log/" + id + "/" + version + "/" + stage,
function(result) {
r.set("stage", result.data);
r.set("logs", result.data);
r.set("currentStage", stage);
},
function(result) {
r.set("error", err(result).message);
});
}
function hasRelease(id, version) {
/*/release/<project-id>/<version>*/
get("/release/" + id + "/" + version,
function(result) {
r.set("releases." + id + version, result.data);
},
function(result) {
r.set("releases." + id + version, undefined);
});
}
function setStatus(project) {
//statuses
if (project.lastLog.version.trim() == project.releaseVersion.trim()) {
@ -165,11 +187,23 @@ function get(url, success, error) {
function err(response) {
"use strict";
var error = {
message: "An error occurred and has been logged",
message: "An error occurred",
};
if (typeof response === "string") {
error.message = response;
} else {
error.message = JSON.parse(response.responseText).message;
}
return error;
}
function formatDate(strDate) {
"use strict";
var date = new Date(strDate);
if (!date) {
return "";
}
return date.toLocaleDateString() + " at " + date.toLocaleTimeString();
}