Commit d948a68c964897ebe7b6eeca212dea053496bb98

Authored by Victor Costa
1 parent 011ca4fd

Add component to display tasks in menu

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
1 1 import * as plugins from "../../plugins";
2   -import {bundle, Component, StateConfig, Inject} from "ng-forward";
3   -import {ArticleBlogComponent} from "./../article/types/blog/blog.component";
4   -
5   -import {ArticleViewComponent} from "./../article/article-default-view.component";
6   -
7   -import {ProfileComponent} from "../profile/profile.component";
8   -import {BoxesComponent} from "../layout/boxes/boxes.component";
9   -import {BlockContentComponent} from "../layout/blocks/block-content.component";
10   -import {BlockComponent} from "../layout/blocks/block.component";
11   -import {EnvironmentComponent} from "../environment/environment.component";
12   -import {EnvironmentHomeComponent} from "../environment/environment-home.component";
13   -import {PeopleBlockComponent} from "../layout/blocks/people/people-block.component";
14   -import {DisplayContentBlockComponent} from "../layout/blocks/display-content/display-content-block.component";
15   -import {LinkListBlockComponent} from "../layout/blocks/link-list/link-list-block.component";
16   -import {RecentDocumentsBlockComponent} from "../layout/blocks/recent-documents/recent-documents-block.component";
17   -import {ProfileImageBlockComponent} from "../layout/blocks/profile-image/profile-image-block.component";
18   -import {RawHTMLBlockComponent} from "../layout/blocks/raw-html/raw-html-block.component";
19   -import {StatisticsBlockComponent} from "../layout/blocks/statistics/statistics-block.component";
20   -import {PersonTagsPluginInterestsBlockComponent} from "../layout/blocks/person-tags-plugin-interests/person-tags-plugin-interests-block.component";
21   -import {TagsBlockComponent} from "../layout/blocks/tags/tags-block.component";
22   -import {CustomContentComponent} from "../profile/custom-content/custom-content.component";
23   -import {RecentActivitiesPluginActivitiesBlockComponent} from "../layout/blocks/recent-activities-plugin-activities/recent-activities-plugin-activities-block.component";
24   -
25   -import {MembersBlockComponent} from "../layout/blocks/members/members-block.component";
26   -import {CommunitiesBlockComponent} from "../layout/blocks/communities/communities-block.component";
27   -
28   -import {LoginBlockComponent} from "../layout/blocks/login-block/login-block.component";
29   -
30   -import {NoosferoTemplate} from "../shared/pipes/noosfero-template.filter";
31   -import {DateFormat} from "../shared/pipes/date-format.filter";
32   -
33   -import {AuthService} from "../login/auth.service";
34   -import {SessionService} from "../login/session.service";
35   -import {EnvironmentService} from "./../../lib/ng-noosfero-api/http/environment.service";
36   -import {NotificationService} from "../shared/services/notification.service";
37   -
38   -import {BodyStateClassesService} from "./../layout/services/body-state-classes.service";
39   -
40   -import {Navbar} from "../layout/navbar/navbar";
41   -
42   -import {SidebarComponent} from "../layout/sidebar/sidebar.component";
43   -
44   -import {MainBlockComponent} from "../layout/blocks/main/main-block.component";
45   -import {HtmlEditorComponent} from "../shared/components/html-editor/html-editor.component";
46   -import {PermissionDirective} from "../shared/components/permission/permission.directive";
47   -import {SearchComponent} from "../search/search.component";
48   -import {SearchFormComponent} from "../search/search-form/search-form.component";
  2 +import { bundle, Component, StateConfig, Inject } from "ng-forward";
  3 +import { ArticleBlogComponent } from "./../article/types/blog/blog.component";
  4 +
  5 +import { ArticleViewComponent } from "./../article/article-default-view.component";
  6 +
  7 +import { ProfileComponent } from "../profile/profile.component";
  8 +import { BoxesComponent } from "../layout/boxes/boxes.component";
  9 +import { BlockContentComponent } from "../layout/blocks/block-content.component";
  10 +import { BlockComponent } from "../layout/blocks/block.component";
  11 +import { EnvironmentComponent } from "../environment/environment.component";
  12 +import { EnvironmentHomeComponent } from "../environment/environment-home.component";
  13 +import { PeopleBlockComponent } from "../layout/blocks/people/people-block.component";
  14 +import { DisplayContentBlockComponent } from "../layout/blocks/display-content/display-content-block.component";
  15 +import { LinkListBlockComponent } from "../layout/blocks/link-list/link-list-block.component";
  16 +import { RecentDocumentsBlockComponent } from "../layout/blocks/recent-documents/recent-documents-block.component";
  17 +import { ProfileImageBlockComponent } from "../layout/blocks/profile-image/profile-image-block.component";
  18 +import { RawHTMLBlockComponent } from "../layout/blocks/raw-html/raw-html-block.component";
  19 +import { StatisticsBlockComponent } from "../layout/blocks/statistics/statistics-block.component";
  20 +import { PersonTagsPluginInterestsBlockComponent } from "../layout/blocks/person-tags-plugin-interests/person-tags-plugin-interests-block.component";
  21 +import { TagsBlockComponent } from "../layout/blocks/tags/tags-block.component";
  22 +import { CustomContentComponent } from "../profile/custom-content/custom-content.component";
  23 +import { RecentActivitiesPluginActivitiesBlockComponent } from "../layout/blocks/recent-activities-plugin-activities/recent-activities-plugin-activities-block.component";
  24 +
  25 +import { MembersBlockComponent } from "../layout/blocks/members/members-block.component";
  26 +import { CommunitiesBlockComponent } from "../layout/blocks/communities/communities-block.component";
  27 +
  28 +import { LoginBlockComponent } from "../layout/blocks/login-block/login-block.component";
  29 +
  30 +import { NoosferoTemplate } from "../shared/pipes/noosfero-template.filter";
  31 +import { DateFormat } from "../shared/pipes/date-format.filter";
  32 +
  33 +import { AuthService } from "../login/auth.service";
  34 +import { SessionService } from "../login/session.service";
  35 +import { EnvironmentService } from "./../../lib/ng-noosfero-api/http/environment.service";
  36 +import { NotificationService } from "../shared/services/notification.service";
  37 +
  38 +import { BodyStateClassesService } from "./../layout/services/body-state-classes.service";
  39 +
  40 +import { Navbar } from "../layout/navbar/navbar";
  41 +
  42 +import { SidebarComponent } from "../layout/sidebar/sidebar.component";
  43 +
  44 +import { MainBlockComponent } from "../layout/blocks/main/main-block.component";
  45 +import { HtmlEditorComponent } from "../shared/components/html-editor/html-editor.component";
  46 +import { PermissionDirective } from "../shared/components/permission/permission.directive";
  47 +import { SearchComponent } from "../search/search.component";
  48 +import { SearchFormComponent } from "../search/search-form/search-form.component";
  49 +import { TasksMenuComponent } from "../task/tasks-menu/tasks-menu.component";
