2020-11-12 09:43:34 +01:00
|
|
|
// (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.
|
|
|
|
|
2021-02-23 12:09:51 +01:00
|
|
|
import { Injector, NgModule } from '@angular/core';
|
|
|
|
import { RouterModule, ROUTES, Routes } from '@angular/router';
|
2020-11-12 09:43:34 +01:00
|
|
|
|
2021-01-12 15:36:18 +01:00
|
|
|
import { CoreSharedModule } from '@/core/shared.module';
|
2023-01-25 11:08:36 +01:00
|
|
|
import { conditionalRoutes } from '@/app/app-routing.module';
|
2021-02-23 12:09:51 +01:00
|
|
|
import { CoreScreen } from '@services/screen';
|
2023-01-25 11:08:36 +01:00
|
|
|
import { CoreSitePreferencesPage } from '@features/settings/pages/site/site';
|
|
|
|
import { resolveSiteRoutes } from '@features/settings/settings-site-routing.module';
|
2020-11-12 09:43:34 +01:00
|
|
|
|
2023-01-25 11:08:36 +01:00
|
|
|
/**
|
|
|
|
* Build module routes.
|
|
|
|
*
|
|
|
|
* @param injector Injector.
|
|
|
|
* @returns Routes.
|
|
|
|
*/
|
2021-02-23 12:09:51 +01:00
|
|
|
function buildRoutes(injector: Injector): Routes {
|
2023-01-25 11:08:36 +01:00
|
|
|
const routes = resolveSiteRoutes(injector);
|
2021-02-23 12:09:51 +01:00
|
|
|
const mobileRoutes: Routes = [
|
|
|
|
{
|
|
|
|
path: '',
|
|
|
|
component: CoreSitePreferencesPage,
|
|
|
|
},
|
|
|
|
...routes.siblings,
|
|
|
|
];
|
|
|
|
const tabletRoutes: Routes = [
|
|
|
|
{
|
|
|
|
path: '',
|
|
|
|
component: CoreSitePreferencesPage,
|
|
|
|
children: routes.siblings,
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
return [
|
2021-02-23 15:29:17 +01:00
|
|
|
...conditionalRoutes(mobileRoutes, () => CoreScreen.isMobile),
|
|
|
|
...conditionalRoutes(tabletRoutes, () => CoreScreen.isTablet),
|
2021-02-23 12:09:51 +01:00
|
|
|
];
|
|
|
|
}
|
2020-11-12 09:43:34 +01:00
|
|
|
|
|
|
|
@NgModule({
|
2021-02-23 12:09:51 +01:00
|
|
|
providers: [
|
|
|
|
{ provide: ROUTES, multi: true, useFactory: buildRoutes, deps: [Injector] },
|
|
|
|
],
|
2020-11-12 09:43:34 +01:00
|
|
|
declarations: [
|
|
|
|
CoreSitePreferencesPage,
|
|
|
|
],
|
|
|
|
imports: [
|
2021-01-12 15:36:18 +01:00
|
|
|
CoreSharedModule,
|
2020-11-12 09:43:34 +01:00
|
|
|
],
|
2021-02-23 12:09:51 +01:00
|
|
|
exports: [RouterModule],
|
2020-11-12 09:43:34 +01:00
|
|
|
})
|
2023-01-25 11:08:36 +01:00
|
|
|
export class CoreettingsSiteLazyModule {}
|