Commit bcab3c27e94b1208809542efd8d5342468aba431
1 parent
0528af25
Exists in
updated_signup_page
and in
1 other branch
Ticket #45: [WIP] Tags block
Showing
8 changed files
with
128 additions
and
2 deletions
Show diff stats
src/app/index.ts
@@ -18,7 +18,7 @@ let noosferoApp: any = bundle("noosferoApp", MainComponent, ["ngAnimate", "ngCoo | @@ -18,7 +18,7 @@ let noosferoApp: any = bundle("noosferoApp", MainComponent, ["ngAnimate", "ngCoo | ||
18 | "angular-bind-html-compile", "angularMoment", "angular.filter", "akoenig.deckgrid", | 18 | "angular-bind-html-compile", "angularMoment", "angular.filter", "akoenig.deckgrid", |
19 | "angular-timeline", "duScroll", "oitozero.ngSweetAlert", | 19 | "angular-timeline", "duScroll", "oitozero.ngSweetAlert", |
20 | "pascalprecht.translate", "tmh.dynamicLocale", "angularLoad", | 20 | "pascalprecht.translate", "tmh.dynamicLocale", "angularLoad", |
21 | - "angular-click-outside"]).publish(); | 21 | + "angular-click-outside", "ngTagCloud"]).publish(); |
22 | 22 | ||
23 | NoosferoApp.angularModule = noosferoApp; | 23 | NoosferoApp.angularModule = noosferoApp; |
24 | 24 |
@@ -0,0 +1 @@ | @@ -0,0 +1 @@ | ||
1 | +// TODO |
@@ -0,0 +1,38 @@ | @@ -0,0 +1,38 @@ | ||
1 | +import {Component, Inject, Input} from "ng-forward"; | ||
2 | +import {EnvironmentService} from "../../../../lib/ng-noosfero-api/http/environment.service"; | ||
3 | + | ||
4 | +@Component({ | ||
5 | + selector: "noosfero-tags-block", | ||
6 | + templateUrl: 'app/layout/blocks/tags/tags-block.html' | ||
7 | +}) | ||
8 | +@Inject(EnvironmentService, "$state") | ||
9 | +export class TagsBlockComponent { | ||
10 | + | ||
11 | + @Input() block: any; | ||
12 | + @Input() owner: any; | ||
13 | + | ||
14 | + profile: any; | ||
15 | + tags: any; | ||
16 | + | ||
17 | + tagsLoaded: boolean = false; | ||
18 | + | ||
19 | + constructor(private environmentService: EnvironmentService, private $state: any) { | ||
20 | + } | ||
21 | + | ||
22 | + ngOnInit() { | ||
23 | + this.profile = this.owner; | ||
24 | + this.tags = []; | ||
25 | + let tag = ''; | ||
26 | + | ||
27 | + this.environmentService.getTags() | ||
28 | + .then((result: noosfero.RestResult<{}>) => { | ||
29 | + for (tag in result) { | ||
30 | + if (result.hasOwnProperty(tag)) { | ||
31 | + let size: number = result[tag]; | ||
32 | + this.tags.push({ text: tag, weight: size, link: '/tag/' + tag }); | ||
33 | + } | ||
34 | + } | ||
35 | + this.tagsLoaded = true; | ||
36 | + }); | ||
37 | + } | ||
38 | +} |
@@ -0,0 +1,11 @@ | @@ -0,0 +1,11 @@ | ||
1 | +<!-- | ||
2 | +<div deckgrid source="ctrl.tags" class="deckgrid"> | ||
3 | + <div class="a-card panel media" ng-click="mother.ctrl.openTag(card);"> | ||
4 | + <div class="header media-body"> | ||
5 | + <h5 class="title media-heading" ng-bind="card.name"></h5> | ||
6 | + <div class="subheader" ng-bind="card.count"></div> | ||
7 | + </div> | ||
8 | + </div> | ||
9 | +</div> | ||
10 | +--> | ||
11 | +<ng-tag-cloud cloud-width="250" cloud-height="250" cloud-data="ctrl.tags"></ng-tag-cloud> |
@@ -0,0 +1,65 @@ | @@ -0,0 +1,65 @@ | ||
1 | +.block.tagsblock { | ||
2 | + .deckgrid[deckgrid]::before { | ||
3 | + font-size: 0; /* See https://github.com/akoenig/angular-deckgrid/issues/14#issuecomment-35728861 */ | ||
4 | + visibility: hidden; | ||
5 | + } | ||
6 | + .author { | ||
7 | + img { | ||
8 | + width: 30px; | ||
9 | + height: 30px; | ||
10 | + } | ||
11 | + } | ||
12 | + .header { | ||
13 | + .subheader { | ||
14 | + color: #C1C1C1; | ||
15 | + font-size: 10px; | ||
16 | + } | ||
17 | + } | ||
18 | + .post-lead { | ||
19 | + color: #8E8E8E; | ||
20 | + font-size: 14px; | ||
21 | + } | ||
22 | + .article-image { | ||
23 | + margin: 10px 0; | ||
24 | + } | ||
25 | +} | ||
26 | + | ||
27 | +.col-md-2-5 { | ||
28 | + .deckgrid[deckgrid]::before { | ||
29 | + content: '1 .deck-column'; | ||
30 | + } | ||
31 | +} | ||
32 | + | ||
33 | +.col-md-7 { | ||
34 | + .block.tagsblock { | ||
35 | + background-color: transparent; | ||
36 | + border: 0; | ||
37 | + | ||
38 | + .deckgrid[deckgrid]::before { | ||
39 | + content: '3 .deck-column'; | ||
40 | + } | ||
41 | + | ||
42 | + .panel-heading { | ||
43 | + display: none; | ||
44 | + } | ||
45 | + .panel-body { | ||
46 | + padding: 0; | ||
47 | + } | ||
48 | + | ||
49 | + .deckgrid { | ||
50 | + .column { | ||
51 | + float: left; | ||
52 | + } | ||
53 | + | ||
54 | + .deck-column { | ||
55 | + @extend .col-md-4; | ||
56 | + padding: 0; | ||
57 | + | ||
58 | + .a-card { | ||
59 | + padding: 10px; | ||
60 | + margin: 3px; | ||
61 | + } | ||
62 | + } | ||
63 | + } | ||
64 | + } | ||
65 | +} |
src/app/main/main.component.ts
@@ -15,6 +15,7 @@ import {RecentDocumentsBlockComponent} from "../layout/blocks/recent-documents/r | @@ -15,6 +15,7 @@ import {RecentDocumentsBlockComponent} from "../layout/blocks/recent-documents/r | ||
15 | import {ProfileImageBlockComponent} from "../layout/blocks/profile-image/profile-image-block.component"; | 15 | import {ProfileImageBlockComponent} from "../layout/blocks/profile-image/profile-image-block.component"; |
16 | import {RawHTMLBlockComponent} from "../layout/blocks/raw-html/raw-html-block.component"; | 16 | import {RawHTMLBlockComponent} from "../layout/blocks/raw-html/raw-html-block.component"; |
17 | import {StatisticsBlockComponent} from "../layout/blocks/statistics/statistics-block.component"; | 17 | import {StatisticsBlockComponent} from "../layout/blocks/statistics/statistics-block.component"; |
18 | +import {TagsBlockComponent} from "../layout/blocks/tags/tags-block.component"; | ||
18 | 19 | ||
19 | import {MembersBlockComponent} from "./../layout/blocks/members/members-block.component"; | 20 | import {MembersBlockComponent} from "./../layout/blocks/members/members-block.component"; |
20 | import {CommunitiesBlockComponent} from "./../layout/blocks/communities/communities-block.component"; | 21 | import {CommunitiesBlockComponent} from "./../layout/blocks/communities/communities-block.component"; |
@@ -98,7 +99,7 @@ export class EnvironmentContent { | @@ -98,7 +99,7 @@ export class EnvironmentContent { | ||
98 | LinkListBlockComponent, CommunitiesBlockComponent, HtmlEditorComponent, | 99 | LinkListBlockComponent, CommunitiesBlockComponent, HtmlEditorComponent, |
99 | MainBlockComponent, RecentDocumentsBlockComponent, Navbar, SidebarComponent, ProfileImageBlockComponent, | 100 | MainBlockComponent, RecentDocumentsBlockComponent, Navbar, SidebarComponent, ProfileImageBlockComponent, |
100 | MembersBlockComponent, NoosferoTemplate, DateFormat, RawHTMLBlockComponent, StatisticsBlockComponent, | 101 | MembersBlockComponent, NoosferoTemplate, DateFormat, RawHTMLBlockComponent, StatisticsBlockComponent, |
101 | - LoginBlockComponent | 102 | + LoginBlockComponent, TagsBlockComponent |
102 | ].concat(plugins.mainComponents).concat(plugins.hotspots), | 103 | ].concat(plugins.mainComponents).concat(plugins.hotspots), |
103 | 104 | ||
104 | providers: [AuthService, SessionService, NotificationService, BodyStateClassesService] | 105 | providers: [AuthService, SessionService, NotificationService, BodyStateClassesService] |
src/lib/ng-noosfero-api/http/environment.service.ts
@@ -34,6 +34,14 @@ export class EnvironmentService { | @@ -34,6 +34,14 @@ export class EnvironmentService { | ||
34 | return deferred.promise; | 34 | return deferred.promise; |
35 | } | 35 | } |
36 | 36 | ||
37 | + getTags(): ng.IPromise<{}> { | ||
38 | + let p = this.restangular.one('environment').customGET('tags'); | ||
39 | + let deferred = this.$q.defer<{}>(); | ||
40 | + p.then(this.getHandleSuccessFunction<{}>(deferred)); | ||
41 | + p.catch(this.getHandleErrorFunction<{}>(deferred)); | ||
42 | + return deferred.promise; | ||
43 | + } | ||
44 | + | ||
37 | /** TODO - Please, use the base class RestangularService | 45 | /** TODO - Please, use the base class RestangularService |
38 | * (description) | 46 | * (description) |
39 | * | 47 | * |