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