Browse Source

Merge pull request #6372 from abpframework/feat/6347

Created abp module proxies and exported from @abp/ng.core
pull/6396/head
Mehmet Erim 6 years ago
committed by GitHub
parent
commit
f6ecd5d71e
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      npm/ng-packs/apps/dev-app/src/environments/environment.ts
  2. 33
      npm/ng-packs/packages/core/src/lib/models/application-configuration.ts
  3. 13
      npm/ng-packs/packages/core/src/lib/models/dtos.ts
  4. 14
      npm/ng-packs/packages/core/src/lib/models/find-tenant-result-dto.ts
  5. 1
      npm/ng-packs/packages/core/src/lib/models/index.ts
  6. 4
      npm/ng-packs/packages/core/src/lib/models/session.ts
  7. 29
      npm/ng-packs/packages/core/src/lib/proxy/pages/abp/multi-tenancy/abp-tenant.service.ts
  8. 21
      npm/ng-packs/packages/core/src/lib/proxy/volo/abp/asp-net-core/mvc/api-exploring/abp-api-definition.service.ts
  9. 19
      npm/ng-packs/packages/core/src/lib/proxy/volo/abp/asp-net-core/mvc/application-configurations/abp-application-configuration.service.ts
  10. 2
      npm/ng-packs/packages/core/src/lib/proxy/volo/abp/asp-net-core/mvc/application-configurations/models.ts
  11. 10
      npm/ng-packs/packages/core/src/lib/services/application-configuration.service.ts
  12. 10
      npm/ng-packs/packages/core/src/lib/services/config-state.service.ts
  13. 10
      npm/ng-packs/packages/core/src/lib/services/localization.service.ts
  14. 15
      npm/ng-packs/packages/core/src/lib/services/multi-tenancy.service.ts
  15. 10
      npm/ng-packs/packages/core/src/lib/services/permission.service.ts
  16. 4
      npm/ng-packs/packages/core/src/lib/services/session-state.service.ts
  17. 3
      npm/ng-packs/packages/core/src/lib/states/config.state.ts
  18. 3
      npm/ng-packs/packages/core/src/lib/strategies/auth-flow.strategy.ts
  19. 8
      npm/ng-packs/packages/core/src/lib/tests/config-state.service.spec.ts
  20. 8
      npm/ng-packs/packages/core/src/lib/tests/date-utils.spec.ts
  21. 9
      npm/ng-packs/packages/core/src/lib/tests/dynamic-layout.component.spec.ts
  22. 7
      npm/ng-packs/packages/core/src/lib/tests/environment-utils.spec.ts
  23. 12
      npm/ng-packs/packages/core/src/lib/tests/initial-utils.spec.ts
  24. 6
      npm/ng-packs/packages/core/src/lib/tests/localization-utils.spec.ts
  25. 17
      npm/ng-packs/packages/core/src/lib/tests/localization.service.spec.ts
  26. 21
      npm/ng-packs/packages/core/src/lib/tests/multi-tenancy-utils.spec.ts
  27. 7
      npm/ng-packs/packages/core/src/lib/utils/date-utils.ts
  28. 11
      npm/ng-packs/packages/core/src/lib/utils/initial-utils.ts
  29. 10
      npm/ng-packs/packages/core/src/lib/utils/localization-utils.ts
  30. 7
      npm/ng-packs/packages/core/src/lib/utils/multi-tenancy-utils.ts
  31. 8
      npm/ng-packs/packages/core/src/public-api.ts
  32. 10
      npm/ng-packs/packages/feature-management/src/lib/components/feature-management/feature-management.component.ts
  33. 14
      npm/ng-packs/packages/permission-management/src/lib/components/permission-management.component.ts
  34. 11
      npm/ng-packs/packages/theme-basic/src/lib/components/nav-items/current-user.component.ts
  35. 8
      npm/ng-packs/packages/theme-basic/src/lib/components/nav-items/languages.component.ts
  36. 7
      npm/ng-packs/packages/theme-shared/extensions/src/lib/utils/localization.util.ts
  37. 4
      npm/ng-packs/packages/theme-shared/extensions/src/lib/utils/state.util.ts
  38. 5
      npm/ng-packs/packages/theme-shared/extensions/src/tests/localization.util.spec.ts
  39. 11
      npm/ng-packs/packages/theme-shared/src/lib/handlers/error.handler.ts
  40. 6
      npm/ng-packs/packages/theme-shared/src/lib/models/confirmation.ts
  41. 10
      npm/ng-packs/packages/theme-shared/src/lib/models/toaster.ts
  42. 22
      npm/ng-packs/packages/theme-shared/src/lib/services/confirmation.service.ts
  43. 29
      npm/ng-packs/packages/theme-shared/src/lib/services/toaster.service.ts
  44. 4
      npm/ng-packs/packages/theme-shared/src/lib/utils/date-parser-formatter.ts
  45. 100
      templates/app/angular/yarn.lock

4
npm/ng-packs/apps/dev-app/src/environments/environment.ts

@ -1,4 +1,4 @@
import { Config } from '@abp/ng.core';
import { Environment } from '@abp/ng.core';
const baseUrl = 'http://localhost:4200';
@ -39,4 +39,4 @@ export const environment = {
rootNamespace: 'Volo.Abp',
},
},
} as Config.Environment;
} as Environment;

33
npm/ng-packs/packages/core/src/lib/models/application-configuration.ts

