Commit 95ba9b521cb2504e44731528d9b91c84e5004e86

Authored by Victor Costa
1 parent 2da0f803

Migrate profile controller

src/app/index.route.ts
@@ -3,17 +3,6 @@ @@ -3,17 +3,6 @@
3 /** @ngInject */ 3 /** @ngInject */
4 export function routeConfig($stateProvider, $urlRouterProvider) { 4 export function routeConfig($stateProvider, $urlRouterProvider) {
5 $stateProvider 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 .state("main.profile.cms", { 6 .state("main.profile.cms", {
18 url: "^/myprofile/:profile/cms", 7 url: "^/myprofile/:profile/cms",
19 views: { 8 views: {
@@ -27,17 +16,6 @@ export function routeConfig($stateProvider, $urlRouterProvider) { @@ -27,17 +16,6 @@ export function routeConfig($stateProvider, $urlRouterProvider) {
27 .state("main.profile.settings", { 16 .state("main.profile.settings", {
28 url: "^/myprofile/:profile" 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 .state("main.profile.home", { 19 .state("main.profile.home", {
42 url: "", 20 url: "",
43 views: { 21 views: {
src/app/index.ts
@@ -24,16 +24,9 @@ NoosferoApp.addConstants("AUTH_EVENTS", { @@ -24,16 +24,9 @@ NoosferoApp.addConstants("AUTH_EVENTS", {
24 logoutSuccess: "auth-logout-success" 24 logoutSuccess: "auth-logout-success"
25 }); 25 });
26 26
27 -  
28 NoosferoApp.addConfig(noosferoModuleConfig); 27 NoosferoApp.addConfig(noosferoModuleConfig);
29 -  
30 NoosferoApp.run(noosferoAngularRunBlock); 28 NoosferoApp.run(noosferoAngularRunBlock);
31 29
32 -noosferoApp.run(() => {  
33 - console.log("RUN!");  
34 -});  
35 -  
36 -// require("./main/main.controller.js");  
37 require("./cms/cms.controller.js"); 30 require("./cms/cms.controller.js");
38 require("./components/auth/auth.controller.js"); 31 require("./components/auth/auth.controller.js");
39 require("./components/auth/auth.service.js"); 32 require("./components/auth/auth.service.js");
@@ -55,7 +48,6 @@ require("./content-viewer/content-viewer-actions.controller.js"); @@ -55,7 +48,6 @@ require("./content-viewer/content-viewer-actions.controller.js");
55 // require("./content-viewer/content-viewer.controller.js"); 48 // require("./content-viewer/content-viewer.controller.js");
56 require("./profile-info/profile-info.controller.js"); 49 require("./profile-info/profile-info.controller.js");
57 require("./profile/profile-home.controller.js"); 50 require("./profile/profile-home.controller.js");
58 -require("./profile/profile.controller.js");  
59 51
60 // NoosferoApp.addController("ContentViewerController", ContentViewerController); 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 @Component({ 4 @Component({
4 selector: 'main-content', 5 selector: 'main-content',
5 templateUrl: "app/main/main.html", 6 templateUrl: "app/main/main.html",
6 }) 7 })
7 export class MainContent { 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,6 +26,17 @@ export class MainContent {
22 return AuthService.loginFromCookie(); 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 export class Main { 42 export class Main {
src/app/profile/profile.component.ts 0 → 100644
@@ -0,0 +1,24 @@ @@ -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,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
1 <div class="profile-container"> 1 <div class="profile-container">
2 <div class="row"> 2 <div class="row">
3 - <noosfero-boxes boxes="vm.boxes" owner="vm.profile"></noosfero-boxes> 3 + <noosfero-boxes boxes="ctrl.boxes" owner="ctrl.profile"></noosfero-boxes>
4 </div> 4 </div>
5 </div> 5 </div>