mirror of https://github.com/abpframework/abp.git
Browse Source
Removed all deprecated components, services, etc. from Angular packagespull/6181/head
committed by
GitHub
35 changed files with 47 additions and 891 deletions
@ -1,5 +1,4 @@ |
|||
export { SetEnvironment, GetAppConfiguration } from './config.actions'; |
|||
export { GetAppConfiguration, SetEnvironment } from './config.actions'; |
|||
export * from './loader.actions'; |
|||
export * from './profile.actions'; |
|||
export * from './replaceable-components.actions'; |
|||
export * from './rest.actions'; |
|||
|
|||
@ -1,13 +0,0 @@ |
|||
import { ReplaceableComponents } from '../models/replaceable-components'; |
|||
|
|||
// tslint:disable: max-line-length
|
|||
/** |
|||
* @deprecated To be deleted in v4.0. Use ReplaceableComponentsService instead. See the doc (https://docs.abp.io/en/abp/latest/UI/Angular/Component-Replacement)
|
|||
*/ |
|||
export class AddReplaceableComponent { |
|||
static readonly type = '[ReplaceableComponents] Add'; |
|||
constructor( |
|||
public payload: ReplaceableComponents.ReplaceableComponent, |
|||
public reload?: boolean, |
|||
) {} |
|||
} |
|||
@ -1,3 +1,2 @@ |
|||
export * from './replaceable-components.state'; |
|||
export * from './config.state'; |
|||
export * from './profile.state'; |
|||
|
|||
@ -1,74 +0,0 @@ |
|||
import { Injectable, isDevMode } from '@angular/core'; |
|||
import { Action, createSelector, Selector, State, StateContext } from '@ngxs/store'; |
|||
import snq from 'snq'; |
|||
import { AddReplaceableComponent } from '../actions/replaceable-components.actions'; |
|||
import { ReplaceableComponents } from '../models/replaceable-components'; |
|||
import { ReplaceableComponentsService } from '../services/replaceable-components.service'; |
|||
|
|||
function logDeprecationMsg() { |
|||
if (isDevMode()) { |
|||
console.warn(` |
|||
ReplacableComponentsState has been deprecated. Use ReplaceableComponentsService instead. |
|||
See the doc https://docs.abp.io/en/abp/latest/UI/Angular/Component-Replacement
|
|||
`);
|
|||
} |
|||
} |
|||
|
|||
// tslint:disable: max-line-length
|
|||
/** |
|||
* @deprecated To be deleted in v4.0. Use ReplaceableComponentsService instead. See the doc (https://docs.abp.io/en/abp/latest/UI/Angular/Component-Replacement)
|
|||
*/ |
|||
@State<ReplaceableComponents.State>({ |
|||
name: 'ReplaceableComponentsState', |
|||
defaults: { replaceableComponents: [] } as ReplaceableComponents.State, |
|||
}) |
|||
@Injectable() |
|||
export class ReplaceableComponentsState { |
|||
@Selector() |
|||
static getAll({ |
|||
replaceableComponents, |
|||
}: ReplaceableComponents.State): ReplaceableComponents.ReplaceableComponent[] { |
|||
logDeprecationMsg(); |
|||
return replaceableComponents || []; |
|||
} |
|||
|
|||
static getComponent(key: string) { |
|||
const selector = createSelector( |
|||
[ReplaceableComponentsState], |
|||
(state: ReplaceableComponents.State): ReplaceableComponents.ReplaceableComponent => { |
|||
logDeprecationMsg(); |
|||
return snq(() => state.replaceableComponents.find(component => component.key === key)); |
|||
}, |
|||
); |
|||
|
|||
return selector; |
|||
} |
|||
|
|||
constructor(private service: ReplaceableComponentsService) {} |
|||
|
|||
@Action(AddReplaceableComponent) |
|||
replaceableComponentsAction( |
|||
{ getState, patchState }: StateContext<ReplaceableComponents.State>, |
|||
{ payload, reload }: AddReplaceableComponent, |
|||
) { |
|||
logDeprecationMsg(); |
|||
|
|||
let { replaceableComponents } = getState(); |
|||
|
|||
const index = snq( |
|||
() => replaceableComponents.findIndex(component => component.key === payload.key), |
|||
-1, |
|||
); |
|||
if (index > -1) { |
|||
replaceableComponents[index] = payload; |
|||
} else { |
|||
replaceableComponents = [...replaceableComponents, payload]; |
|||
} |
|||
|
|||
patchState({ |
|||
replaceableComponents, |
|||
}); |
|||
|
|||
this.service.add(payload, reload); |
|||
} |
|||
} |
|||
@ -1,59 +0,0 @@ |
|||
import { APP_BASE_HREF } from '@angular/common'; |
|||
import { Component } from '@angular/core'; |
|||
import { Router, RouterModule } from '@angular/router'; |
|||
import { SpyObject } from '@ngneat/spectator'; |
|||
import { createHostFactory, SpectatorHost } from '@ngneat/spectator/jest'; |
|||
import { NgxsModule, Store } from '@ngxs/store'; |
|||
import { AddReplaceableComponent } from '../actions'; |
|||
import { ReplaceableComponentsState } from '../states/replaceable-components.state'; |
|||
|
|||
@Component({ selector: 'abp-dummy', template: 'dummy works' }) |
|||
class DummyComponent {} |
|||
|
|||
describe('ReplaceableComponentsState', () => { |
|||
let spectator: SpectatorHost<DummyComponent>; |
|||
let router: SpyObject<Router>; |
|||
const createHost = createHostFactory({ |
|||
component: DummyComponent, |
|||
providers: [{ provide: APP_BASE_HREF, useValue: '/' }], |
|||
imports: [RouterModule.forRoot([]), NgxsModule.forRoot([ReplaceableComponentsState])], |
|||
}); |
|||
|
|||
beforeEach(() => { |
|||
spectator = createHost('<abp-dummy></abp-dummy>'); |
|||
router = spectator.inject(Router); |
|||
}); |
|||
|
|||
it('should add a component to the state', () => { |
|||
const store = spectator.inject(Store); |
|||
expect(store.selectSnapshot(ReplaceableComponentsState.getAll)).toEqual([]); |
|||
store.dispatch(new AddReplaceableComponent({ component: DummyComponent, key: 'Dummy' })); |
|||
expect(store.selectSnapshot(ReplaceableComponentsState.getComponent('Dummy'))).toEqual({ |
|||
component: DummyComponent, |
|||
key: 'Dummy', |
|||
}); |
|||
}); |
|||
|
|||
it('should replace a exist component', () => { |
|||
const store = spectator.inject(Store); |
|||
store.dispatch(new AddReplaceableComponent({ component: DummyComponent, key: 'Dummy' })); |
|||
store.dispatch(new AddReplaceableComponent({ component: null, key: 'Dummy' })); |
|||
expect(store.selectSnapshot(ReplaceableComponentsState.getComponent('Dummy'))).toEqual({ |
|||
component: null, |
|||
key: 'Dummy', |
|||
}); |
|||
expect(store.selectSnapshot(ReplaceableComponentsState.getAll)).toHaveLength(1); |
|||
}); |
|||
|
|||
it('should call reloadRoute when reload parameter is given as true to AddReplaceableComponent', async () => { |
|||
const spy = jest.spyOn(router, 'navigateByUrl'); |
|||
const store = spectator.inject(Store); |
|||
store.dispatch(new AddReplaceableComponent({ component: DummyComponent, key: 'Dummy' })); |
|||
store.dispatch(new AddReplaceableComponent({ component: null, key: 'Dummy' }, true)); |
|||
|
|||
await spectator.fixture.whenStable(); |
|||
|
|||
expect(spy).toHaveBeenCalledTimes(1); |
|||
expect(spy).toHaveBeenCalledWith(router.url); |
|||
}); |
|||
}); |
|||
@ -1,17 +0,0 @@ |
|||
import { FeatureManagement } from '../models'; |
|||
|
|||
/** |
|||
* @deprecated To be deleted in v4.0. |
|||
*/ |
|||
export class GetFeatures { |
|||
static readonly type = '[FeatureManagement] Get Features'; |
|||
constructor(public payload: FeatureManagement.Provider) {} |
|||
} |
|||
|
|||
/** |
|||
* @deprecated To be deleted in v4.0. |
|||
*/ |
|||
export class UpdateFeatures { |
|||
static readonly type = '[FeatureManagement] Update Features'; |
|||
constructor(public payload: FeatureManagement.Provider & FeatureManagement.Features) {} |
|||
} |
|||
@ -1 +0,0 @@ |
|||
export * from './feature-management.actions'; |
|||
@ -1,22 +1,16 @@ |
|||
import { CoreModule } from '@abp/ng.core'; |
|||
import { ThemeSharedModule } from '@abp/ng.theme.shared'; |
|||
import { NgModule } from '@angular/core'; |
|||
import { NgxsModule } from '@ngxs/store'; |
|||
import { NgbNavModule } from '@ng-bootstrap/ng-bootstrap'; |
|||
import { FreeTextInputDirective } from './directives/free-text-input.directive'; |
|||
import { NgxsModule } from '@ngxs/store'; |
|||
import { FeatureManagementComponent } from './components/feature-management/feature-management.component'; |
|||
import { FeatureManagementState } from './states/feature-management.state'; |
|||
import { FreeTextInputDirective } from './directives/free-text-input.directive'; |
|||
|
|||
const exported = [FeatureManagementComponent, FreeTextInputDirective]; |
|||
|
|||
@NgModule({ |
|||
declarations: [...exported], |
|||
imports: [ |
|||
CoreModule, |
|||
ThemeSharedModule, |
|||
NgbNavModule, |
|||
NgxsModule.forFeature([FeatureManagementState]), |
|||
], |
|||
imports: [CoreModule, ThemeSharedModule, NgbNavModule, NgxsModule.forFeature([])], |
|||
exports: [...exported], |
|||
}) |
|||
export class FeatureManagementModule {} |
|||
|
|||
@ -1,23 +0,0 @@ |
|||
import { Injectable } from '@angular/core'; |
|||
import { Store } from '@ngxs/store'; |
|||
import { GetFeatures, UpdateFeatures } from '../actions/feature-management.actions'; |
|||
import { FeatureManagementState } from '../states/feature-management.state'; |
|||
|
|||
@Injectable({ |
|||
providedIn: 'root', |
|||
}) |
|||
export class FeatureManagementStateService { |
|||
constructor(private store: Store) {} |
|||
|
|||
getFeatures() { |
|||
return this.store.selectSnapshot(FeatureManagementState.getFeatures); |
|||
} |
|||
|
|||
dispatchGetFeatures(...args: ConstructorParameters<typeof GetFeatures>) { |
|||
return this.store.dispatch(new GetFeatures(...args)); |
|||
} |
|||
|
|||
dispatchUpdateFeatures(...args: ConstructorParameters<typeof UpdateFeatures>) { |
|||
return this.store.dispatch(new UpdateFeatures(...args)); |
|||
} |
|||
} |
|||
@ -1,42 +0,0 @@ |
|||
import { Injectable } from '@angular/core'; |
|||
import { RestService, Rest } from '@abp/ng.core'; |
|||
import { Store } from '@ngxs/store'; |
|||
import { Observable } from 'rxjs'; |
|||
import { FeatureManagement } from '../models'; |
|||
|
|||
@Injectable({ |
|||
providedIn: 'root', |
|||
}) |
|||
/** |
|||
* @deprecated Use FeaturesService instead. To be deleted in v4.0. |
|||
*/ |
|||
export class FeatureManagementService { |
|||
apiName = 'FeatureManagement'; |
|||
|
|||
constructor(private rest: RestService, private store: Store) {} |
|||
|
|||
getFeatures(params: FeatureManagement.Provider): Observable<FeatureManagement.Features> { |
|||
const request: Rest.Request<null> = { |
|||
method: 'GET', |
|||
url: '/api/feature-management/features', |
|||
params, |
|||
}; |
|||
return this.rest.request<FeatureManagement.Provider, FeatureManagement.Features>(request, { |
|||
apiName: this.apiName, |
|||
}); |
|||
} |
|||
|
|||
updateFeatures({ |
|||
features, |
|||
providerKey, |
|||
providerName, |
|||
}: FeatureManagement.Provider & FeatureManagement.Features): Observable<null> { |
|||
const request: Rest.Request<FeatureManagement.Features> = { |
|||
method: 'PUT', |
|||
url: '/api/feature-management/features', |
|||
body: { features }, |
|||
params: { providerKey, providerName }, |
|||
}; |
|||
return this.rest.request<FeatureManagement.Features, null>(request, { apiName: this.apiName }); |
|||
} |
|||
} |
|||
@ -1,2 +0,0 @@ |
|||
export * from './feature-management.service'; |
|||
export * from './feature-management-state.service'; |
|||
@ -1,39 +0,0 @@ |
|||
import { Action, Selector, State, StateContext } from '@ngxs/store'; |
|||
import { tap } from 'rxjs/operators'; |
|||
import { GetFeatures, UpdateFeatures } from '../actions/feature-management.actions'; |
|||
import { FeatureManagement } from '../models/feature-management'; |
|||
import { FeatureManagementService } from '../services/feature-management.service'; |
|||
import { Injectable } from '@angular/core'; |
|||
|
|||
/** |
|||
* @deprecated To be deleted in v4.0. |
|||
*/ |
|||
@State<FeatureManagement.State>({ |
|||
name: 'FeatureManagementState', |
|||
defaults: { features: {} } as FeatureManagement.State, |
|||
}) |
|||
@Injectable() |
|||
export class FeatureManagementState { |
|||
@Selector() |
|||
static getFeatures({ features }: FeatureManagement.State) { |
|||
return features || []; |
|||
} |
|||
|
|||
constructor(private featureManagementService: FeatureManagementService) {} |
|||
|
|||
@Action(GetFeatures) |
|||
getFeatures({ patchState }: StateContext<FeatureManagement.State>, { payload }: GetFeatures) { |
|||
return this.featureManagementService.getFeatures(payload).pipe( |
|||
tap(({ features = [] }) => |
|||
patchState({ |
|||
features, |
|||
}), |
|||
), |
|||
); |
|||
} |
|||
|
|||
@Action(UpdateFeatures) |
|||
updateFeatures(_, { payload }: UpdateFeatures) { |
|||
return this.featureManagementService.updateFeatures(payload); |
|||
} |
|||
} |
|||
@ -1 +0,0 @@ |
|||
export * from './feature-management.state'; |
|||
@ -1,61 +0,0 @@ |
|||
import { createServiceFactory, SpectatorService, SpyObject } from '@ngneat/spectator/jest'; |
|||
import { Store } from '@ngxs/store'; |
|||
import { FeatureManagementStateService } from '../services/feature-management-state.service'; |
|||
import { FeatureManagementState } from '../states'; |
|||
import * as FeatureManagementActions from '../actions'; |
|||
|
|||
describe('FeatureManagementStateService', () => { |
|||
let service: FeatureManagementStateService; |
|||
let spectator: SpectatorService<FeatureManagementStateService>; |
|||
let store: SpyObject<Store>; |
|||
|
|||
const createService = createServiceFactory({ |
|||
service: FeatureManagementStateService, |
|||
mocks: [Store], |
|||
}); |
|||
beforeEach(() => { |
|||
spectator = createService(); |
|||
service = spectator.service; |
|||
store = spectator.inject(Store); |
|||
}); |
|||
|
|||
test('should have the all FeatureManagementState static methods', () => { |
|||
const reg = /(?<=static )(.*)(?=\()/gm; |
|||
FeatureManagementState.toString() |
|||
.match(reg) |
|||
.forEach(fnName => { |
|||
expect(service[fnName]).toBeTruthy(); |
|||
|
|||
const spy = jest.spyOn(store, 'selectSnapshot'); |
|||
spy.mockClear(); |
|||
|
|||
const isDynamicSelector = FeatureManagementState[fnName].name !== 'memoized'; |
|||
|
|||
if (isDynamicSelector) { |
|||
FeatureManagementState[fnName] = jest.fn((...args) => args); |
|||
service[fnName]('test', 0, {}); |
|||
expect(FeatureManagementState[fnName]).toHaveBeenCalledWith('test', 0, {}); |
|||
} else { |
|||
service[fnName](); |
|||
expect(spy).toHaveBeenCalledWith(FeatureManagementState[fnName]); |
|||
} |
|||
}); |
|||
}); |
|||
|
|||
test('should have a dispatch method for every FeatureManagementState action', () => { |
|||
const reg = /(?<=dispatch)(\w+)(?=\()/gm; |
|||
FeatureManagementStateService.toString() |
|||
.match(reg) |
|||
.forEach(fnName => { |
|||
expect(FeatureManagementActions[fnName]).toBeTruthy(); |
|||
|
|||
const spy = jest.spyOn(store, 'dispatch'); |
|||
spy.mockClear(); |
|||
|
|||
const params = Array.from(new Array(FeatureManagementActions[fnName].length)); |
|||
|
|||
service[`dispatch${fnName}`](...params); |
|||
expect(spy).toHaveBeenCalledWith(new FeatureManagementActions[fnName](...params)); |
|||
}); |
|||
}); |
|||
}); |
|||
@ -1,150 +0,0 @@ |
|||
import { Injectable } from '@angular/core'; |
|||
import { Observable } from 'rxjs'; |
|||
import { RestService, Rest, ABP } from '@abp/ng.core'; |
|||
import { Identity } from '../models/identity'; |
|||
|
|||
@Injectable({ |
|||
providedIn: 'root', |
|||
}) |
|||
export class IdentityService { |
|||
apiName = 'AbpIdentity'; |
|||
|
|||
constructor(private rest: RestService) {} |
|||
|
|||
getRoles(params = {} as ABP.PageQueryParams): Observable<Identity.RoleResponse> { |
|||
const request: Rest.Request<null> = { |
|||
method: 'GET', |
|||
url: '/api/identity/roles', |
|||
params, |
|||
}; |
|||
|
|||
return this.rest.request<null, Identity.RoleResponse>(request, { apiName: this.apiName }); |
|||
} |
|||
|
|||
getAllRoles(): Observable<Identity.RoleResponse> { |
|||
const request: Rest.Request<null> = { |
|||
method: 'GET', |
|||
url: '/api/identity/roles/all', |
|||
}; |
|||
|
|||
return this.rest.request<null, Identity.RoleResponse>(request, { apiName: this.apiName }); |
|||
} |
|||
|
|||
getRoleById(id: string): Observable<Identity.RoleItem> { |
|||
const request: Rest.Request<null> = { |
|||
method: 'GET', |
|||
url: `/api/identity/roles/${id}`, |
|||
}; |
|||
|
|||
return this.rest.request<null, Identity.RoleItem>(request, { apiName: this.apiName }); |
|||
} |
|||
|
|||
deleteRole(id: string): Observable<Identity.RoleItem> { |
|||
const request: Rest.Request<null> = { |
|||
method: 'DELETE', |
|||
url: `/api/identity/roles/${id}`, |
|||
}; |
|||
|
|||
return this.rest.request<null, Identity.RoleItem>(request, { apiName: this.apiName }); |
|||
} |
|||
|
|||
createRole(body: Identity.RoleSaveRequest): Observable<Identity.RoleItem> { |
|||
const request: Rest.Request<Identity.RoleSaveRequest> = { |
|||
method: 'POST', |
|||
url: '/api/identity/roles', |
|||
body, |
|||
}; |
|||
|
|||
return this.rest.request<Identity.RoleSaveRequest, Identity.RoleItem>(request, { |
|||
apiName: this.apiName, |
|||
}); |
|||
} |
|||
|
|||
updateRole(body: Identity.RoleItem): Observable<Identity.RoleItem> { |
|||
const url = `/api/identity/roles/${body.id}`; |
|||
delete body.id; |
|||
|
|||
const request: Rest.Request<Identity.RoleItem> = { |
|||
method: 'PUT', |
|||
url, |
|||
body, |
|||
}; |
|||
|
|||
return this.rest.request<Identity.RoleItem, Identity.RoleItem>(request, { |
|||
apiName: this.apiName, |
|||
}); |
|||
} |
|||
|
|||
getUsers(params = {} as ABP.PageQueryParams): Observable<Identity.UserResponse> { |
|||
const request: Rest.Request<null> = { |
|||
method: 'GET', |
|||
url: '/api/identity/users', |
|||
params, |
|||
}; |
|||
|
|||
return this.rest.request<null, Identity.UserResponse>(request, { apiName: this.apiName }); |
|||
} |
|||
|
|||
getUserById(id: string): Observable<Identity.UserItem> { |
|||
const request: Rest.Request<null> = { |
|||
method: 'GET', |
|||
url: `/api/identity/users/${id}`, |
|||
}; |
|||
|
|||
return this.rest.request<null, Identity.UserItem>(request, { apiName: this.apiName }); |
|||
} |
|||
|
|||
getUserRoles(id: string): Observable<Identity.RoleResponse> { |
|||
const request: Rest.Request<null> = { |
|||
method: 'GET', |
|||
url: `/api/identity/users/${id}/roles`, |
|||
}; |
|||
|
|||
return this.rest.request<null, Identity.RoleResponse>(request, { apiName: this.apiName }); |
|||
} |
|||
|
|||
getUserAssingableRoles(): Observable<Identity.RoleResponse> { |
|||
const request: Rest.Request<null> = { |
|||
method: 'GET', |
|||
url: '/api/identity/users/assignable-roles', |
|||
}; |
|||
|
|||
return this.rest.request<null, Identity.RoleResponse>(request, { apiName: this.apiName }); |
|||
} |
|||
|
|||
deleteUser(id: string): Observable<null> { |
|||
const request: Rest.Request<null> = { |
|||
method: 'DELETE', |
|||
url: `/api/identity/users/${id}`, |
|||
}; |
|||
|
|||
return this.rest.request<null, null>(request, { apiName: this.apiName }); |
|||
} |
|||
|
|||
createUser(body: Identity.UserSaveRequest): Observable<Identity.UserItem> { |
|||
const request: Rest.Request<Identity.UserSaveRequest> = { |
|||
method: 'POST', |
|||
url: '/api/identity/users', |
|||
body, |
|||
}; |
|||
|
|||
return this.rest.request<Identity.UserSaveRequest, Identity.UserItem>(request, { |
|||
apiName: this.apiName, |
|||
}); |
|||
} |
|||
|
|||
updateUser(body: Identity.UserItem): Observable<Identity.UserItem> { |
|||
const url = `/api/identity/users/${body.id}`; |
|||
delete body.id; |
|||
|
|||
const request: Rest.Request<Identity.UserItem> = { |
|||
method: 'PUT', |
|||
url, |
|||
body, |
|||
}; |
|||
|
|||
return this.rest.request<Identity.UserItem, Identity.UserItem>(request, { |
|||
apiName: this.apiName, |
|||
}); |
|||
} |
|||
} |
|||
@ -1,2 +1 @@ |
|||
export * from './identity.service'; |
|||
export * from './identity-state.service'; |
|||
|
|||
@ -1,12 +1,11 @@ |
|||
import { PermissionManagement } from '../models/permission-management'; |
|||
import { UpdatePermissionsDto } from '../proxy/models'; |
|||
import { ProviderInfoDto, UpdatePermissionsDto } from '../proxy/models'; |
|||
|
|||
export class GetPermissions { |
|||
static readonly type = '[PermissionManagement] Get Permissions'; |
|||
constructor(public payload: PermissionManagement.GrantedProvider) {} |
|||
constructor(public payload: ProviderInfoDto) {} |
|||
} |
|||
|
|||
export class UpdatePermissions { |
|||
static readonly type = '[PermissionManagement] Update Permissions'; |
|||
constructor(public payload: PermissionManagement.GrantedProvider & UpdatePermissionsDto) {} |
|||
constructor(public payload: ProviderInfoDto & UpdatePermissionsDto) {} |
|||
} |
|||
|
|||
@ -1,2 +1 @@ |
|||
export * from './permission-management.service'; |
|||
export * from './permission-management-state.service'; |
|||
|
|||
@ -1,45 +0,0 @@ |
|||
import { Injectable } from '@angular/core'; |
|||
import { RestService, Rest } from '@abp/ng.core'; |
|||
import { Observable } from 'rxjs'; |
|||
import { PermissionManagement } from '../models/permission-management'; |
|||
|
|||
@Injectable({ |
|||
providedIn: 'root', |
|||
}) |
|||
export class PermissionManagementService { |
|||
apiName = 'AbpPermissionManagement'; |
|||
|
|||
constructor(private rest: RestService) {} |
|||
|
|||
getPermissions( |
|||
params: PermissionManagement.GrantedProvider, |
|||
): Observable<PermissionManagement.Response> { |
|||
const request: Rest.Request<PermissionManagement.GrantedProvider> = { |
|||
method: 'GET', |
|||
url: '/api/permission-management/permissions', |
|||
params, |
|||
}; |
|||
|
|||
return this.rest.request<PermissionManagement.GrantedProvider, PermissionManagement.Response>( |
|||
request, |
|||
{ apiName: this.apiName }, |
|||
); |
|||
} |
|||
|
|||
updatePermissions({ |
|||
permissions, |
|||
providerKey, |
|||
providerName, |
|||
}: PermissionManagement.GrantedProvider & PermissionManagement.UpdateRequest): Observable<null> { |
|||
const request: Rest.Request<PermissionManagement.UpdateRequest> = { |
|||
method: 'PUT', |
|||
url: '/api/permission-management/permissions', |
|||
body: { permissions }, |
|||
params: { providerKey, providerName }, |
|||
}; |
|||
|
|||
return this.rest.request<PermissionManagement.UpdateRequest, null>(request, { |
|||
apiName: this.apiName, |
|||
}); |
|||
} |
|||
} |
|||
@ -1,2 +1 @@ |
|||
export * from './tenant-management.service'; |
|||
export * from './tenant-management-state.service'; |
|||
|
|||
@ -1,111 +0,0 @@ |
|||
import { Injectable } from '@angular/core'; |
|||
import { Observable } from 'rxjs'; |
|||
import { RestService, Rest, ABP } from '@abp/ng.core'; |
|||
import { TenantManagement } from '../models/tenant-management'; |
|||
|
|||
@Injectable({ |
|||
providedIn: 'root', |
|||
}) |
|||
/** |
|||
* @deprecated Use TenantService instead. To be deleted in v4.0. |
|||
*/ |
|||
export class TenantManagementService { |
|||
apiName = 'AbpTenantManagement'; |
|||
|
|||
constructor(private rest: RestService) {} |
|||
|
|||
getTenant(params = {} as ABP.PageQueryParams): Observable<TenantManagement.Response> { |
|||
const request: Rest.Request<null> = { |
|||
method: 'GET', |
|||
url: '/api/multi-tenancy/tenants', |
|||
params, |
|||
}; |
|||
|
|||
return this.rest.request<null, TenantManagement.Response>(request, { apiName: this.apiName }); |
|||
} |
|||
|
|||
getTenantById(id: string): Observable<ABP.BasicItem> { |
|||
const request: Rest.Request<null> = { |
|||
method: 'GET', |
|||
url: `/api/multi-tenancy/tenants/${id}`, |
|||
}; |
|||
|
|||
return this.rest.request<null, ABP.BasicItem>(request, { apiName: this.apiName }); |
|||
} |
|||
|
|||
deleteTenant(id: string): Observable<null> { |
|||
const request: Rest.Request<null> = { |
|||
method: 'DELETE', |
|||
url: `/api/multi-tenancy/tenants/${id}`, |
|||
}; |
|||
|
|||
return this.rest.request<null, null>(request, { apiName: this.apiName }); |
|||
} |
|||
|
|||
createTenant(body: TenantManagement.AddRequest): Observable<ABP.BasicItem> { |
|||
const request: Rest.Request<TenantManagement.AddRequest> = { |
|||
method: 'POST', |
|||
url: '/api/multi-tenancy/tenants', |
|||
body, |
|||
}; |
|||
|
|||
return this.rest.request<TenantManagement.AddRequest, ABP.BasicItem>(request, { |
|||
apiName: this.apiName, |
|||
}); |
|||
} |
|||
|
|||
updateTenant(body: TenantManagement.UpdateRequest): Observable<ABP.BasicItem> { |
|||
const url = `/api/multi-tenancy/tenants/${body.id}`; |
|||
delete body.id; |
|||
|
|||
const request: Rest.Request<TenantManagement.UpdateRequest> = { |
|||
method: 'PUT', |
|||
url, |
|||
body, |
|||
}; |
|||
|
|||
return this.rest.request<TenantManagement.UpdateRequest, ABP.BasicItem>(request, { |
|||
apiName: this.apiName, |
|||
}); |
|||
} |
|||
|
|||
getDefaultConnectionString(id: string): Observable<string> { |
|||
const url = `/api/multi-tenancy/tenants/${id}/default-connection-string`; |
|||
|
|||
const request: Rest.Request<TenantManagement.DefaultConnectionStringRequest> = { |
|||
method: 'GET', |
|||
responseType: Rest.ResponseType.Text, |
|||
url, |
|||
}; |
|||
return this.rest.request<TenantManagement.DefaultConnectionStringRequest, string>(request, { |
|||
apiName: this.apiName, |
|||
}); |
|||
} |
|||
|
|||
updateDefaultConnectionString( |
|||
payload: TenantManagement.DefaultConnectionStringRequest, |
|||
): Observable<any> { |
|||
const url = `/api/multi-tenancy/tenants/${payload.id}/default-connection-string`; |
|||
|
|||
const request: Rest.Request<TenantManagement.DefaultConnectionStringRequest> = { |
|||
method: 'PUT', |
|||
url, |
|||
params: { defaultConnectionString: payload.defaultConnectionString }, |
|||
}; |
|||
return this.rest.request<TenantManagement.DefaultConnectionStringRequest, any>(request, { |
|||
apiName: this.apiName, |
|||
}); |
|||
} |
|||
|
|||
deleteDefaultConnectionString(id: string): Observable<string> { |
|||
const url = `/api/multi-tenancy/tenants/${id}/default-connection-string`; |
|||
|
|||
const request: Rest.Request<TenantManagement.DefaultConnectionStringRequest> = { |
|||
method: 'DELETE', |
|||
url, |
|||
}; |
|||
return this.rest.request<TenantManagement.DefaultConnectionStringRequest, any>(request, { |
|||
apiName: this.apiName, |
|||
}); |
|||
} |
|||
} |
|||
Loading…
Reference in new issue