|
|
@ -31,7 +31,7 @@ import { forkJoin, from, Observable, ReplaySubject, throwError } from 'rxjs'; |
|
|
import { HttpClient } from '@angular/common/http'; |
|
|
import { HttpClient } from '@angular/common/http'; |
|
|
import { IModulesMap } from '@modules/common/modules-map.models'; |
|
|
import { IModulesMap } from '@modules/common/modules-map.models'; |
|
|
import { TbResourceId } from '@shared/models/id/tb-resource-id'; |
|
|
import { TbResourceId } from '@shared/models/id/tb-resource-id'; |
|
|
import { isObject } from '@core/utils'; |
|
|
import { camelCase, isObject } from '@core/utils'; |
|
|
import { AuthService } from '@core/auth/auth.service'; |
|
|
import { AuthService } from '@core/auth/auth.service'; |
|
|
import { select, Store } from '@ngrx/store'; |
|
|
import { select, Store } from '@ngrx/store'; |
|
|
import { selectIsAuthenticated } from '@core/auth/auth.selectors'; |
|
|
import { selectIsAuthenticated } from '@core/auth/auth.selectors'; |
|
|
@ -51,6 +51,8 @@ export interface ModulesWithComponents { |
|
|
standaloneComponents: ɵComponentDef<any>[]; |
|
|
standaloneComponents: ɵComponentDef<any>[]; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
export type ComponentsSelectorMap = Record<string, Type<any>>; |
|
|
|
|
|
|
|
|
export const flatModulesWithComponents = (modulesWithComponentsList: ModulesWithComponents[]): ModulesWithComponents => { |
|
|
export const flatModulesWithComponents = (modulesWithComponentsList: ModulesWithComponents[]): ModulesWithComponents => { |
|
|
const modulesWithComponents: ModulesWithComponents = { |
|
|
const modulesWithComponents: ModulesWithComponents = { |
|
|
modules: [], |
|
|
modules: [], |
|
|
@ -91,6 +93,17 @@ export const componentTypeBySelector = (modulesWithComponents: ModulesWithCompon |
|
|
const matchesSelector = (selectors: ɵCssSelectorList, selector: string) => |
|
|
const matchesSelector = (selectors: ɵCssSelectorList, selector: string) => |
|
|
selectors.some(s => s.some(s1 => typeof s1 === 'string' && s1 === selector)); |
|
|
selectors.some(s => s.some(s1 => typeof s1 === 'string' && s1 === selector)); |
|
|
|
|
|
|
|
|
|
|
|
const extractSelectorFromComponent = (comp: ɵComponentDef<any>): string => { |
|
|
|
|
|
for (const selectors of comp.selectors) { |
|
|
|
|
|
for (const selector of selectors) { |
|
|
|
|
|
if (typeof selector === 'string') { |
|
|
|
|
|
return selector; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
return null; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
@Injectable({ |
|
|
@Injectable({ |
|
|
providedIn: 'root' |
|
|
providedIn: 'root' |
|
|
}) |
|
|
}) |
|
|
@ -252,6 +265,27 @@ export class ResourcesService { |
|
|
); |
|
|
); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public extractComponentsFromModule(module: any, isCamelCaseSelector = false): ComponentsSelectorMap { |
|
|
|
|
|
const modulesWithComponents = this.extractModulesWithComponents(module); |
|
|
|
|
|
const componentMap = {}; |
|
|
|
|
|
|
|
|
|
|
|
const processComponents = (components: Array<ɵComponentDef<any>>) => { |
|
|
|
|
|
components.forEach(item => { |
|
|
|
|
|
let selector = extractSelectorFromComponent(item); |
|
|
|
|
|
if (isCamelCaseSelector) { |
|
|
|
|
|
selector = camelCase(selector); |
|
|
|
|
|
} |
|
|
|
|
|
componentMap[selector] = item.type; |
|
|
|
|
|
}); |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
processComponents(modulesWithComponents.standaloneComponents); |
|
|
|
|
|
|
|
|
|
|
|
modulesWithComponents.modules.forEach(module => { |
|
|
|
|
|
processComponents(module.components); |
|
|
|
|
|
}) |
|
|
|
|
|
return componentMap; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
private extractModulesWithComponents(module: any, |
|
|
private extractModulesWithComponents(module: any, |
|
|
modulesWithComponents: ModulesWithComponents = { |
|
|
modulesWithComponents: ModulesWithComponents = { |
|
|
@ -284,7 +318,7 @@ export class ResourcesService { |
|
|
modulesWithComponents.standaloneComponents.push(component); |
|
|
modulesWithComponents.standaloneComponents.push(component); |
|
|
} |
|
|
} |
|
|
} else { |
|
|
} else { |
|
|
this.extractModulesWithComponents(module, modulesWithComponents, visitedModules); |
|
|
this.extractModulesWithComponents(element, modulesWithComponents, visitedModules); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} else if (ɵNG_COMP_DEF in module) { |
|
|
} else if (ɵNG_COMP_DEF in module) { |
|
|
|