Commit 95ba9b521cb2504e44731528d9b91c84e5004e86
1 parent
2da0f803
Exists in
master
and in
35 other branches
Migrate profile controller
Showing
6 changed files
with
41 additions
and
57 deletions
Show diff stats
src/app/index.route.ts
... | ... | @@ -3,17 +3,6 @@ |
3 | 3 | /** @ngInject */ |
4 | 4 | export function routeConfig($stateProvider, $urlRouterProvider) { |
5 | 5 | $stateProvider |
6 | - /*.state("main", { | |
7 | - url: "/", | |
8 | - templateUrl: "app/main/main.html", | |
9 | - controller: "MainController", | |
10 | - controllerAs: "vm", | |
11 | - resolve: { | |
12 | - currentUser: function(AuthService) { | |
13 | - return AuthService.loginFromCookie(); | |
14 | - } | |
15 | - } | |
16 | - })*/ | |
17 | 6 | .state("main.profile.cms", { |
18 | 7 | url: "^/myprofile/:profile/cms", |
19 | 8 | views: { |
... | ... | @@ -27,17 +16,6 @@ export function routeConfig($stateProvider, $urlRouterProvider) { |
27 | 16 | .state("main.profile.settings", { |
28 | 17 | url: "^/myprofile/:profile" |
29 | 18 | }) |
30 | - .state("main.profile", { | |
31 | - url: "^/:profile", | |
32 | - abstract: true, | |
33 | - views: { | |
34 | - "content": { | |
35 | - templateUrl: "app/profile/profile.html", | |
36 | - controller: "ProfileController", | |
37 | - controllerAs: "vm" | |
38 | - } | |
39 | - } | |
40 | - }) | |
41 | 19 | .state("main.profile.home", { |
42 | 20 | url: "", |
43 | 21 | views: { | ... | ... |
src/app/index.ts
... | ... | @@ -24,16 +24,9 @@ NoosferoApp.addConstants("AUTH_EVENTS", { |
24 | 24 | logoutSuccess: "auth-logout-success" |
25 | 25 | }); |
26 | 26 | |
27 | - | |
28 | 27 | NoosferoApp.addConfig(noosferoModuleConfig); |
29 | - | |
30 | 28 | NoosferoApp.run(noosferoAngularRunBlock); |
31 | 29 | |
32 | -noosferoApp.run(() => { | |
33 | - console.log("RUN!"); | |
34 | -}); | |
35 | - | |
36 | -// require("./main/main.controller.js"); | |
37 | 30 | require("./cms/cms.controller.js"); |
38 | 31 | require("./components/auth/auth.controller.js"); |
39 | 32 | require("./components/auth/auth.service.js"); |
... | ... | @@ -55,7 +48,6 @@ require("./content-viewer/content-viewer-actions.controller.js"); |
55 | 48 | // require("./content-viewer/content-viewer.controller.js"); |
56 | 49 | require("./profile-info/profile-info.controller.js"); |
57 | 50 | require("./profile/profile-home.controller.js"); |
58 | -require("./profile/profile.controller.js"); | |
59 | 51 | |
60 | 52 | // NoosferoApp.addController("ContentViewerController", ContentViewerController); |
61 | 53 | ... | ... |
src/app/main/main.component.ts
1 | -import {bundle, Component, StateConfig} from 'ng-forward'; | |
1 | +import {Component, StateConfig} from 'ng-forward'; | |
2 | +import {Profile} from '../profile/profile.component'; | |
2 | 3 | |
3 | 4 | @Component({ |
4 | 5 | selector: 'main-content', |
5 | 6 | templateUrl: "app/main/main.html", |
6 | 7 | }) |
7 | 8 | export class MainContent { |
9 | + constructor() { | |
10 | + console.log("MAIN"); | |
11 | + } | |
8 | 12 | |
9 | 13 | } |
10 | 14 | |
... | ... | @@ -22,6 +26,17 @@ export class MainContent { |
22 | 26 | return AuthService.loginFromCookie(); |
23 | 27 | } |
24 | 28 | } |
29 | + }, | |
30 | + { | |
31 | + url: "^/:profile", | |
32 | + // abstract: true, | |
33 | + component: Profile, | |
34 | + name: 'main.profile', | |
35 | + views: { | |
36 | + "content": { | |
37 | + templateUrl: "app/profile/profile.html", | |
38 | + } | |
39 | + } | |
25 | 40 | } |
26 | 41 | ]) |
27 | 42 | export class Main { | ... | ... |
... | ... | @@ -0,0 +1,24 @@ |
1 | +import {Component, Inject} from 'ng-forward'; | |
2 | + | |
3 | +@Component({ | |
4 | + selector: 'profile', | |
5 | + templateUrl: "app/profile/profile.html" | |
6 | +}) | |
7 | + | |
8 | +@Inject("noosfero", "$log", "$stateParams") | |
9 | +export class Profile { | |
10 | + | |
11 | + boxes: any | |
12 | + profile: any | |
13 | + | |
14 | + constructor(noosfero, $log, $stateParams) { | |
15 | + console.log("PROFILE"); | |
16 | + noosfero.profiles.one().get({ identifier: $stateParams.profile }).then((response) => { | |
17 | + this.profile = response.data[0]; | |
18 | + noosfero.setCurrentProfile(this.profile); | |
19 | + return noosfero.boxes(this.profile.id).one().get(); | |
20 | + }).then((response) => { | |
21 | + this.boxes = response.data.boxes; | |
22 | + }); | |
23 | + } | |
24 | +} | ... | ... |
src/app/profile/profile.controller.js
... | ... | @@ -1,25 +0,0 @@ |
1 | -(function() { | |
2 | - 'use strict'; | |
3 | - | |
4 | - angular | |
5 | - .module('noosferoApp') | |
6 | - .controller('ProfileController', ProfileController); | |
7 | - | |
8 | - | |
9 | - /** @ngInject */ | |
10 | - function ProfileController(noosfero, $log, $stateParams) { | |
11 | - var vm = this; | |
12 | - vm.boxes = []; | |
13 | - activate(); | |
14 | - | |
15 | - function activate() { | |
16 | - noosfero.profiles.one().get({identifier: $stateParams.profile}).then(function(response) { | |
17 | - vm.profile = response.data[0]; | |
18 | - noosfero.setCurrentProfile(vm.profile); | |
19 | - return noosfero.boxes(vm.profile.id).one().get(); | |
20 | - }).then(function(response) { | |
21 | - vm.boxes = response.data.boxes; | |
22 | - }); | |
23 | - } | |
24 | - } | |
25 | -})(); |
src/app/profile/profile.html