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 ( import (
"encoding/json" "encoding/json"
"errors" "errors"
"fmt"
"io/ioutil" "io/ioutil"
"os" "os"
"path/filepath" "path/filepath"
@ -219,6 +220,13 @@ func (p *Project) release() {
return 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 //build successfull, remove working dir
p.errHandled(os.RemoveAll(p.workingDir())) p.errHandled(os.RemoveAll(p.workingDir()))

View File

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

View File

@ -57,28 +57,6 @@
margin: 10px; margin: 10px;
} }
/*stages*/
.stage-load {
}
.stage-fetch {
}
.stage-build {
}
.stage-test {
}
.stage-release {
}
/* breadcrumbs */ /* breadcrumbs */
#breadcrumbs { #breadcrumbs {
@ -177,9 +155,37 @@
{{/partial}} {{/partial}}
{{#partial project}} {{#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}}
{{#partial version}} {{#partial version}}
{{/partial}} {{/partial}}
{{#partial stage}} {{#partial stage}}

View File

@ -3,6 +3,8 @@
// that can be found in the LICENSE file. // that can be found in the LICENSE file.
/* jshint strict: true */ /* jshint strict: true */
Ractive.DEBUG = false;
(function() { (function() {
"use strict"; "use strict";
@ -39,14 +41,11 @@
if (paths[2]) { if (paths[2]) {
getProject(paths[2]); getProject(paths[2]);
if (paths[3]) { if (paths[3]) {
r.set("version", paths[3]); getVersion(paths[2], paths[3]);
if (paths[4]) { if (paths[4]) {
r.set("stage", paths[4]); getStage(paths[2], paths[3], paths[4]);
//get stage
} }
//get version
} }
} }
getProjects(); getProjects();
return; 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) { function setStatus(project) {
//statuses //statuses
if (project.lastLog.version == project.releaseVersion) { if (project.lastLog.version.trim() == project.releaseVersion.trim()) {
project.status = "Success"; project.status = "Success";
} else { } else {
if (project.lastLog.stage == "loading") { if (project.lastLog.stage == "loading") {

View File

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