@ -1,6 +1,9 @@
import { ABP } from './common';
export namespace ApplicationConfiguration {
/**
* @deprecated Use the ApplicationConfigurationDto interface instead. To be deleted in v5.0.
*/
export interface Response {
localization: Localization;
auth: Auth;
@ -10,6 +13,9 @@ export namespace ApplicationConfiguration {
features: Value;
}
/**
* @deprecated Use the ApplicationLocalizationConfigurationDto interface instead. To be deleted in v5.0.
*/
export interface Localization {
currentCulture: CurrentCulture;
defaultResourceName: string;
@ -17,10 +23,16 @@ export namespace ApplicationConfiguration {
values: LocalizationValue;
}
/**
* @deprecated Use the Record<string, Record<string, string>> type instead. To be deleted in v5.0.
*/
export interface LocalizationValue {
[key: string]: { [key: string]: string };
}
/**
* @deprecated Use the LanguageInfo interface instead. To be deleted in v5.0.
*/
export interface Language {
cultureName: string;
uiCultureName: string;
@ -28,6 +40,9 @@ export namespace ApplicationConfiguration {
flagIcon: string;
}
/**
* @deprecated Use the CurrentCultureDto interface instead. To be deleted in v5.0.
*/
export interface CurrentCulture {
cultureName: string;
dateTimeFormat: DateTimeFormat;
@ -40,6 +55,9 @@ export namespace ApplicationConfiguration {
twoLetterIsoLanguageName: string;
}
/**
* @deprecated Use the DateTimeFormatDto interface instead. To be deleted in v5.0.
*/
export interface DateTimeFormat {
calendarAlgorithmType: string;
dateSeparator: string;
@ -49,19 +67,31 @@ export namespace ApplicationConfiguration {
shortTimePattern: string;
}
/**
* @deprecated Use the ApplicationAuthConfigurationDto interface instead. To be deleted in v5.0.
*/
export interface Auth {
policies: Policy;
grantedPolicies: Policy;
}
/**
* @deprecated Use the Record<string, boolean> type instead. To be deleted in v5.0.
*/
export interface Policy {
[key: string]: boolean;
}
/**
* @deprecated To be deleted in v5.0.
*/
export interface Value {
values: ABP.Dictionary<string>;
}
/**
* @deprecated Use the CurrentUserDto interface instead. To be deleted in v5.0.
*/
export interface CurrentUser {
email: string;
emailVerified: false;
@ -76,6 +106,9 @@ export namespace ApplicationConfiguration {
surName: string;
}
/**
* @deprecated Use the CurrentTenantDto interface instead. To be deleted in v5.0.
*/
export interface CurrentTenant {
id: string;
name: string;

13
npm/ng-packs/packages/core/src/lib/models/dtos.ts

@ -91,9 +91,10 @@ export class AuditedEntityDto<TPrimaryKey = string> extends CreationAuditedEntit
}
}
export class AuditedEntityWithUserDto<TUserDto, TPrimaryKey = string> extends AuditedEntityDto<
TPrimaryKey
> {
export class AuditedEntityWithUserDto<
TUserDto,
TPrimaryKey = string
> extends AuditedEntityDto<TPrimaryKey> {
creator?: TUserDto;
lastModifier?: TUserDto;
@ -145,9 +146,9 @@ export class ExtensibleEntityDto<TKey = string> extends ExtensibleObject {
}
}
export class ExtensibleCreationAuditedEntityDto<TPrimaryKey = string> extends ExtensibleEntityDto<
TPrimaryKey
> {
export class ExtensibleCreationAuditedEntityDto<
TPrimaryKey = string
> extends ExtensibleEntityDto<TPrimaryKey> {
creationTime: Date | string;
creatorId?: string;

14
npm/ng-packs/packages/core/src/lib/models/find-tenant-result-dto.ts

@ -1,14 +0,0 @@
export class FindTenantResultDto {
success: boolean;
tenantId?: string;
name: string;
constructor(initialValues: Partial<FindTenantResultDto> = {}) {
for (const key in initialValues) {
if (initialValues.hasOwnProperty(key)) {
this[key] = initialValues[key];
}
}
}
}

1
npm/ng-packs/packages/core/src/lib/models/index.ts

@ -3,7 +3,6 @@ export * from './common';
export * from './config';
export * from './dtos';
export * from './environment';
export * from './find-tenant-result-dto';
export * from './localization';
export * from './profile';
export * from './replaceable-components';

4
npm/ng-packs/packages/core/src/lib/models/session.ts

@ -1,9 +1,9 @@
import { ApplicationConfiguration } from './application-configuration';
import { CurrentTenantDto } from '../proxy/volo/abp/asp-net-core/mvc/multi-tenancy/models';
export namespace Session {
export interface State {
language: string;
tenant: ApplicationConfiguration.CurrentTenant;
tenant: CurrentTenantDto;
sessionDetail: SessionDetail;
}

29
npm/ng-packs/packages/core/src/lib/proxy/pages/abp/multi-tenancy/abp-tenant.service.ts

@ -1,5 +1,5 @@
import { RestService } from '@abp/ng.core';
import { Injectable } from '@angular/core';
import { RestService } from '../../../../services/rest.service';
import type { FindTenantResultDto } from '../../../volo/abp/asp-net-core/mvc/multi-tenancy/models';
@Injectable({
@ -9,18 +9,23 @@ export class AbpTenantService {
apiName = 'abp';
findTenantById = (id: string) =>
this.restService.request<any, FindTenantResultDto>({
method: 'GET',
url: `/api/abp/multi-tenancy/tenants/by-id/${id}`,
},
{ apiName: this.apiName });
this.restService.request<any, FindTenantResultDto>(
{
method: 'GET',
url: `/api/abp/multi-tenancy/tenants/by-id/${id}`,
},
{ apiName: this.apiName },
);
findTenantByName = (name: string) =>
this.restService.request<any, FindTenantResultDto>({
method: 'GET',
url: `/api/abp/multi-tenancy/tenants/by-name/${name}`,
},
{ apiName: this.apiName });
findTenantByName = (name: string, headers: Record<string, string>) =>
this.restService.request<any, FindTenantResultDto>(
{
method: 'GET',
url: `/api/abp/multi-tenancy/tenants/by-name/${name}`,
headers,
},
{ apiName: this.apiName },
);
constructor(private restService: RestService) {}
}

21
npm/ng-packs/packages/core/src/lib/proxy/volo/abp/asp-net-core/mvc/api-exploring/abp-api-definition.service.ts

@ -1,6 +1,9 @@
import { RestService } from '@abp/ng.core';
import { Injectable } from '@angular/core';
import type { ApplicationApiDescriptionModel, ApplicationApiDescriptionModelRequestDto } from '../../../http/modeling/models';
import { RestService } from '../../../../../../services/rest.service';
import type {
ApplicationApiDescriptionModel,
ApplicationApiDescriptionModelRequestDto,
} from '../../../http/modeling/models';
@Injectable({
providedIn: 'root',
@ -9,12 +12,14 @@ export class AbpApiDefinitionService {
apiName = 'abp';
getByModel = (model: ApplicationApiDescriptionModelRequestDto) =>
this.restService.request<any, ApplicationApiDescriptionModel>({
method: 'GET',
url: '/api/abp/api-definition',
params: { includeTypes: model.includeTypes },
},
{ apiName: this.apiName });
this.restService.request<any, ApplicationApiDescriptionModel>(
{
method: 'GET',
url: '/api/abp/api-definition',
params: { includeTypes: model.includeTypes },
},
{ apiName: this.apiName },
);
constructor(private restService: RestService) {}
}

19
npm/ng-packs/packages/core/src/lib/proxy/volo/abp/asp-net-core/mvc/application-configurations/abp-application-configuration.service.ts

@ -1,6 +1,6 @@
import type { ApplicationConfigurationDto } from './models';
import { RestService } from '@abp/ng.core';
import { Injectable } from '@angular/core';
import { RestService } from '../../../../../../services/rest.service';
import type { ApplicationConfigurationDto } from './models';
@Injectable({
providedIn: 'root',
@ -8,12 +8,15 @@ import { Injectable } from '@angular/core';
export class AbpApplicationConfigurationService {
apiName = 'abp';
get = () =>
this.restService.request<any, ApplicationConfigurationDto>({
method: 'GET',
url: '/api/abp/application-configuration',
},
{ apiName: this.apiName });
get() {
return this.restService.request<any, ApplicationConfigurationDto>(
{
method: 'GET',
url: '/api/abp/application-configuration',
},
{ apiName: this.apiName },
);
}
constructor(private restService: RestService) {}
}

2
npm/ng-packs/packages/core/src/lib/proxy/volo/abp/asp-net-core/mvc/application-configurations/models.ts

@ -26,7 +26,7 @@ export interface ApplicationFeatureConfigurationDto {
}
export interface ApplicationLocalizationConfigurationDto {
values: Record<string, Dictionary<string, string>>;
values: Record<string, Record<string, string>>;
languages: LanguageInfo[];
currentCulture: CurrentCultureDto;
defaultResourceName?: string;

10
npm/ng-packs/packages/core/src/lib/services/application-configuration.service.ts

@ -1,22 +1,24 @@
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { ApplicationConfiguration } from '../models/application-configuration';
import { Rest } from '../models/rest';
import { EnvironmentService } from './environment.service';
import { ApplicationConfigurationDto } from '../proxy/volo/abp/asp-net-core/mvc/application-configurations/models';
import { RestService } from './rest.service';
/**
* @deprecated Use AbpApplicationConfigurationService instead. To be deleted in v5.0.
*/
@Injectable({
providedIn: 'root',
})
export class ApplicationConfigurationService {
constructor(private rest: RestService) {}
getConfiguration(): Observable<ApplicationConfiguration.Response> {
getConfiguration(): Observable<ApplicationConfigurationDto> {
const request: Rest.Request<null> = {
method: 'GET',
url: '/api/abp/application-configuration',
};
return this.rest.request<null, ApplicationConfiguration.Response>(request, {});
return this.rest.request<null, ApplicationConfigurationDto>(request, {});
}
}

10
npm/ng-packs/packages/core/src/lib/services/config-state.service.ts

@ -1,20 +1,20 @@
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';
import { ApplicationConfiguration } from '../models/application-configuration';
import { ApplicationConfigurationDto } from '../proxy/volo/abp/asp-net-core/mvc/application-configurations/models';
import { InternalStore } from '../utils/internal-store-utils';
@Injectable({
providedIn: 'root',
})
export class ConfigStateService {
private readonly store = new InternalStore({} as ApplicationConfiguration.Response);
private readonly store = new InternalStore({} as ApplicationConfigurationDto);
get createOnUpdateStream() {
return this.store.sliceUpdate;
}
setState(state: ApplicationConfiguration.Response) {
setState(state: ApplicationConfigurationDto) {
this.store.set(state);
}
@ -26,11 +26,11 @@ export class ConfigStateService {
return this.store.state[key];
}
getAll$(): Observable<ApplicationConfiguration.Response> {
getAll$(): Observable<ApplicationConfigurationDto> {
return this.store.sliceState(state => state);
}
getAll(): ApplicationConfiguration.Response {
getAll(): ApplicationConfigurationDto {
return this.store.state;
}

10
npm/ng-packs/packages/core/src/lib/services/localization.service.ts

@ -3,13 +3,13 @@ import { Injectable, Injector, isDevMode, NgZone, Optional, SkipSelf } from '@an
import { Router } from '@angular/router';
import { noop, Observable, Subject } from 'rxjs';
import { filter, map, mapTo, switchMap, tap } from 'rxjs/operators';
import { ApplicationConfiguration } from '../models/application-configuration';
import { ABP } from '../models/common';
import { Config } from '../models/config';
import { AbpApplicationConfigurationService } from '../proxy/volo/abp/asp-net-core/mvc/application-configurations/abp-application-configuration.service';
import { ApplicationConfigurationDto } from '../proxy/volo/abp/asp-net-core/mvc/application-configurations/models';
import { CORE_OPTIONS } from '../tokens/options.token';
import { createLocalizer, createLocalizerWithFallback } from '../utils/localization-utils';
import { interpolate } from '../utils/string-utils';
import { ApplicationConfigurationService } from './application-configuration.service';
import { ConfigStateService } from './config-state.service';
import { SessionStateService } from './session-state.service';
@ -37,7 +37,7 @@ export class LocalizationService {
@SkipSelf()
otherInstance: LocalizationService,
private configState: ConfigStateService,
private appConfigService: ApplicationConfigurationService,
private appConfigService: AbpApplicationConfigurationService,
) {
if (otherInstance) throw new Error('LocalizationService should have only one instance.');
@ -53,7 +53,7 @@ export class LocalizationService {
),
switchMap(lang =>
this.appConfigService
.getConfiguration()
.get()
.pipe(tap(res => this.configState.setState(res)))
.pipe(mapTo(lang)),
),
@ -144,7 +144,7 @@ export class LocalizationService {
}
function getLocalization(
state: ApplicationConfiguration.Response,
state: ApplicationConfigurationDto,
key: string | Config.LocalizationWithDefault,
...interpolateParams: string[]
) {

15
npm/ng-packs/packages/core/src/lib/services/multi-tenancy.service.ts

@ -1,15 +1,18 @@
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { ABP } from '../models/common';
import { FindTenantResultDto } from '../models/find-tenant-result-dto';
import {
CurrentTenantDto,
FindTenantResultDto,
} from '../proxy/volo/abp/asp-net-core/mvc/multi-tenancy/models';
import { RestService } from './rest.service';
import { SessionStateService } from './session-state.service';
@Injectable({ providedIn: 'root' })
export class MultiTenancyService {
private _domainTenant: ABP.BasicItem = null;
private _domainTenant: CurrentTenantDto = null;
set domainTenant(value: ABP.BasicItem) {
set domainTenant(value: CurrentTenantDto) {
this._domainTenant = value;
this.sessionState.setTenant(value);
}
@ -24,6 +27,9 @@ export class MultiTenancyService {
constructor(private restService: RestService, private sessionState: SessionStateService) {}
/**
* @deprecated Use AbpTenantService.findTenantByName method instead. To be deleted in v5.0.
*/
findTenantByName(name: string, headers: ABP.Dictionary<string>): Observable<FindTenantResultDto> {
return this.restService.request(
{
@ -35,6 +41,9 @@ export class MultiTenancyService {
);
}
/**
* @deprecated Use AbpTenantService.findTenantById method instead. To be deleted in v5.0.
*/
findTenantById(id: string, headers: ABP.Dictionary<string>): Observable<FindTenantResultDto> {
return this.restService.request(
{ url: `/api/abp/multi-tenancy/tenants/by-id/${id}`, method: 'GET', headers },

10
npm/ng-packs/packages/core/src/lib/services/permission.service.ts

@ -1,7 +1,7 @@
import { Injectable } from '@angular/core';
import { map, tap } from 'rxjs/operators';
import { map } from 'rxjs/operators';
import snq from 'snq';
import { ApplicationConfiguration } from '../models/application-configuration';
import { ApplicationConfigurationDto } from '../proxy/volo/abp/asp-net-core/mvc/application-configurations/models';
import { ConfigStateService } from './config-state.service';
@Injectable({ providedIn: 'root' })
@ -19,7 +19,7 @@ export class PermissionService {
return this.isPolicyGranted(key, policies);
}
private isPolicyGranted(key: string, grantedPolicies: ApplicationConfiguration.Policy) {
private isPolicyGranted(key: string, grantedPolicies: Record<string, boolean>) {
if (!key) return true;
const orRegexp = /\|\|/g;
@ -51,11 +51,11 @@ export class PermissionService {
return this.mapToPolicies(this.configState.getAll());
}
private mapToPolicies(applicationConfiguration: ApplicationConfiguration.Response) {
private mapToPolicies(applicationConfiguration: ApplicationConfigurationDto) {
return snq(() => applicationConfiguration.auth.grantedPolicies);
}
private getPolicy(key: string, grantedPolicies: ApplicationConfiguration.Policy) {
private getPolicy(key: string, grantedPolicies: Record<string, boolean>) {
return snq(() => grantedPolicies[key], false);
}
}

4
npm/ng-packs/packages/core/src/lib/services/session-state.service.ts

@ -1,8 +1,8 @@
import { Injectable } from '@angular/core';
import compare from 'just-compare';
import { filter, take } from 'rxjs/operators';
import { ApplicationConfiguration } from '../models/application-configuration';
import { Session } from '../models/session';
import { CurrentTenantDto } from '../proxy/volo/abp/asp-net-core/mvc/multi-tenancy/models';
import { InternalStore } from '../utils/internal-store-utils';
import { ConfigStateService } from './config-state.service';
@ -78,7 +78,7 @@ export class SessionStateService {
return this.store.sliceState(state => state.tenant);
}
setTenant(tenant: ApplicationConfiguration.CurrentTenant) {
setTenant(tenant: CurrentTenantDto) {
if (compare(tenant, this.store.state.tenant)) return;
this.store.patch({ tenant });

3
npm/ng-packs/packages/core/src/lib/states/config.state.ts

@ -13,6 +13,7 @@ import { EnvironmentService } from '../services/environment.service';
import { SessionStateService } from '../services/session-state.service';
import { interpolate } from '../utils/string-utils';
import compare from 'just-compare';
import { ApplicationConfigurationDto } from '../proxy/volo/abp/asp-net-core/mvc/application-configurations/models';
/**
* @deprecated Use ConfigStateService instead. To be deleted in v5.0.
@ -245,7 +246,7 @@ export class ConfigState {
const apiName = 'default';
const api = this.store.selectSnapshot(ConfigState.getApiUrl(apiName));
return this.http
.get<ApplicationConfiguration.Response>(`${api}/api/abp/application-configuration`)
.get<ApplicationConfigurationDto>(`${api}/api/abp/application-configuration`)
.pipe(
tap(configuration => this.configState.setState(configuration)),
catchError((err: HttpErrorResponse) => {

3
npm/ng-packs/packages/core/src/lib/strategies/auth-flow.strategy.ts

@ -3,7 +3,6 @@ import { Store } from '@ngxs/store';
import { AuthConfig, OAuthService, OAuthStorage } from 'angular-oauth2-oidc';
import { Observable, of } from 'rxjs';
import { RestOccurError } from '../actions/rest.actions';
import { ApplicationConfigurationService } from '../services/application-configuration.service';
import { ConfigStateService } from '../services/config-state.service';
import { EnvironmentService } from '../services/environment.service';
@ -15,7 +14,6 @@ export abstract class AuthFlowStrategy {
protected store: Store;
protected environment: EnvironmentService;
protected configState: ConfigStateService;
protected appConfigService: ApplicationConfigurationService;
protected oAuthService: OAuthService;
protected oAuthConfig: AuthConfig;
abstract checkIfInternalAuth(): boolean;
@ -29,7 +27,6 @@ export abstract class AuthFlowStrategy {
this.store = injector.get(Store);
this.environment = injector.get(EnvironmentService);
this.configState = injector.get(ConfigStateService);
this.appConfigService = injector.get(ApplicationConfigurationService);
this.oAuthService = injector.get(OAuthService);
this.oAuthConfig = this.environment.getEnvironment().oAuthConfig;
}

8
npm/ng-packs/packages/core/src/lib/tests/config-state.service.spec.ts

@ -1,5 +1,9 @@
import { createServiceFactory, SpectatorService } from '@ngneat/spectator/jest';
import { ApplicationConfiguration } from '../models/application-configuration';
import {
ApplicationConfigurationDto,
CurrentUserDto,
} from '../proxy/volo/abp/asp-net-core/mvc/application-configurations/models';
import { ConfigStateService } from '../services';
export const CONFIG_STATE_DATA = ({
@ -86,14 +90,14 @@ export const CONFIG_STATE_DATA = ({
userName: null,
email: null,
roles: [],
} as ApplicationConfiguration.CurrentUser,
} as CurrentUserDto,
features: {
values: {
'Chat.Enable': 'True',
},
},
registerLocaleFn: () => Promise.resolve(),
} as any) as ApplicationConfiguration.Response;
} as any) as ApplicationConfigurationDto;
describe('ConfigState', () => {
let spectator: SpectatorService<ConfigStateService>;

8
npm/ng-packs/packages/core/src/lib/tests/date-utils.spec.ts

@ -1,9 +1,5 @@
import {
ConfigStateService,
getShortDateFormat,
getShortDateShortTimeFormat,
getShortTimeFormat,
} from '@abp/ng.core';
import { ConfigStateService } from '../services';
import { getShortDateFormat, getShortTimeFormat, getShortDateShortTimeFormat } from '../utils';
const dateTimeFormat = {
calendarAlgorithmType: 'SolarCalendar',

9
npm/ng-packs/packages/core/src/lib/tests/dynamic-layout.component.spec.ts

@ -5,11 +5,8 @@ import { createRoutingFactory, SpectatorRouting } from '@ngneat/spectator/jest';
import { DynamicLayoutComponent, RouterOutletComponent } from '../components';
import { eLayoutType } from '../enums/common';
import { ABP } from '../models';
import {
ApplicationConfigurationService,
ReplaceableComponentsService,
RoutesService,
} from '../services';
import { AbpApplicationConfigurationService } from '../proxy/volo/abp/asp-net-core/mvc/application-configurations/abp-application-configuration.service';
import { ReplaceableComponentsService, RoutesService } from '../services';
import { mockRoutesService } from './routes.service.spec';
@Component({
@ -85,7 +82,7 @@ describe('DynamicLayoutComponent', () => {
component: RouterOutletComponent,
stubsEnabled: false,
declarations: [DummyComponent, DynamicLayoutComponent],
mocks: [ApplicationConfigurationService, HttpClient],
mocks: [AbpApplicationConfigurationService, HttpClient],
providers: [
{
provide: RoutesService,

7
npm/ng-packs/packages/core/src/lib/tests/environment-utils.spec.ts

@ -1,9 +1,8 @@
import { HttpClient } from '@angular/common/http';
import { Component, Injector } from '@angular/core';
import { createComponentFactory, Spectator } from '@ngneat/spectator/jest';
import { BehaviorSubject, of } from 'rxjs';
import { Config } from '../models/config';
import { Environment } from '../models/environment';
import { BehaviorSubject } from 'rxjs';
import { Environment, RemoteEnv } from '../models/environment';
import { EnvironmentService } from '../services';
import { getRemoteEnv } from '../utils/environment-utils';
import { deepMerge } from '../utils/object-utils';
@ -76,7 +75,7 @@ describe('EnvironmentUtils', () => {
({ strategy, expected }) => setupTestAndRun({ mergeStrategy: strategy }, expected),
);
function setupTestAndRun(strategy: Pick<Config.RemoteEnv, 'mergeStrategy'>, expectedValue) {
function setupTestAndRun(strategy: Pick<RemoteEnv, 'mergeStrategy'>, expectedValue) {
const injector = spectator.inject(Injector);
const injectorSpy = jest.spyOn(injector, 'get');
const http = spectator.inject(HttpClient);

12
npm/ng-packs/packages/core/src/lib/tests/initial-utils.spec.ts

@ -2,9 +2,9 @@ import { Component, Injector } from '@angular/core';
import { createComponentFactory, Spectator } from '@ngneat/spectator/jest';
import { OAuthService } from 'angular-oauth2-oidc';
import { of } from 'rxjs';
import { ApplicationConfiguration } from '../models';
import { AbpApplicationConfigurationService } from '../proxy/volo/abp/asp-net-core/mvc/application-configurations/abp-application-configuration.service';
import { ApplicationConfigurationDto } from '../proxy/volo/abp/asp-net-core/mvc/application-configurations/models';
import {
ApplicationConfigurationService,
AuthService,
ConfigStateService,
EnvironmentService,
@ -31,7 +31,7 @@ describe('InitialUtils', () => {
mocks: [
EnvironmentService,
ConfigStateService,
ApplicationConfigurationService,
AbpApplicationConfigurationService,
AuthService,
OAuthService,
SessionStateService,
@ -54,7 +54,7 @@ describe('InitialUtils', () => {
const environmentService = spectator.inject(EnvironmentService);
const configStateService = spectator.inject(ConfigStateService);
const sessionStateService = spectator.inject(SessionStateService);
const applicationConfigurationService = spectator.inject(ApplicationConfigurationService);
const applicationConfigurationService = spectator.inject(AbpApplicationConfigurationService);
const parseTenantFromUrlSpy = jest.spyOn(multiTenancyUtils, 'parseTenantFromUrl');
const getRemoteEnvSpy = jest.spyOn(environmentUtils, 'getRemoteEnv');
parseTenantFromUrlSpy.mockReturnValue(Promise.resolve());
@ -62,9 +62,9 @@ describe('InitialUtils', () => {
const appConfigRes = {
currentTenant: { id: 'test', name: 'testing' },
} as ApplicationConfiguration.Response;
} as ApplicationConfigurationDto;
const getConfigurationSpy = jest.spyOn(applicationConfigurationService, 'getConfiguration');
const getConfigurationSpy = jest.spyOn(applicationConfigurationService, 'get');
getConfigurationSpy.mockReturnValue(of(appConfigRes));
const environmentSetStateSpy = jest.spyOn(environmentService, 'setState');

6
npm/ng-packs/packages/core/src/lib/tests/localization-utils.spec.ts

@ -55,6 +55,8 @@ describe('Localization Utils', () => {
defaultResourceName: 'x',
currentCulture: null,
languages: [],
languageFilesMap: null,
languagesMap: null,
});
test.each`
@ -96,6 +98,8 @@ describe('Localization Utils', () => {
defaultResourceName: 'x',
currentCulture: null,
languages: [],
languageFilesMap: null,
languagesMap: null,
});
test.each`
@ -142,6 +146,8 @@ describe('Localization Utils', () => {
defaultResourceName: 'x',
currentCulture: null,
languages: [],
languageFilesMap: null,
languagesMap: null,
});
test.each`

17
npm/ng-packs/packages/core/src/lib/tests/localization.service.spec.ts

@ -2,11 +2,8 @@ import { Injector } from '@angular/core';
import { Router } from '@angular/router';
import { createServiceFactory, SpectatorService, SpyObject } from '@ngneat/spectator/jest';
import { of } from 'rxjs';
import {
ApplicationConfigurationService,
ConfigStateService,
SessionStateService,
} from '../services';
import { AbpApplicationConfigurationService } from '../proxy/volo/abp/asp-net-core/mvc/application-configurations/abp-application-configuration.service';
import { ConfigStateService, SessionStateService } from '../services';
import { LocalizationService } from '../services/localization.service';
import { CORE_OPTIONS } from '../tokens/options.token';
import { CONFIG_STATE_DATA } from './config-state.service.spec';
@ -19,17 +16,20 @@ describe('LocalizationService', () => {
let configState: SpyObject<ConfigStateService>;
let router: SpyObject<Router>;
let service: LocalizationService;
let appConfigService: ApplicationConfigurationService;
const createService = createServiceFactory({
service: LocalizationService,
entryComponents: [],
mocks: [ApplicationConfigurationService, Router],
mocks: [Router],
providers: [
{
provide: CORE_OPTIONS,
useValue: { registerLocaleFn: () => Promise.resolve(), cultureNameLocaleFileMap: {} },
},
{
provide: AbpApplicationConfigurationService,
useValue: { get: () => of(CONFIG_STATE_DATA) },
},
],
});
@ -40,10 +40,7 @@ describe('LocalizationService', () => {
router = spectator.inject(Router);
router.routeReuseStrategy = { shouldReuseRoute } as any;
service = spectator.service;
appConfigService = spectator.inject(ApplicationConfigurationService);
const getConfigurationSpy = jest.spyOn(appConfigService, 'getConfiguration');
getConfigurationSpy.mockReturnValue(of(CONFIG_STATE_DATA));
configState.setState(CONFIG_STATE_DATA);
sessionState.setLanguage('tr');
});

21
npm/ng-packs/packages/core/src/lib/tests/multi-tenancy-utils.spec.ts

@ -2,9 +2,12 @@ import { Component } from '@angular/core';
import { createComponentFactory, Spectator } from '@ngneat/spectator/jest';
import clone from 'just-clone';
import { BehaviorSubject } from 'rxjs';
import { FindTenantResultDto } from '../models/find-tenant-result-dto';
import { EnvironmentService } from '../services';
import { MultiTenancyService } from '../services/multi-tenancy.service';
import { AbpTenantService } from '../proxy/pages/abp/multi-tenancy/abp-tenant.service';
import {
CurrentTenantDto,
FindTenantResultDto,
} from '../proxy/volo/abp/asp-net-core/mvc/multi-tenancy/models';
import { EnvironmentService, MultiTenancyService } from '../services';
import { parseTenantFromUrl } from '../utils';
const environment = {
@ -54,15 +57,17 @@ describe('MultiTenancyUtils', () => {
const createComponent = createComponentFactory({
component: DummyComponent,
mocks: [EnvironmentService, MultiTenancyService],
providers: [{ provide: AbpTenantService, useValue: { findTenantByName: () => {} } }],
});
beforeEach(() => (spectator = createComponent()));
describe('#parseTenantFromUrl', () => {
test('should get the tenancyName, set replaced environment and call the findTenantByName method of MultiTenancyService', async () => {
test('should get the tenancyName, set replaced environment and call the findTenantByName method of AbpTenantService', async () => {
const environmentService = spectator.inject(EnvironmentService);
const multiTenancyService = spectator.inject(MultiTenancyService);
const findTenantByNameSpy = jest.spyOn(multiTenancyService, 'findTenantByName');
const abpTenantService = spectator.inject(AbpTenantService);
const findTenantByNameSpy = jest.spyOn(abpTenantService, 'findTenantByName');
const getEnvironmentSpy = jest.spyOn(environmentService, 'getEnvironment');
const setStateSpy = jest.spyOn(environmentService, 'setState');
@ -77,6 +82,7 @@ describe('MultiTenancyUtils', () => {
const mockInjector = {
get: arg => {
if (arg === EnvironmentService) return environmentService;
if (arg === AbpTenantService) return abpTenantService;
if (arg === MultiTenancyService) return multiTenancyService;
},
};
@ -98,7 +104,10 @@ describe('MultiTenancyUtils', () => {
expect(setStateSpy).toHaveBeenCalledWith(replacedEnv);
expect(findTenantByNameSpy).toHaveBeenCalledWith('abp', { __tenant: '' });
expect(multiTenancyService.domainTenant).toEqual({ id: '1', name: 'abp' });
expect(multiTenancyService.domainTenant).toEqual({
id: '1',
name: 'abp',
} as CurrentTenantDto);
});
});
});

7
npm/ng-packs/packages/core/src/lib/utils/date-utils.ts

@ -1,10 +1,11 @@
import { ApplicationConfiguration } from '../models/application-configuration';
import { DateTimeFormatDto } from '../proxy/volo/abp/asp-net-core/mvc/application-configurations/models';
import { ConfigStateService } from '../services';
export function getShortDateFormat(configStateService: ConfigStateService) {
const dateTimeFormat = configStateService.getDeep(
'localization.currentCulture.dateTimeFormat',
) as ApplicationConfiguration.DateTimeFormat;
) as DateTimeFormatDto;
return dateTimeFormat.shortDatePattern;
}
@ -12,7 +13,7 @@ export function getShortDateFormat(configStateService: ConfigStateService) {
export function getShortTimeFormat(configStateService: ConfigStateService) {
const dateTimeFormat = configStateService.getDeep(
'localization.currentCulture.dateTimeFormat',
) as ApplicationConfiguration.DateTimeFormat;
) as DateTimeFormatDto;
return dateTimeFormat.shortTimePattern.replace('tt', 'a');
}
@ -20,7 +21,7 @@ export function getShortTimeFormat(configStateService: ConfigStateService) {
export function getShortDateShortTimeFormat(configStateService: ConfigStateService) {
const dateTimeFormat = configStateService.getDeep(
'localization.currentCulture.dateTimeFormat',
) as ApplicationConfiguration.DateTimeFormat;
) as DateTimeFormatDto;
return `${dateTimeFormat.shortDatePattern} ${dateTimeFormat.shortTimePattern.replace('tt', 'a')}`;
}

11
npm/ng-packs/packages/core/src/lib/utils/initial-utils.ts

@ -6,7 +6,8 @@ import { tap } from 'rxjs/operators';
import { ApplicationConfiguration } from '../models/application-configuration';
import { ABP } from '../models/common';
import { Environment } from '../models/environment';
import { ApplicationConfigurationService } from '../services/application-configuration.service';
import { AbpApplicationConfigurationService } from '../proxy/volo/abp/asp-net-core/mvc/application-configurations/abp-application-configuration.service';
import { CurrentTenantDto } from '../proxy/volo/abp/asp-net-core/mvc/multi-tenancy/models';
import { AuthService } from '../services/auth.service';
import { ConfigStateService } from '../services/config-state.service';
import { EnvironmentService } from '../services/environment.service';
@ -20,7 +21,7 @@ export function getInitialData(injector: Injector) {
const fn = async () => {
const environmentService = injector.get(EnvironmentService);
const configState = injector.get(ConfigStateService);
const appConfigService = injector.get(ApplicationConfigurationService);
const appConfigService = injector.get(AbpApplicationConfigurationService);
const options = injector.get(CORE_OPTIONS) as ABP.Root;
environmentService.setState(options.environment as Environment);
@ -31,14 +32,12 @@ export function getInitialData(injector: Injector) {
if (options.skipGetAppConfiguration) return;
return appConfigService
.getConfiguration()
.get()
.pipe(
tap(res => configState.setState(res)),
tap(() => checkAccessToken(injector)),
tap(() => {
const currentTenant = configState.getOne(
'currentTenant',
) as ApplicationConfiguration.CurrentTenant;
const currentTenant = configState.getOne('currentTenant') as CurrentTenantDto;
if (!currentTenant?.id) return;
injector.get(SessionStateService).setTenant(currentTenant);

10
npm/ng-packs/packages/core/src/lib/utils/localization-utils.ts

@ -1,4 +1,4 @@
import { ApplicationConfiguration } from '../models/application-configuration';
import { ApplicationLocalizationConfigurationDto } from '../proxy/volo/abp/asp-net-core/mvc/application-configurations/models';
// This will not be necessary when only Angukar 9.1+ is supported
export function getLocaleDirection(locale: string): 'ltr' | 'rtl' {
@ -9,7 +9,7 @@ export function getLocaleDirection(locale: string): 'ltr' | 'rtl' {
: 'ltr';
}
export function createLocalizer(localization: ApplicationConfiguration.Localization) {
export function createLocalizer(localization: ApplicationLocalizationConfigurationDto) {
return (resourceName: string, key: string, defaultValue: string) => {
if (resourceName === '_') return key;
@ -21,7 +21,7 @@ export function createLocalizer(localization: ApplicationConfiguration.Localizat
};
}
export function createLocalizerWithFallback(localization: ApplicationConfiguration.Localization) {
export function createLocalizerWithFallback(localization: ApplicationLocalizationConfigurationDto) {
const findLocalization = createLocalizationFinder(localization);
return (resourceNames: string[], keys: string[], defaultValue: string) => {
@ -31,7 +31,7 @@ export function createLocalizerWithFallback(localization: ApplicationConfigurati
}
export function createLocalizationPipeKeyGenerator(
localization: ApplicationConfiguration.Localization,
localization: ApplicationLocalizationConfigurationDto,
) {
const findLocalization = createLocalizationFinder(localization);
@ -41,7 +41,7 @@ export function createLocalizationPipeKeyGenerator(
};
}
function createLocalizationFinder(localization: ApplicationConfiguration.Localization) {
function createLocalizationFinder(localization: ApplicationLocalizationConfigurationDto) {
const localize = createLocalizer(localization);
return (resourceNames: string[], keys: string[]) => {

7
npm/ng-packs/packages/core/src/lib/utils/multi-tenancy-utils.ts

@ -3,6 +3,8 @@ import clone from 'just-clone';
import { of } from 'rxjs';
import { switchMap, tap } from 'rxjs/operators';
import { Environment } from '../models/environment';
import { AbpTenantService } from '../proxy/pages/abp/multi-tenancy/abp-tenant.service';
import { CurrentTenantDto } from '../proxy/volo/abp/asp-net-core/mvc/multi-tenancy/models';
import { EnvironmentService } from '../services/environment.service';
import { MultiTenancyService } from '../services/multi-tenancy.service';
import { createTokenParser } from './string-utils';
@ -20,6 +22,7 @@ function getCurrentTenancyName(appBaseUrl: string): string {
export async function parseTenantFromUrl(injector: Injector) {
const environmentService = injector.get(EnvironmentService);
const multiTenancyService = injector.get(MultiTenancyService);
const abpTenantService = injector.get(AbpTenantService);
const baseUrl = environmentService.getEnvironment()?.application?.baseUrl || '';
const tenancyName = getCurrentTenancyName(baseUrl);
@ -30,10 +33,10 @@ export async function parseTenantFromUrl(injector: Injector) {
return of(null)
.pipe(
switchMap(() => multiTenancyService.findTenantByName(tenancyName, { __tenant: '' })),
switchMap(() => abpTenantService.findTenantByName(tenancyName, { __tenant: '' })),
tap(res => {
multiTenancyService.domainTenant = res.success
? { id: res.tenantId, name: res.name }
? ({ id: res.tenantId, name: res.name } as CurrentTenantDto)
: null;
}),
)

8
npm/ng-packs/packages/core/src/public-api.ts

@ -21,3 +21,11 @@ export * from './lib/strategies';
export * from './lib/tokens';
export * from './lib/utils';
export * from './lib/validators';
export * from './lib/proxy/volo/abp/asp-net-core/mvc/api-exploring';
export * from './lib/proxy/volo/abp/asp-net-core/mvc/multi-tenancy';
export * from './lib/proxy/volo/abp/asp-net-core/mvc/application-configurations';
export * from './lib/proxy/volo/abp/asp-net-core/mvc/application-configurations/object-extending';
export * from './lib/proxy/volo/abp/http/modeling';
export * from './lib/proxy/volo/abp/models';
export * from './lib/proxy/volo/abp/localization';
export * from './lib/proxy/pages/abp/multi-tenancy';

10
npm/ng-packs/packages/feature-management/src/lib/components/feature-management/feature-management.component.ts

@ -1,4 +1,8 @@
import { ApplicationConfigurationService, ConfigStateService, TrackByService } from '@abp/ng.core';
import {
AbpApplicationConfigurationService,
ConfigStateService,
TrackByService,
} from '@abp/ng.core';
import { LocaleDirection } from '@abp/ng.theme.shared';
import { Component, EventEmitter, Input, Output } from '@angular/core';
import { Store } from '@ngxs/store';
@ -66,7 +70,7 @@ export class FeatureManagementComponent
protected service: FeaturesService,
protected store: Store,
protected configState: ConfigStateService,
protected appConfigService: ApplicationConfigurationService,
protected appConfigService: AbpApplicationConfigurationService,
) {}
openModal() {
@ -118,7 +122,7 @@ export class FeatureManagementComponent
if (!this.providerKey) {
// to refresh host's features
this.appConfigService
.getConfiguration()
.get()
.pipe(tap(res => this.configState.setState(res)))
.subscribe();
}

14
npm/ng-packs/packages/permission-management/src/lib/components/permission-management.component.ts

@ -1,7 +1,7 @@
import {
ApplicationConfiguration,
ApplicationConfigurationService,
AbpApplicationConfigurationService,
ConfigStateService,
CurrentUserDto,
} from '@abp/ng.core';
import { LocaleDirection } from '@abp/ng.theme.shared';
import { Component, EventEmitter, Input, Output, TrackByFunction } from '@angular/core';
@ -118,7 +118,7 @@ export class PermissionManagementComponent
constructor(
protected store: Store,
protected configState: ConfigStateService,
protected appConfigService: ApplicationConfigurationService,
protected appConfigService: AbpApplicationConfigurationService,
) {}
getChecked(name: string) {
@ -254,9 +254,7 @@ export class PermissionManagementComponent
.pipe(
switchMap(() =>
this.shouldFetchAppConfig()
? this.appConfigService
.getConfiguration()
.pipe(tap(res => this.configState.setState(res)))
? this.appConfigService.get().pipe(tap(res => this.configState.setState(res)))
: of(null),
),
finalize(() => (this.modalBusy = false)),
@ -300,9 +298,7 @@ export class PermissionManagementComponent
}
shouldFetchAppConfig() {
const currentUser = this.configState.getOne(
'currentUser',
) as ApplicationConfiguration.CurrentUser;
const currentUser = this.configState.getOne('currentUser') as CurrentUserDto;
if (this.providerName === 'R') return currentUser.roles.some(role => role === this.providerKey);

11
npm/ng-packs/packages/theme-basic/src/lib/components/nav-items/current-user.component.ts

@ -1,9 +1,4 @@
import {
ApplicationConfiguration,
AuthService,
ConfigStateService,
EnvironmentService,
} from '@abp/ng.core';
import { AuthService, ConfigStateService, CurrentUserDto, EnvironmentService } from '@abp/ng.core';
import { Component } from '@angular/core';
import { Router } from '@angular/router';
import { Observable } from 'rxjs';
@ -52,9 +47,7 @@ import { Observable } from 'rxjs';
`,
})
export class CurrentUserComponent {
currentUser$: Observable<ApplicationConfiguration.CurrentUser> = this.configState.getOne$(
'currentUser',
);
currentUser$: Observable<CurrentUserDto> = this.configState.getOne$('currentUser');
get smallScreen(): boolean {
return window.innerWidth < 992;

8
npm/ng-packs/packages/theme-basic/src/lib/components/nav-items/languages.component.ts

@ -1,4 +1,4 @@
import { ApplicationConfiguration, ConfigStateService, SessionStateService } from '@abp/ng.core';
import { ConfigStateService, LanguageInfo, SessionStateService } from '@abp/ng.core';
import { Component } from '@angular/core';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';
@ -48,9 +48,7 @@ export class LanguagesComponent {
return window.innerWidth < 992;
}
languages$: Observable<ApplicationConfiguration.Language[]> = this.configState.getDeep$(
'localization.languages',
);
languages$: Observable<LanguageInfo[]> = this.configState.getDeep$('localization.languages');
get defaultLanguage$(): Observable<string> {
return this.languages$.pipe(
@ -64,7 +62,7 @@ export class LanguagesComponent {
);
}
get dropdownLanguages$(): Observable<ApplicationConfiguration.Language[]> {
get dropdownLanguages$(): Observable<LanguageInfo[]> {
return this.languages$.pipe(
map(
languages =>

7
npm/ng-packs/packages/theme-shared/extensions/src/lib/utils/localization.util.ts

@ -1,8 +1,11 @@
import { ApplicationConfiguration, createLocalizationPipeKeyGenerator } from '@abp/ng.core';
import {
ApplicationLocalizationConfigurationDto,
createLocalizationPipeKeyGenerator,
} from '@abp/ng.core';
import { ObjectExtensions } from '../models/object-extensions';
export function createDisplayNameLocalizationPipeKeyGenerator(
localization: ApplicationConfiguration.Localization,
localization: ApplicationLocalizationConfigurationDto,
) {
const generateLocalizationPipeKey = createLocalizationPipeKeyGenerator(localization);

4
npm/ng-packs/packages/theme-shared/extensions/src/lib/utils/state.util.ts

@ -1,4 +1,4 @@
import { ABP, ApplicationConfiguration, ConfigStateService } from '@abp/ng.core';
import { ABP, ApplicationLocalizationConfigurationDto, ConfigStateService } from '@abp/ng.core';
import { Observable, pipe, zip } from 'rxjs';
import { filter, map, switchMap, take } from 'rxjs/operators';
import { ePropType } from '../enums/props.enum';
@ -19,7 +19,7 @@ function selectObjectExtensions(
function selectLocalization(
configState: ConfigStateService,
): Observable<ApplicationConfiguration.Localization> {
): Observable<ApplicationLocalizationConfigurationDto> {
return configState.getOne$('localization');
}

5
npm/ng-packs/packages/theme-shared/extensions/src/tests/localization.util.spec.ts

@ -1,3 +1,4 @@
import { ApplicationLocalizationConfigurationDto } from '@abp/ng.core';
import { createDisplayNameLocalizationPipeKeyGenerator } from '../lib/utils/localization.util';
describe('Localization Utils', () => {
@ -10,7 +11,9 @@ describe('Localization Utils', () => {
defaultResourceName: 'Default',
currentCulture: null,
languages: [],
});
languageFilesMap: null,
languagesMap: null,
} as ApplicationLocalizationConfigurationDto);
test.each`
displayName | fallback | expected

11
npm/ng-packs/packages/theme-shared/src/lib/handlers/error.handler.ts

@ -1,4 +1,4 @@
import { Config, RestOccurError } from '@abp/ng.core';
import { Config, LocalizationParam, RestOccurError } from '@abp/ng.core';
import { HttpErrorResponse } from '@angular/common/http';
import {
ApplicationRef,
@ -87,10 +87,7 @@ export class ErrorHandler {
private listenToRouterError() {
this.actions
.pipe(
ofActionSuccessful(RouterError),
filter(this.filterRouteErrors),
)
.pipe(ofActionSuccessful(RouterError), filter(this.filterRouteErrors))
.subscribe(() => this.show404Page());
}
@ -233,8 +230,8 @@ export class ErrorHandler {
}
private showError(
message?: Config.LocalizationParam,
title?: Config.LocalizationParam,
message?: LocalizationParam,
title?: LocalizationParam,
body?: any,
): Observable<Confirmation.Status> {
if (body) {

6
npm/ng-packs/packages/theme-shared/src/lib/models/confirmation.ts

@ -1,4 +1,4 @@
import { Config } from '@abp/ng.core';
import { Config, LocalizationParam } from '@abp/ng.core';
export namespace Confirmation {
export interface Options {
@ -8,8 +8,8 @@ export namespace Confirmation {
titleLocalizationParams?: string[];
hideCancelBtn?: boolean;
hideYesBtn?: boolean;
cancelText?: Config.LocalizationParam;
yesText?: Config.LocalizationParam;
cancelText?: LocalizationParam;
yesText?: LocalizationParam;
}
export interface DialogData {

10
npm/ng-packs/packages/theme-shared/src/lib/models/toaster.ts

@ -1,4 +1,4 @@
import { Config } from '@abp/ng.core';
import { Config, LocalizationParam } from '@abp/ng.core';
export namespace Toaster {
export interface ToastOptions {
@ -13,8 +13,8 @@ export namespace Toaster {
}
export interface Toast {
message: Config.LocalizationParam;
title?: Config.LocalizationParam;
message: LocalizationParam;
title?: LocalizationParam;
severity?: string;
options?: ToastOptions;
}
@ -24,8 +24,8 @@ export namespace Toaster {
export interface Service {
show: (
message: Config.LocalizationParam,
title: Config.LocalizationParam,
message: LocalizationParam,
title: LocalizationParam,
severity: Toaster.Severity,
options: Partial<Toaster.ToastOptions>,
) => ToasterId;

22
npm/ng-packs/packages/theme-shared/src/lib/services/confirmation.service.ts

@ -1,4 +1,4 @@
import { Config, ContentProjectionService, PROJECTION_STRATEGY } from '@abp/ng.core';
import { ContentProjectionService, LocalizationParam, PROJECTION_STRATEGY } from '@abp/ng.core';
import { ComponentRef, Injectable } from '@angular/core';
import { fromEvent, Observable, ReplaySubject, Subject } from 'rxjs';
import { debounceTime, filter, takeUntil } from 'rxjs/operators';
@ -33,40 +33,40 @@ export class ConfirmationService {
}
info(
message: Config.LocalizationParam,
title: Config.LocalizationParam,
message: LocalizationParam,
title: LocalizationParam,
options?: Partial<Confirmation.Options>,
): Observable<Confirmation.Status> {
return this.show(message, title, 'info', options);
}
success(
message: Config.LocalizationParam,
title: Config.LocalizationParam,
message: LocalizationParam,
title: LocalizationParam,
options?: Partial<Confirmation.Options>,
): Observable<Confirmation.Status> {
return this.show(message, title, 'success', options);
}
warn(
message: Config.LocalizationParam,
title: Config.LocalizationParam,
message: LocalizationParam,
title: LocalizationParam,
options?: Partial<Confirmation.Options>,
): Observable<Confirmation.Status> {
return this.show(message, title, 'warning', options);
}
error(
message: Config.LocalizationParam,
title: Config.LocalizationParam,
message: LocalizationParam,
title: LocalizationParam,
options?: Partial<Confirmation.Options>,
): Observable<Confirmation.Status> {
return this.show(message, title, 'error', options);
}
show(
message: Config.LocalizationParam,
title: Config.LocalizationParam,
message: LocalizationParam,
title: LocalizationParam,
severity?: Confirmation.Severity,
options = {} as Partial<Confirmation.Options>,
): Observable<Confirmation.Status> {

29
npm/ng-packs/packages/theme-shared/src/lib/services/toaster.service.ts

@ -1,9 +1,14 @@
import {
ContentProjectionService,
LocalizationParam,
PROJECTION_STRATEGY,
Strict,
} from '@abp/ng.core';
import { ComponentRef, Injectable } from '@angular/core';
import { Toaster } from '../models';
import { ReplaySubject } from 'rxjs';
import { Config, ContentProjectionService, PROJECTION_STRATEGY, Strict } from '@abp/ng.core';
import snq from 'snq';
import { ToastContainerComponent } from '../components/toast-container/toast-container.component';
import { Toaster } from '../models';
@Injectable({
providedIn: 'root',
@ -34,8 +39,8 @@ export class ToasterService implements ToasterContract {
* @param options Spesific style or structural options for individual toast
*/
info(
message: Config.LocalizationParam,
title?: Config.LocalizationParam,
message: LocalizationParam,
title?: LocalizationParam,
options?: Partial<Toaster.ToastOptions>,
): Toaster.ToasterId {
return this.show(message, title, 'info', options);
@ -48,8 +53,8 @@ export class ToasterService implements ToasterContract {
* @param options Spesific style or structural options for individual toast
*/
success(
message: Config.LocalizationParam,
title?: Config.LocalizationParam,
message: LocalizationParam,
title?: LocalizationParam,
options?: Partial<Toaster.ToastOptions>,
): Toaster.ToasterId {
return this.show(message, title, 'success', options);
@ -62,8 +67,8 @@ export class ToasterService implements ToasterContract {
* @param options Spesific style or structural options for individual toast
*/
warn(
message: Config.LocalizationParam,
title?: Config.LocalizationParam,
message: LocalizationParam,
title?: LocalizationParam,
options?: Partial<Toaster.ToastOptions>,
): Toaster.ToasterId {
return this.show(message, title, 'warning', options);
@ -76,8 +81,8 @@ export class ToasterService implements ToasterContract {
* @param options Spesific style or structural options for individual toast
*/
error(
message: Config.LocalizationParam,
title?: Config.LocalizationParam,
message: LocalizationParam,
title?: LocalizationParam,
options?: Partial<Toaster.ToastOptions>,
): Toaster.ToasterId {
return this.show(message, title, 'error', options);
@ -92,8 +97,8 @@ export class ToasterService implements ToasterContract {
*/
show(
message: Config.LocalizationParam,
title: Config.LocalizationParam = null,
message: LocalizationParam,
title: LocalizationParam = null,
severity: Toaster.Severity = 'neutral',
options = {} as Partial<Toaster.ToastOptions>,
): Toaster.ToasterId {

4
npm/ng-packs/packages/theme-shared/src/lib/utils/date-parser-formatter.ts

@ -1,4 +1,4 @@
import { ApplicationConfiguration, ConfigStateService } from '@abp/ng.core';
import { ApplicationLocalizationConfigurationDto, ConfigStateService } from '@abp/ng.core';
import { DatePipe } from '@angular/common';
import { Injectable, Optional } from '@angular/core';
import { NgbDateParserFormatter, NgbDateStruct } from '@ng-bootstrap/ng-bootstrap';
@ -51,7 +51,7 @@ export class DateParserFormatter extends NgbDateParserFormatter {
format(date: NgbDateStruct): string {
const { shortDatePattern } = (this.configState.getOne(
'localization',
) as ApplicationConfiguration.Localization).currentCulture.dateTimeFormat;
) as ApplicationLocalizationConfigurationDto).currentCulture.dateTimeFormat;
if (date && this.datePipe) {
return this.datePipe.transform(

100
templates/app/angular/yarn.lock

@ -2,15 +2,14 @@
# yarn lockfile v1
"@abp/ng.core@~3.3.1":
version "3.3.1"
resolved "https://registry.yarnpkg.com/@abp/ng.core/-/ng.core-3.3.1.tgz#230518da3cd1a8b4efef85df9d4d07e5c66b2549"
integrity sha512-x2zD3zhK5YD9EaV1p8AEboj9yoqzYCvyOkb7YDDBNR1VP2v+m7T8NRASBHkVrGZLwLkyd/qwOBUjEitz8XAbUA==
"@abp/ng.core@~4.0.0-rc.4":
version "4.0.0-rc.4"
resolved "https://registry.yarnpkg.com/@abp/ng.core/-/ng.core-4.0.0-rc.4.tgz#f1cbb7d43662579a7977c9d98bf28f7a6726537f"
integrity sha512-EtvoUr52v4+DEn3j2mru4OiLJf9tcg5ptLRjwBg1psftz1t3atnmvP1F8+sIhOwnj/Zm5hlhqSqnedpTzdALPg==
dependencies:
"@abp/utils" "^3.3.0"
"@abp/utils" "^4.0.0-rc.3"
"@angular/localize" "~10.0.10"
"@ngxs/router-plugin" "^3.7.0"
"@ngxs/storage-plugin" "^3.7.0"
"@ngxs/store" "^3.7.0"
angular-oauth2-oidc "^10.0.0"
just-clone "^3.1.0"
@ -19,29 +18,29 @@
ts-toolbelt "6.15.4"
tslib "^2.0.0"
"@abp/ng.feature-management@~3.3.1":
version "3.3.1"
resolved "https://registry.yarnpkg.com/@abp/ng.feature-management/-/ng.feature-management-3.3.1.tgz#b4497d999e87049b266473daf8d274d5fb26b248"
integrity sha512-SdUrZ67bGJQZ0RchS7bcA5wSF6PiD3hcJwsReWzw49nM2Qr8vbHlsstXww6slvq8nT5gwC6O0OA71zsHarpHfg==
"@abp/ng.feature-management@~4.0.0-rc.4":
version "4.0.0-rc.4"
resolved "https://registry.yarnpkg.com/@abp/ng.feature-management/-/ng.feature-management-4.0.0-rc.4.tgz#ab740e4327b8fd10ba4567bfeb24debbd4ffe8a5"
integrity sha512-PlWxAA2wECRrBGwqWeaWi+f3YPayIaOJhW4INTvD5JUFMIRJsOJZlxpmcz8x2pU64bUO42/YM26+Xy2TyVKFNg==
dependencies:
"@abp/ng.theme.shared" "~3.3.1"
"@abp/ng.theme.shared" "~4.0.0-rc.4"
tslib "^2.0.0"
"@abp/ng.identity@~3.3.1":
version "3.3.1"
resolved "https://registry.yarnpkg.com/@abp/ng.identity/-/ng.identity-3.3.1.tgz#e357e8bb1281e4fcbdeb20ef9d288eee6b274d3c"
integrity sha512-NjCmLdHUQtyGWPqIBo0OVSxUeQ4laQ501xPsJYZG7WOWmMJGTkBQKIFkUAG8gLKv8EDTIzBuVs8V8scr+EUSiw==
"@abp/ng.identity@~4.0.0-rc.4":
version "4.0.0-rc.4"
resolved "https://registry.yarnpkg.com/@abp/ng.identity/-/ng.identity-4.0.0-rc.4.tgz#5b8694b1d1d6f1a039e1a445add14dcc5d6eb5ad"
integrity sha512-nqx3ofuTT5kOdJHWAyrZyEmGGp08DZNNC7IIY7L1/NueiAcfjghKrAiGkNnt5SApdk86OzdrLdIvpELnZVCMzg==
dependencies:
"@abp/ng.permission-management" "~3.3.1"
"@abp/ng.theme.shared" "~3.3.1"
"@abp/ng.permission-management" "~4.0.0-rc.4"
"@abp/ng.theme.shared" "~4.0.0-rc.4"
tslib "^2.0.0"
"@abp/ng.permission-management@~3.3.1":
version "3.3.1"
resolved "https://registry.yarnpkg.com/@abp/ng.permission-management/-/ng.permission-management-3.3.1.tgz#2870a517b00b266c064df0914f0c4227c83677d7"
integrity sha512-69h0MLXOOQ9Iav4drwg1P6dcA+tl7+Vgt34IGJW1o0Aj0pYBlqBZQqq8IOW2g/xVLRE8qkfRnmoyAGBQfbJkTA==
"@abp/ng.permission-management@~4.0.0-rc.4":
version "4.0.0-rc.4"
resolved "https://registry.yarnpkg.com/@abp/ng.permission-management/-/ng.permission-management-4.0.0-rc.4.tgz#3d838528549860e2a8b6aba2c5f35f6764089322"
integrity sha512-2o/1dtfNQOkqHWzdHyI8Ske5E5VseCM+N3erJu4NSLIWrj5G3CG9wwbJm3BqEjHG7hzbcvR6fYxKpDUmqvQR0A==
dependencies:
"@abp/ng.theme.shared" "~3.3.1"
"@abp/ng.theme.shared" "~4.0.0-rc.4"
tslib "^2.0.0"
"@abp/ng.schematics@~3.3.1":
@ -55,37 +54,37 @@
jsonc-parser "^2.3.0"
typescript "~3.9.2"
"@abp/ng.setting-management@~3.3.1":
version "3.3.1"
resolved "https://registry.yarnpkg.com/@abp/ng.setting-management/-/ng.setting-management-3.3.1.tgz#f89ed79ab5b6348a5bd57a8699ee6298279e30ec"
integrity sha512-TGIeAUemaKEFcC/HG6d9JEYOG9EIYTry1goAKJReI0CShrykZUM5WPHe3wK0CQIqgI6MChVSYeq4yC+oyl8JnQ==
"@abp/ng.setting-management@~4.0.0-rc.4":
version "4.0.0-rc.4"
resolved "https://registry.yarnpkg.com/@abp/ng.setting-management/-/ng.setting-management-4.0.0-rc.4.tgz#45e7fe04a8069da19d644860617e5b5aeab39281"
integrity sha512-L7liYuB+DdWdcdJwG4OkQhBdb1bNqFO08TjfbRdkPARHje/tat+z8jtZ58yQVYOVCs9M2vJt3ydHnvZ+PQWpow==
dependencies:
"@abp/ng.theme.shared" "~3.3.1"
"@abp/ng.theme.shared" "~4.0.0-rc.4"
tslib "^2.0.0"
"@abp/ng.tenant-management@~3.3.1":
version "3.3.1"
resolved "https://registry.yarnpkg.com/@abp/ng.tenant-management/-/ng.tenant-management-3.3.1.tgz#315fdc5980adddbc9d561fba15bed6c27d8203ec"
integrity sha512-dehegHTe459UCc+45G0yL/ptGBk4xDk+Nl5DIRKDyf0k7l5HZstS5UrWwOAY8JO2SECUB5RjX33yvqt2/nxt4Q==
"@abp/ng.tenant-management@~4.0.0-rc.4":
version "4.0.0-rc.4"
resolved "https://registry.yarnpkg.com/@abp/ng.tenant-management/-/ng.tenant-management-4.0.0-rc.4.tgz#0978a65423b9f56df1fd58eaaa01fd912b2875ab"
integrity sha512-K7BCZMTs/nPoPrDo/yGu3IWZjXktZHcq0qg2pvjVZRqlfbgk0m+mih01H6WC+/tjKYfdb4PtWQJ36mGR17zvuQ==
dependencies:
"@abp/ng.feature-management" "~3.3.1"
"@abp/ng.theme.shared" "~3.3.1"
"@abp/ng.feature-management" "~4.0.0-rc.4"
"@abp/ng.theme.shared" "~4.0.0-rc.4"
tslib "^2.0.0"
"@abp/ng.theme.basic@~3.3.1":
version "3.3.1"
resolved "https://registry.yarnpkg.com/@abp/ng.theme.basic/-/ng.theme.basic-3.3.1.tgz#e9d711c3d1895a481d15409f35e52608d71259fc"
integrity sha512-DcAdBQNdgpkEGhFHXClBJIfTOuG43AQkk6o4yzaglCkYKQDuJ4XRtbRdFQNb/we/OtdIFHQtxVLEeqrMTZYYcQ==
"@abp/ng.theme.basic@~4.0.0-rc.4":
version "4.0.0-rc.4"
resolved "https://registry.yarnpkg.com/@abp/ng.theme.basic/-/ng.theme.basic-4.0.0-rc.4.tgz#438d73fed9962dae3d92b0d1f87f36e3601ab720"
integrity sha512-Gunzo6N1YoGZ3crLCYqflmvnuayekyV5Aa63dwCikOTloEBmfQy4FylAcUvncNo841BwmWOk7oDGmxQmrx+5bw==
dependencies:
"@abp/ng.theme.shared" "~3.3.1"
"@abp/ng.theme.shared" "~4.0.0-rc.4"
tslib "^2.0.0"
"@abp/ng.theme.shared@~3.3.1":
version "3.3.1"
resolved "https://registry.yarnpkg.com/@abp/ng.theme.shared/-/ng.theme.shared-3.3.1.tgz#694453546b4e4147a9f89058570dbbef81ef1196"
integrity sha512-21wJPa/cNBU3OoLiact4w1sHnQpsm0R5JUD6pRCzp14EyPN3QgOY8JC+/YgGuasKY2xm5pvgbgIdTryy9j4IyQ==
"@abp/ng.theme.shared@~4.0.0-rc.4":
version "4.0.0-rc.4"
resolved "https://registry.yarnpkg.com/@abp/ng.theme.shared/-/ng.theme.shared-4.0.0-rc.4.tgz#6341acbb647c8606c1147cad4387334a42908a2c"
integrity sha512-r3V+PIJC9pCA1OD7xL6I+sJ0AFeF/wcjyUJvn7ZRvevK+eDkHf6AqTXRCNgd+VTfCqtjIpiU5oC7rSOB1gGwPw==
dependencies:
"@abp/ng.core" "~3.3.1"
"@abp/ng.core" "~4.0.0-rc.4"
"@fortawesome/fontawesome-free" "^5.14.0"
"@ng-bootstrap/ng-bootstrap" "^7.0.0"
"@ngx-validate/core" "^0.0.12"
@ -94,10 +93,10 @@
chart.js "^2.9.3"
tslib "^2.0.0"
"@abp/utils@^3.3.0":
version "3.3.1"
resolved "https://registry.yarnpkg.com/@abp/utils/-/utils-3.3.1.tgz#f1759161ac8af10e57b50ac90538a24a51b64ebd"
integrity sha512-XEYJYp94zDdln48P7X51wa4v1yg3Q+p0o2DdZxQbZxXChRkCwVC/B0uyMGPs75wkft6xiz965Xr7vcNvMo0nOA==
"@abp/utils@^4.0.0-rc.3":
version "4.0.0-rc.4"
resolved "https://registry.yarnpkg.com/@abp/utils/-/utils-4.0.0-rc.4.tgz#99573069c7dac8751e3124e60511a11a169df565"
integrity sha512-z1l6A07+rSgf7fzI/UTlZv1cJBiIUa0kpEvhcChe7mwlHB7oQ3SlGjZX37kzOqWcOusfMOANPuVulkZLSCOB/w==
dependencies:
just-compare "^1.3.0"
@ -1291,13 +1290,6 @@
dependencies:
tslib "^1.9.0"
"@ngxs/storage-plugin@^3.7.0":
version "3.7.0"
resolved "https://registry.yarnpkg.com/@ngxs/storage-plugin/-/storage-plugin-3.7.0.tgz#3a0bc75f5dbba17a18e37b69cfde5d470cfceb45"
integrity sha512-j5rGYfhi1S+sAky956DIs+6AYP9FMBWL2Uz+omKBS/i42mjhyD26UfApORjwCOyW5PCb4Tq3B14ZPxyAaSi/OA==
dependencies:
tslib "^1.9.0"
"@ngxs/store@^3.7.0":
version "3.7.0"
resolved "https://registry.yarnpkg.com/@ngxs/store/-/store-3.7.0.tgz#e46387219dae610c685accc119ae42e351afcaa4"

Loading…
Cancel
Save