Commit 338aae2ef7b6a2d9dbbbe8421cb8d783ae57e4aa
1 parent
c132a4a9
Exists in
master
and in
6 other branches
Minor refactory and sintax adjusts
Showing
12 changed files
with
86 additions
and
87 deletions
Show diff stats
src/app/layout/blocks/profile-image/profile-image-block.component.spec.ts
1 | -import {TestComponentBuilder, ComponentFixture} from 'ng-forward/cjs/testing/test-component-builder'; | ||
2 | -import {Pipe, Input, provide, Component} from 'ng-forward'; | 1 | +import { TestComponentBuilder, ComponentFixture } from 'ng-forward/cjs/testing/test-component-builder'; |
2 | +import { Pipe, Input, provide, Component } from 'ng-forward'; | ||
3 | 3 | ||
4 | -import {ProfileImageBlockComponent} from './profile-image-block.component'; | 4 | +import { ProfileImageBlockComponent } from './profile-image-block.component'; |
5 | 5 | ||
6 | import * as helpers from "./../../../../spec/helpers"; | 6 | import * as helpers from "./../../../../spec/helpers"; |
7 | 7 | ||
@@ -14,7 +14,7 @@ describe("Components", () => { | @@ -14,7 +14,7 @@ describe("Components", () => { | ||
14 | describe("Profile Image Block Component", () => { | 14 | describe("Profile Image Block Component", () => { |
15 | 15 | ||
16 | beforeEach(angular.mock.module("templates")); | 16 | beforeEach(angular.mock.module("templates")); |
17 | - let personService = jasmine.createSpyObj("personService", ["upload"]); | 17 | + let personService = jasmine.createSpyObj("personService", ["upload"]); |
18 | 18 | ||
19 | let profileService = jasmine.createSpyObj("ProfileService", ["isMember", "addMember", "removeMember"]); | 19 | let profileService = jasmine.createSpyObj("ProfileService", ["isMember", "addMember", "removeMember"]); |
20 | profileService.isMember = jasmine.createSpy("isMember").and.returnValue(Promise.resolve(false)); | 20 | profileService.isMember = jasmine.createSpy("isMember").and.returnValue(Promise.resolve(false)); |
@@ -25,8 +25,8 @@ describe("Components", () => { | @@ -25,8 +25,8 @@ describe("Components", () => { | ||
25 | directives: [ProfileImageBlockComponent], | 25 | directives: [ProfileImageBlockComponent], |
26 | providers: [ | 26 | providers: [ |
27 | helpers.createProviderToValue('SessionService', helpers.mocks.sessionWithCurrentUser({})), | 27 | helpers.createProviderToValue('SessionService', helpers.mocks.sessionWithCurrentUser({})), |
28 | - helpers.createProviderToValue("PersonService", personService), | ||
29 | - helpers.createProviderToValue("$uibModal", helpers.mocks.$modal), | 28 | + helpers.createProviderToValue("PersonService", personService), |
29 | + helpers.createProviderToValue("$uibModal", helpers.mocks.$modal), | ||
30 | helpers.createProviderToValue('ProfileService', profileService), | 30 | helpers.createProviderToValue('ProfileService', profileService), |
31 | helpers.createProviderToValue('NotificationService', helpers.mocks.notificationService) | 31 | helpers.createProviderToValue('NotificationService', helpers.mocks.notificationService) |
32 | ].concat(helpers.provideFilters("translateFilter")) | 32 | ].concat(helpers.provideFilters("translateFilter")) |
src/app/profile/image/image.component.spec.ts
@@ -4,14 +4,14 @@ | @@ -4,14 +4,14 @@ | ||
4 | * @description | 4 | * @description |
5 | * This file contains the tests for the {@link components.noosfero.profile-image.ProfileImage} component. | 5 | * This file contains the tests for the {@link components.noosfero.profile-image.ProfileImage} component. |
6 | */ | 6 | */ |
7 | -import {ComponentTestHelper, createClass} from '../../../spec/component-test-helper'; | ||
8 | -import {TestComponentBuilder, ComponentFixture} from 'ng-forward/cjs/testing/test-component-builder'; | ||
9 | -import {Pipe, Input, provide, Component} from 'ng-forward'; | ||
10 | -import {PersonService} from "../../../lib/ng-noosfero-api/http/person.service"; | 7 | +import { ComponentTestHelper, createClass } from '../../../spec/component-test-helper'; |
8 | +import { TestComponentBuilder, ComponentFixture } from 'ng-forward/cjs/testing/test-component-builder'; | ||
9 | +import { Pipe, Input, provide, Component } from 'ng-forward'; | ||
10 | +import { PersonService } from "../../../lib/ng-noosfero-api/http/person.service"; | ||
11 | 11 | ||
12 | import * as helpers from "../../../spec/helpers"; | 12 | import * as helpers from "../../../spec/helpers"; |
13 | 13 | ||
14 | -import {ProfileImageComponent} from "./image.component"; | 14 | +import { ProfileImageComponent } from "./image.component"; |
15 | 15 | ||
16 | const htmlTemplate: string = '<noosfero-profile-image [editable]="true" [edit-class]="editable-class" [profile]="ctrl.profile"></noosfero-profile-image>'; | 16 | const htmlTemplate: string = '<noosfero-profile-image [editable]="true" [edit-class]="editable-class" [profile]="ctrl.profile"></noosfero-profile-image>'; |
17 | 17 | ||
@@ -46,33 +46,30 @@ describe("Components", () => { | @@ -46,33 +46,30 @@ describe("Components", () => { | ||
46 | expect(helper.component['$uibModal'].open).toHaveBeenCalled(); | 46 | expect(helper.component['$uibModal'].open).toHaveBeenCalled(); |
47 | }); | 47 | }); |
48 | 48 | ||
49 | - /* | ||
50 | - it("show community users image if profile is not Person", done => { | ||
51 | - helpers.tcb.createAsync(ProfileImageComponent).then(fixture => { | ||
52 | - let profileImageComponent: ProfileImageComponent = fixture.componentInstance; | ||
53 | - let profile = <noosfero.Profile>{ id: 1, identifier: "myprofile", type: "Community" }; | ||
54 | - profileImageComponent.profile = profile; | ||
55 | - profileImageComponent.ngOnInit(); | ||
56 | - | ||
57 | - // Check the attribute | ||
58 | - expect(profileImageComponent.defaultIcon).toBe("fa-users", "The default icon should be community users"); | ||
59 | - // var elProfile = fixture.debugElement.componentViewChildren[0]; | ||
60 | - // expect(elProfile.query('div.profile-image-block').length).toEqual(1); | ||
61 | - done(); | ||
62 | - }); | 49 | + |
50 | + it("show community users image if profile is not Person", (done) => { | ||
51 | + | ||
52 | + let profile = <noosfero.Profile>{ id: 1, identifier: "myprofile", type: "Community" }; | ||
53 | + helper.component.profile = profile; | ||
54 | + helper.component.ngOnInit(); | ||
55 | + | ||
56 | + // Check the attribute | ||
57 | + expect(helper.component.defaultIcon).toBe("fa-users", "The default icon should be community users"); | ||
58 | + // var elProfile = fixture.debugElement.componentViewChildren[0]; | ||
59 | + // expect(elProfile.query('div.profile-image-block').length).toEqual(1); | ||
60 | + done(); | ||
61 | + | ||
63 | }); | 62 | }); |
64 | 63 | ||
65 | - it("show Person image if profile is Person", done => { | ||
66 | - tcb.createAsync(ProfileImageComponent).then(fixture => { | ||
67 | - let profileImageComponent: ProfileImageComponent = fixture.componentInstance; | ||
68 | - let profile = <noosfero.Profile>{ id: 1, identifier: "myprofile", type: "Person" }; | ||
69 | - profileImageComponent.profile = profile; | ||
70 | - profileImageComponent.ngOnInit(); | ||
71 | - // Check the attribute | ||
72 | - expect(profileImageComponent.defaultIcon).toEqual("fa-user", "The default icon should be person user"); | ||
73 | - done(); | ||
74 | - }); | ||
75 | - });*/ | 64 | + it("show Person image if profile is Person", (done) => { |
65 | + | ||
66 | + let profile = <noosfero.Profile>{ id: 1, identifier: "myprofile", type: "Person" }; | ||
67 | + helper.component.profile = profile; | ||
68 | + helper.component.ngOnInit(); | ||
69 | + // Check the attribute | ||
70 | + expect(helper.component.defaultIcon).toEqual("fa-user", "The default icon should be person user"); | ||
71 | + done(); | ||
72 | + }); | ||
76 | 73 | ||
77 | }); | 74 | }); |
78 | -}); | ||
79 | \ No newline at end of file | 75 | \ No newline at end of file |
76 | +}); |
src/app/profile/image/image.component.ts
1 | -import {Inject, Input, Component, provide} from "ng-forward"; | ||
2 | -import {PersonService} from "../../../lib/ng-noosfero-api/http/person.service"; | ||
3 | -import {ProfileImageEditorComponent} from "./profile-image-editor.component"; | 1 | +import { Inject, Input, Component, provide } from "ng-forward"; |
2 | +import { PersonService } from "../../../lib/ng-noosfero-api/http/person.service"; | ||
3 | +import { ProfileImageEditorComponent } from "./profile-image-editor.component"; | ||
4 | 4 | ||
5 | /** | 5 | /** |
6 | * @ngdoc controller | 6 | * @ngdoc controller |
@@ -11,7 +11,7 @@ import {ProfileImageEditorComponent} from "./profile-image-editor.component"; | @@ -11,7 +11,7 @@ import {ProfileImageEditorComponent} from "./profile-image-editor.component"; | ||
11 | @Component({ | 11 | @Component({ |
12 | selector: "noosfero-profile-image", | 12 | selector: "noosfero-profile-image", |
13 | templateUrl: 'app/profile/image/image.html', | 13 | templateUrl: 'app/profile/image/image.html', |
14 | - providers: [ provide('personService', { useClass: PersonService }) ] | 14 | + providers: [provide('personService', { useClass: PersonService })] |
15 | }) | 15 | }) |
16 | @Inject(PersonService, "$uibModal", "$scope") | 16 | @Inject(PersonService, "$uibModal", "$scope") |
17 | export class ProfileImageComponent { | 17 | export class ProfileImageComponent { |
@@ -20,7 +20,7 @@ export class ProfileImageComponent { | @@ -20,7 +20,7 @@ export class ProfileImageComponent { | ||
20 | * @ngdoc property | 20 | * @ngdoc property |
21 | * @name profile | 21 | * @name profile |
22 | * @propertyOf components.noosfero.profile-image.ProfileImage | 22 | * @propertyOf components.noosfero.profile-image.ProfileImage |
23 | - * @description | 23 | + * @description |
24 | * The Noosfero {@link models.Profile} holding the image. | 24 | * The Noosfero {@link models.Profile} holding the image. |
25 | */ | 25 | */ |
26 | @Input() profile: noosfero.Profile; | 26 | @Input() profile: noosfero.Profile; |
@@ -41,7 +41,7 @@ export class ProfileImageComponent { | @@ -41,7 +41,7 @@ export class ProfileImageComponent { | ||
41 | croppedDataUrl: any; | 41 | croppedDataUrl: any; |
42 | modalInstance: any; | 42 | modalInstance: any; |
43 | 43 | ||
44 | - constructor(private personService: PersonService, private $uibModal: any, private $scope: ng.IScope) { | 44 | + constructor(private personService: PersonService, private $uibModal: ng.ui.bootstrap.IModalService, private $scope: ng.IScope) { |
45 | } | 45 | } |
46 | 46 | ||
47 | fileSelected(file: any, errFiles: any) { | 47 | fileSelected(file: any, errFiles: any) { |
@@ -79,8 +79,8 @@ export class ProfileImageComponent { | @@ -79,8 +79,8 @@ export class ProfileImageComponent { | ||
79 | * @ngdoc method | 79 | * @ngdoc method |
80 | * @name ngOnInit | 80 | * @name ngOnInit |
81 | * @methodOf components.noosfero.profile-image.ProfileImage | 81 | * @methodOf components.noosfero.profile-image.ProfileImage |
82 | - * @description | ||
83 | - * Initializes the icon names to their corresponding values depending on the profile type passed to the controller | 82 | + * @description |
83 | + * Initializes the icon names to their corresponding values depending on the profile type passed to the controller | ||
84 | */ | 84 | */ |
85 | ngOnInit() { | 85 | ngOnInit() { |
86 | this.defaultIcon = 'fa-users'; | 86 | this.defaultIcon = 'fa-users'; |
@@ -90,4 +90,3 @@ export class ProfileImageComponent { | @@ -90,4 +90,3 @@ export class ProfileImageComponent { | ||
90 | } | 90 | } |
91 | 91 | ||
92 | } | 92 | } |
93 | - |
src/app/profile/image/image.html
1 | -<div id="profile-image-container" style=""> | 1 | +<div id="profile-image-container" style=""> |
2 | <div class="profile-image-wrap" title="{{ctrl.profile.name}}" ng-mouseenter="ctrl.showChange(true)" ng-mouseleave="ctrl.showChange(false)"> | 2 | <div class="profile-image-wrap" title="{{ctrl.profile.name}}" ng-mouseenter="ctrl.showChange(true)" ng-mouseleave="ctrl.showChange(false)"> |
3 | <img ng-if="ctrl.profile.image" ng-src="{{ctrl.profile.image.url}}" class="img-responsive profile-image"> | 3 | <img ng-if="ctrl.profile.image" ng-src="{{ctrl.profile.image.url}}" class="img-responsive profile-image"> |
4 | <i ng-if="!ctrl.profile.image" class="fa {{ctrl.defaultIcon}} fa-5x profile-image"></i> | 4 | <i ng-if="!ctrl.profile.image" class="fa {{ctrl.defaultIcon}} fa-5x profile-image"></i> |
@@ -10,12 +10,12 @@ | @@ -10,12 +10,12 @@ | ||
10 | <!-- The upload button hidden behind the camera --> | 10 | <!-- The upload button hidden behind the camera --> |
11 | <div class="upload-button" ngf-select="ctrl.fileSelected($file)" | 11 | <div class="upload-button" ngf-select="ctrl.fileSelected($file)" |
12 | ngf-pattern="'image/*'" ngf-accept="'image/*'" | 12 | ngf-pattern="'image/*'" ngf-accept="'image/*'" |
13 | - ngf-max-size="20MB" ngf-resize="{width: 100, height: 100}" | 13 | + ngf-max-size="20MB" ngf-resize="{width: 100, height: 100}" |
14 | data-toggle="modal" data-target=".crop-dialog"> | 14 | data-toggle="modal" data-target=".crop-dialog"> |
15 | {{"profile.image.upload" | translate}} | 15 | {{"profile.image.upload" | translate}} |
16 | </div> | 16 | </div> |
17 | - </a> | 17 | + </a> |
18 | </div> | 18 | </div> |
19 | - | 19 | + |
20 | </div> | 20 | </div> |
21 | </div> | 21 | </div> |
src/app/profile/image/image.scss
@@ -37,9 +37,8 @@ i.profile-image { | @@ -37,9 +37,8 @@ i.profile-image { | ||
37 | } | 37 | } |
38 | 38 | ||
39 | .select-photo-container { | 39 | .select-photo-container { |
40 | - //overflow: hidden; | ||
41 | position: absolute; | 40 | position: absolute; |
42 | - z-index: -1; | 41 | + z-index: -1; |
43 | background: #000; | 42 | background: #000; |
44 | background: rgba(0, 0, 0, .6); | 43 | background: rgba(0, 0, 0, .6); |
45 | background: linear-gradient(transparent, rgba(0, 0, 0, .6) 70%, rgba(0, 0, 0, .6) 100%); | 44 | background: linear-gradient(transparent, rgba(0, 0, 0, .6) 70%, rgba(0, 0, 0, .6) 100%); |
@@ -58,7 +57,6 @@ i.profile-image { | @@ -58,7 +57,6 @@ i.profile-image { | ||
58 | .upload-button { | 57 | .upload-button { |
59 | -webkit-font-smoothing: antialiased; | 58 | -webkit-font-smoothing: antialiased; |
60 | color: #fff; | 59 | color: #fff; |
61 | - //word-wrap: break-word; | ||
62 | } | 60 | } |
63 | 61 | ||
64 | .upload-container { | 62 | .upload-container { |
@@ -95,4 +93,3 @@ form .progress { | @@ -95,4 +93,3 @@ form .progress { | ||
95 | background: orange; | 93 | background: orange; |
96 | width: 0; | 94 | width: 0; |
97 | } | 95 | } |
98 | - |
src/app/profile/image/profile-image-editor.component.spec.ts
1 | -import {Pipe, Input, provide, Component} from 'ng-forward'; | ||
2 | -import {ComponentTestHelper, createClass} from '../../../spec/component-test-helper'; | 1 | +import { Pipe, Input, provide, Component } from 'ng-forward'; |
2 | +import { ComponentTestHelper, createClass } from '../../../spec/component-test-helper'; | ||
3 | import * as helpers from "../../../spec/helpers"; | 3 | import * as helpers from "../../../spec/helpers"; |
4 | 4 | ||
5 | -import {ProfileImageEditorComponent} from "./profile-image-editor.component"; | 5 | +import { ProfileImageEditorComponent } from "./profile-image-editor.component"; |
6 | 6 | ||
7 | describe("Components", () => { | 7 | describe("Components", () => { |
8 | 8 | ||
@@ -11,6 +11,7 @@ describe("Components", () => { | @@ -11,6 +11,7 @@ describe("Components", () => { | ||
11 | beforeEach(angular.mock.module("templates")); | 11 | beforeEach(angular.mock.module("templates")); |
12 | 12 | ||
13 | let expectedData = "iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAYAAACtWK6eAAAgAElEQ…Cm2OLHvfdNPte3zrH709Q0esN1LPQ0t7DL696ERpu+9/8BVPLIpElf7VYAAAAASUVORK5CYII="; | 13 | let expectedData = "iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAYAAACtWK6eAAAgAElEQ…Cm2OLHvfdNPte3zrH709Q0esN1LPQ0t7DL696ERpu+9/8BVPLIpElf7VYAAAAASUVORK5CYII="; |
14 | + let testDataUrl = "data:image/png;base64," + expectedData; | ||
14 | 15 | ||
15 | let profile = <noosfero.Profile>{ name: "profile_name", id: 1, identifier: "test" }; | 16 | let profile = <noosfero.Profile>{ name: "profile_name", id: 1, identifier: "test" }; |
16 | let modal = helpers.mocks.$modal; | 17 | let modal = helpers.mocks.$modal; |
@@ -28,7 +29,7 @@ describe("Components", () => { | @@ -28,7 +29,7 @@ describe("Components", () => { | ||
28 | let comp = new ProfileImageEditorComponent(picFile, this.profile, personServiceMock, modalInstance); | 29 | let comp = new ProfileImageEditorComponent(picFile, this.profile, personServiceMock, modalInstance); |
29 | 30 | ||
30 | it("get data", done => { | 31 | it("get data", done => { |
31 | - let testDataUrl = "data:image/png;base64," + expectedData; | 32 | + |
32 | let result = comp.getData(testDataUrl); | 33 | let result = comp.getData(testDataUrl); |
33 | expect(result).toBe(expectedData); | 34 | expect(result).toBe(expectedData); |
34 | done(); | 35 | done(); |
@@ -44,7 +45,6 @@ describe("Components", () => { | @@ -44,7 +45,6 @@ describe("Components", () => { | ||
44 | }); | 45 | }); |
45 | 46 | ||
46 | it("upload image", done => { | 47 | it("upload image", done => { |
47 | - let testDataUrl = "data:image/png;base64," + expectedData; | ||
48 | let imageName = "image1"; | 48 | let imageName = "image1"; |
49 | personServiceMock = jasmine.createSpyObj("personServiceMock", ["uploadImage"]); | 49 | personServiceMock = jasmine.createSpyObj("personServiceMock", ["uploadImage"]); |
50 | console.log("PersonServiceMock:", personServiceMock); | 50 | console.log("PersonServiceMock:", personServiceMock); |
@@ -54,7 +54,7 @@ describe("Components", () => { | @@ -54,7 +54,7 @@ describe("Components", () => { | ||
54 | comp.uploadImage(testDataUrl, imageName); | 54 | comp.uploadImage(testDataUrl, imageName); |
55 | deferredUploadImage.resolve(); | 55 | deferredUploadImage.resolve(); |
56 | $rootScope.$apply(); | 56 | $rootScope.$apply(); |
57 | - expect(comp.$uibModalInstance.close).toHaveBeenCalled(); | 57 | + expect(comp.modalInstance.close).toHaveBeenCalled(); |
58 | done(); | 58 | done(); |
59 | }); | 59 | }); |
60 | 60 |
src/app/profile/image/profile-image-editor.component.ts
1 | -import {StateConfig, Component, Input, Output, Inject, provide} from 'ng-forward'; | ||
2 | -import {TranslateProfile} from "../../shared/pipes/translate-profile.filter"; | ||
3 | -import {PersonService} from "../../../lib/ng-noosfero-api/http/person.service"; | 1 | +import { StateConfig, Component, Input, Output, Inject, provide } from 'ng-forward'; |
2 | +import { TranslateProfile } from "../../shared/pipes/translate-profile.filter"; | ||
3 | +import { PersonService } from "../../../lib/ng-noosfero-api/http/person.service"; | ||
4 | 4 | ||
5 | export class ProfileImageEditorComponent { | 5 | export class ProfileImageEditorComponent { |
6 | 6 | ||
@@ -9,17 +9,17 @@ export class ProfileImageEditorComponent { | @@ -9,17 +9,17 @@ export class ProfileImageEditorComponent { | ||
9 | static $inject = ["picFile", "profile", "personService", "$uibModalInstance"]; | 9 | static $inject = ["picFile", "profile", "personService", "$uibModalInstance"]; |
10 | 10 | ||
11 | constructor(public picFile: any, public profile: noosfero.Profile, public personService: PersonService, | 11 | constructor(public picFile: any, public profile: noosfero.Profile, public personService: PersonService, |
12 | - public $uibModalInstance: any) { | 12 | + public modalInstance: ng.ui.bootstrap.IModalServiceInstance) { |
13 | } | 13 | } |
14 | 14 | ||
15 | uploadImage(dataUrl: any, name: any) { | 15 | uploadImage(dataUrl: any, name: any) { |
16 | - let base64_image_json = this.getBase64ImageJson(dataUrl, name); | ||
17 | - this.personService.uploadImage(this.profile, base64_image_json).then( (result: any) => { | ||
18 | - this.$uibModalInstance.close(name); | 16 | + let base64ImageJson = this.getBase64ImageJson(dataUrl, name); |
17 | + this.personService.uploadImage(this.profile, base64ImageJson).then((result: any) => { | ||
18 | + this.modalInstance.close(name); | ||
19 | }); | 19 | }); |
20 | } | 20 | } |
21 | 21 | ||
22 | - getBase64ImageJson(dataUrl: any, name: any) { | 22 | + getBase64ImageJson(dataUrl: any, name: any): any { |
23 | let data = this.getData(dataUrl); | 23 | let data = this.getData(dataUrl); |
24 | let image_name = this.getImageName(name); | 24 | let image_name = this.getImageName(name); |
25 | return { | 25 | return { |
@@ -29,15 +29,15 @@ export class ProfileImageEditorComponent { | @@ -29,15 +29,15 @@ export class ProfileImageEditorComponent { | ||
29 | }; | 29 | }; |
30 | } | 30 | } |
31 | 31 | ||
32 | - getImageName(name: any) { | 32 | + getImageName(name: any): string { |
33 | return this.profile.name + "_" + name; | 33 | return this.profile.name + "_" + name; |
34 | } | 34 | } |
35 | 35 | ||
36 | - getData(dataUrl: any) { | 36 | + getData(dataUrl: any): string { |
37 | return dataUrl.substring(dataUrl.indexOf('base64,') + 7); | 37 | return dataUrl.substring(dataUrl.indexOf('base64,') + 7); |
38 | } | 38 | } |
39 | 39 | ||
40 | cancel() { | 40 | cancel() { |
41 | - this.$uibModalInstance.close(); | 41 | + this.modalInstance.close(); |
42 | } | 42 | } |
43 | } | 43 | } |
src/app/profile/image/profile-image-editor.html
@@ -10,7 +10,7 @@ | @@ -10,7 +10,7 @@ | ||
10 | </div> | 10 | </div> |
11 | <div> | 11 | <div> |
12 | <img ng-src="{{ctrl.croppedDataUrl}}" /> | 12 | <img ng-src="{{ctrl.croppedDataUrl}}" /> |
13 | - </div> | 13 | + </div> |
14 | <span class="progress" ng-show="progress >= 0"> | 14 | <span class="progress" ng-show="progress >= 0"> |
15 | <div style="width: {{progress" ng-bind="progress + '%'"></div> | 15 | <div style="width: {{progress" ng-bind="progress + '%'"></div> |
16 | </span> <span ng-show="ctrl.result">Upload Successful</span> <span class="err" | 16 | </span> <span ng-show="ctrl.result">Upload Successful</span> <span class="err" |
@@ -18,7 +18,7 @@ | @@ -18,7 +18,7 @@ | ||
18 | </form> | 18 | </form> |
19 | 19 | ||
20 | <div class="actions"> | 20 | <div class="actions"> |
21 | - <button type="submit" class="btn btn-default" ng-click="ctrl.uploadImage(ctrl.croppedDataUrl, ctrl.picFile.name)">Upload</button> | ||
22 | - <button type="submit" class="btn btn-danger" ng-click="ctrl.cancel()">Cancel</button> | 21 | + <button type="submit" class="btn btn-default" (click)="ctrl.uploadImage(ctrl.croppedDataUrl, ctrl.picFile.name)">Upload</button> |
22 | + <button type="submit" class="btn btn-danger" (click)="ctrl.cancel()">Cancel</button> | ||
23 | </div> | 23 | </div> |
24 | </div> | 24 | </div> |
src/app/profile/info/profile-info.scss
1 | -.profile-info .upload-camera-container { | ||
2 | - top: 55%; | ||
3 | - left: 39px; | 1 | +.profile-info { |
2 | + .upload-camera-container { | ||
3 | + top: 55%; | ||
4 | + left: 39px; | ||
5 | + } | ||
4 | } | 6 | } |
5 | 7 | ||
6 | .profile-info-editable { | 8 | .profile-info-editable { |
@@ -9,13 +11,15 @@ | @@ -9,13 +11,15 @@ | ||
9 | height: 28px; | 11 | height: 28px; |
10 | } | 12 | } |
11 | 13 | ||
12 | -.profile-info-editable .upload-button { | ||
13 | - font-size: 0.8em; | ||
14 | - padding-top: 9px; | ||
15 | - padding-left: 6px; | ||
16 | - font-weight: bold; | 14 | +.profile-info-editable { |
15 | + .upload-button { | ||
16 | + font-size: 0.8em; | ||
17 | + padding-top: 9px; | ||
18 | + padding-left: 6px; | ||
19 | + font-weight: bold; | ||
20 | + } | ||
17 | } | 21 | } |
18 | 22 | ||
19 | .profile-info-extrainfo { | 23 | .profile-info-extrainfo { |
20 | margin-top: 10px; | 24 | margin-top: 10px; |
21 | -} | ||
22 | \ No newline at end of file | 25 | \ No newline at end of file |
26 | +} |
src/languages/en.json
@@ -23,6 +23,7 @@ | @@ -23,6 +23,7 @@ | ||
23 | "profile.others_info": "Others", | 23 | "profile.others_info": "Others", |
24 | "profile.community.title": "Community", | 24 | "profile.community.title": "Community", |
25 | "profile.person.title": "Person", | 25 | "profile.person.title": "Person", |
26 | + "profile.image.edit": "Crop photo", | ||
26 | "profile.image.upload": "Upload Photo", | 27 | "profile.image.upload": "Upload Photo", |
27 | "activities.title": "Activities", | 28 | "activities.title": "Activities", |
28 | "activities.create_article.description": "has published on", | 29 | "activities.create_article.description": "has published on", |
src/languages/pt.json
@@ -23,6 +23,7 @@ | @@ -23,6 +23,7 @@ | ||
23 | "profile.others_info": "Outras informações", | 23 | "profile.others_info": "Outras informações", |
24 | "profile.community.title": "Comunidade", | 24 | "profile.community.title": "Comunidade", |
25 | "profile.person.title": "Pessoa", | 25 | "profile.person.title": "Pessoa", |
26 | + "profile.image.edit": "Recortar photo", | ||
26 | "profile.image.upload": "Enviar photo", | 27 | "profile.image.upload": "Enviar photo", |
27 | "activities.title": "Atividades", | 28 | "activities.title": "Atividades", |
28 | "activities.create_article.description": "publicou em", | 29 | "activities.create_article.description": "publicou em", |
src/lib/ng-noosfero-api/http/person.service.ts
1 | import { Injectable, Inject } from "ng-forward"; | 1 | import { Injectable, Inject } from "ng-forward"; |
2 | -import {RestangularService} from "./restangular_service"; | ||
3 | -import {ProfileService} from "./profile.service"; | 2 | +import { RestangularService } from "./restangular_service"; |
3 | +import { ProfileService } from "./profile.service"; | ||
4 | 4 | ||
5 | @Injectable() | 5 | @Injectable() |
6 | @Inject("Restangular", "$q", "$log", ProfileService) | 6 | @Inject("Restangular", "$q", "$log", ProfileService) |
@@ -29,12 +29,12 @@ export class PersonService extends RestangularService<noosfero.Person> { | @@ -29,12 +29,12 @@ export class PersonService extends RestangularService<noosfero.Person> { | ||
29 | return deferred.promise; | 29 | return deferred.promise; |
30 | } | 30 | } |
31 | 31 | ||
32 | - uploadImage(profile: noosfero.Profile, base64_image_json: any) { | 32 | + uploadImage(profile: noosfero.Profile, base64ImageJson: any) { |
33 | let headers = { 'Content-Type': 'application/json' }; | 33 | let headers = { 'Content-Type': 'application/json' }; |
34 | let deferred = this.$q.defer<noosfero.RestResult<noosfero.Profile>>(); | 34 | let deferred = this.$q.defer<noosfero.RestResult<noosfero.Profile>>(); |
35 | // TODO dynamically copy the selected attributes to update | 35 | // TODO dynamically copy the selected attributes to update |
36 | let attributesToUpdate: any = { | 36 | let attributesToUpdate: any = { |
37 | - person: { image_builder: base64_image_json } | 37 | + person: { image_builder: base64ImageJson } |
38 | }; | 38 | }; |
39 | let restRequest: ng.IPromise<noosfero.RestResult<any>> = | 39 | let restRequest: ng.IPromise<noosfero.RestResult<any>> = |
40 | this.getElement(profile.id).customPOST(attributesToUpdate, null, null, headers); | 40 | this.getElement(profile.id).customPOST(attributesToUpdate, null, null, headers); |