49 50  
50 51 /**
51 52 * @ngdoc controller
... ... @@ -107,7 +108,8 @@ export class EnvironmentContent {
107 108 MainBlockComponent, RecentDocumentsBlockComponent, Navbar, SidebarComponent, ProfileImageBlockComponent,
108 109 MembersBlockComponent, NoosferoTemplate, DateFormat, RawHTMLBlockComponent, StatisticsBlockComponent,
109 110 LoginBlockComponent, CustomContentComponent, PermissionDirective, SearchFormComponent, SearchComponent,
110   - PersonTagsPluginInterestsBlockComponent, TagsBlockComponent, RecentActivitiesPluginActivitiesBlockComponent, BlockComponent
  111 + PersonTagsPluginInterestsBlockComponent, TagsBlockComponent, RecentActivitiesPluginActivitiesBlockComponent, BlockComponent,
  112 + TasksMenuComponent
111 113 ].concat(plugins.mainComponents).concat(plugins.hotspots),
112 114 providers: [AuthService, SessionService, NotificationService, BodyStateClassesService,
113 115 "ngAnimate", "ngCookies", "ngStorage", "ngTouch",
... ...
src/app/task/tasks-menu/tasks-menu.component.ts 0 → 100644
... ... @@ -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 +}
... ...
src/app/task/tasks-menu/tasks-menu.html 0 → 100644
... ... @@ -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>
... ...
src/app/task/tasks-menu/tasks-menu.scss 0 → 100644
... ... @@ -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
... ... @@ -97,5 +97,6 @@
97 97 "block.edition.display_user.all": "All users",
98 98 "block.edition.display_user.logged": "Logged",
99 99 "block.edition.display_user.not_logged": "Not logged",
100   - "block.edition.language.label": "Show for:"
  100 + "block.edition.language.label": "Show for:",
  101 + "tasks.menu.all": "All tasks"
101 102 }
... ...
src/languages/pt.json
... ... @@ -97,5 +97,6 @@
97 97 "block.edition.display_user.all": "Todos os usuários",
98 98 "block.edition.display_user.logged": "Logados",
99 99 "block.edition.display_user.not_logged": "Não logados",
100   - "block.edition.language.label": "Exibir para:"
  100 + "block.edition.language.label": "Exibir para:",
  101 + "tasks.menu.all": "Todas as tarefas"
101 102 }
... ...
src/lib/ng-noosfero-api/http/task.service.ts 0 → 100644
... ... @@ -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 +}
... ...
src/lib/ng-noosfero-api/interfaces/task.ts 0 → 100644
... ... @@ -0,0 +1,11 @@
  1 +namespace noosfero {
  2 + /**
  3 + * @ngdoc interface
  4 + * @name noosfero.Task
  5 + * @description
  6 + * A representation of a Task in Noosfero.
  7 + */
  8 + export interface Task extends RestModel {
  9 + type: string;
  10 + }
  11 +}
... ...