Commit a5a7671139c2686f515d5d47c9447ccef58c923a
Exists in
master
and in
26 other branches
Merge branch 'statistics_block' into 'master'
Statistics block Create statistics block See merge request !14
Showing
9 changed files
with
111 additions
and
3 deletions
Show diff stats
src/app/layout/blocks/statistics/statistics-block.component.spec.ts
0 → 100644
| ... | ... | @@ -0,0 +1,53 @@ |
| 1 | +import {ComponentTestHelper, createClass} from './../../../../spec/component-test-helper'; | |
| 2 | +import {StatisticsBlockComponent} from './statistics-block.component'; | |
| 3 | +import * as helpers from "../../../../spec/helpers"; | |
| 4 | + | |
| 5 | +const htmlTemplate: string = '<noosfero-statistics-block [block]="ctrl.block" [owner]="ctrl.owner"></noosfero-statistics-block>'; | |
| 6 | + | |
| 7 | +describe("Components", () => { | |
| 8 | + | |
| 9 | + describe("Statistics Block Component", () => { | |
| 10 | + let helper: ComponentTestHelper<StatisticsBlockComponent>; | |
| 11 | + beforeEach(angular.mock.module("templates")); | |
| 12 | + | |
| 13 | + beforeEach((done) => { | |
| 14 | + let cls = createClass({ | |
| 15 | + template: htmlTemplate, | |
| 16 | + directives: [StatisticsBlockComponent], | |
| 17 | + providers: helpers.provideFilters("translateFilter"), | |
| 18 | + properties: { | |
| 19 | + block: { | |
| 20 | + statistics: [ | |
| 21 | + { | |
| 22 | + name: "users", | |
| 23 | + display: true, | |
| 24 | + quantity: 10 | |
| 25 | + }, | |
| 26 | + { | |
| 27 | + name: "communities", | |
| 28 | + display: true, | |
| 29 | + quantity: 20 | |
| 30 | + }, | |
| 31 | + { | |
| 32 | + name: "hits", | |
| 33 | + display: false, | |
| 34 | + quantity: null | |
| 35 | + } | |
| 36 | + ] | |
| 37 | + } | |
| 38 | + } | |
| 39 | + }); | |
| 40 | + helper = new ComponentTestHelper<StatisticsBlockComponent>(cls, done); | |
| 41 | + }); | |
| 42 | + | |
| 43 | + it("shows statistics marked with display equals 'true'", () => { | |
| 44 | + expect(helper.debugElement.queryAll("li.statistic").length).toEqual(2); | |
| 45 | + expect(helper.debugElement.query("span.users").text()).toEqual("10"); | |
| 46 | + expect(helper.debugElement.query("span.communities").text()).toEqual("20"); | |
| 47 | + }); | |
| 48 | + | |
| 49 | + it("does not shows statistics marked with display equals 'false'", () => { | |
| 50 | + expect(helper.debugElement.queryAll("span.hits").length).toEqual(0); | |
| 51 | + }); | |
| 52 | + }); | |
| 53 | +}); | ... | ... |
src/app/layout/blocks/statistics/statistics-block.component.ts
0 → 100644
| ... | ... | @@ -0,0 +1,11 @@ |
| 1 | +import {Input, Inject, Component} from "ng-forward"; | |
| 2 | + | |
| 3 | +@Component({ | |
| 4 | + selector: "noosfero-statistics-block", | |
| 5 | + templateUrl: 'app/layout/blocks/statistics/statistics-block.html' | |
| 6 | +}) | |
| 7 | + | |
| 8 | +export class StatisticsBlockComponent { | |
| 9 | + @Input() block: noosfero.StatisticsBlock; | |
| 10 | + @Input() owner: any; | |
| 11 | +} | ... | ... |
| ... | ... | @@ -0,0 +1,9 @@ |
| 1 | +<div class="statistics-block"> | |
| 2 | + <ul class="list-group"> | |
| 3 | + <li ng-repeat="counter in ctrl.block.statistics" class="list-group-item statistic {{counter.name}}" ng-if="counter.display" > | |
| 4 | + <span class="badge {{counter.name}}">{{counter.quantity}}</span> | |
| 5 | + {{"statistics." + counter.name | translate}} | |
| 6 | + </li> | |
| 7 | + | |
| 8 | + </ul> | |
| 9 | +</div> | ... | ... |
src/app/main/main.component.ts
| ... | ... | @@ -14,9 +14,12 @@ import {LinkListBlockComponent} from "./../layout/blocks/link-list/link-list-blo |
| 14 | 14 | import {RecentDocumentsBlockComponent} from "../layout/blocks/recent-documents/recent-documents-block.component"; |
| 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 | +import {StatisticsBlockComponent} from "../layout/blocks/statistics/statistics-block.component"; | |
| 17 | 18 | |
| 18 | 19 | import {MembersBlockComponent} from "./../layout/blocks/members/members-block.component"; |
| 19 | 20 | import {CommunitiesBlockComponent} from "./../layout/blocks/communities/communities-block.component"; |
| 21 | + | |
| 22 | + | |
| 20 | 23 | import {NoosferoTemplate} from "../shared/pipes/noosfero-template.filter"; |
| 21 | 24 | import {DateFormat} from "../shared/pipes/date-format.filter"; |
| 22 | 25 | |
| ... | ... | @@ -93,8 +96,9 @@ export class EnvironmentContent { |
| 93 | 96 | EnvironmentComponent, PeopleBlockComponent, |
| 94 | 97 | LinkListBlockComponent, CommunitiesBlockComponent, HtmlEditorComponent, |
| 95 | 98 | MainBlockComponent, RecentDocumentsBlockComponent, Navbar, SidebarComponent, ProfileImageBlockComponent, |
| 96 | - MembersBlockComponent, NoosferoTemplate, DateFormat, RawHTMLBlockComponent | |
| 99 | + MembersBlockComponent, NoosferoTemplate, DateFormat, RawHTMLBlockComponent, StatisticsBlockComponent | |
| 97 | 100 | ].concat(plugins.mainComponents).concat(plugins.hotspots), |
| 101 | + | |
| 98 | 102 | providers: [AuthService, SessionService, NotificationService, BodyStateClassesService] |
| 99 | 103 | }) |
| 100 | 104 | @StateConfig([ | ... | ... |
src/languages/en.json
| ... | ... | @@ -46,5 +46,13 @@ |
| 46 | 46 | "article.basic_editor.success.message": "Article saved!", |
| 47 | 47 | "article.basic_editor.visibility": "Visibility", |
| 48 | 48 | "article.basic_editor.visibility.public": "Public", |
| 49 | - "article.basic_editor.visibility.private": "Private" | |
| 49 | + "article.basic_editor.visibility.private": "Private", | |
| 50 | + "statistics.users": "Users", | |
| 51 | + "statistics.enterprises": "Enterprises", | |
| 52 | + "statistics.products": "Products", | |
| 53 | + "statistics.communities": "Communities", | |
| 54 | + "statistics.categories": "Categories", | |
| 55 | + "statistics.tags": "Tags", | |
| 56 | + "statistics.comments": "Comments", | |
| 57 | + "statistics.hits": "Hits" | |
| 50 | 58 | } | ... | ... |
src/languages/pt.json
| ... | ... | @@ -46,5 +46,13 @@ |
| 46 | 46 | "article.basic_editor.success.message": "Artigo salvo com sucesso!", |
| 47 | 47 | "article.basic_editor.visibility": "Visibilidade", |
| 48 | 48 | "article.basic_editor.visibility.public": "Público", |
| 49 | - "article.basic_editor.visibility.private": "Privado" | |
| 49 | + "article.basic_editor.visibility.private": "Privado", | |
| 50 | + "statistics.users": "Usuários", | |
| 51 | + "statistics.enterprises": "Empreendimentos", | |
| 52 | + "statistics.products": "Produtos", | |
| 53 | + "statistics.communities": "Comunidades", | |
| 54 | + "statistics.categories": "Categorias", | |
| 55 | + "statistics.tags": "Tags", | |
| 56 | + "statistics.comments": "Comentários", | |
| 57 | + "statistics.hits": "Acessos" | |
| 50 | 58 | } | ... | ... |