Skip to content

Commit ab6da3d

Browse files
committed
Dash top widgets almost done.
1 parent 2e4c54f commit ab6da3d

File tree

7 files changed

+92
-148
lines changed

7 files changed

+92
-148
lines changed

src/app/modules/dashboard/dashboard.html

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
<div class="row">
2-
<div posts-total class="col-md-3 col-sm-6 col-xs-12"></div>
3-
<div posts-today class="col-md-3 col-sm-6 col-xs-12"></div>
4-
<div posts-this-month class="col-md-3 col-sm-6 col-xs-12"></div>
5-
<div last-edited class="col-md-3 col-sm-6 col-xs-12"></div>
2+
<div posts-list-dash-widget class="col-md-3 col-sm-6 col-xs-12"
3+
description="total" widget-class="posts-total" icon-class="glyphicon glyphicon-globe"></div>
4+
<div posts-list-dash-widget class="col-md-3 col-sm-6 col-xs-12"
5+
description="today" widget-class="posts-today" icon-class="glyphicon glyphicon-hourglass" interval="1"></div>
6+
<div posts-list-dash-widget class="col-md-3 col-sm-6 col-xs-12"
7+
description="this month" widget-class="posts-this-month" icon-class="glyphicon glyphicon-calendar" interval="30"></div>
8+
<div last-edited-dash-widget class="col-md-3 col-sm-6 col-xs-12"></div>
69
</div>
710
</div>
811

src/app/modules/dashboard/top_widget/widget.html

Lines changed: 0 additions & 15 deletions
This file was deleted.

src/app/modules/dashboard/top_widget/widget.js

Lines changed: 0 additions & 126 deletions
This file was deleted.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<div class="widget dash-top-widget last-edited">
2+
<div class="row">
3+
<div class="col-xs-12 widget-info">
4+
<i class="widget-icon glyphicon glyphicon-pencil"></i>
5+
<div class="text-right widget-text">
6+
<div ><span class="huge">fresh</span> <span class="tiny">post</span></div>
7+
<div><span class="large">last edited</span></div>
8+
</div>
9+
</div>
10+
</div>
11+
<span class="widget-action" ng-click="action()">
12+
Show
13+
<span class="glyphicon glyphicon-menu-right"></span>
14+
</span>
15+
</div>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<div class="widget dash-top-widget {{widgetClass}}">
2+
<div class="row">
3+
<div class="col-xs-12 widget-info">
4+
<i class="widget-icon {{iconClass}}"></i>
5+
<div class="text-right widget-text">
6+
<div ><span class="huge">{{number}}</span> <span class="tiny">posts</span></div>
7+
<div><span class="large">{{description}}</span></div>
8+
</div>
9+
</div>
10+
</div>
11+
<span class="widget-action" ng-click="action()">
12+
View all
13+
<span class="glyphicon glyphicon-menu-right"></span>
14+
</span>
15+
</div>
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
(function() {
2+
'use strict';
3+
4+
angular.module('app.dashboard')
5+
.directive('postsListDashWidget', postsListDashWidget)
6+
.directive('lastEditedDashWidget', lastEditedDashWidget);
7+
8+
function lastEditedDashWidget() {
9+
return {
10+
restrict: 'EA',
11+
scope: {},
12+
controller: ['$scope', '$state', 'postsUtils', function ($scope, $state, postsUtils) {
13+
$scope.lastEdited;
14+
15+
postsUtils.lastEdited().then(function(lastEdited) {
16+
$scope.lastEdited = lastEdited;
17+
});
18+
19+
vm.action = function() {
20+
$state.go('app.editPost', {id: vm.lastEdited.id})
21+
}
22+
}],
23+
templateUrl: 'app/modules/dashboard/top_widgets/last_edited.html'
24+
}
25+
}
26+
27+
function postsListDashWidget() {
28+
return {
29+
restrict: 'EA',
30+
scope: {
31+
'widgetClass': '@',
32+
'iconClass': '@',
33+
'description': '@',
34+
'interval': '@'
35+
},
36+
controller: ['$scope', '$state', 'postsUtils', function($scope, $state, postsUtils) {
37+
var utilsMethod = $scope.interval ? 'postsDuringInterval' : 'total';
38+
39+
postsUtils[utilsMethod]($scope.interval).then(function(posts) {
40+
$scope.number = posts.length;
41+
});
42+
43+
$scope.action = function() {
44+
$state.go('app.posts', {interval: $scope.interval})
45+
}
46+
47+
}],
48+
templateUrl: 'app/modules/dashboard/top_widgets/posts_list_widget.html'
49+
}
50+
}
51+
52+
})();

src/index.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363

6464
<script src="app/modules/dashboard/dashboard.module.js"></script>
6565

66-
<script src="app/modules/dashboard/top_widget/widget.js"></script>
66+
<script src="app/modules/dashboard/top_widgets/widget.js"></script>
6767

6868
<script src="app/modules/dashboard/recently_published/recently_published.js"></script>
6969

@@ -77,12 +77,12 @@
7777

7878
<script src="app/modules/post/delete_post_modal.js"></script>
7979

80+
<script src="app/modules/dashboard/dashboard.js"></script>
81+
8082
<script src="app/modules/data/data.module.js"></script>
8183

8284
<script src="app/modules/data/posts.js"></script>
8385

84-
<script src="app/modules/dashboard/dashboard.js"></script>
85-
8686
<script src="app/modules/core/core.js"></script>
8787

8888
<script src="app/modules/core/config.js"></script>

0 commit comments

Comments
 (0)