Web front end work

This commit is contained in:
Tim Shannon 2016-04-14 16:29:56 +00:00
parent a1ced419c0
commit 7ca04a5594
6 changed files with 92 additions and 17 deletions

View File

@ -107,12 +107,13 @@ func (p *Project) fetch() {
p.setVersion(strings.TrimSpace(string(version)))
lVer, err := p.ds.LastVersion("")
// check if this specific version has attempted a build yet
lVer, err := p.ds.LastVersion(stageBuild)
if err != datastore.ErrNotFound && p.errHandled(err) {
return
}
if p.version == "" || p.version == lVer {
if p.version == "" || p.version == lVer.Version {
// no new build clean up temp dir
p.errHandled(os.RemoveAll(tempDir))

View File

@ -37,8 +37,8 @@ func (ds *Store) AddLog(version, stage, entry string) error {
// LastVersion returns the last version in the log for the given stage. If stage is blank,
// then it returns the last of any stage
func (ds *Store) LastVersion(stage string) (string, error) {
version := ""
func (ds *Store) LastVersion(stage string) (*Log, error) {
last := &Log{}
err := ds.bolt.View(func(tx *bolt.Tx) error {
c := tx.Bucket([]byte(bucketLog)).Cursor()
@ -52,7 +52,7 @@ func (ds *Store) LastVersion(stage string) (string, error) {
if l.Version != "" {
if stage == "" || l.Stage == stage {
version = l.Version
last = l
return nil
}
}
@ -62,10 +62,10 @@ func (ds *Store) LastVersion(stage string) (string, error) {
})
if err != nil {
return "", err
return nil, err
}
return version, nil
return last, nil
}
// Versions lists the versions in a given project, including the last stage that version got to

View File

@ -27,7 +27,7 @@ func runCmd(cmd, dir string) ([]byte, error) {
result, err := ec.CombinedOutput()
if err != nil {
return nil, fmt.Errorf("%s:\n%s", err, result)
return nil, fmt.Errorf("%s", result)
}
return result, nil
}

View File

@ -189,6 +189,7 @@ type webProject struct {
Name string `json:"name"`
ReleaseVersion string `json:"releaseVersion"` //last successfully released version
LastVersion string `json:"lastVersion"` //last version success or otherwise
LastLog string `json:"lastLog"` // last log entry of last cycle
Stage string `json:"stage"` // current stage
}
@ -209,8 +210,9 @@ func (p *Project) webData() (*webProject, error) {
d := &webProject{
Name: p.Name,
ID: p.id(),
LastVersion: last,
ReleaseVersion: release,
ReleaseVersion: release.Version,
LastVersion: last.Version,
LastLog: last.Log,
Stage: p.stage,
}

View File

@ -10,20 +10,86 @@
<link rel="stylesheet" href="/css/pure-min.css">
<style>
.container {
padding-right: 15px;
padding-left: 15px;
margin-right: auto;
margin-left: auto;
}
@media (min-width: 768px) {
.container {
padding-right: 40px;
padding-left: 40px;
}
}
.center-block {
display: block;
margin-left: auto;
margin-right: auto;
}
.text-center {
text-align: center;
}
/*tables*/
.table-responsive {
margin-left: auto;
margin-right: auto;
overflow-x: auto;
-webkit-overflow-scrolling: touch;
margin-bottom: 1em;
}
.table-responsive table {
width: 100%;
max-width: 100%;
}
/*stages*/
.stage-load {
}
.stage-fetch {
}
.stage-build {
}
.stage-test {
}
.stage-release {
}
</style>
</head>
<body>
<script id="tMain" type="text/ractive">
{{#if view == "projects"}}
<div class="container pure-g">
<div class="pure-u-1">
<h3 class="text-center">Iron Smith Project List</h3>
{{#if !project}}
{{>projects}}
{{elseif view == "project"}}
{{elseif view == "version"}}
{{elseif view == "stage"}}
{{elseif !version}}
{{elseif !stage}}
{{else}}
{{/if}}
</div>
</div>
{{#partial projects}}
<div class="table-responsive">
<table class="pure-table pure-table-striped">
<thead>
<tr>
@ -32,6 +98,7 @@
<th>Stage</th>
<th>Last Release</th>
<th>Last Version</th>
<th>Last Log</th>
</tr>
</thead>
<tbody>
@ -42,10 +109,12 @@
<td>{{.stage}}</td>
<td>{{.releaseVersion}}</td>
<td>{{.lastVersion}}</td>
<td title="{{.lastLog}}">{{.lastLog.substring(0,100) + " ..."}}</td>
</tr>
{{/projects}}
</tbody>
</table>
</div>
{{/partial}}
</script>

View File

@ -11,7 +11,9 @@
template: "#tMain",
data: function() {
return {
view: "projects",
project: null,
version: null,
stage: null,
projects: [],
};
},
@ -69,3 +71,4 @@ function get(url, success, error) {
"use strict";
ajax("GET", url, null, success, error);
}