Merge pull request #2638 from NoelDeMartin/MOBILE-3320
MOBILE-3320: Refactor lazy modules and configure Github Actionsmain
commit
15de34a31a
|
@ -0,0 +1,19 @@
|
|||
name: Testing
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Use Node.js
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: '12.x'
|
||||
- run: npm ci
|
||||
- run: npm run lint
|
||||
- run: npm run test:ci
|
||||
- run: npm run build:prod
|
|
@ -14,11 +14,11 @@
|
|||
|
||||
import { NgModule } from '@angular/core';
|
||||
|
||||
import { AddonPrivateFilesInitModule } from './privatefiles/privatefiles-init.module';
|
||||
import { AddonPrivateFilesModule } from './privatefiles/privatefiles.module';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
AddonPrivateFilesInitModule,
|
||||
AddonPrivateFilesModule,
|
||||
],
|
||||
})
|
||||
export class AddonsModule {}
|
||||
|
|
|
@ -1,45 +0,0 @@
|
|||
// (C) Copyright 2015 Moodle Pty Ltd.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
import { NgModule } from '@angular/core';
|
||||
import { Routes } from '@angular/router';
|
||||
|
||||
import { CoreMainMenuDelegate } from '@features/mainmenu/services/mainmenu-delegate';
|
||||
import { CoreMainMenuRoutingModule } from '@features/mainmenu/mainmenu-routing.module';
|
||||
import { AddonPrivateFilesMainMenuHandler } from './services/handlers/mainmenu';
|
||||
|
||||
const routes: Routes = [
|
||||
{
|
||||
path: 'addon-privatefiles',
|
||||
loadChildren: () => import('@/addons/privatefiles/privatefiles.module').then(m => m.AddonPrivateFilesModule),
|
||||
},
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
imports: [CoreMainMenuRoutingModule.forChild(routes)],
|
||||
exports: [CoreMainMenuRoutingModule],
|
||||
providers: [
|
||||
AddonPrivateFilesMainMenuHandler,
|
||||
],
|
||||
})
|
||||
export class AddonPrivateFilesInitModule {
|
||||
|
||||
constructor(
|
||||
mainMenuDelegate: CoreMainMenuDelegate,
|
||||
mainMenuHandler: AddonPrivateFilesMainMenuHandler,
|
||||
) {
|
||||
mainMenuDelegate.registerHandler(mainMenuHandler);
|
||||
}
|
||||
|
||||
}
|
|
@ -23,7 +23,7 @@ const routes: Routes = [
|
|||
},
|
||||
{
|
||||
path: ':hash',
|
||||
loadChildren: () => import('./pages/index/index.module').then( m => m.AddonPrivateFilesIndexPageModule),
|
||||
loadChildren: () => import('./pages/index/index.module').then(m => m.AddonPrivateFilesIndexPageModule),
|
||||
},
|
||||
];
|
||||
|
||||
|
@ -31,4 +31,4 @@ const routes: Routes = [
|
|||
imports: [RouterModule.forChild(routes)],
|
||||
exports: [RouterModule],
|
||||
})
|
||||
export class AddonPrivateFilesRoutingModule {}
|
||||
export class AddonPrivateFilesLazyModule {}
|
|
@ -13,13 +13,33 @@
|
|||
// limitations under the License.
|
||||
|
||||
import { NgModule } from '@angular/core';
|
||||
import { Routes } from '@angular/router';
|
||||
|
||||
import { AddonPrivateFilesRoutingModule } from './privatefiles-routing.module';
|
||||
import { CoreMainMenuDelegate } from '@features/mainmenu/services/mainmenu-delegate';
|
||||
import { CoreMainMenuRoutingModule } from '@features/mainmenu/mainmenu-routing.module';
|
||||
import { AddonPrivateFilesMainMenuHandler } from './services/handlers/mainmenu';
|
||||
|
||||
const routes: Routes = [
|
||||
{
|
||||
path: AddonPrivateFilesMainMenuHandler.PAGE_NAME,
|
||||
loadChildren: () => import('@/addons/privatefiles/privatefiles-lazy.module').then(m => m.AddonPrivateFilesLazyModule),
|
||||
},
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
AddonPrivateFilesRoutingModule,
|
||||
imports: [CoreMainMenuRoutingModule.forChild({ children: routes })],
|
||||
exports: [CoreMainMenuRoutingModule],
|
||||
providers: [
|
||||
AddonPrivateFilesMainMenuHandler,
|
||||
],
|
||||
declarations: [],
|
||||
})
|
||||
export class AddonPrivateFilesModule {}
|
||||
export class AddonPrivateFilesModule {
|
||||
|
||||
constructor(
|
||||
mainMenuDelegate: CoreMainMenuDelegate,
|
||||
mainMenuHandler: AddonPrivateFilesMainMenuHandler,
|
||||
) {
|
||||
mainMenuDelegate.registerHandler(mainMenuHandler);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -23,6 +23,8 @@ import { AddonPrivateFiles } from '@/addons/privatefiles/services/privatefiles';
|
|||
@Injectable()
|
||||
export class AddonPrivateFilesMainMenuHandler implements CoreMainMenuHandler {
|
||||
|
||||
static readonly PAGE_NAME = 'private';
|
||||
|
||||
name = 'AddonPrivateFiles';
|
||||
priority = 400;
|
||||
|
||||
|
@ -44,7 +46,7 @@ export class AddonPrivateFilesMainMenuHandler implements CoreMainMenuHandler {
|
|||
return {
|
||||
icon: 'fas-folder',
|
||||
title: 'addon.privatefiles.files',
|
||||
page: 'addon-privatefiles',
|
||||
page: AddonPrivateFilesMainMenuHandler.PAGE_NAME,
|
||||
subPage: 'root',
|
||||
class: 'addon-privatefiles-handler',
|
||||
};
|
||||
|
|
|
@ -12,35 +12,49 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
import { NgModule } from '@angular/core';
|
||||
import { PreloadAllModules, RouterModule, Routes } from '@angular/router';
|
||||
import { InjectionToken, Injector, ModuleWithProviders, NgModule } from '@angular/core';
|
||||
import { PreloadAllModules, RouterModule, ROUTES, Routes } from '@angular/router';
|
||||
|
||||
import { AuthGuard } from '@guards/auth';
|
||||
import { CoreArray } from '@singletons/array';
|
||||
|
||||
const routes: Routes = [
|
||||
{
|
||||
path: 'login',
|
||||
loadChildren: () => import('@features/login/login.module').then( m => m.CoreLoginModule),
|
||||
},
|
||||
{
|
||||
path: 'settings',
|
||||
loadChildren: () => import('@features/settings/settings.module').then( m => m.CoreSettingsModule),
|
||||
},
|
||||
{
|
||||
path: '',
|
||||
loadChildren: () => import('@features/mainmenu/mainmenu.module').then( m => m.CoreMainMenuModule),
|
||||
canActivate: [AuthGuard],
|
||||
canLoad: [AuthGuard],
|
||||
},
|
||||
];
|
||||
function buildAppRoutes(injector: Injector): Routes {
|
||||
return CoreArray.flatten(injector.get<Routes[]>(APP_ROUTES, []));
|
||||
}
|
||||
|
||||
export type ModuleRoutes = { children: Routes; siblings: Routes };
|
||||
|
||||
export function resolveModuleRoutes(injector: Injector, token: InjectionToken<Partial<ModuleRoutes>[]>): ModuleRoutes {
|
||||
const routes = injector.get(token, []);
|
||||
|
||||
return {
|
||||
children: CoreArray.flatten(routes.map(r => r.children || [])),
|
||||
siblings: CoreArray.flatten(routes.map(r => r.siblings || [])),
|
||||
};
|
||||
}
|
||||
|
||||
export const APP_ROUTES = new InjectionToken('APP_ROUTES');
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
RouterModule.forRoot(routes, {
|
||||
RouterModule.forRoot([], {
|
||||
preloadingStrategy: PreloadAllModules,
|
||||
relativeLinkResolution: 'corrected',
|
||||
}),
|
||||
],
|
||||
providers: [
|
||||
{ provide: ROUTES, multi: true, useFactory: buildAppRoutes, deps: [Injector] },
|
||||
],
|
||||
exports: [RouterModule],
|
||||
})
|
||||
export class AppRoutingModule { }
|
||||
export class AppRoutingModule {
|
||||
|
||||
static forChild(routes: Routes): ModuleWithProviders<AppRoutingModule> {
|
||||
return {
|
||||
ngModule: AppRoutingModule,
|
||||
providers: [
|
||||
{ provide: APP_ROUTES, multi: true, useValue: routes },
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -16,19 +16,13 @@ import { NgModule } from '@angular/core';
|
|||
|
||||
import { CORE_SITE_SCHEMAS } from '@services/sites';
|
||||
|
||||
import {
|
||||
SITE_SCHEMA as COURSE_SITE_SCHEMA,
|
||||
OFFLINE_SITE_SCHEMA as COURSE_OFFLINE_SITE_SCHEMA,
|
||||
} from './services/db/course';
|
||||
import { SITE_SCHEMA, OFFLINE_SITE_SCHEMA } from './services/db/course';
|
||||
|
||||
@NgModule({
|
||||
providers: [
|
||||
{
|
||||
provide: CORE_SITE_SCHEMAS,
|
||||
useValue: [
|
||||
COURSE_SITE_SCHEMA,
|
||||
COURSE_OFFLINE_SITE_SCHEMA,
|
||||
],
|
||||
useValue: [SITE_SCHEMA, OFFLINE_SITE_SCHEMA],
|
||||
multi: true,
|
||||
},
|
||||
],
|
||||
|
|
|
@ -0,0 +1,64 @@
|
|||
// (C) Copyright 2015 Moodle Pty Ltd.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
import { NgModule } from '@angular/core';
|
||||
import { RouterModule, Routes } from '@angular/router';
|
||||
|
||||
const routes: Routes = [
|
||||
{
|
||||
path: '',
|
||||
redirectTo: 'my',
|
||||
pathMatch: 'full',
|
||||
},
|
||||
{
|
||||
path: 'categories',
|
||||
redirectTo: 'categories/root', // Fake "id".
|
||||
pathMatch: 'full',
|
||||
},
|
||||
{
|
||||
path: 'categories/:id',
|
||||
loadChildren: () =>
|
||||
import('./pages/categories/categories.module')
|
||||
.then(m => m.CoreCoursesCategoriesPageModule),
|
||||
},
|
||||
{
|
||||
path: 'all',
|
||||
loadChildren: () =>
|
||||
import('./pages/available-courses/available-courses.module')
|
||||
.then(m => m.CoreCoursesAvailableCoursesPageModule),
|
||||
},
|
||||
{
|
||||
path: 'search',
|
||||
loadChildren: () =>
|
||||
import('./pages/search/search.module')
|
||||
.then(m => m.CoreCoursesSearchPageModule),
|
||||
},
|
||||
{
|
||||
path: 'my',
|
||||
loadChildren: () =>
|
||||
import('./pages/my-courses/my-courses.module')
|
||||
.then(m => m.CoreCoursesMyCoursesPageModule),
|
||||
},
|
||||
{
|
||||
path: 'preview',
|
||||
loadChildren: () =>
|
||||
import('./pages/course-preview/course-preview.module')
|
||||
.then(m => m.CoreCoursesCoursePreviewPageModule),
|
||||
},
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
imports: [RouterModule.forChild(routes)],
|
||||
})
|
||||
export class CoreCoursesLazyModule {}
|
|
@ -13,82 +13,43 @@
|
|||
// limitations under the License.
|
||||
|
||||
import { NgModule } from '@angular/core';
|
||||
import { RouterModule, Routes } from '@angular/router';
|
||||
import { CoreHomeRoutingModule } from '@features/mainmenu/pages/home/home-routing.module';
|
||||
import { CoreHomeDelegate } from '@features/mainmenu/services/home-delegate';
|
||||
import { Routes } from '@angular/router';
|
||||
|
||||
import { CoreMainMenuHomeRoutingModule } from '@features/mainmenu/pages/home/home-routing.module';
|
||||
import { CoreMainMenuHomeDelegate } from '@features/mainmenu/services/home-delegate';
|
||||
|
||||
import { CoreDashboardHomeHandler } from './services/handlers/dashboard-home';
|
||||
import { CoreCoursesMyCoursesHomeHandler } from './services/handlers/my-courses.home';
|
||||
|
||||
const homeRoutes: Routes = [
|
||||
const mainMenuHomeChildrenRoutes: Routes = [
|
||||
{
|
||||
path: 'dashboard',
|
||||
loadChildren: () =>
|
||||
import('@features/courses/pages/dashboard/dashboard.module').then(m => m.CoreCoursesDashboardPageModule),
|
||||
path: '',
|
||||
pathMatch: 'full',
|
||||
redirectTo: CoreDashboardHomeHandler.PAGE_NAME,
|
||||
},
|
||||
{
|
||||
path: 'courses/my',
|
||||
loadChildren: () =>
|
||||
import('@features/courses/pages/my-courses/my-courses.module')
|
||||
.then(m => m.CoreCoursesMyCoursesPageModule),
|
||||
path: CoreDashboardHomeHandler.PAGE_NAME,
|
||||
loadChildren: () => import('./pages/dashboard/dashboard.module').then(m => m.CoreCoursesDashboardPageModule),
|
||||
},
|
||||
{
|
||||
path: CoreCoursesMyCoursesHomeHandler.PAGE_NAME,
|
||||
loadChildren: () => import('./pages/my-courses/my-courses.module').then(m => m.CoreCoursesMyCoursesPageModule),
|
||||
},
|
||||
];
|
||||
|
||||
const routes: Routes = [
|
||||
const mainMenuHomeSiblingRoutes: Routes = [
|
||||
{
|
||||
path: 'courses',
|
||||
children: [
|
||||
{
|
||||
path: '',
|
||||
redirectTo: 'my',
|
||||
pathMatch: 'full',
|
||||
},
|
||||
{
|
||||
path: 'categories',
|
||||
redirectTo: 'categories/root', // Fake "id".
|
||||
pathMatch: 'full',
|
||||
},
|
||||
{
|
||||
path: 'categories/:id',
|
||||
loadChildren: () =>
|
||||
import('@features/courses/pages/categories/categories.module')
|
||||
.then(m => m.CoreCoursesCategoriesPageModule),
|
||||
},
|
||||
{
|
||||
path: 'all',
|
||||
loadChildren: () =>
|
||||
import('@features/courses/pages/available-courses/available-courses.module')
|
||||
.then(m => m.CoreCoursesAvailableCoursesPageModule),
|
||||
},
|
||||
{
|
||||
path: 'search',
|
||||
loadChildren: () =>
|
||||
import('@features/courses/pages/search/search.module')
|
||||
.then(m => m.CoreCoursesSearchPageModule),
|
||||
},
|
||||
{
|
||||
path: 'my',
|
||||
loadChildren: () =>
|
||||
import('@features/courses/pages/my-courses/my-courses.module')
|
||||
.then(m => m.CoreCoursesMyCoursesPageModule),
|
||||
},
|
||||
{
|
||||
path: 'preview',
|
||||
loadChildren: () =>
|
||||
import('@features/courses/pages/course-preview/course-preview.module')
|
||||
.then(m => m.CoreCoursesCoursePreviewPageModule),
|
||||
},
|
||||
],
|
||||
loadChildren: () => import('./courses-lazy.module').then(m => m.CoreCoursesLazyModule),
|
||||
},
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
CoreHomeRoutingModule.forChild(homeRoutes),
|
||||
RouterModule.forChild(routes),
|
||||
],
|
||||
exports: [
|
||||
CoreHomeRoutingModule,
|
||||
RouterModule,
|
||||
CoreMainMenuHomeRoutingModule.forChild({
|
||||
children: mainMenuHomeChildrenRoutes,
|
||||
siblings: mainMenuHomeSiblingRoutes,
|
||||
}),
|
||||
],
|
||||
providers: [
|
||||
CoreDashboardHomeHandler,
|
||||
|
@ -98,7 +59,7 @@ const routes: Routes = [
|
|||
export class CoreCoursesModule {
|
||||
|
||||
constructor(
|
||||
homeDelegate: CoreHomeDelegate,
|
||||
homeDelegate: CoreMainMenuHomeDelegate,
|
||||
coursesDashboardHandler: CoreDashboardHomeHandler,
|
||||
coursesMyCoursesHandler: CoreCoursesMyCoursesHomeHandler,
|
||||
) {
|
||||
|
|
|
@ -90,7 +90,7 @@ export class CoreCoursesDashboardPage implements OnInit, OnDestroy {
|
|||
* Go to search courses.
|
||||
*/
|
||||
openSearch(): void {
|
||||
this.navCtrl.navigateForward(['/courses/search']);
|
||||
this.navCtrl.navigateForward(['/main/home/courses/search']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -200,7 +200,7 @@ export class CoreCoursesMyCoursesPage implements OnInit, OnDestroy {
|
|||
* Go to search courses.
|
||||
*/
|
||||
openSearch(): void {
|
||||
this.navCtrl.navigateForward(['/courses/search']);
|
||||
this.navCtrl.navigateForward(['/main/home/courses/search']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -13,13 +13,15 @@
|
|||
// limitations under the License.
|
||||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { CoreHomeHandler, CoreHomeHandlerToDisplay } from '@features/mainmenu/services/home-delegate';
|
||||
import { CoreMainMenuHomeHandler, CoreMainMenuHomeHandlerToDisplay } from '@features/mainmenu/services/home-delegate';
|
||||
|
||||
/**
|
||||
* Handler to add dashboard into home page.
|
||||
*/
|
||||
Injectable();
|
||||
export class CoreDashboardHomeHandler implements CoreHomeHandler {
|
||||
export class CoreDashboardHomeHandler implements CoreMainMenuHomeHandler {
|
||||
|
||||
static readonly PAGE_NAME = 'dashboard';
|
||||
|
||||
name = 'CoreCoursesDashboard';
|
||||
priority = 1100;
|
||||
|
@ -50,10 +52,10 @@ export class CoreDashboardHomeHandler implements CoreHomeHandler {
|
|||
*
|
||||
* @return Data needed to render the handler.
|
||||
*/
|
||||
getDisplayData(): CoreHomeHandlerToDisplay {
|
||||
getDisplayData(): CoreMainMenuHomeHandlerToDisplay {
|
||||
return {
|
||||
title: 'core.courses.mymoodle',
|
||||
page: 'dashboard',
|
||||
page: CoreDashboardHomeHandler.PAGE_NAME,
|
||||
class: 'core-courses-dashboard-handler',
|
||||
icon: 'fas-tachometer-alt',
|
||||
selectPriority: 1000,
|
||||
|
|
|
@ -13,13 +13,15 @@
|
|||
// limitations under the License.
|
||||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { CoreHomeHandler, CoreHomeHandlerToDisplay } from '@features/mainmenu/services/home-delegate';
|
||||
import { CoreMainMenuHomeHandler, CoreMainMenuHomeHandlerToDisplay } from '@features/mainmenu/services/home-delegate';
|
||||
|
||||
/**
|
||||
* Handler to add my courses into home page.
|
||||
*/
|
||||
Injectable();
|
||||
export class CoreCoursesMyCoursesHomeHandler implements CoreHomeHandler {
|
||||
export class CoreCoursesMyCoursesHomeHandler implements CoreMainMenuHomeHandler {
|
||||
|
||||
static readonly PAGE_NAME = 'courses';
|
||||
|
||||
name = 'CoreCoursesMyCourses';
|
||||
priority = 900;
|
||||
|
@ -50,10 +52,10 @@ export class CoreCoursesMyCoursesHomeHandler implements CoreHomeHandler {
|
|||
*
|
||||
* @return Data needed to render the handler.
|
||||
*/
|
||||
getDisplayData(): CoreHomeHandlerToDisplay {
|
||||
getDisplayData(): CoreMainMenuHomeHandlerToDisplay {
|
||||
return {
|
||||
title: 'core.courses.mycourses',
|
||||
page: 'courses/my',
|
||||
page: CoreCoursesMyCoursesHomeHandler.PAGE_NAME,
|
||||
class: 'core-courses-my-courses-handler',
|
||||
icon: 'fas-graduation-cap',
|
||||
selectPriority: 900,
|
||||
|
|
|
@ -17,20 +17,22 @@ import { NgModule } from '@angular/core';
|
|||
import { CoreCourseModule } from './course/course.module';
|
||||
import { CoreCoursesModule } from './courses/courses.module';
|
||||
import { CoreEmulatorModule } from './emulator/emulator.module';
|
||||
import { CoreFileUploaderInitModule } from './fileuploader/fileuploader-init.module';
|
||||
import { CoreFileUploaderModule } from './fileuploader/fileuploader.module';
|
||||
import { CoreLoginModule } from './login/login.module';
|
||||
import { CoreSettingsInitModule } from './settings/settings-init.module';
|
||||
import { CoreSiteHomeInitModule } from './sitehome/sitehome-init.module';
|
||||
import { CoreMainMenuModule } from './mainmenu/mainmenu.module';
|
||||
import { CoreSettingsModule } from './settings/settings.module';
|
||||
import { CoreSiteHomeModule } from './sitehome/sitehome.module';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
CoreEmulatorModule,
|
||||
CoreLoginModule,
|
||||
CoreCourseModule,
|
||||
CoreCoursesModule,
|
||||
CoreSettingsInitModule,
|
||||
CoreFileUploaderInitModule,
|
||||
CoreSiteHomeInitModule,
|
||||
CoreEmulatorModule,
|
||||
CoreFileUploaderModule,
|
||||
CoreLoginModule,
|
||||
CoreMainMenuModule,
|
||||
CoreSettingsModule,
|
||||
CoreSiteHomeModule,
|
||||
],
|
||||
})
|
||||
export class CoreFeaturesModule {}
|
||||
|
|
|
@ -33,7 +33,7 @@ import { CoreFileUploaderVideoHandler } from './services/handlers/video';
|
|||
CoreFileUploaderVideoHandler,
|
||||
],
|
||||
})
|
||||
export class CoreFileUploaderInitModule {
|
||||
export class CoreFileUploaderModule {
|
||||
|
||||
constructor(
|
||||
delegate: CoreFileUploaderDelegate,
|
|
@ -14,6 +14,14 @@
|
|||
|
||||
import { NgModule } from '@angular/core';
|
||||
import { RouterModule, Routes } from '@angular/router';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { IonicModule } from '@ionic/angular';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
|
||||
import { CoreComponentsModule } from '@components/components.module';
|
||||
import { CoreDirectivesModule } from '@directives/directives.module';
|
||||
import { CoreLoginSiteHelpComponent } from './components/site-help/site-help';
|
||||
import { CoreLoginSiteOnboardingComponent } from './components/site-onboarding/site-onboarding';
|
||||
|
||||
const routes: Routes = [
|
||||
{
|
||||
|
@ -62,7 +70,17 @@ const routes: Routes = [
|
|||
];
|
||||
|
||||
@NgModule({
|
||||
imports: [RouterModule.forChild(routes)],
|
||||
exports: [RouterModule],
|
||||
imports: [
|
||||
CommonModule,
|
||||
IonicModule,
|
||||
TranslateModule.forChild(),
|
||||
CoreComponentsModule,
|
||||
CoreDirectivesModule,
|
||||
RouterModule.forChild(routes),
|
||||
],
|
||||
declarations: [
|
||||
CoreLoginSiteHelpComponent,
|
||||
CoreLoginSiteOnboardingComponent,
|
||||
],
|
||||
})
|
||||
export class CoreLoginRoutingModule {}
|
||||
export class CoreLoginLazyModule {}
|
|
@ -13,32 +13,18 @@
|
|||
// limitations under the License.
|
||||
|
||||
import { NgModule } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { IonicModule } from '@ionic/angular';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { Routes } from '@angular/router';
|
||||
|
||||
import { CoreComponentsModule } from '@components/components.module';
|
||||
import { CoreDirectivesModule } from '@directives/directives.module';
|
||||
import { CoreLoginRoutingModule } from './login-routing.module';
|
||||
import { CoreLoginSiteHelpComponent } from './components/site-help/site-help';
|
||||
import { CoreLoginSiteOnboardingComponent } from './components/site-onboarding/site-onboarding';
|
||||
import { AppRoutingModule } from '@/app/app-routing.module';
|
||||
|
||||
const appRoutes: Routes = [
|
||||
{
|
||||
path: 'login',
|
||||
loadChildren: () => import('./login-lazy.module').then(m => m.CoreLoginLazyModule),
|
||||
},
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
CoreLoginRoutingModule,
|
||||
CommonModule,
|
||||
IonicModule,
|
||||
TranslateModule.forChild(),
|
||||
CoreComponentsModule,
|
||||
CoreDirectivesModule,
|
||||
],
|
||||
declarations: [
|
||||
CoreLoginSiteHelpComponent,
|
||||
CoreLoginSiteOnboardingComponent,
|
||||
],
|
||||
exports: [
|
||||
CoreLoginSiteHelpComponent,
|
||||
CoreLoginSiteOnboardingComponent,
|
||||
],
|
||||
imports: [AppRoutingModule.forChild(appRoutes)],
|
||||
})
|
||||
export class CoreLoginModule {}
|
||||
|
|
|
@ -0,0 +1,75 @@
|
|||
// (C) Copyright 2015 Moodle Pty Ltd.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { Injector, NgModule } from '@angular/core';
|
||||
import { ROUTES, Routes } from '@angular/router';
|
||||
import { CoreComponentsModule } from '@components/components.module';
|
||||
import { CoreDirectivesModule } from '@directives/directives.module';
|
||||
import { IonicModule } from '@ionic/angular';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { CorePipesModule } from '@pipes/pipes.module';
|
||||
|
||||
import { resolveModuleRoutes } from '@/app/app-routing.module';
|
||||
|
||||
import { MAIN_MENU_ROUTES } from './mainmenu-routing.module';
|
||||
import { CoreMainMenuPage } from './pages/menu/menu';
|
||||
import { CoreMainMenuHomeHandler } from './services/handlers/mainmenu';
|
||||
|
||||
function buildRoutes(injector: Injector): Routes {
|
||||
const routes = resolveModuleRoutes(injector, MAIN_MENU_ROUTES);
|
||||
|
||||
return [
|
||||
{
|
||||
path: '',
|
||||
component: CoreMainMenuPage,
|
||||
children: [
|
||||
{
|
||||
path: '',
|
||||
pathMatch: 'full',
|
||||
redirectTo: CoreMainMenuHomeHandler.PAGE_NAME,
|
||||
},
|
||||
{
|
||||
path: CoreMainMenuHomeHandler.PAGE_NAME,
|
||||
loadChildren: () => import('./pages/home/home.module').then(m => m.CoreMainMenuHomePageModule),
|
||||
},
|
||||
{
|
||||
path: 'more',
|
||||
loadChildren: () => import('./pages/more/more.module').then(m => m.CoreMainMenuMorePageModule),
|
||||
},
|
||||
...routes.children,
|
||||
],
|
||||
},
|
||||
...routes.siblings,
|
||||
];
|
||||
}
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonModule,
|
||||
IonicModule,
|
||||
TranslateModule,
|
||||
CoreComponentsModule,
|
||||
CoreDirectivesModule,
|
||||
CorePipesModule,
|
||||
],
|
||||
declarations: [
|
||||
CoreMainMenuPage,
|
||||
],
|
||||
providers: [
|
||||
CoreMainMenuHomeHandler,
|
||||
{ provide: ROUTES, multi: true, useFactory: buildRoutes, deps: [Injector] },
|
||||
],
|
||||
})
|
||||
export class CoreMainMenuLazyModule {}
|
|
@ -12,54 +12,16 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
import { InjectionToken, Injector, ModuleWithProviders, NgModule } from '@angular/core';
|
||||
import { RouterModule, ROUTES, Routes } from '@angular/router';
|
||||
import { InjectionToken, ModuleWithProviders, NgModule } from '@angular/core';
|
||||
|
||||
import { CoreArray } from '@singletons/array';
|
||||
|
||||
import { CoreMainMenuPage } from './pages/menu/menu';
|
||||
import { CoreMainMenuMorePage } from './pages/more/more';
|
||||
|
||||
function buildMainMenuRoutes(injector: Injector): Routes {
|
||||
const routes = CoreArray.flatten(injector.get<Routes[]>(MAIN_MENU_ROUTES, []));
|
||||
|
||||
return [
|
||||
{
|
||||
path: '',
|
||||
component: CoreMainMenuPage,
|
||||
children: [
|
||||
{
|
||||
path: 'home', // @todo: Add this route dynamically.
|
||||
loadChildren: () => import('./pages/home/home.module').then(m => m.CoreHomePageModule),
|
||||
},
|
||||
{
|
||||
path: 'more',
|
||||
children: [
|
||||
{
|
||||
path: '',
|
||||
component: CoreMainMenuMorePage,
|
||||
},
|
||||
...routes,
|
||||
],
|
||||
},
|
||||
...routes,
|
||||
// @todo handle 404.
|
||||
],
|
||||
},
|
||||
];
|
||||
}
|
||||
import { ModuleRoutes } from '@/app/app-routing.module';
|
||||
|
||||
export const MAIN_MENU_ROUTES = new InjectionToken('MAIN_MENU_ROUTES');
|
||||
|
||||
@NgModule({
|
||||
providers: [
|
||||
{ provide: ROUTES, multi: true, useFactory: buildMainMenuRoutes, deps: [Injector] },
|
||||
],
|
||||
exports: [RouterModule],
|
||||
})
|
||||
@NgModule()
|
||||
export class CoreMainMenuRoutingModule {
|
||||
|
||||
static forChild(routes: Routes): ModuleWithProviders<CoreMainMenuRoutingModule> {
|
||||
static forChild(routes: Partial<ModuleRoutes>): ModuleWithProviders<CoreMainMenuRoutingModule> {
|
||||
return {
|
||||
ngModule: CoreMainMenuRoutingModule,
|
||||
providers: [
|
||||
|
|
|
@ -13,44 +13,36 @@
|
|||
// limitations under the License.
|
||||
|
||||
import { NgModule } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { Routes } from '@angular/router';
|
||||
import { AuthGuard } from '@guards/auth';
|
||||
|
||||
import { IonicModule } from '@ionic/angular';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
|
||||
import { CoreComponentsModule } from '@components/components.module';
|
||||
import { CoreDirectivesModule } from '@directives/directives.module';
|
||||
import { AppRoutingModule } from '@/app/app-routing.module';
|
||||
|
||||
import { CoreMainMenuDelegate } from './services/mainmenu-delegate';
|
||||
import { CoreMainMenuHomeHandler } from './services/handlers/mainmenu';
|
||||
|
||||
import { CoreMainMenuRoutingModule } from './mainmenu-routing.module';
|
||||
import { CoreMainMenuPage } from './pages/menu/menu';
|
||||
import { CoreMainMenuMorePage } from './pages/more/more';
|
||||
import { CoreHomeMainMenuHandler } from './services/handlers/mainmenu';
|
||||
|
||||
const appRoutes: Routes = [
|
||||
{
|
||||
path: '',
|
||||
pathMatch: 'full',
|
||||
redirectTo: 'main',
|
||||
},
|
||||
{
|
||||
path: 'main',
|
||||
loadChildren: () => import('./mainmenu-lazy.module').then(m => m.CoreMainMenuLazyModule),
|
||||
canActivate: [AuthGuard],
|
||||
canLoad: [AuthGuard],
|
||||
},
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonModule,
|
||||
IonicModule,
|
||||
CoreMainMenuRoutingModule,
|
||||
TranslateModule.forChild(),
|
||||
CoreComponentsModule,
|
||||
CoreDirectivesModule,
|
||||
],
|
||||
declarations: [
|
||||
CoreMainMenuPage,
|
||||
CoreMainMenuMorePage,
|
||||
],
|
||||
providers: [
|
||||
CoreHomeMainMenuHandler,
|
||||
],
|
||||
imports: [AppRoutingModule.forChild(appRoutes)],
|
||||
})
|
||||
export class CoreMainMenuModule {
|
||||
|
||||
constructor(
|
||||
mainMenuDelegate: CoreMainMenuDelegate,
|
||||
homeMainMenuHandler: CoreHomeMainMenuHandler,
|
||||
homeMainMenuHandler: CoreMainMenuHomeHandler,
|
||||
) {
|
||||
mainMenuDelegate.registerHandler(homeMainMenuHandler);
|
||||
}
|
||||
|
|
|
@ -12,43 +12,20 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
import { InjectionToken, Injector, ModuleWithProviders, NgModule } from '@angular/core';
|
||||
import { RouterModule, ROUTES, Routes } from '@angular/router';
|
||||
import { InjectionToken, ModuleWithProviders, NgModule } from '@angular/core';
|
||||
|
||||
import { CoreArray } from '@singletons/array';
|
||||
import { ModuleRoutes } from '@/app/app-routing.module';
|
||||
|
||||
import { CoreHomePage } from './home';
|
||||
export const MAIN_MENU_HOME_ROUTES = new InjectionToken('MAIN_MENU_HOME_ROUTES');
|
||||
|
||||
function buildHomeRoutes(injector: Injector): Routes {
|
||||
const routes = CoreArray.flatten(injector.get<Routes[]>(HOME_ROUTES, []));
|
||||
@NgModule()
|
||||
export class CoreMainMenuHomeRoutingModule {
|
||||
|
||||
return [
|
||||
{
|
||||
path: '',
|
||||
component: CoreHomePage,
|
||||
children: [
|
||||
...routes,
|
||||
// @todo handle 404.
|
||||
],
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
export const HOME_ROUTES = new InjectionToken('HOME_ROUTES');
|
||||
|
||||
@NgModule({
|
||||
providers: [
|
||||
{ provide: ROUTES, multi: true, useFactory: buildHomeRoutes, deps: [Injector] },
|
||||
],
|
||||
exports: [RouterModule],
|
||||
})
|
||||
export class CoreHomeRoutingModule {
|
||||
|
||||
static forChild(routes: Routes): ModuleWithProviders<CoreHomeRoutingModule> {
|
||||
static forChild(routes: Partial<ModuleRoutes>): ModuleWithProviders<CoreMainMenuHomeRoutingModule> {
|
||||
return {
|
||||
ngModule: CoreHomeRoutingModule,
|
||||
ngModule: CoreMainMenuHomeRoutingModule,
|
||||
providers: [
|
||||
{ provide: HOME_ROUTES, multi: true, useValue: routes },
|
||||
{ provide: MAIN_MENU_HOME_ROUTES, multi: true, useValue: routes },
|
||||
],
|
||||
};
|
||||
}
|
||||
|
|
|
@ -12,16 +12,31 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
import { NgModule } from '@angular/core';
|
||||
import { Injector, NgModule } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { RouterModule, ROUTES, Routes } from '@angular/router';
|
||||
import { IonicModule } from '@ionic/angular';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
|
||||
import { resolveModuleRoutes } from '@/app/app-routing.module';
|
||||
import { CoreComponentsModule } from '@components/components.module';
|
||||
import { CoreDirectivesModule } from '@directives/directives.module';
|
||||
|
||||
import { CoreHomePage } from './home';
|
||||
import { CoreHomeRoutingModule } from './home-routing.module';
|
||||
import { CoreMainMenuHomePage } from './home';
|
||||
import { MAIN_MENU_HOME_ROUTES } from './home-routing.module';
|
||||
|
||||
function buildRoutes(injector: Injector): Routes {
|
||||
const routes = resolveModuleRoutes(injector, MAIN_MENU_HOME_ROUTES);
|
||||
|
||||
return [
|
||||
{
|
||||
path: '',
|
||||
component: CoreMainMenuHomePage,
|
||||
children: routes.children,
|
||||
},
|
||||
...routes.siblings,
|
||||
];
|
||||
}
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
|
@ -30,10 +45,15 @@ import { CoreHomeRoutingModule } from './home-routing.module';
|
|||
TranslateModule.forChild(),
|
||||
CoreComponentsModule,
|
||||
CoreDirectivesModule,
|
||||
CoreHomeRoutingModule,
|
||||
],
|
||||
providers: [
|
||||
{ provide: ROUTES, multi: true, useFactory: buildRoutes, deps: [Injector] },
|
||||
],
|
||||
declarations: [
|
||||
CoreHomePage,
|
||||
CoreMainMenuHomePage,
|
||||
],
|
||||
exports: [
|
||||
RouterModule,
|
||||
],
|
||||
})
|
||||
export class CoreHomePageModule {}
|
||||
export class CoreMainMenuHomePageModule {}
|
||||
|
|
|
@ -18,39 +18,36 @@ import { Subscription } from 'rxjs';
|
|||
import { CoreSites } from '@services/sites';
|
||||
import { CoreEventObserver, CoreEvents } from '@singletons/events';
|
||||
import { CoreTabsComponent } from '@components/tabs/tabs';
|
||||
import { CoreHomeDelegate, CoreHomeHandlerToDisplay } from '../../services/home-delegate';
|
||||
import { CoreMainMenuHomeDelegate, CoreMainMenuHomeHandlerToDisplay } from '../../services/home-delegate';
|
||||
|
||||
/**
|
||||
* Page that displays the Home.
|
||||
*/
|
||||
@Component({
|
||||
selector: 'page-core-home',
|
||||
selector: 'page-core-mainmenu-home',
|
||||
templateUrl: 'home.html',
|
||||
styleUrls: ['home.scss'],
|
||||
})
|
||||
export class CoreHomePage implements OnInit {
|
||||
export class CoreMainMenuHomePage implements OnInit {
|
||||
|
||||
@ViewChild(CoreTabsComponent) tabsComponent?: CoreTabsComponent;
|
||||
|
||||
|
||||
siteName!: string;
|
||||
tabs: CoreHomeHandlerToDisplay[] = [];
|
||||
tabs: CoreMainMenuHomeHandlerToDisplay[] = [];
|
||||
loaded = false;
|
||||
selectedTab?: number;
|
||||
|
||||
protected subscription?: Subscription;
|
||||
protected updateSiteObserver?: CoreEventObserver;
|
||||
|
||||
constructor(
|
||||
protected homeDelegate: CoreHomeDelegate,
|
||||
) {
|
||||
this.loadSiteName();
|
||||
}
|
||||
constructor(protected homeDelegate: CoreMainMenuHomeDelegate) {}
|
||||
|
||||
/**
|
||||
* Initialize the component.
|
||||
*/
|
||||
ngOnInit(): void {
|
||||
this.loadSiteName();
|
||||
|
||||
this.subscription = this.homeDelegate.getHandlersObservable().subscribe((handlers) => {
|
||||
handlers && this.initHandlers(handlers);
|
||||
});
|
||||
|
@ -64,10 +61,10 @@ export class CoreHomePage implements OnInit {
|
|||
/**
|
||||
* Init handlers on change (size or handlers).
|
||||
*/
|
||||
initHandlers(handlers: CoreHomeHandlerToDisplay[]): void {
|
||||
initHandlers(handlers: CoreMainMenuHomeHandlerToDisplay[]): void {
|
||||
// Re-build the list of tabs. If a handler is already in the list, use existing object to prevent re-creating the tab.
|
||||
const newTabs: CoreHomeHandlerToDisplay[] = handlers.map((handler) => {
|
||||
handler.page = '/home/' + handler.page;
|
||||
const newTabs: CoreMainMenuHomeHandlerToDisplay[] = handlers.map((handler) => {
|
||||
handler.page = '/main/home/' + handler.page;
|
||||
|
||||
// Check if the handler is already in the tabs list. If so, use it.
|
||||
const tab = this.tabs.find((tab) => tab.title == handler.title);
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
// (C) Copyright 2015 Moodle Pty Ltd.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
import { InjectionToken, ModuleWithProviders, NgModule } from '@angular/core';
|
||||
|
||||
import { ModuleRoutes } from '@/app/app-routing.module';
|
||||
|
||||
export const MAIN_MENU_MORE_ROUTES = new InjectionToken('MAIN_MENU_MORE_ROUTES');
|
||||
|
||||
@NgModule()
|
||||
export class CoreMainMenuMoreRoutingModule {
|
||||
|
||||
static forChild(routes: Partial<ModuleRoutes>): ModuleWithProviders<CoreMainMenuMoreRoutingModule> {
|
||||
return {
|
||||
ngModule: CoreMainMenuMoreRoutingModule,
|
||||
providers: [
|
||||
{ provide: MAIN_MENU_MORE_ROUTES, multi: true, useValue: routes },
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
// (C) Copyright 2015 Moodle Pty Ltd.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
import { Injector, NgModule } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { RouterModule, ROUTES, Routes } from '@angular/router';
|
||||
import { IonicModule } from '@ionic/angular';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
|
||||
import { resolveModuleRoutes } from '@/app/app-routing.module';
|
||||
import { CoreComponentsModule } from '@components/components.module';
|
||||
import { CoreDirectivesModule } from '@directives/directives.module';
|
||||
|
||||
import { CoreMainMenuMorePage } from './more';
|
||||
import { MAIN_MENU_MORE_ROUTES } from './more-routing.module';
|
||||
|
||||
function buildRoutes(injector: Injector): Routes {
|
||||
const routes = resolveModuleRoutes(injector, MAIN_MENU_MORE_ROUTES);
|
||||
|
||||
return [
|
||||
{
|
||||
path: '',
|
||||
component: CoreMainMenuMorePage,
|
||||
children: routes.children,
|
||||
},
|
||||
...routes.siblings,
|
||||
];
|
||||
}
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonModule,
|
||||
IonicModule,
|
||||
TranslateModule.forChild(),
|
||||
CoreComponentsModule,
|
||||
CoreDirectivesModule,
|
||||
],
|
||||
providers: [
|
||||
{ provide: ROUTES, multi: true, useFactory: buildRoutes, deps: [Injector] },
|
||||
],
|
||||
declarations: [
|
||||
CoreMainMenuMorePage,
|
||||
],
|
||||
exports: [
|
||||
RouterModule,
|
||||
],
|
||||
})
|
||||
export class CoreMainMenuMorePageModule {}
|
|
@ -18,10 +18,12 @@ import { CoreMainMenuHandler, CoreMainMenuHandlerData } from '../mainmenu-delega
|
|||
/**
|
||||
* Handler to add Home into main menu.
|
||||
*/
|
||||
Injectable();
|
||||
export class CoreHomeMainMenuHandler implements CoreMainMenuHandler {
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class CoreMainMenuHomeHandler implements CoreMainMenuHandler {
|
||||
|
||||
name = 'CoreHome';
|
||||
static readonly PAGE_NAME = 'home';
|
||||
|
||||
name = 'CoreMainMenuHome';
|
||||
priority = 1100;
|
||||
|
||||
/**
|
||||
|
@ -54,7 +56,7 @@ export class CoreHomeMainMenuHandler implements CoreMainMenuHandler {
|
|||
return {
|
||||
icon: 'fa-home',
|
||||
title: 'core.mainmenu.home',
|
||||
page: 'home',
|
||||
page: CoreMainMenuHomeHandler.PAGE_NAME,
|
||||
// @todo: subPage? The page can change due to core-tabs.
|
||||
class: 'core-home-handler',
|
||||
};
|
||||
|
|
|
@ -21,12 +21,12 @@ import { CoreSortedDelegate } from '@classes/delegate-sorted';
|
|||
/**
|
||||
* Interface that all home handlers must implement.
|
||||
*/
|
||||
export type CoreHomeHandler = CoreDelegateDisplayHandler<CoreHomeHandlerToDisplay>;
|
||||
export type CoreMainMenuHomeHandler = CoreDelegateDisplayHandler<CoreMainMenuHomeHandlerToDisplay>;
|
||||
|
||||
/**
|
||||
* Data needed to render a main menu handler. It's returned by the handler.
|
||||
*/
|
||||
export interface CoreHomeHandlerData {
|
||||
export interface CoreMainMenuHomeHandlerData {
|
||||
/**
|
||||
* Name of the page to load for the handler.
|
||||
*/
|
||||
|
@ -71,7 +71,7 @@ export interface CoreHomeHandlerData {
|
|||
/**
|
||||
* Data returned by the delegate for each handler.
|
||||
*/
|
||||
export interface CoreHomeHandlerToDisplay extends CoreDelegateToDisplay, CoreHomeHandlerData {
|
||||
export interface CoreMainMenuHomeHandlerToDisplay extends CoreDelegateToDisplay, CoreMainMenuHomeHandlerData {
|
||||
/**
|
||||
* Priority to select handler.
|
||||
*/
|
||||
|
@ -85,12 +85,12 @@ export interface CoreHomeHandlerToDisplay extends CoreDelegateToDisplay, CoreHom
|
|||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class CoreHomeDelegate extends CoreSortedDelegate<CoreHomeHandlerToDisplay, CoreHomeHandler> {
|
||||
export class CoreMainMenuHomeDelegate extends CoreSortedDelegate<CoreMainMenuHomeHandlerToDisplay, CoreMainMenuHomeHandler> {
|
||||
|
||||
protected featurePrefix = 'CoreHomeDelegate_';
|
||||
protected featurePrefix = 'CoreMainMenuHomeDelegate_';
|
||||
|
||||
constructor() {
|
||||
super('CoreHomeDelegate');
|
||||
super('CoreMainMenuHomeDelegate');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,48 +0,0 @@
|
|||
// (C) Copyright 2015 Moodle Pty Ltd.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
import { NgModule } from '@angular/core';
|
||||
import { Routes } from '@angular/router';
|
||||
|
||||
import { CoreMainMenuRoutingModule } from '@features/mainmenu/mainmenu-routing.module';
|
||||
|
||||
const routes: Routes = [
|
||||
{
|
||||
path: 'settings',
|
||||
loadChildren: () => import('@features/settings/settings.module').then(m => m.CoreSettingsModule),
|
||||
},
|
||||
{
|
||||
path: 'preferences',
|
||||
loadChildren: () => import('@features/settings/pages/site/site.module').then(m => m.CoreSitePreferencesPageModule),
|
||||
},
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
CoreMainMenuRoutingModule.forChild(routes),
|
||||
],
|
||||
exports: [
|
||||
CoreMainMenuRoutingModule,
|
||||
],
|
||||
providers: [
|
||||
],
|
||||
})
|
||||
export class CoreSettingsInitModule {
|
||||
|
||||
constructor() {
|
||||
// @todo
|
||||
// settingsHelper.initDomSettings();
|
||||
}
|
||||
|
||||
}
|
|
@ -26,14 +26,12 @@ const routes: Routes = [
|
|||
},
|
||||
{
|
||||
path: 'spaceusage',
|
||||
loadChildren: () =>
|
||||
import('@features/settings/pages/space-usage/space-usage.module')
|
||||
.then(m => m.CoreSettingsSpaceUsagePageModule),
|
||||
loadChildren: () => import('./pages/space-usage/space-usage.module').then(m => m.CoreSettingsSpaceUsagePageModule),
|
||||
},
|
||||
{
|
||||
path: 'sync',
|
||||
loadChildren: () =>
|
||||
import('@features/settings/pages/synchronization/synchronization.module')
|
||||
import('./pages/synchronization/synchronization.module')
|
||||
.then(m => m.CoreSettingsSynchronizationPageModule),
|
||||
},
|
||||
{
|
||||
|
@ -44,6 +42,5 @@ const routes: Routes = [
|
|||
|
||||
@NgModule({
|
||||
imports: [RouterModule.forChild(routes)],
|
||||
exports: [RouterModule],
|
||||
})
|
||||
export class CoreSettingsRoutingModule {}
|
||||
export class CoreSettingsLazyModule {}
|
|
@ -12,13 +12,44 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
import { NgModule } from '@angular/core';
|
||||
import { APP_INITIALIZER, NgModule } from '@angular/core';
|
||||
import { Routes } from '@angular/router';
|
||||
|
||||
import { CoreSettingsRoutingModule } from './settings-routing.module';
|
||||
import { AppRoutingModule } from '@/app/app-routing.module';
|
||||
import { CoreMainMenuMoreRoutingModule } from '@features/mainmenu/pages/more/more-routing.module';
|
||||
|
||||
import { CoreSettingsHelperProvider } from './services/settings-helper';
|
||||
|
||||
const appRoutes: Routes = [
|
||||
{
|
||||
path: 'settings',
|
||||
loadChildren: () => import('./settings-lazy.module').then(m => m.CoreSettingsLazyModule),
|
||||
},
|
||||
];
|
||||
|
||||
const mainMenuMoreRoutes: Routes = [
|
||||
{
|
||||
path: 'settings',
|
||||
loadChildren: () => import('./settings-lazy.module').then(m => m.CoreSettingsLazyModule),
|
||||
},
|
||||
{
|
||||
path: 'preferences',
|
||||
loadChildren: () => import('./pages/site/site.module').then(m => m.CoreSitePreferencesPageModule),
|
||||
},
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
CoreSettingsRoutingModule,
|
||||
AppRoutingModule.forChild(appRoutes),
|
||||
CoreMainMenuMoreRoutingModule.forChild({ siblings: mainMenuMoreRoutes }),
|
||||
],
|
||||
providers: [
|
||||
{
|
||||
provide: APP_INITIALIZER,
|
||||
multi: true,
|
||||
deps: [CoreSettingsHelperProvider],
|
||||
useFactory: (helper: CoreSettingsHelperProvider) => () => helper.initDomSettings(),
|
||||
},
|
||||
],
|
||||
})
|
||||
export class CoreSettingsModule {}
|
||||
|
|
|
@ -201,7 +201,7 @@ export class CoreSiteHomeIndexPage implements OnInit, OnDestroy {
|
|||
* Go to search courses.
|
||||
*/
|
||||
openSearch(): void {
|
||||
this.navCtrl.navigateForward(['/courses/search']);
|
||||
this.navCtrl.navigateForward(['/main/home/courses/search']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -14,14 +14,16 @@
|
|||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { CoreSites } from '@services/sites';
|
||||
import { CoreHomeHandler, CoreHomeHandlerToDisplay } from '@features/mainmenu/services/home-delegate';
|
||||
import { CoreMainMenuHomeHandler, CoreMainMenuHomeHandlerToDisplay } from '@features/mainmenu/services/home-delegate';
|
||||
import { CoreSiteHome } from '../sitehome';
|
||||
|
||||
/**
|
||||
* Handler to add site home into home page.
|
||||
*/
|
||||
Injectable();
|
||||
export class CoreSiteHomeHomeHandler implements CoreHomeHandler {
|
||||
export class CoreSiteHomeHomeHandler implements CoreMainMenuHomeHandler {
|
||||
|
||||
static readonly PAGE_NAME = 'site';
|
||||
|
||||
name = 'CoreSiteHomeDashboard';
|
||||
priority = 1200;
|
||||
|
@ -50,13 +52,13 @@ export class CoreSiteHomeHomeHandler implements CoreHomeHandler {
|
|||
*
|
||||
* @return Data needed to render the handler.
|
||||
*/
|
||||
getDisplayData(): CoreHomeHandlerToDisplay {
|
||||
getDisplayData(): CoreMainMenuHomeHandlerToDisplay {
|
||||
const site = CoreSites.instance.getCurrentSite();
|
||||
const displaySiteHome = site?.getInfo() && site?.getInfo()?.userhomepage === 0;
|
||||
|
||||
return {
|
||||
title: 'core.sitehome.sitehome',
|
||||
page: 'sitehome',
|
||||
page: CoreSiteHomeHomeHandler.PAGE_NAME,
|
||||
class: 'core-sitehome-dashboard-handler',
|
||||
icon: 'fas-home',
|
||||
selectPriority: displaySiteHome ? 1100 : 900,
|
||||
|
|
|
@ -18,36 +18,34 @@ import { Routes } from '@angular/router';
|
|||
import { CoreSiteHomeIndexLinkHandler } from './services/handlers/index-link';
|
||||
import { CoreContentLinksDelegate } from '@features/contentlinks/services/contentlinks-delegate';
|
||||
import { CoreSiteHomeHomeHandler } from './services/handlers/sitehome-home';
|
||||
import { CoreHomeDelegate } from '@features/mainmenu/services/home-delegate';
|
||||
import { CoreHomeRoutingModule } from '@features/mainmenu/pages/home/home-routing.module';
|
||||
import { CoreMainMenuHomeDelegate } from '@features/mainmenu/services/home-delegate';
|
||||
import { CoreMainMenuHomeRoutingModule } from '@features/mainmenu/pages/home/home-routing.module';
|
||||
|
||||
const routes: Routes = [
|
||||
const mainMenuHomeRoutes: Routes = [
|
||||
{
|
||||
path: 'sitehome',
|
||||
loadChildren: () =>
|
||||
import('@features/sitehome/pages/index/index.module').then(m => m.CoreSiteHomeIndexPageModule),
|
||||
path: CoreSiteHomeHomeHandler.PAGE_NAME,
|
||||
loadChildren: () => import('./pages/index/index.module').then(m => m.CoreSiteHomeIndexPageModule),
|
||||
},
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
imports: [CoreHomeRoutingModule.forChild(routes)],
|
||||
exports: [CoreHomeRoutingModule],
|
||||
imports: [CoreMainMenuHomeRoutingModule.forChild({ children: mainMenuHomeRoutes })],
|
||||
exports: [CoreMainMenuHomeRoutingModule],
|
||||
providers: [
|
||||
CoreSiteHomeIndexLinkHandler,
|
||||
CoreSiteHomeHomeHandler,
|
||||
],
|
||||
})
|
||||
export class CoreSiteHomeInitModule {
|
||||
export class CoreSiteHomeModule {
|
||||
|
||||
constructor(
|
||||
contentLinksDelegate: CoreContentLinksDelegate,
|
||||
homeDelegate: CoreHomeDelegate,
|
||||
homeDelegate: CoreMainMenuHomeDelegate,
|
||||
siteHomeIndexLinkHandler: CoreSiteHomeIndexLinkHandler,
|
||||
siteHomeDashboardHandler: CoreSiteHomeHomeHandler,
|
||||
) {
|
||||
contentLinksDelegate.registerHandler(siteHomeIndexLinkHandler);
|
||||
homeDelegate.registerHandler(siteHomeDashboardHandler);
|
||||
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue