-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1692 from shanzi/md
Overview panel's content
- Loading branch information
Showing
9 changed files
with
185 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
div.inner-container | ||
div.title-bar(layout="row") | ||
div.title.no-select(flex, ng-class="{locked: panel.locked}") {{ panel.title }} | ||
div.title.no-select(flex, ng-class="{locked: panel.locked}") {{ panel.bind.title }} | ||
div.buttons(ng-if="!panel.locked") | ||
md-button(ng-click="panel.toggleCollapse()") | ||
md-icon(md-svg-icon="expand-panel", ng-show="panel.isCollapsed") | ||
md-icon(md-svg-icon="collapse-panel", ng-show="!panel.isCollapsed") | ||
md-icon(md-svg-icon="expand-panel", ng-show="panel.bind.collapsed") | ||
md-icon(md-svg-icon="collapse-panel", ng-show="!panel.bind.collapsed") | ||
div.content |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 39 additions & 2 deletions
41
www/md_base/src/app/home/panels/overview/overview.directive.coffee
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,45 @@ | ||
class Overview extends Directive | ||
|
||
constructor: -> | ||
constructor: -> | ||
return { | ||
restrict: 'E' | ||
templateUrl: 'views/overview_panel.html' | ||
controller: '_OverviewController' | ||
controllerAs: 'overview' | ||
} | ||
|
||
|
||
class _Overview extends Controller | ||
masters: | ||
count: 0 | ||
active: 0 | ||
|
||
slaves: | ||
count: 0 | ||
connections: 0 | ||
|
||
builders: | ||
count: 0 | ||
|
||
schedulers: | ||
count: 0 | ||
|
||
constructor: (buildbotService) -> | ||
# TODO: Avoid fetch all the data here after # there is a direct API interface | ||
buildbotService.all('masters').getList().then (entries) => | ||
actives = 0 | ||
for master in entries | ||
actives += 1 if master.active | ||
@masters.count = entries.length | ||
@masters.active = actives | ||
|
||
buildbotService.all('buildslaves').getList().then (entries) => | ||
connections = 0 | ||
connections += slave.connected_to.length for slave in entries | ||
@slaves.count = entries.length | ||
@slaves.connections = connections | ||
|
||
buildbotService.all('builders').getList().then (entries) => | ||
@builders.count = entries.length | ||
|
||
buildbotService.all('schedulers').getList().then (entries) => | ||
@schedulers.count = entries.length |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
overview { | ||
display: block; | ||
overflow: hidden; | ||
padding: 20px 0; | ||
|
||
.tile { | ||
float: left; | ||
width: 25%; | ||
text-align: center; | ||
|
||
.title { | ||
font-size: 0.8em; | ||
color: #333; | ||
} | ||
|
||
.count { | ||
font-size: 80px; | ||
color: #673ab7; | ||
} | ||
|
||
.extra { | ||
color: #999; | ||
font-size: 14px; | ||
} | ||
} | ||
|
||
@media (max-width: 640px) { | ||
.count { | ||
font-size: 50px !important; | ||
} | ||
} | ||
} | ||
|
||
.collapsed overview { | ||
.tile { | ||
width: 50%; | ||
margin-bottom: 5px; | ||
} | ||
|
||
.count { | ||
font-size: 50px; | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
www/md_base/src/app/home/panels/overview/overview.spec.coffee
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
beforeEach module 'app' | ||
|
||
describe 'overview', -> | ||
|
||
$rootScope = $compile = $httpBackend = null | ||
|
||
injected = ($injector) -> | ||
$compile = $injector.get('$compile') | ||
$rootScope = $injector.get('$rootScope') | ||
$httpBackend = $injector.get('$httpBackend') | ||
$q = $injector.get('$q') | ||
mqService = $injector.get('mqService') | ||
spyOn(mqService,"setBaseUrl").and.returnValue(null) | ||
spyOn(mqService,"startConsuming").and.returnValue($q.when( -> )) | ||
spyOn(mqService,"stopConsuming").and.returnValue(null) | ||
decorateHttpBackend($httpBackend) | ||
|
||
beforeEach inject injected | ||
|
||
it 'should display tiles normally', -> | ||
$httpBackend.expectDataGET('masters') | ||
$httpBackend.expectDataGET('buildslaves') | ||
$httpBackend.expectDataGET('builders') | ||
$httpBackend.expectDataGET('schedulers') | ||
elem = $compile('<overview></overview>')($rootScope) | ||
$httpBackend.flush() | ||
|
||
mastertile = elem.children().eq(0) | ||
count = mastertile.children().eq(1).text().trim() | ||
expect(count).toBe('1') | ||
extra = mastertile.children().eq(2).text().trim() | ||
expect(extra).toBe('0 active.') | ||
|
||
slavetile = elem.children().eq(1) | ||
count = slavetile.children().eq(1).text().trim() | ||
expect(count).toBe('1') | ||
extra = slavetile.children().eq(2).text().trim() | ||
expect(extra).toBe('1 connections.') | ||
|
||
builderstile = elem.children().eq(2) | ||
count = builderstile.children().eq(1).text().trim() | ||
expect(count).toBe('1') | ||
|
||
schedulerstile = elem.children().eq(3) | ||
count = schedulerstile.children().eq(1).text().trim() | ||
expect(count).toBe('1') |
23 changes: 22 additions & 1 deletion
23
www/md_base/src/app/home/panels/overview/overview_panel.tpl.jade
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,22 @@ | ||
| overview panel content | ||
div.tile | ||
div.title Masters | ||
div.count {{ overview.masters.count }} | ||
div.extra | ||
| {{ overview.masters.active }} active. | ||
div.tile | ||
div.title Slaves | ||
div.count {{ overview.slaves.count }} | ||
div.extra | ||
ng-pluralize( | ||
count="overview.slaves.connections", | ||
when="{'0': 'No connection.','one': '1 connection.','other': '{} connections.'}") | ||
div.tile | ||
div.title Builders | ||
div.count {{ overview.builders.count }} | ||
div.extra | ||
a(ui-sref="builds") View all builders | ||
div.tile | ||
div.title Schedulers | ||
div.count {{ overview.schedulers.count }} | ||
div.extra | ||
a(ui-sref="builds") View all schedulers |