Navigation Menu

Skip to content

Commit

Permalink
Merge pull request #1752 from shanzi/md
Browse files Browse the repository at this point in the history
Material Design: Masters, Slaves, Schedulers and latest changes page
  • Loading branch information
tardyp committed Jul 6, 2015
2 parents 61e440c + 451bae4 commit b309a89
Show file tree
Hide file tree
Showing 29 changed files with 395 additions and 25 deletions.
2 changes: 1 addition & 1 deletion www/md_base/guanlecoja/config.coffee
Expand Up @@ -120,7 +120,7 @@ gulp.task 'proxy', ['processindex'], ->
console.log "[Proxy] #{req.method} #{req.url}"

server = http.createServer (req, res) ->
if req.url.match /^\/(api|sse)/
if req.url.match /^\/(api|sse|avatar)/
proxy.web req, res, {target: 'http://' + argv.host}
else
filepath = config.dir.build + req.url.split('?')[0]
Expand Down
4 changes: 4 additions & 0 deletions www/md_base/src/app/app.module.coffee
Expand Up @@ -14,3 +14,7 @@ angular.module 'app', [

.config ($mdIconProvider) ->
$mdIconProvider.defaultIconSet('/icons/iconset.svg', 512)

.constant 'angularMomentConfig', {
preprocess: 'unix'
}
6 changes: 3 additions & 3 deletions www/md_base/src/app/builds/builds.less
Expand Up @@ -59,7 +59,6 @@

input {
width: 100%;
outline: none;
text-align: center;
font-size: 12px;
line-height: 18px;
Expand All @@ -85,7 +84,6 @@
}

.builder-title {
outline: none;
color: rgb(103, 58, 183);
display: block;
font-size: 20px;
Expand Down Expand Up @@ -116,13 +114,15 @@
border-radius: 3px;
color: #666;
background: #ddd;
outline: none;
}
}
}
}

