From 7ca04a55949d9f1a819759ea27166415c3efcbc2 Mon Sep 17 00:00:00 2001 From: Tim Shannon Date: Thu, 14 Apr 2016 16:29:56 +0000 Subject: [PATCH] Web front end work --- cycle.go | 5 +-- datastore/log.go | 10 +++--- exec.go | 2 +- project.go | 6 ++-- web/index.html | 81 ++++++++++++++++++++++++++++++++++++++++++++---- web/js/index.js | 5 ++- 6 files changed, 92 insertions(+), 17 deletions(-) diff --git a/cycle.go b/cycle.go index f46f4d2..98f9fa2 100644 --- a/cycle.go +++ b/cycle.go @@ -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)) diff --git a/datastore/log.go b/datastore/log.go index 89b005e..3b2aee6 100644 --- a/datastore/log.go +++ b/datastore/log.go @@ -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 diff --git a/exec.go b/exec.go index ceb9e7b..b50865f 100644 --- a/exec.go +++ b/exec.go @@ -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 } diff --git a/project.go b/project.go index 0f16379..ac9d836 100644 --- a/project.go +++ b/project.go @@ -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, } diff --git a/web/index.html b/web/index.html index fea75c6..711484e 100644 --- a/web/index.html +++ b/web/index.html @@ -10,20 +10,86 @@ diff --git a/web/js/index.js b/web/js/index.js index 0bfac9e..64aec7a 100644 --- a/web/js/index.js +++ b/web/js/index.js @@ -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); } +