MOBILE-4616 imscp: Move imscp constants to a file
parent
8236f1c38b
commit
70507ce604
|
@ -17,8 +17,9 @@ import { CoreCourseModuleMainResourceComponent } from '@features/course/classes/
|
|||
import { CoreCourseContentsPage } from '@features/course/pages/contents/contents';
|
||||
import { CoreCourse } from '@features/course/services/course';
|
||||
import { CoreNavigator } from '@services/navigator';
|
||||
import { AddonModImscpProvider, AddonModImscp, AddonModImscpTocItem } from '../../services/imscp';
|
||||
import { AddonModImscp, AddonModImscpTocItem } from '../../services/imscp';
|
||||
import { CoreUtils } from '@services/utils/utils';
|
||||
import { ADDON_MOD_IMSCP_COMPONENT } from '../../constants';
|
||||
|
||||
/**
|
||||
* Component that displays a IMSCP.
|
||||
|
@ -30,7 +31,7 @@ import { CoreUtils } from '@services/utils/utils';
|
|||
})
|
||||
export class AddonModImscpIndexComponent extends CoreCourseModuleMainResourceComponent implements OnInit {
|
||||
|
||||
component = AddonModImscpProvider.COMPONENT;
|
||||
component = ADDON_MOD_IMSCP_COMPONENT;
|
||||
pluginName = 'imscp';
|
||||
|
||||
items: AddonModImscpTocItem[] = [];
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
// (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.
|
||||
|
||||
export const ADDON_MOD_IMSCP_COMPONENT = 'mmaModImscp';
|
||||
export const ADDON_MOD_IMSCP_PAGE_NAME = 'mod_imscp';
|
|
@ -42,4 +42,4 @@ const routes: Routes = [
|
|||
AddonModImscpViewPage,
|
||||
],
|
||||
})
|
||||
export class AddonModImscpLazyModule {}
|
||||
export default class AddonModImscpLazyModule {}
|
||||
|
|
|
@ -21,14 +21,15 @@ import { CoreMainMenuTabRoutingModule } from '@features/mainmenu/mainmenu-tab-ro
|
|||
import { CorePluginFileDelegate } from '@services/plugin-file-delegate';
|
||||
import { AddonModImscpIndexLinkHandler } from './services/handlers/index-link';
|
||||
import { AddonModImscpListLinkHandler } from './services/handlers/list-link';
|
||||
import { AddonModImscpModuleHandler, AddonModImscpModuleHandlerService } from './services/handlers/module';
|
||||
import { AddonModImscpModuleHandler } from './services/handlers/module';
|
||||
import { AddonModImscpPluginFileHandler } from './services/handlers/pluginfile';
|
||||
import { AddonModImscpPrefetchHandler } from './services/handlers/prefetch';
|
||||
import { ADDON_MOD_IMSCP_PAGE_NAME } from './constants';
|
||||
|
||||
const routes: Routes = [
|
||||
{
|
||||
path: AddonModImscpModuleHandlerService.PAGE_NAME,
|
||||
loadChildren: () => import('./imscp-lazy.module').then(m => m.AddonModImscpLazyModule),
|
||||
path: ADDON_MOD_IMSCP_PAGE_NAME,
|
||||
loadChildren: () => import('./imscp-lazy.module'),
|
||||
},
|
||||
];
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@ import { CoreModuleHandlerBase } from '@features/course/classes/module-base-hand
|
|||
import { CoreCourseModuleHandler } from '@features/course/services/module-delegate';
|
||||
import { makeSingleton } from '@singletons';
|
||||
import { AddonModImscp } from '../imscp';
|
||||
import { ADDON_MOD_IMSCP_PAGE_NAME } from '../../constants';
|
||||
|
||||
/**
|
||||
* Handler to support IMSCP modules.
|
||||
|
@ -25,11 +26,9 @@ import { AddonModImscp } from '../imscp';
|
|||
@Injectable( { providedIn: 'root' })
|
||||
export class AddonModImscpModuleHandlerService extends CoreModuleHandlerBase implements CoreCourseModuleHandler {
|
||||
|
||||
static readonly PAGE_NAME = 'mod_imscp';
|
||||
|
||||
name = 'AddonModImscp';
|
||||
modName = 'imscp';
|
||||
protected pageName = AddonModImscpModuleHandlerService.PAGE_NAME;
|
||||
protected pageName = ADDON_MOD_IMSCP_PAGE_NAME;
|
||||
|
||||
supportedFeatures = {
|
||||
[CoreConstants.FEATURE_MOD_ARCHETYPE]: CoreConstants.MOD_ARCHETYPE_RESOURCE,
|
||||
|
|
|
@ -25,7 +25,8 @@ import { CoreSites, CoreSitesReadingStrategy } from '@services/sites';
|
|||
import { CoreUtils } from '@services/utils/utils';
|
||||
import { CoreWSFile } from '@services/ws';
|
||||
import { makeSingleton } from '@singletons';
|
||||
import { AddonModImscp, AddonModImscpProvider } from '../imscp';
|
||||
import { AddonModImscp } from '../imscp';
|
||||
import { ADDON_MOD_IMSCP_COMPONENT } from '../../constants';
|
||||
|
||||
/**
|
||||
* Handler to prefetch IMSCPs.
|
||||
|
@ -35,7 +36,7 @@ export class AddonModImscpPrefetchHandlerService extends CoreCourseResourcePrefe
|
|||
|
||||
name = 'AddonModImscp';
|
||||
modName = 'imscp';
|
||||
component = AddonModImscpProvider.COMPONENT;
|
||||
component = ADDON_MOD_IMSCP_COMPONENT;
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
|
|
|
@ -27,8 +27,7 @@ import { CoreWSExternalFile, CoreWSExternalWarning } from '@services/ws';
|
|||
import { makeSingleton, Translate } from '@singletons';
|
||||
import { CorePath } from '@singletons/path';
|
||||
import { CoreSiteWSPreSets } from '@classes/sites/authenticated-site';
|
||||
|
||||
const ROOT_CACHE_KEY = 'mmaModImscp:';
|
||||
import { ADDON_MOD_IMSCP_COMPONENT } from '../constants';
|
||||
|
||||
/**
|
||||
* Service that provides some features for IMSCP.
|
||||
|
@ -36,7 +35,7 @@ const ROOT_CACHE_KEY = 'mmaModImscp:';
|
|||
@Injectable( { providedIn: 'root' })
|
||||
export class AddonModImscpProvider {
|
||||
|
||||
static readonly COMPONENT = 'mmaModImscp';
|
||||
protected static readonly ROOT_CACHE_KEY = 'mmaModImscp:';
|
||||
|
||||
/**
|
||||
* Get the IMSCP toc as an array.
|
||||
|
@ -89,7 +88,7 @@ export class AddonModImscpProvider {
|
|||
* @returns Cache key.
|
||||
*/
|
||||
protected getImscpDataCacheKey(courseId: number): string {
|
||||
return ROOT_CACHE_KEY + 'imscp:' + courseId;
|
||||
return AddonModImscpProvider.ROOT_CACHE_KEY + 'imscp:' + courseId;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -116,7 +115,7 @@ export class AddonModImscpProvider {
|
|||
const preSets: CoreSiteWSPreSets = {
|
||||
cacheKey: this.getImscpDataCacheKey(courseId),
|
||||
updateFrequency: CoreSite.FREQUENCY_RARELY,
|
||||
component: AddonModImscpProvider.COMPONENT,
|
||||
component: ADDON_MOD_IMSCP_COMPONENT,
|
||||
...CoreSites.getReadingStrategyPreSets(options.readingStrategy),
|
||||
};
|
||||
|
||||
|
@ -207,7 +206,7 @@ export class AddonModImscpProvider {
|
|||
*/
|
||||
async getLastItemViewed(id: number, siteId?: string): Promise<string | undefined> {
|
||||
const site = await CoreSites.getSite(siteId);
|
||||
const entry = await site.getLastViewed(AddonModImscpProvider.COMPONENT, id);
|
||||
const entry = await site.getLastViewed(ADDON_MOD_IMSCP_COMPONENT, id);
|
||||
|
||||
return entry?.value;
|
||||
}
|
||||
|
@ -226,7 +225,7 @@ export class AddonModImscpProvider {
|
|||
const promises: Promise<void>[] = [];
|
||||
|
||||
promises.push(this.invalidateImscpData(courseId, siteId));
|
||||
promises.push(CoreFilepool.invalidateFilesByComponent(siteId, AddonModImscpProvider.COMPONENT, moduleId));
|
||||
promises.push(CoreFilepool.invalidateFilesByComponent(siteId, ADDON_MOD_IMSCP_COMPONENT, moduleId));
|
||||
promises.push(CoreCourse.invalidateModule(moduleId, siteId));
|
||||
|
||||
await CoreUtils.allPromises(promises);
|
||||
|
@ -283,7 +282,7 @@ export class AddonModImscpProvider {
|
|||
await CoreCourseLogHelper.log(
|
||||
'mod_imscp_view_imscp',
|
||||
params,
|
||||
AddonModImscpProvider.COMPONENT,
|
||||
ADDON_MOD_IMSCP_COMPONENT,
|
||||
id,
|
||||
siteId,
|
||||
);
|
||||
|
@ -301,7 +300,7 @@ export class AddonModImscpProvider {
|
|||
async storeLastItemViewed(id: number, href: string, courseId: number, siteId?: string): Promise<void> {
|
||||
const site = await CoreSites.getSite(siteId);
|
||||
|
||||
await site.storeLastViewed(AddonModImscpProvider.COMPONENT, id, href, { data: String(courseId) });
|
||||
await site.storeLastViewed(ADDON_MOD_IMSCP_COMPONENT, id, href, { data: String(courseId) });
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue