Skip to content

Commit

Permalink
feat: add Moment.js for parsing dates
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaixhin committed Oct 14, 2015
1 parent a999f28 commit 22d707e
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 35 deletions.
1 change: 1 addition & 0 deletions README.md
@@ -1,5 +1,6 @@
[![Build Status](https://img.shields.io/travis/Kaixhin/FGLab.svg)](https://travis-ci.org/Kaixhin/FGLab)
[![Dependency Status](https://img.shields.io/david/kaixhin/fglab.svg)](https://david-dm.org/Kaixhin/FGLab)
[![devDependency Status](https://img.shields.io/david/dev/kaixhin/fglab.svg)](https://david-dm.org/Kaixhin/FGLab#info=devDependencies)
[![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/Kaixhin/FGLab/master/LICENSE)
[![Docker Pulls](https://img.shields.io/docker/pulls/kaixhin/fglab.svg)](https://hub.docker.com/r/kaixhin/fglab/)
[![Docker Stars](https://img.shields.io/docker/stars/kaixhin/fglab.svg)](https://hub.docker.com/r/kaixhin/fglab/)
Expand Down
3 changes: 2 additions & 1 deletion bower.json
Expand Up @@ -28,7 +28,8 @@
"octicons": "~3.1.0",
"d3": "~3.5.6",
"c3": "~0.4.11",
"largest-triangle-three-buckets": "git://github.com/joshcarr/largest-triangle-three-buckets.js.git"
"largest-triangle-three-buckets": "git://github.com/joshcarr/largest-triangle-three-buckets.js.git",
"moment": "~2.10.6"
},
"resolutions": {
"jquery": "~3.0.0-alpha",
Expand Down
1 change: 1 addition & 0 deletions gulpfile.js
Expand Up @@ -12,6 +12,7 @@ var conventionalGithubReleaser = require("conventional-github-releaser");

// Load CONVENTIONAL_GITHUB_RELEASER_TOKEN from .env
require("dotenv").config({silent: true});
// Use --bump=<type> for a major/minor release
var options = parseArgs(process.argv.slice(2), {string: ["bump", "github_token"], default: {bump: "patch", github_token: process.env.CONVENTIONAL_GITHUB_RELEASER_TOKEN}});

// Changelogs use AngularJS convention (https://github.com/ajoslin/conventional-changelog/blob/master/conventions/angular.md)
Expand Down
16 changes: 8 additions & 8 deletions package.json
Expand Up @@ -37,13 +37,6 @@
"serve-favicon": "^2.3.0",
"ws": "^0.8.0"
},
"engines": {
"node": "4.x"
},
"cacheDirectories": [
"node_modules",
"bower_components"
],
"devDependencies": {
"conventional-github-releaser": "^0.5.0",
"gulp": "^3.9.0",
Expand All @@ -53,5 +46,12 @@
"gulp-util": "^3.0.6",
"minimist": "^1.2.0",
"run-sequence": "^1.1.4"
}
},
"engines": {
"node": "4.x"
},
"cacheDirectories": [
"node_modules",
"bower_components"
]
}
32 changes: 13 additions & 19 deletions views/experiment.jade
Expand Up @@ -5,21 +5,6 @@ block title

block styles
link(href="/bower_components/c3/c3.min.css", rel="stylesheet")
style(type="text/css").
path {
stroke: green;
stroke-width: 1;
fill: none;
}
path.valLoss {
stroke: blue;
}
line {
stroke: black;
}
text {
font-size: 9pt;
}

block content
h1 #[span.mega-octicon.octicon-graph] Experiment: #{experiment._id}
Expand All @@ -35,16 +20,16 @@ block content
dd.col-sm-9 #[a(href="/machines/#{machine._id}") #{machine.hostname}]
if experiment._started
dt.col-sm-3 Started
dd.col-sm-9 #{experiment._started}
dd#experiment-started.col-sm-9
if experiment._finished
dt.col-sm-3 Finished
dd.col-sm-9 #{experiment._finished}
dd#experiment-finished.col-sm-9
dt.col-sm-3 Options
dd.col-sm-9= JSON.stringify(experiment._options)
- if (experiment._files.length > 0)
dt.col-sm-3 Files
dd.col-sm-9
ul.list-unstyled
ul.list-unstyled(style="margin-bottom: 0;")
- each file in experiment._files
li #[a(href="/files/#{file._id}") #{file.filename}]
if experiment._val
Expand Down Expand Up @@ -73,13 +58,14 @@ block scripts
script(src="/bower_components/c3/c3.min.js")
script(src="/bower_components/lodash/lodash.min.js")
script(src="/bower_components/largest-triangle-three-buckets/dist/largest-triangle-three-buckets.v0.1.0.min.js")
script(src="/bower_components/moment/min/moment.min.js")
script.
// Parse from string instead prior to accessing internal objects via Jade
var experiment = !{JSON.stringify(experiment)};

$(function() {
// Adjust status
var status = "#{experiment._status}";
var status = experiment._status;
var textClass;
var iconClass;
if (status === "success") {
Expand All @@ -95,6 +81,14 @@ block scripts
$("#status").addClass(textClass);
$("#status .octicon").addClass(iconClass);

// Add times
if (experiment._started) {
$("#experiment-started").html(moment().format(experiment._started));
}
if (experiment._finished) {
$("#experiment-finished").html(moment().format(experiment._finished));
}

// Create chart for training
var chart;
// Use Largest-Triangle-Three-Buckets downsampling
Expand Down
11 changes: 4 additions & 7 deletions views/experiments.jade
Expand Up @@ -15,6 +15,7 @@ block scripts
script(src="/bower_components/bootstrap/dist/js/bootstrap.min.js")
script(src="/bower_components/bootstrap-table/dist/bootstrap-table.min.js")
script(src="/bower_components/bootstrap-table/dist/extensions/multiple-sort/bootstrap-table-multiple-sort.min.js")
script(src="/bower_components/moment/min/moment.min.js")
script.
// Flattens JSON objects
JSON.flatten = function(data) {
Expand Down Expand Up @@ -54,19 +55,15 @@ block scripts
{field: "_id", title: "ID", sortable: "true", formatter: function(val) {return "<a href='/experiments/" + val + "'>" + val + "</a>";}},
{field: "_status", title: "Status", sortable: "true", formatter: function(val) {
// Colour-code status
var textClass;
var iconClass;
if (val === "success") {
textClass = "text-success";
iconClass = "octicon octicon-check text-success";
} else if (val === "fail") {
textClass = "text-danger";
iconClass = "octicon octicon-circle-slash text-danger";
} else if (val == "running") {
textClass = "text-info";
iconClass = "octicon octicon-clock text-info";
}
return "<span class='" + textClass + "'>" + val + "</span> <span class='" + iconClass + "'></span>";
return "<span class='" + iconClass + "'></span>";
}},
{field: "_val.score", title: "Val Score", sortable: "true"},
{field: "_test.score", title: "Test Score", sortable: "true"}
Expand All @@ -82,8 +79,8 @@ block scripts
return "<span class='" + textClass + "'>" + val + "</span>";
}}(key)});
}
columns.push({field: "_started", title: "Started", sortable: "true"});
columns.push({field: "_finished", title: "Finished", sortable: "true"});
columns.push({field: "_started", title: "Started", sortable: "true", formatter: function(val) {return moment().format(val);}});
columns.push({field: "_finished", title: "Finished", sortable: "true", formatter: function(val) {return moment().format(val);}});

// Flatten each experiment
for (var i = 0; i < experiments.length; i++) {
Expand Down

0 comments on commit 22d707e

Please sign in to comment.