.sub-content {
background: #fff;
padding: 10px;

.placeholder {
text-align: center;
color: #999;
Expand Down
5 changes: 4 additions & 1 deletion www/md_base/src/app/builds/changes/builds.changes.tpl.jade
@@ -1 +1,4 @@
h1 changes
md-list.changes-list
md-subheader.md-no-sticky Latest changes
md-divider
change-item(change="change", ng-repeat="change in changes.list")
5 changes: 4 additions & 1 deletion www/md_base/src/app/builds/changes/changes.controller.coffee
@@ -1,2 +1,5 @@
class Changes extends Controller
constructor: () ->
constructor: ($scope, dataService) ->
opened = dataService.open()
opened.closeOnDestroy($scope)
@list = opened.getChanges(limit: 40, order: '-when_timestamp').getArray()
15 changes: 14 additions & 1 deletion www/md_base/src/app/builds/masters/builds.masters.tpl.jade
@@ -1 +1,14 @@
h1 masters
md-list.master-list
md-subheader.md-no-sticky Masters
md-divider
md-list-item.master-item(ng-repeat="master in masters.list")
div.master-id
span \#{{ master.id }}
div.master-title(flex)
h3 {{ master.name}}
p(ng-if="master.last_active > 0") Last active at
span(am-time-ago="master.last_active")
p(ng-if="master.last_active == 0") Never been active.
div.master-state
span.active(ng-if="master.active") Active
span.inactive(ng-if="!master.active") Inactive
5 changes: 4 additions & 1 deletion www/md_base/src/app/builds/masters/masters.controller.coffee
@@ -1,2 +1,5 @@
class Masters extends Controller
constructor: () ->
constructor: ($scope, dataService) ->
opened = dataService.open()
opened.closeOnDestroy($scope)
@list = opened.getMasters().getArray()
41 changes: 41 additions & 0 deletions www/md_base/src/app/builds/masters/masters.less
@@ -0,0 +1,41 @@
.master-list {
.master-item {
margin: 20px 10px;
}

.master-id {
width: 50px;
font-size: 24px;
color: #999;
}

.master-title {
white-space: nowrap;

h3 {
margin: 0;
color: #673ab7;
overflow: hidden;
text-overflow: ellipsis;
}

p {
margin: 0;
color: #999;
}
}

.master-state {
font-weight: bold;
width: 50px;
text-align: center;

.active {
color: #8d4;
}

.inactive {
color: #ecc;
}
}
}
@@ -1 +1,7 @@
h1 schedulers
md-list.scheduler-list
md-subheader.md-no-sticky Schedulers
md-divider
md-list-item.scheduler-item(ng-repeat="scheduler in schedulers.list")
span.scheduler-id \#{{ scheduler.id }}
p.scheduler-name(flex) {{ scheduler.name }}
span.scheduler-master {{ scheduler.master || "No master" }}
@@ -1,2 +1,5 @@
class Schedulers extends Controller
constructor: () ->
constructor: ($scope, dataService) ->
opened = dataService.open()
opened.closeOnDestroy($scope)
@list = opened.getSchedulers().getArray()
11 changes: 11 additions & 0 deletions www/md_base/src/app/builds/schedulers/schedulers.less
@@ -0,0 +1,11 @@
.scheduler-list {
color: #999;

.scheduler-id {
min-width: 40px;
}

.scheduler-name {
color: #673ab7;
}
}
Expand Up @@ -7,7 +7,7 @@ class State extends Config
# Register new state
$stateProvider.state
controller: "schedulersController"
controllerAs: name
controllerAs: "schedulers"
templateUrl: "views/#{name}.html"
name: name
url: "/schedulers"
Expand Down
19 changes: 18 additions & 1 deletion www/md_base/src/app/builds/slaves/builds.slaves.tpl.jade
@@ -1 +1,18 @@
h1 slaves
md-list.slave-list
md-subheader.md-no-sticky Slaves
md-divider
div.slave-item(ng-repeat="slave in slaves.list", layout="row", layout-md="column")
div.slave-title(flex-gt-md="50")
h3 {{ slave.name }}
p
| Connected to
ng-pluralize(
count="slave.connected_to.length",
when="{'0': 'no master.','one': '1 master.','other': '{} masters.'}")
p
| Configured on
ng-pluralize(
count="slave.configured_on.length",
when="{'0': 'no builder.','one': '1 builder.','other': '{} builders.'}")
div.slave-info(flex-gt-md="50")
inspect-data(data="slave.slaveinfo")
7 changes: 6 additions & 1 deletion www/md_base/src/app/builds/slaves/slaves.controller.coffee
@@ -1,2 +1,7 @@
class Slaves extends Controller
constructor: () ->
constructor: ($scope, dataService) ->
opened = dataService.open()
opened.closeOnDestroy($scope)
# TODO: show builder names related to one slave after cache function
# of dataService has been finished.
@list = opened.getBuildslaves().getArray()
16 changes: 16 additions & 0 deletions www/md_base/src/app/builds/slaves/slaves.less
@@ -0,0 +1,16 @@
.slave-list {
.slave-item {
margin: 20px 10px;
}

.slave-title {
h3 {
color: #673ab7;
}

p {
margin: 5px 0;
color: #999;
}
}
}
Expand Up @@ -3,4 +3,4 @@ div.inner(layout="row")
span.builder-name(ng-if="builditem.showBuilder") {{ builditem.builder.name }}
span.number(flex) \#{{ builditem.build.number }}
span.status-text {{ builditem.build.state_string }}
span.time(am-time-ago="builditem.build.started_at", am-preprocess="unix")
span.time(am-time-ago="builditem.build.started_at")
Expand Up @@ -19,16 +19,16 @@ class _BuildStatus extends Controller

if build.complete is false and build.started_at > 0
@status_class = 'pending'
@icon = 'build-pending'
@icon = 'pending'
else if build.results == 0
@status_class = 'success'
@icon = 'build-success'
@icon = 'checkmark'
else if build.results >= 1 and build.results <= 6
@status_class = RESULTS_TEXT[build.results].toLowerCase()
@icon = 'build-fail'
@icon = 'crossmark'
else
@status_class = 'unknown'
@icon = 'build-pending'
@icon = 'pending'

$scope.$watch 'status.build', updateBuild, true

Expand Up @@ -24,7 +24,7 @@ describe 'buildstatus', ->
icon = elem.children().eq(0)

# unknown status
expect(icon.attr('md-svg-icon')).toBe('build-pending')
expect(icon.attr('md-svg-icon')).toBe('pending')
expect(icon.hasClass('unknown')).toBe(true)
expect(icon.hasClass('pending')).toBe(false)
for _, text of RESULTS_TEXT
Expand All @@ -33,7 +33,7 @@ describe 'buildstatus', ->
# pending status
$rootScope.build.started_at = (new Date()).valueOf()
$rootScope.$digest()
expect(icon.attr('md-svg-icon')).toBe('build-pending')
expect(icon.attr('md-svg-icon')).toBe('pending')
expect(icon.hasClass('unknown')).toBe(false)
expect(icon.hasClass('pending')).toBe(true)
for _, text of RESULTS_TEXT
Expand All @@ -43,7 +43,7 @@ describe 'buildstatus', ->
$rootScope.build.complete = true
$rootScope.build.results = 0
$rootScope.$digest()
expect(icon.attr('md-svg-icon')).toBe('build-success')
expect(icon.attr('md-svg-icon')).toBe('checkmark')
expect(icon.hasClass('unknown')).toBe(false)
expect(icon.hasClass('pending')).toBe(false)
for code, text of RESULTS_TEXT
Expand All @@ -53,7 +53,7 @@ describe 'buildstatus', ->
for i in [1..6]
$rootScope.build.results = i
$rootScope.$digest()
expect(icon.attr('md-svg-icon')).toBe('build-fail')
expect(icon.attr('md-svg-icon')).toBe('crossmark')
expect(icon.hasClass('unknown')).toBe(false)
expect(icon.hasClass('pending')).toBe(false)
for code, text of RESULTS_TEXT
Expand Down
@@ -0,0 +1,37 @@
class ChangeItem extends Directive

constructor: ->
return {
restrict: 'E'
templateUrl: 'views/changeitem.html'
controller: '_ChangeItemController'
controllerAs: 'changeitem'
bindToController: true
scope:
change: "="
}

class _ChangeItem extends Controller
showDetail: false

toggleDetail: ->
@showDetail = !@showDetail

constructor: (dataService) ->
@author = @change.author
@revision = @change.revision[0...6]
@comments = @change.comments
@date = @change.when_timestamp
@files = @change.files

# Official W3C email regular expression
emailRegex = /[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*/
email = emailRegex.exec @author

@email = email[0] if email

@displayData =
'Repository': @change.repository
'Branch': @change.branch
'Revision': @change.revision

79 changes: 79 additions & 0 deletions www/md_base/src/app/common/directives/changeitem/changeitem.less
@@ -0,0 +1,79 @@
change-item {
display: block;
padding: 5px;

.inner {
line-height: 30px;
font-size: 16px;
color: #999;

span {
padding: 0 5px;
}
}

.author {
height: 20px;
width: 20px;
overflow: hidden;
border-radius: 50%;
margin: 5px;

img {
width: 100%;
height: 100%;
}
}

.comments {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}

.revision {
width: 80px;
text-align: right;
font-family: monospace;
color: #666;
}

.detail {
color: #666;
margin-left: 30px;
padding: 10px 0;

&>div {
border-bottom: 1px solid #eee;
padding-bottom: 10px;
}
}

.sub-title {
margin: 10px 0;
text-transform: uppercase;
font-size: 12px;
font-weight: bold;
}

.meta {
.author-name {
font-weight: bold;
}

.time {
float: right;
}
}

.full-comment {

.content {
white-space: pre-wrap;
}
}

.changed-files {

}
}

0 comments on commit b309a89

Please sign in to comment.