Skip to content
Snippets Groups Projects
Commit 1c8acab3 authored by OZGCloud's avatar OZGCloud
Browse files

OZG-4949 adjust service provider

parent dc510da7
No related branches found
No related tags found
No related merge requests found
import { ApiRootResource, ApiRootService } from '@alfa-client/api-root-shared';
import { InjectionToken, Provider } from '@angular/core';
import { ResourceListService } from 'libs/tech-shared/src/lib/resource/list-resource.service';
import { ResourceService } from 'libs/tech-shared/src/lib/resource/resource.service';
import {
ListResourceServiceConfig,
ResourceServiceConfig,
} from 'libs/tech-shared/src/lib/resource/resource.model';
import { SettingsListLinkRel, SettingsListResource, SettingsService } from './settings.model';
import { ResourceRepository } from 'libs/tech-shared/src/lib/resource/resource.repository';
import { PostfachLinkRel, PostfachResource, PostfachService } from './postfach/postfach.model';
import { Observable } from 'rxjs';
import { StateResource } from '@alfa-client/tech-shared';
export const SettingServiceToken = new InjectionToken<SettingsService>(null);
export const SettingsServiceProvider: Provider = {
provide: SettingServiceToken,
useFactory: (
apiRootService: ApiRootService,
repository: ResourceRepository<SettingsListResource>,
) => new ResourceListService(createSettingsServiceConfig(apiRootService), repository),
deps: [ApiRootService, ResourceRepository],
};
export function createSettingsServiceConfig(
apiRootService: ApiRootService,
): ListResourceServiceConfig<ApiRootResource> {
console.info('Create Settingsservice...');
return {
baseResource: apiRootService.getApiRoot(),
createLinkRel: SettingsListLinkRel.CREATE,
listLinkRel: SettingsListLinkRel.LIST,
};
}
export const PostfachServiceToken = new InjectionToken<PostfachService>(null);
export const PostfachServiceProvider: Provider = {
provide: PostfachServiceToken,
useFactory: (
settingsListService: SettingsService,
repository: ResourceRepository<PostfachResource>,
) => new ResourceService(createPostfachServiceConfig(settingsListService), repository),
deps: [SettingServiceToken, ResourceRepository],
};
export function createPostfachServiceConfig(
settingsListService: SettingsService,
): ResourceServiceConfig<PostfachResource> {
console.info('Create Postfachservice...');
return {
resource: <Observable<StateResource<PostfachResource>>>settingsListService.getSelected(),
editLinkRel: PostfachLinkRel.SELF,
deleteLinkRel: PostfachLinkRel.SELF,
getLinkRel: PostfachLinkRel.SELF,
};
}
...@@ -7,8 +7,11 @@ import { ReactiveFormsModule } from '@angular/forms'; ...@@ -7,8 +7,11 @@ import { ReactiveFormsModule } from '@angular/forms';
import { PostfachContainerComponent } from './postfach/postfach-container/postfach-container.component'; import { PostfachContainerComponent } from './postfach/postfach-container/postfach-container.component';
import { PostfachFormComponent } from './postfach/postfach-container/postfach-form/postfach-form.component'; import { PostfachFormComponent } from './postfach/postfach-container/postfach-form/postfach-form.component';
import { TextFieldComponent } from './shared/text-field/text-field.component'; import { TextFieldComponent } from './shared/text-field/text-field.component';
import { NavigationContainerComponent } from './navigation-container/navigation-container.component';
import { PostfachNavigationItemComponent } from './postfach/postfach-navigation-item/postfach-navigation-item.component'; import { PostfachNavigationItemComponent } from './postfach/postfach-navigation-item/postfach-navigation-item.component';
import { NavigationComponent } from './navigation/navigation.component';
import { SettingsService } from './admin-settings.service';
import { PostfachService } from './postfach/postfach.service';
import { ConfigurationService } from './configuration/configuration.service';
@NgModule({ @NgModule({
declarations: [ declarations: [
...@@ -16,10 +19,11 @@ import { PostfachNavigationItemComponent } from './postfach/postfach-navigation- ...@@ -16,10 +19,11 @@ import { PostfachNavigationItemComponent } from './postfach/postfach-navigation-
PostfachFormComponent, PostfachFormComponent,
NavigationItemComponent, NavigationItemComponent,
TextFieldComponent, TextFieldComponent,
NavigationContainerComponent,
PostfachNavigationItemComponent, PostfachNavigationItemComponent,
NavigationComponent,
], ],
imports: [CommonModule, TechSharedModule, RouterModule, ReactiveFormsModule], imports: [CommonModule, TechSharedModule, RouterModule, ReactiveFormsModule],
exports: [PostfachContainerComponent, NavigationItemComponent], exports: [PostfachContainerComponent, NavigationComponent],
providers: [ConfigurationService, SettingsService, PostfachService],
}) })
export class AdminSettingsModule {} export class AdminSettingsModule {}
...@@ -24,8 +24,6 @@ ...@@ -24,8 +24,6 @@
import { PostfachResource } from './postfach/postfach.model'; import { PostfachResource } from './postfach/postfach.model';
import { ListResource } from '@alfa-client/tech-shared'; import { ListResource } from '@alfa-client/tech-shared';
import { ListItemResource } from 'libs/tech-shared/src/lib/resource/resource.model'; import { ListItemResource } from 'libs/tech-shared/src/lib/resource/resource.model';
import { ResourceListService } from 'libs/tech-shared/src/lib/resource/list-resource.service';
import { ApiRootResource } from '@alfa-client/api-root-shared';
export interface SettingsListResource extends ListResource { export interface SettingsListResource extends ListResource {
_embedded: { settings: SettingsItemResource[] }; _embedded: { settings: SettingsItemResource[] };
...@@ -39,6 +37,6 @@ export interface EmptyResource extends ListItemResource { ...@@ -39,6 +37,6 @@ export interface EmptyResource extends ListItemResource {
} }
export enum SettingsListLinkRel { export enum SettingsListLinkRel {
CREATE = '', //entsprechend anpassen CREATE = '',
LIST = 'configuration', //entsprechend anpassen LIST = 'settings',
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment