2020-12-14 14:50:37 +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-03-01 16:12:38 +01:00
|
|
|
import { APP_INITIALIZER, NgModule, Type } from '@angular/core';
|
2020-12-14 14:50:37 +01:00
|
|
|
import { Routes } from '@angular/router';
|
|
|
|
import { CoreMainMenuRoutingModule } from '@features/mainmenu/mainmenu-routing.module';
|
|
|
|
|
|
|
|
import { CoreMainMenuDelegate } from '@features/mainmenu/services/mainmenu-delegate';
|
|
|
|
import { CoreCronDelegate } from '@services/cron';
|
|
|
|
import { CoreContentLinksDelegate } from '@features/contentlinks/services/contentlinks-delegate';
|
|
|
|
import { AddonCalendarViewLinkHandler } from './services/handlers/view-link';
|
|
|
|
import { AddonCalendarMainMenuHandler, AddonCalendarMainMenuHandlerService } from './services/handlers/mainmenu';
|
|
|
|
import { AddonCalendarSyncCronHandler } from './services/handlers/sync-cron';
|
|
|
|
|
|
|
|
import { CORE_SITE_SCHEMAS } from '@services/sites';
|
|
|
|
import { CALENDAR_SITE_SCHEMA } from './services/database/calendar';
|
|
|
|
import { CALENDAR_OFFLINE_SITE_SCHEMA } from './services/database/calendar-offline';
|
|
|
|
import { AddonCalendarComponentsModule } from './components/components.module';
|
2021-03-01 16:12:38 +01:00
|
|
|
import { AddonCalendar, AddonCalendarProvider } from './services/calendar';
|
2021-02-09 11:35:36 +01:00
|
|
|
import { CoreMainMenuTabRoutingModule } from '@features/mainmenu/mainmenu-tab-routing.module';
|
2021-03-01 16:12:38 +01:00
|
|
|
import { AddonCalendarOfflineProvider } from './services/calendar-offline';
|
|
|
|
import { AddonCalendarHelperProvider } from './services/calendar-helper';
|
|
|
|
import { AddonCalendarSyncProvider } from './services/calendar-sync';
|
|
|
|
|
|
|
|
export const ADDON_CALENDAR_SERVICES: Type<unknown>[] = [
|
|
|
|
AddonCalendarProvider,
|
|
|
|
AddonCalendarOfflineProvider,
|
|
|
|
AddonCalendarHelperProvider,
|
|
|
|
AddonCalendarSyncProvider,
|
|
|
|
];
|
2020-12-14 14:50:37 +01:00
|
|
|
|
|
|
|
const mainMenuChildrenRoutes: Routes = [
|
|
|
|
{
|
|
|
|
path: AddonCalendarMainMenuHandlerService.PAGE_NAME,
|
|
|
|
loadChildren: () => import('./calendar-lazy.module').then(m => m.AddonCalendarLazyModule),
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
@NgModule({
|
|
|
|
imports: [
|
2021-02-09 11:35:36 +01:00
|
|
|
CoreMainMenuTabRoutingModule.forChild(mainMenuChildrenRoutes),
|
2020-12-14 14:50:37 +01:00
|
|
|
CoreMainMenuRoutingModule.forChild({ children: mainMenuChildrenRoutes }),
|
|
|
|
AddonCalendarComponentsModule,
|
|
|
|
],
|
|
|
|
exports: [CoreMainMenuRoutingModule],
|
|
|
|
providers: [
|
|
|
|
{
|
|
|
|
provide: CORE_SITE_SCHEMAS,
|
|
|
|
useValue: [CALENDAR_SITE_SCHEMA, CALENDAR_OFFLINE_SITE_SCHEMA],
|
|
|
|
multi: true,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
provide: APP_INITIALIZER,
|
|
|
|
multi: true,
|
2021-08-12 14:03:13 +02:00
|
|
|
useValue: async () => {
|
2021-03-02 11:41:04 +01:00
|
|
|
CoreContentLinksDelegate.registerHandler(AddonCalendarViewLinkHandler.instance);
|
|
|
|
CoreMainMenuDelegate.registerHandler(AddonCalendarMainMenuHandler.instance);
|
|
|
|
CoreCronDelegate.register(AddonCalendarSyncCronHandler.instance);
|
2020-12-14 14:50:37 +01:00
|
|
|
|
2021-03-02 11:41:04 +01:00
|
|
|
await AddonCalendar.initialize();
|
2020-12-14 14:50:37 +01:00
|
|
|
|
2022-11-08 17:21:25 +01:00
|
|
|
AddonCalendar.updateAllSitesEventReminders();
|
2020-12-14 14:50:37 +01:00
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
})
|
|
|
|
export class AddonCalendarModule {}
|