diff --git a/src/app/index.module.ts b/src/app/index.module.ts deleted file mode 100644 index 6bd9e3a..0000000 --- a/src/app/index.module.ts +++ /dev/null @@ -1,97 +0,0 @@ - -/** - * @ngdoc service - * @name NoosferoApp - * @description - * The main NoosferoApp module class. It provide helper static methods used by - * the module to initialize the application. - */ -export class NoosferoApp { - - /** - * @ngdoc property - * @name appName - * @propertyOf NoosferoApp - * @returns {string} the name of this application ('noosferoApp') - */ - static appName: string = "noosferoApp"; - - /** - * @ngdoc property - * @name angularModule - * @propertyOf NoosferoApp - * @returns {any} all the modules installed for this application - */ - static angularModule: any; - - /** - * @ngdoc method - * @name addConfig - * @methodOf NoosferoApp - * @param {Function} configFunc the configuration function to add - * @descprition adds a configuration function to - * the {@link NoosferoApp#angularModule} - */ - static addConfig(configFunc: Function) { - NoosferoApp.angularModule.config(configFunc); - } - - /** - * @ngdoc method - * @name addConstants - * @methodOf NoosferoApp - * @param {string} constantName the constant name - * @param {any} value the constant value - * @description adds a constant to the {@link NoosferoApp#angularModule} - */ - static addConstants(constantName: string, value: any) { - NoosferoApp.angularModule.constant(constantName, value); - } - - /** - * @ngdoc method - * @name addService - * @methodOf NoosferoApp - * @param {string} serviceName the service name - * @param {any} value the service value - * @description adds a service to the {@link NoosferoApp#angularModule} - */ - static addService(serviceName: string, value: any) { - NoosferoApp.angularModule.service(serviceName, value); - } - - /** - * @ngdoc method - * @name addFactory - * @methodOf NoosferoApp - * @param {string} factoryName the factory name - * @param {any} value the factory value - * @description adds a factory to the {@link NoosferoApp#angularModule} - */ - static addFactory(factoryName: string, value: any) { - NoosferoApp.angularModule.factory(factoryName, value); - } - - /** - * @ngdoc method - * @name addController - * @methodOf NoosferoApp - * @param {string} controllerName the controller name - * @param {any} value the controller value - * @description adds a controller to the {@link NoosferoApp#angularModule} - */ - static addController(controllerName: string, value: any) { - NoosferoApp.angularModule.controller(controllerName, value); - } - - /** - * @ngdoc method - * @name run - * @methodOf NoosferoApp - * @param {Function} runFunction the function to execute - * @description runs a function using the {@link NoosferoApp#angularModule} - */ - static run(runFunction: Function) { - NoosferoApp.angularModule.run(runFunction); - } -} diff --git a/src/app/index.ts b/src/app/index.ts index 56eda82..fb601fe 100644 --- a/src/app/index.ts +++ b/src/app/index.ts @@ -1,30 +1,13 @@ -import {NoosferoApp} from "./index.module"; +import {bootstrap} from "ng-forward"; import {noosferoModuleConfig} from "./index.config"; import {noosferoAngularRunBlock} from "./index.run"; - import {MainComponent} from "./main/main.component"; -import {bootstrap, bundle} from "ng-forward"; - import {AuthEvents} from "./login/auth-events"; -import {AuthController} from "./login/auth.controller"; - -import {Navbar} from "./layout/navbar/navbar"; declare var moment: any; -let noosferoApp: any = bundle("noosferoApp", MainComponent, ["ngAnimate", "ngCookies", "ngStorage", "ngTouch", - "ngSanitize", "ngMessages", "ngAria", "restangular", - "ui.router", "ui.bootstrap", "toastr", "ngCkeditor", - "angular-bind-html-compile", "angularMoment", "angular.filter", "akoenig.deckgrid", - "angular-timeline", "duScroll", "oitozero.ngSweetAlert", - "pascalprecht.translate", "tmh.dynamicLocale", "angularLoad", - "angular-click-outside"]).publish(); - -NoosferoApp.angularModule = noosferoApp; - - -NoosferoApp.addConstants("moment", moment); -NoosferoApp.addConstants("AuthEvents", AuthEvents); - -NoosferoApp.addConfig(noosferoModuleConfig); -NoosferoApp.run(noosferoAngularRunBlock); +angular.module('noosfero.init', []).config(noosferoModuleConfig). + run(noosferoAngularRunBlock). + constant("moment", moment). + constant("AuthEvents", AuthEvents); +bootstrap(MainComponent); diff --git a/src/app/layout/blocks/main/main-block.component.spec.ts b/src/app/layout/blocks/main/main-block.component.spec.ts index fd47bec..d9949ac 100644 --- a/src/app/layout/blocks/main/main-block.component.spec.ts +++ b/src/app/layout/blocks/main/main-block.component.spec.ts @@ -1,8 +1,7 @@ import {TestComponentBuilder} from 'ng-forward/cjs/testing/test-component-builder'; import {Input, provide, Component, StateConfig} from 'ng-forward'; - import {MainBlockComponent} from './main-block.component'; -import {NoosferoApp} from '../../../index.module'; + const tcb = new TestComponentBuilder(); @@ -37,4 +36,4 @@ describe("Components", () => { }); }); }); -}); \ No newline at end of file +}); diff --git a/src/app/login/auth.service.spec.ts b/src/app/login/auth.service.spec.ts index d836be5..168c14b 100644 --- a/src/app/login/auth.service.spec.ts +++ b/src/app/login/auth.service.spec.ts @@ -17,7 +17,7 @@ describe("Services", () => { let $rootScope: ng.IRootScopeService; let user: noosfero.User; - beforeEach(angular.mock.module("noosferoApp", ($translateProvider: angular.translate.ITranslateProvider) => { + beforeEach(angular.mock.module("main", ($translateProvider: angular.translate.ITranslateProvider) => { $translateProvider.translations('en', {}); })); diff --git a/src/app/main/main.component.spec.ts b/src/app/main/main.component.spec.ts index 43a746d..deefb17 100644 --- a/src/app/main/main.component.spec.ts +++ b/src/app/main/main.component.spec.ts @@ -1,20 +1,24 @@ - import { provide, Component, componentStore, bundleStore } from "ng-forward"; import {MainComponent} from "./main.component"; import {TestComponentBuilder, ComponentFixture} from "ng-forward/cjs/testing/test-component-builder"; -import {quickCreateComponent} from "./../../spec/helpers"; +import {quickCreateComponent} from "../../spec/helpers"; +import {getAngularServiceFactory} from "../../spec/helpers"; -describe("MainComponent", function () { +describe("MainComponent", function() { let localFixture: ComponentFixture; let $state: angular.ui.IStateService; let $q: ng.IQService; - let authService: any = jasmine.createSpyObj("authService", ["loginFromCookie"]); - let environmentService: any = jasmine.createSpyObj("environmentService", ["get"]); + let $httpBackend: ng.IHttpBackendService; + let authService: any = jasmine.createSpyObj("authService", ["loginFromCookie", "isAuthenticated", "subscribe"]); + let environmentService: any = jasmine.createSpyObj("environmentService", ["get", "getCurrentEnvironment"]); beforeEach(angular.mock.module("ui.router")); beforeEach(angular.mock.module("templates")); + beforeEach(angular.mock.module("pascalprecht.translate", ($translateProvider: angular.translate.ITranslateProvider) => { + $translateProvider.translations('en', {}); + })); @Component({ selector: "parent", @@ -46,6 +50,7 @@ describe("MainComponent", function () { it("renders the main component only when the login and environment were resolved", (done) => { quickCreateComponent({ directives: [MainComponentParent], template: "" }) .then((fixture) => { + fixture.debugElement.getLocal("$httpBackend").expectGET("/api/v1/environments/1/boxes").respond(200, {}); localFixture = fixture; // get the $state service to navigate between routes $state = fixture.debugElement.getLocal("$state"); diff --git a/src/app/main/main.component.ts b/src/app/main/main.component.ts index 1a4d607..16b5a19 100644 --- a/src/app/main/main.component.ts +++ b/src/app/main/main.component.ts @@ -93,17 +93,23 @@ export class EnvironmentContent { */ @Component({ selector: 'main', - template: '
', + template: '', directives: [ ArticleBlogComponent, ArticleViewComponent, BoxesComponent, BlockComponent, EnvironmentComponent, PeopleBlockComponent, DisplayContentBlockComponent, - LinkListBlockComponent, CommunitiesBlockComponent, HtmlEditorComponent, + LinkListBlockComponent, CommunitiesBlockComponent, HtmlEditorComponent, ProfileComponent, MainBlockComponent, RecentDocumentsBlockComponent, Navbar, SidebarComponent, ProfileImageBlockComponent, MembersBlockComponent, NoosferoTemplate, DateFormat, RawHTMLBlockComponent, StatisticsBlockComponent, LoginBlockComponent, CustomContentComponent, PermissionDirective ].concat(plugins.mainComponents).concat(plugins.hotspots), - - providers: [AuthService, SessionService, NotificationService, BodyStateClassesService] + providers: [AuthService, SessionService, NotificationService, BodyStateClassesService, + "ngAnimate", "ngCookies", "ngStorage", "ngTouch", + "ngSanitize", "ngMessages", "ngAria", "restangular", + "ui.router", "ui.bootstrap", "toastr", "ngCkeditor", + "angular-bind-html-compile", "angularMoment", "angular.filter", "akoenig.deckgrid", + "angular-timeline", "duScroll", "oitozero.ngSweetAlert", + "pascalprecht.translate", "tmh.dynamicLocale", "angularLoad", + "angular-click-outside", "noosfero.init"] }) @StateConfig([ { @@ -147,5 +153,4 @@ export class EnvironmentContent { } } ]) -export class MainComponent { -} +export class MainComponent { } diff --git a/src/index.html b/src/index.html index 6c61cb8..463d494 100644 --- a/src/index.html +++ b/src/index.html @@ -1,5 +1,5 @@ - + @@ -25,7 +25,7 @@

You are using an outdated browser. Please upgrade your browser to improve your experience.

-
+