Skip to content

Commit

Permalink
added changeitem and finish change page
Browse files Browse the repository at this point in the history
  • Loading branch information
shanzi committed Jun 30, 2015
1 parent 429b5c8 commit 2b5eda7
Show file tree
Hide file tree
Showing 9 changed files with 152 additions and 4 deletions.
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'
}
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()
2 changes: 1 addition & 1 deletion www/md_base/src/app/builds/masters/builds.masters.tpl.jade
Expand Up @@ -7,7 +7,7 @@ md-list.master-list
div.master-title(flex)
h3 {{ master.name}}
p(ng-if="master.last_active > 0") Last active at
span(am-time-ago="master.last_active", am-preprocess="unix")
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
Expand Down
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")
@@ -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

80 changes: 80 additions & 0 deletions www/md_base/src/app/common/directives/changeitem/changeitem.less
@@ -0,0 +1,80 @@
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;
outline: none;
}

.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,0 +1,3 @@
beforeEach module 'app'

describe 'changeitem', ->
@@ -0,0 +1,18 @@
div.inner(layout="row")
a.author(title="{{ changeitem.author }}", ng-href="mailto:{{ changeitem.email }}")
img(ng-if="changeitem.email", ng-src="avatar?email={{ changeitem.email }}")
a.comments(flex, ng-click="changeitem.toggleDetail()") {{ changeitem.comments }}
span.revision {{ changeitem.revision }}
div.detail(ng-if="changeitem.showDetail")
div.meta
span.time(am-time-ago="changeitem.date", title="{{ changeitem.date|amCalendar }}")
span.author-name {{ changeitem.author }}
div.full-comment
div.sub-title Comments
div.content {{ changeitem.comments}}
div.changed-files(ng-if="changeitem.files.length > 0")
div.sub-title Changed files
div.file-line(ng-repeat="file in changeitem.files") {{ file }}

inspect-data(data="changeitem.displayData")

0 comments on commit 2b5eda7

Please sign in to comment.