From e0bc90e954b2ccc55a4a4cb5b601dae554f617fd Mon Sep 17 00:00:00 2001 From: Tim Shannon Date: Mon, 18 Apr 2016 19:45:16 +0000 Subject: [PATCH] More front end work, stages and log entries --- web/index.html | 80 ++++++++++++++++++++++++++++++++++++++++--------- web/js/index.js | 50 ++++++++++++++++++++++++++----- 2 files changed, 108 insertions(+), 22 deletions(-) diff --git a/web/index.html b/web/index.html index 045e706..c48dfe4 100644 --- a/web/index.html +++ b/web/index.html @@ -68,7 +68,29 @@ font-weight: bold; font-size: 2em; } + + + .pull-left { + float: left; + } + .pull-right { + float: right; + } + .timestamp { + font-size: .75em; + color: #777; + margin-left: 10px; + } + + .log { + margin-left: 15px; + margin-right: 15px; + } + + .log > pre { + margin-left: 15px; + } @@ -102,12 +124,12 @@ {{version}} {{/if}} - {{#if project && version && stage}} + {{#if project && version && currentStage}}
  • /
  • - {{stage}} + {{currentStage}}
  • {{/if}} @@ -116,10 +138,8 @@ {{>projects}} {{elseif !version}} {{>project}} - {{elseif !stage}} - {{>version}} {{else}} - {{>stage}} + {{>version}} {{/if}} @@ -141,7 +161,7 @@ {{#projects:i}} - + {{.name}} {{.status}} {{.stage}} @@ -149,7 +169,11 @@ {{.releaseVersion}} - Download + {{#if releases[.id]}} + {{releases[id].fileName}} + {{else}} + No release file available + {{/if}} {{.lastLog.version}} @@ -175,15 +199,15 @@ {{#project.versions:i}} - + {{.version}} {{.stage}} {{#if .log}}{{.log.substring(0,100) + " ..."}}{{/if}} - {{#if .stage == "released"}} - Download + {{#if releases[project.id + .version]}} + {{releases[project.id + .version].fileName}} {{/if}} @@ -195,13 +219,41 @@ {{/partial}} {{#partial version}} +
    +{{#if releases[project.id + .version]}} + Download Release +{{/if}} +
    + +
    +
    +
    + {{#if currentStage}} +

    {{currentStage}}{{formatDate(logs.when)}}

    +
    
    +			{{logs.log}}			
    +		
    + {{else}} + {{#stages:i}} +

    {{.stage}}{{formatDate(.when)}}

    +
    
    +				{{.log}}
    +			
    + {{/stages}} + {{/if}} +
    {{/partial}} -{{#partial stage}} - -{{/partial}} - diff --git a/web/js/index.js b/web/js/index.js index b0b3ada..c04cb25 100644 --- a/web/js/index.js +++ b/web/js/index.js @@ -15,10 +15,13 @@ Ractive.DEBUG = false; return { project: null, version: null, - stages: null, - stage: null, + stages: null, + currentStage: null, + logs: null, projects: [], error: null, + formatDate: formatDate, + releases: {}, }; }, }); @@ -40,13 +43,13 @@ Ractive.DEBUG = false; if (paths[1] == "project") { if (paths[2]) { - getProject(paths[2]); if (paths[3]) { - getVersion(paths[2], paths[3]); if (paths[4]) { getStage(paths[2], paths[3], paths[4]); } + getVersion(paths[2], paths[3]); } + getProject(paths[2]); } getProjects(); return; @@ -61,8 +64,8 @@ Ractive.DEBUG = false; function(result) { for (var i = 0; i < result.data.length; i++) { setStatus(result.data[i]); + hasRelease(result.data[i].id, ""); } - r.set("projects", result.data); }, function(result) { @@ -74,6 +77,11 @@ Ractive.DEBUG = false; get("/log/" + id, function(result) { r.set("project", result.data); + if (result.data.versions) { + for (var i = 0; i < result.data.versions.length; i++) { + hasRelease(result.data.id, result.data.versions[i].version); + } + } }, function(result) { r.set("error", err(result).message); @@ -81,9 +89,9 @@ Ractive.DEBUG = false; } function getVersion(id, version) { - r.set("version", version); get("/log/" + id + "/" + version, function(result) { + r.set("version", version); r.set("stages", result.data); }, function(result) { @@ -94,13 +102,27 @@ Ractive.DEBUG = false; function getStage(id, version, stage) { get("/log/" + id + "/" + version + "/" + stage, function(result) { - r.set("stage", result.data); + r.set("logs", result.data); + r.set("currentStage", stage); }, function(result) { r.set("error", err(result).message); }); } + function hasRelease(id, version) { + /*/release//*/ + get("/release/" + id + "/" + version, + function(result) { + r.set("releases." + id + version, result.data); + }, + function(result) { + r.set("releases." + id + version, undefined); + }); + + + } + function setStatus(project) { //statuses if (project.lastLog.version.trim() == project.releaseVersion.trim()) { @@ -165,11 +187,23 @@ function get(url, success, error) { function err(response) { "use strict"; var error = { - message: "An error occurred and has been logged", + message: "An error occurred", }; if (typeof response === "string") { error.message = response; + } else { + error.message = JSON.parse(response.responseText).message; } + return error; } + +function formatDate(strDate) { + "use strict"; + var date = new Date(strDate); + if (!date) { + return ""; + } + return date.toLocaleDateString() + " at " + date.toLocaleTimeString(); +}