Merge "Added simple logged-in dashboard"

This commit is contained in:
Jenkins 2014-06-06 21:04:36 +00:00 committed by Gerrit Code Review
commit cf7985da2f
8 changed files with 149 additions and 6 deletions

View File

@ -0,0 +1,29 @@
/*
* Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License. You may obtain
* a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/
/**
* A controller that manages our logged-in dashboard
*/
angular.module('sb.dashboard').controller('DashboardController',
function ($scope, currentUser, Story) {
'use strict';
// Load the list of current assigned stories.
$scope.assignedStories = Story.query({
assignee_id: currentUser.id,
status: 'active'
});
});

View File

@ -15,9 +15,14 @@
*/
/**
* Controller for our home(index) page, currently just a placeholder.
* Controller for our home(index) page.
*/
angular.module('sb.dashboard').controller('HomeController',
function () {
function ($state, sessionState, SessionState) {
'use strict';
// If we're logged in, go to the dashboard instead.
if (sessionState === SessionState.LOGGED_IN) {
$state.transitionTo('dashboard');
}
});

View File

@ -19,7 +19,7 @@
*/
angular.module('sb.dashboard',
[ 'sb.services', 'sb.templates', 'sb.auth', 'ui.router', 'ui.bootstrap'])
.config(function ($stateProvider) {
.config(function ($stateProvider, SessionResolver) {
'use strict';
// Set an initial home page.
@ -27,6 +27,18 @@ angular.module('sb.dashboard',
.state('index', {
url: '/',
templateUrl: 'app/templates/dashboard/index.html',
controller: 'HomeController'
controller: 'HomeController',
resolve: {
sessionState: SessionResolver.resolveSessionState
}
})
.state('dashboard', {
url: '/dashboard',
templateUrl: 'app/templates/dashboard/dashboard.html',
controller: 'DashboardController',
resolve: {
sessionState: SessionResolver.requireLoggedIn,
currentUser: SessionResolver.requireCurrentUser
}
});
});

View File

@ -0,0 +1,36 @@
<div class="container">
<div class="row">
<div class="col-sm-12">
<h1>Dashboard</h1>
</div>
<div class="col-sm-12">
<table class="table table-striped">
<thead>
<th colspan="2">Stories assigned to me</th>
</thead>
<tbody>
<tr ng-repeat="story in assignedStories">
<td class="col-sm-2">
<story-status-label story="story"/>
</td>
<td>
<p>
<a href="#!/story/{{story.id}}">
{{story.title}}
</a>
</p>
<story-task-status story="story"/>
</td>
</tr>
</tbody>
<tbody ng-show="assignedStories.length == 0">
<td colspan="3" class="text-center text-muted">
<em>
There are no active stories currently assigned to you.
</em>
</td>
</tbody>
</table>
</div>
</div>
</div>

View File

@ -27,9 +27,9 @@
</div>
<ul class="nav nav-pilltabs nav-stacked">
<li active-path="^\/$">
<li active-path="^\/(dashboard)?$">
<a href="#!/">
<span class="hidden-xs">Overview</span>
<span class="hidden-xs">Dashboard</span>
<i class="fa fa-home visible-xs"></i>
</a>
</li>

View File

@ -0,0 +1,26 @@
<small>
<span class="badge"
ng-class="{'badge-primary': story.todo > 0}">
{{story.todo}}
</span> ToDo
&nbsp;
<span class="badge"
ng-class="{'badge-primary': story.inprogress > 0}">
{{story.inprogress}}
</span> In Progress
&nbsp;
<span class="badge"
ng-class="{'badge-primary': story.review > 0}">
{{story.review}}
</span> In Review
&nbsp;
<span class="badge"
ng-class="{'badge-primary': story.merged > 0}">
{{story.merged}}
</span> Merged
&nbsp;
<span class="badge"
ng-class="{'badge-primary': story.invalid > 0}">
{{story.invalid}}
</span> Invalid
</small>

View File

@ -0,0 +1,32 @@
/*
* Copyright (c) 2013 Hewlett-Packard Development Company, L.P.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License. You may obtain
* a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/
/**
* A story status label that automatically selects color and text based on
* the bound-in story.
*/
angular.module('sb.util').directive('storyTaskStatus',
function () {
'use strict';
return {
restrict: 'E',
templateUrl: 'app/templates/util/story_task_status.html',
scope: {
story: '='
}
};
});

View File

@ -1,6 +1,9 @@
// Bootstrap extension that adds colors to badges
.badge {
&.badge-primary {
background-color: @brand-primary;
}
&.badge-info {
background-color: @brand-info;