diff --git a/.gitignore b/.gitignore index 50be67f..b2685d4 100644 --- a/.gitignore +++ b/.gitignore @@ -2,9 +2,10 @@ node_modules test/workspace test/distributor/workspace test/repos/mercurial/.hg/strip-backup +test/repos/mercurial/.hg/cache/branch2-served static/css/**/*.css static/fonts static/js/libs static/js/templates data/projects/**/workspace -data/builds \ No newline at end of file +data/builds diff --git a/resources/builds.js b/resources/builds.js index bd03ab3..6a110c9 100644 --- a/resources/builds.js +++ b/resources/builds.js @@ -10,9 +10,19 @@ module.exports = function(app) { resource.use('readAll', function(req, res, next) { Steppy( function() { - var findParams = _(req.data).pick('offset', 'limit'); + var data = req.data || {}; + + var start = {}; + if (data.projectName) { + start.projectName = data.projectName; + } + if (data.descCreateDate) { + start.descCreateDate = data.descCreateDate; + } + + var findParams = _(data).pick('offset', 'limit'); + findParams.start = start; findParams.limit = findParams.limit || 20; - findParams.start = {descCreateDate: ''}; db.builds.find(findParams, this.slot()); }, diff --git a/resources/projects.js b/resources/projects.js index 153bf2c..d004f13 100644 --- a/resources/projects.js +++ b/resources/projects.js @@ -1,6 +1,7 @@ 'use strict'; var Steppy = require('twostep').Steppy, + _ = require('underscore'), createBuildDataResource = require('../distributor').createBuildDataResource, logger = require('../lib/logger')('projects resource'); @@ -18,6 +19,10 @@ module.exports = function(app) { res.send(app.projects); }); + resource.use('read', function(req, res) { + res.send(_(app.projects).findWhere(req.data)); + }); + resource.use('run', function(req, res) { var projectName = req.data.projectName; logger.log('Run the project: "%s"', projectName); diff --git a/static/css/index.less b/static/css/index.less index d4d8335..7920b76 100644 --- a/static/css/index.less +++ b/static/css/index.less @@ -14,6 +14,9 @@ //variables @import "./sources/common/variables.less"; +//fonts +@import "./sources/common/fonts.less"; + //layout @import "./sources/components/layout.less"; diff --git a/static/css/sources/common/fonts.less b/static/css/sources/common/fonts.less new file mode 100644 index 0000000..be336ff --- /dev/null +++ b/static/css/sources/common/fonts.less @@ -0,0 +1 @@ +@import url(http://fonts.googleapis.com/css?family=Ubuntu&subset=latin,cyrillic); diff --git a/static/css/sources/components/terminal.less b/static/css/sources/components/terminal.less index 496013a..ba9ddf6 100644 --- a/static/css/sources/components/terminal.less +++ b/static/css/sources/components/terminal.less @@ -3,15 +3,15 @@ &_code { height: 300px; - padding: 8px; + padding: 8px 12px; box-sizing: border-box; overflow-y: scroll; border: none; color: white; background-color: black; line-height: 0.8; - font-size: 12px; - font-family: Monaco, Monosapce, sans-serif; + font-size: 13px; + font-family: 'Ubuntu', sans-serif; &_newline { display: block; diff --git a/static/js/app/actions/project.js b/static/js/app/actions/project.js index d03a1ef..46e5d2e 100644 --- a/static/js/app/actions/project.js +++ b/static/js/app/actions/project.js @@ -3,7 +3,8 @@ define(['reflux'], function(Reflux) { var Actions = Reflux.createActions([ 'run', - 'readAll' + 'readAll', + 'read' ]); return Actions; diff --git a/static/js/app/app.js b/static/js/app/app.js index c2ebb7d..62ac40c 100644 --- a/static/js/app/app.js +++ b/static/js/app/app.js @@ -19,7 +19,11 @@ define([ var routes = ( Route({name: 'index', path: '/'}, Route({name: 'dashboard', path: '/', handler: Components.App}), - Route({name: 'projects', path: 'projects', handler: Components.Project.List}), + Route({ + name: 'projects', + path: 'projects/:name', + handler: Components.Project.View + }), Route({name: 'build', path: 'builds/:id', handler: Components.Build.View}) ) ); diff --git a/static/js/app/components/builds/item.jade b/static/js/app/components/builds/item.jade index 8f32991..dab942f 100644 --- a/static/js/app/components/builds/item.jade +++ b/static/js/app/components/builds/item.jade @@ -66,7 +66,3 @@ mixin statusText(build) i.fa.fa-fw.fa-clock-o | queued at DateTime(date=new Date(build.createDate)) - - if this.state.showTerminal - .build_terminal - Terminal(build=build.id) diff --git a/static/js/app/components/builds/list.jade b/static/js/app/components/builds/list.jade index 38e4ede..75b8e26 100644 --- a/static/js/app/components/builds/list.jade +++ b/static/js/app/components/builds/list.jade @@ -1,6 +1,5 @@ -- console.log('builds', items) .builds - if !items.length - p Build queue is empty - each build, index in items + if !this.state.items.length + p Build list is empty + each build, index in this.state.items Item(build=build, key=build.id) diff --git a/static/js/app/components/builds/list.js b/static/js/app/components/builds/list.js index eff7974..053e5b4 100644 --- a/static/js/app/components/builds/list.js +++ b/static/js/app/components/builds/list.js @@ -7,6 +7,10 @@ define([ 'app/stores/builds', 'templates/app/components/builds/list' ], function(React, Reflux, Item, buildsStore, template) { + template = template.locals({ + Item: Item + }); + var Component = React.createClass({ mixins: [Reflux.ListenerMixin], componentDidMount: function() { @@ -15,12 +19,7 @@ define([ updateItems: function(items) { this.setState({items: items}); }, - render: function() { - return template({ - Item: Item, - items: this.state.items - }); - }, + render: template, getInitialState: function() { return { items: [] diff --git a/static/js/app/components/projects/index.js b/static/js/app/components/projects/index.js index 1b24ecc..e2d9799 100644 --- a/static/js/app/components/projects/index.js +++ b/static/js/app/components/projects/index.js @@ -1,9 +1,11 @@ 'use strict'; define([ - 'app/components/projects/selector/index' -], function(Selector) { + 'app/components/projects/selector/index', + 'app/components/projects/view/index' +], function(Selector, View) { return { - Selector: Selector + Selector: Selector, + View: View }; }); diff --git a/static/js/app/components/projects/selector/index.js b/static/js/app/components/projects/selector/index.js index a72b959..adc3f28 100644 --- a/static/js/app/components/projects/selector/index.js +++ b/static/js/app/components/projects/selector/index.js @@ -1,10 +1,14 @@ 'use strict'; define([ - 'react', 'reflux', 'app/actions/project', - 'app/stores/project', + 'react', 'react-router', 'reflux', 'app/actions/project', + 'app/stores/projects', 'templates/app/components/projects/selector/index' -], function(React, Reflux, ProjectActions, projectsStore, template) { +], function(React, Router, Reflux, ProjectActions, projectsStore, template) { + template = template.locals({ + Link: Router.Link + }); + return React.createClass({ mixins: [Reflux.ListenerMixin], componentDidMount: function() { diff --git a/static/js/app/components/projects/view/index.jade b/static/js/app/components/projects/view/index.jade new file mode 100644 index 0000000..8636d94 --- /dev/null +++ b/static/js/app/components/projects/view/index.jade @@ -0,0 +1,2 @@ +h1= this.state.project.name +Builds() diff --git a/static/js/app/components/projects/view/index.js b/static/js/app/components/projects/view/index.js new file mode 100644 index 0000000..3810603 --- /dev/null +++ b/static/js/app/components/projects/view/index.js @@ -0,0 +1,35 @@ +'use strict'; + +define([ + 'react', 'reflux', + 'app/actions/project', + 'app/actions/build', + 'app/stores/project', + 'app/components/builds/list', + 'templates/app/components/projects/view/index' +], function(React, Reflux, ProjectActions, BuildActions, + projectStore, Builds, template +) { + template = template.locals({ + Builds: Builds + }); + + return React.createClass({ + mixins: [Reflux.ListenerMixin], + componentDidMount: function() { + ProjectActions.read({name: this.props.params.name}); + BuildActions.readAll({projectName: this.props.params.name}); + + this.listenTo(projectStore, this.updateItem); + }, + updateItem: function(project) { + this.setState({project: project}); + }, + getInitialState: function() { + return { + project: {} + } + }, + render: template, + }); +}); diff --git a/static/js/app/stores/builds.js b/static/js/app/stores/builds.js index 310eed2..c1ece11 100644 --- a/static/js/app/stores/builds.js +++ b/static/js/app/stores/builds.js @@ -27,9 +27,9 @@ define([ resource.subscribe('change', this.onChange); }, - onReadAll: function() { + onReadAll: function(params) { var self = this; - resource.sync('readAll', function(err, builds) { + resource.sync('readAll', params, function(err, builds) { if (err) throw err; self.builds = builds; self.trigger(self.builds); diff --git a/static/js/app/stores/project.js b/static/js/app/stores/project.js index e2c2ca3..c1a3a59 100644 --- a/static/js/app/stores/project.js +++ b/static/js/app/stores/project.js @@ -1,22 +1,28 @@ 'use strict'; define([ + 'underscore', 'reflux', 'app/actions/project', 'app/resources' -], function(Reflux, ProjectActions, resources) { +], function(_, Reflux, ProjectActions, resources) { var resource = resources.projects; var Store = Reflux.createStore({ listenables: ProjectActions, - onRun: function(projectName) { - resource.sync('run', {projectName: projectName}, function(err, result) { - console.log('run project, shoould get queue'); - }); + project: null, + + onChange: function(data, action) { }, - onReadAll: function() { + + init: function() { + resource.subscribe('change', this.onChange); + }, + + onRead: function(params) { var self = this; - resource.sync('readAll', function(err, projects) { + resource.sync('read', params, function(err, project) { if (err) throw err; - self.trigger(projects); + self.project = project; + self.trigger(self.project); }); } }); diff --git a/static/js/app/stores/projects.js b/static/js/app/stores/projects.js new file mode 100644 index 0000000..e2c2ca3 --- /dev/null +++ b/static/js/app/stores/projects.js @@ -0,0 +1,25 @@ +'use strict'; + +define([ + 'reflux', 'app/actions/project', 'app/resources' +], function(Reflux, ProjectActions, resources) { + var resource = resources.projects; + + var Store = Reflux.createStore({ + listenables: ProjectActions, + onRun: function(projectName) { + resource.sync('run', {projectName: projectName}, function(err, result) { + console.log('run project, shoould get queue'); + }); + }, + onReadAll: function() { + var self = this; + resource.sync('readAll', function(err, projects) { + if (err) throw err; + self.trigger(projects); + }); + } + }); + + return Store; +});