More frontend work.

Added project data to version list.

Fleshing out project page
This commit is contained in:
Tim Shannon 2016-04-17 20:43:27 -05:00
parent ae961e9dd1
commit d117c3e664
5 changed files with 83 additions and 35 deletions

View File

@ -7,6 +7,7 @@ package main
import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"os"
"path/filepath"
@ -219,6 +220,13 @@ func (p *Project) release() {
return
}
p.setStage(stageReleased)
if p.errHandled(p.ds.AddLog(p.version, p.stage,
fmt.Sprintf("Project: %s Version %s built, tested, and released successfully.\n", p.id(), p.version))) {
return
}
//build successfull, remove working dir
p.errHandled(os.RemoveAll(p.workingDir()))

View File

@ -25,12 +25,13 @@ const (
//stages
const (
stageLoad = "loading"
stageFetch = "fetching"
stageBuild = "building"
stageTest = "testing"
stageRelease = "releasing"
stageWait = "waiting"
stageLoad = "loading"
stageFetch = "fetching"
stageBuild = "building"
stageTest = "testing"
stageRelease = "releasing"
stageReleased = "released"
stageWait = "waiting"
)
const projectFilePoll = 30 * time.Second

View File

@ -57,28 +57,6 @@
margin: 10px;
}
/*stages*/
.stage-load {
}
.stage-fetch {
}
.stage-build {
}
.stage-test {
}
.stage-release {
}
/* breadcrumbs */
#breadcrumbs {
@ -177,9 +155,37 @@
{{/partial}}
{{#partial project}}
<div class="table-responsive">
<table class="pure-table pure-table-striped">
<thead>
<tr>
<th>Version</th>
<th>Stage</th>
<th>Last Log</th>
<th>Release File</th>
</tr>
</thead>
<tbody>
{{#project.versions:i}}
<tr>
<td>{{.version}}</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}}
</td>
</tr>
{{/versions}}
</tbody>
</table>
</div>
{{/partial}}
{{#partial version}}
{{/partial}}
{{#partial stage}}

View File

@ -3,6 +3,8 @@
// that can be found in the LICENSE file.
/* jshint strict: true */
Ractive.DEBUG = false;
(function() {
"use strict";
@ -39,14 +41,11 @@
if (paths[2]) {
getProject(paths[2]);
if (paths[3]) {
r.set("version", paths[3]);
getVersion(paths[2], paths[3]);
if (paths[4]) {
r.set("stage", paths[4]);
//get stage
getStage(paths[2], paths[3], paths[4]);
}
//get version
}
}
getProjects();
return;
@ -80,9 +79,29 @@
});
}
function getVersion(id, version) {
get("/log/" + id + "/" + version,
function(result) {
r.set("version", result.data);
},
function(result) {
r.set("error", err(result).message);
});
}
function getStage(id, version, stage) {
get("/log/" + id + "/" + version + "/" + stage,
function(result) {
r.set("stage", result.data);
},
function(result) {
r.set("error", err(result).message);
});
}
function setStatus(project) {
//statuses
if (project.lastLog.version == project.releaseVersion) {
if (project.lastLog.version.trim() == project.releaseVersion.trim()) {
project.status = "Success";
} else {
if (project.lastLog.stage == "loading") {

View File

@ -10,6 +10,8 @@ import (
"net/url"
"strings"
"time"
"git.townsourced.com/ironsmith/datastore"
)
// /path/<project-id>/<version>/<stage>
@ -73,9 +75,21 @@ func logGet(w http.ResponseWriter, r *http.Request) {
if errHandled(err, w, r) {
return
}
prjData, err := project.webData()
if errHandled(err, w, r) {
return
}
respondJsend(w, &JSend{
Status: statusSuccess,
Data: vers,
Data: struct {
*webProject
Versions []*datastore.Log `json:"versions"`
}{
webProject: prjData,
Versions: vers,
},
})
return
}