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))) 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) { if err != datastore.ErrNotFound && p.errHandled(err) {
return return
} }
if p.version == "" || p.version == lVer { if p.version == "" || p.version == lVer.Version {
// no new build clean up temp dir // no new build clean up temp dir
p.errHandled(os.RemoveAll(tempDir)) 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, // LastVersion returns the last version in the log for the given stage. If stage is blank,
// then it returns the last of any stage // then it returns the last of any stage
func (ds *Store) LastVersion(stage string) (string, error) { func (ds *Store) LastVersion(stage string) (*Log, error) {
version := "" last := &Log{}
err := ds.bolt.View(func(tx *bolt.Tx) error { err := ds.bolt.View(func(tx *bolt.Tx) error {
c := tx.Bucket([]byte(bucketLog)).Cursor() c := tx.Bucket([]byte(bucketLog)).Cursor()
@ -52,7 +52,7 @@ func (ds *Store) LastVersion(stage string) (string, error) {
if l.Version != "" { if l.Version != "" {
if stage == "" || l.Stage == stage { if stage == "" || l.Stage == stage {
version = l.Version last = l
return nil return nil
} }
} }
@ -62,10 +62,10 @@ func (ds *Store) LastVersion(stage string) (string, error) {
}) })
if err != nil { 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 // 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() result, err := ec.CombinedOutput()
if err != nil { if err != nil {
return nil, fmt.Errorf("%s:\n%s", err, result) return nil, fmt.Errorf("%s", result)
} }
return result, nil return result, nil
} }

View File

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

View File

@ -10,20 +10,86 @@
<link rel="stylesheet" href="/css/pure-min.css"> <link rel="stylesheet" href="/css/pure-min.css">
<style> <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> </style>
</head> </head>
<body> <body>
<script id="tMain" type="text/ractive"> <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}} {{>projects}}
{{elseif view == "project"}} {{elseif !version}}
{{elseif view == "version"}} {{elseif !stage}}
{{elseif view == "stage"}} {{else}}
{{/if}} {{/if}}
</div>
</div>
{{#partial projects}} {{#partial projects}}
<div class="table-responsive">
<table class="pure-table pure-table-striped"> <table class="pure-table pure-table-striped">
<thead> <thead>
<tr> <tr>
@ -32,6 +98,7 @@
<th>Stage</th> <th>Stage</th>
<th>Last Release</th> <th>Last Release</th>
<th>Last Version</th> <th>Last Version</th>
<th>Last Log</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@ -42,10 +109,12 @@
<td>{{.stage}}</td> <td>{{.stage}}</td>
<td>{{.releaseVersion}}</td> <td>{{.releaseVersion}}</td>
<td>{{.lastVersion}}</td> <td>{{.lastVersion}}</td>
<td title="{{.lastLog}}">{{.lastLog.substring(0,100) + " ..."}}</td>
</tr> </tr>
{{/projects}} {{/projects}}
</tbody> </tbody>
</table> </table>
</div>
{{/partial}} {{/partial}}
</script> </script>

View File

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