Commit bcab3c27e94b1208809542efd8d5342468aba431

Authored by Caio Almeida
1 parent 0528af25

Ticket #45: [WIP] Tags block

src/app/index.ts
... ... @@ -18,7 +18,7 @@ let noosferoApp: any = bundle("noosferoApp", MainComponent, ["ngAnimate", "ngCoo
18 18 "angular-bind-html-compile", "angularMoment", "angular.filter", "akoenig.deckgrid",
19 19 "angular-timeline", "duScroll", "oitozero.ngSweetAlert",
20 20 "pascalprecht.translate", "tmh.dynamicLocale", "angularLoad",
21   - "angular-click-outside"]).publish();
  21 + "angular-click-outside", "ngTagCloud"]).publish();
22 22  
23 23 NoosferoApp.angularModule = noosferoApp;
24 24  
... ...
src/app/layout/blocks/tags/index.ts 0 → 100644
... ... @@ -0,0 +1,2 @@
  1 +/* Module Index Entry - generated using the script npm run generate-index */
  2 +export * from "./tags-block.component";
... ...
src/app/layout/blocks/tags/tags-block.component.spec.ts 0 → 100644
... ... @@ -0,0 +1 @@
  1 +// TODO
... ...
src/app/layout/blocks/tags/tags-block.component.ts 0 → 100644
... ... @@ -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 +}
... ...
src/app/layout/blocks/tags/tags-block.html 0 → 100644
... ... @@ -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>
... ...
src/app/layout/blocks/tags/tags-block.scss 0 → 100644
... ... @@ -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 &quot;../layout/blocks/recent-documents/r
15 15 import {ProfileImageBlockComponent} from "../layout/blocks/profile-image/profile-image-block.component";
16 16 import {RawHTMLBlockComponent} from "../layout/blocks/raw-html/raw-html-block.component";
17 17 import {StatisticsBlockComponent} from "../layout/blocks/statistics/statistics-block.component";
  18 +import {TagsBlockComponent} from "../layout/blocks/tags/tags-block.component";
18 19  
19 20 import {MembersBlockComponent} from "./../layout/blocks/members/members-block.component";
20 21 import {CommunitiesBlockComponent} from "./../layout/blocks/communities/communities-block.component";
... ... @@ -98,7 +99,7 @@ export class EnvironmentContent {
98 99 LinkListBlockComponent, CommunitiesBlockComponent, HtmlEditorComponent,
99 100 MainBlockComponent, RecentDocumentsBlockComponent, Navbar, SidebarComponent, ProfileImageBlockComponent,
100 101 MembersBlockComponent, NoosferoTemplate, DateFormat, RawHTMLBlockComponent, StatisticsBlockComponent,
101   - LoginBlockComponent
  102 + LoginBlockComponent, TagsBlockComponent
102 103 ].concat(plugins.mainComponents).concat(plugins.hotspots),
103 104  
104 105 providers: [AuthService, SessionService, NotificationService, BodyStateClassesService]
... ...
src/lib/ng-noosfero-api/http/environment.service.ts
... ... @@ -34,6 +34,14 @@ export class EnvironmentService {
34 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 45 /** TODO - Please, use the base class RestangularService
38 46 * (description)
39 47 *
... ...