Commit f0967aa0e4ad3b81c02179a332923d37d50670a2
1 parent
fb1e923a
Add component to display tasks in menu
Showing
9 changed files
with
124 additions
and
5 deletions
Show diff stats
src/app/layout/navbar/navbar.html
... | ... | @@ -39,10 +39,12 @@ |
39 | 39 | </ul> |
40 | 40 | </li> |
41 | 41 | </ul> |
42 | - | |
43 | 42 | <ul class="nav navbar-nav navbar-right"> |
44 | 43 | <language-selector class="nav navbar-nav navbar-right"></language-selector> |
45 | 44 | </ul> |
45 | + <ul class="nav navbar-nav navbar-right"> | |
46 | + <tasks-menu class="nav navbar-nav navbar-right"></tasks-menu> | |
47 | + </ul> | |
46 | 48 | <div ui-view="actions"></div> |
47 | 49 | <div class="nav navbar-nav search navbar-right"> |
48 | 50 | <search-form></search-form> | ... | ... |
src/app/main/main.component.ts
... | ... | @@ -46,9 +46,10 @@ import { HtmlEditorComponent } from "../shared/components/html-editor/html-edito |
46 | 46 | import { PermissionDirective } from "../shared/components/permission/permission.directive"; |
47 | 47 | import { SearchComponent } from "../search/search.component"; |
48 | 48 | import { SearchFormComponent } from "../search/search-form/search-form.component"; |
49 | - | |
50 | 49 | import { EVENTS_HUB_KNOW_EVENT_NAMES, EventsHubService } from "../shared/services/events-hub.service"; |
51 | 50 | import { NoosferoKnownEvents } from "../known-events"; |
51 | +import { TasksMenuComponent } from "../task/tasks-menu/tasks-menu.component"; | |
52 | + | |
52 | 53 | /** |
53 | 54 | * @ngdoc controller |
54 | 55 | * @name main.MainContentComponent |
... | ... | @@ -113,7 +114,8 @@ export class EnvironmentContent { |
113 | 114 | MainBlockComponent, RecentDocumentsBlockComponent, Navbar, SidebarComponent, ProfileImageBlockComponent, |
114 | 115 | MembersBlockComponent, NoosferoTemplate, DateFormat, RawHTMLBlockComponent, StatisticsBlockComponent, |
115 | 116 | LoginBlockComponent, CustomContentComponent, PermissionDirective, SearchFormComponent, SearchComponent, |
116 | - PersonTagsPluginInterestsBlockComponent, TagsBlockComponent, RecentActivitiesPluginActivitiesBlockComponent, BlockComponent | |
117 | + PersonTagsPluginInterestsBlockComponent, TagsBlockComponent, RecentActivitiesPluginActivitiesBlockComponent, BlockComponent, | |
118 | + TasksMenuComponent | |
117 | 119 | ].concat(plugins.mainComponents).concat(plugins.hotspots), |
118 | 120 | providers: [AuthService, SessionService, NotificationService, BodyStateClassesService, |
119 | 121 | "ngAnimate", "ngCookies", "ngStorage", "ngTouch", | ... | ... |
... | ... | @@ -0,0 +1,24 @@ |
1 | +import { Component, Inject } from "ng-forward"; | |
2 | +import { TaskService } from "../../../lib/ng-noosfero-api/http/task.service"; | |
3 | + | |
4 | +@Component({ | |
5 | + selector: "tasks-menu", | |
6 | + templateUrl: "app/task/tasks-menu/tasks-menu.html" | |
7 | +}) | |
8 | +@Inject(TaskService) | |
9 | +export class TasksMenuComponent { | |
10 | + | |
11 | + tasks: noosfero.Task[]; | |
12 | + total: number; | |
13 | + perPage: 5; | |
14 | + | |
15 | + constructor(private taskService: TaskService) { } | |
16 | + | |
17 | + ngOnInit() { | |
18 | + this.taskService.getAllPending({ per_page: this.perPage }).then((result: noosfero.RestResult) => { | |
19 | + this.total = result.headers('total'); | |
20 | + this.tasks = result.data; | |
21 | + }); | |
22 | + } | |
23 | + | |
24 | +} | ... | ... |
... | ... | @@ -0,0 +1,20 @@ |
1 | +<li class="btn-nav tasks-menu" uib-dropdown ng-show="ctrl.total > 0"> | |
2 | + <a href="#" uib-dropdown-toggle> | |
3 | + <i class="fa fa-bell-o fa-fw fa-2x"></i> | |
4 | + <span class="badge">{{ctrl.total}}</span> | |
5 | + </a> | |
6 | + <ul class="dropdown-menu task-list" uib-dropdown-menu> | |
7 | + <li ng-repeat="(target, tasks) in ctrl.tasks | groupBy: 'target.name'"> | |
8 | + {{target}} | |
9 | + <a href="#" ng-repeat="task in tasks | orderBy: 'created_at':true" class="task"> | |
10 | + {{task.type}} | |
11 | + {{task.requestor.name}} | |
12 | + {{task.target.name}} | |
13 | + <span class="time"> | |
14 | + <span class="bullet-separator">•</span> <span am-time-ago="task.created_at | dateFormat"></span> | |
15 | + </span> | |
16 | + </a> | |
17 | + </li> | |
18 | + <a href="#" class="all-tasks btn btn-default btn-xs">{{"tasks.menu.all" | translate}}</a> | |
19 | + </ul> | |
20 | +</li> | ... | ... |
... | ... | @@ -0,0 +1,32 @@ |
1 | +.tasks-menu { | |
2 | + position: relative; | |
3 | + margin-right: 0; | |
4 | + .badge { | |
5 | + position: absolute; | |
6 | + top: 1px; | |
7 | + right: 8px; | |
8 | + border-radius: 6px; | |
9 | + } | |
10 | + i { | |
11 | + color: #FFF; | |
12 | + } | |
13 | + .task-list { | |
14 | + width: 500px; | |
15 | + padding: 16px 16px 8px 16px; | |
16 | + .task { | |
17 | + .time { | |
18 | + color: #c1c1c1; | |
19 | + font-size: 12px; | |
20 | + .bullet-separator { | |
21 | + font-size: 10px; | |
22 | + color: #d1d1d1; | |
23 | + } | |
24 | + } | |
25 | + } | |
26 | + .all-tasks { | |
27 | + text-align: center; | |
28 | + width: 100%; | |
29 | + display: inline-block; | |
30 | + } | |
31 | + } | |
32 | +} | ... | ... |
src/languages/en.json
src/languages/pt.json
... | ... | @@ -0,0 +1,26 @@ |
1 | +import { Injectable, Inject } from "ng-forward"; | |
2 | +import { RestangularService } from "./restangular_service"; | |
3 | + | |
4 | +@Injectable() | |
5 | +@Inject("Restangular", "$q", "$log") | |
6 | +export class TaskService extends RestangularService<noosfero.Task> { | |
7 | + | |
8 | + constructor(Restangular: restangular.IService, $q: ng.IQService, $log: ng.ILogService) { | |
9 | + super(Restangular, $q, $log); | |
10 | + } | |
11 | + | |
12 | + getResourcePath() { | |
13 | + return "tasks"; | |
14 | + } | |
15 | + | |
16 | + getDataKeys() { | |
17 | + return { | |
18 | + singular: 'task', | |
19 | + plural: 'tasks' | |
20 | + }; | |
21 | + } | |
22 | + | |
23 | + getAllPending(params: any) { | |
24 | + return this.list(null, { all_pending: true }); | |
25 | + } | |
26 | +} | ... | ... |