mirror of https://github.com/abpframework/abp
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
2 lines
11 KiB
2 lines
11 KiB
{"version":3,"file":"abp-ng.feature-management.js","sources":["ng://@abp/ng.feature-management/lib/actions/feature-management.actions.ts","ng://@abp/ng.feature-management/lib/services/feature-management.service.ts","ng://@abp/ng.feature-management/lib/states/feature-management.state.ts","ng://@abp/ng.feature-management/lib/components/feature-management/feature-management.component.ts","ng://@abp/ng.feature-management/lib/feature-management.module.ts"],"sourcesContent":["import { FeatureManagement } from '../models';\r\n\r\nexport class GetFeatures {\r\n static readonly type = '[FeatureManagement] Get Features';\r\n constructor(public payload: FeatureManagement.Provider) {}\r\n}\r\n\r\nexport class UpdateFeatures {\r\n static readonly type = '[FeatureManagement] Update Features';\r\n constructor(public payload: FeatureManagement.Provider & FeatureManagement.Features) {}\r\n}\r\n","import { Injectable } from '@angular/core';\r\nimport { RestService, Rest } from '@abp/ng.core';\r\nimport { Store } from '@ngxs/store';\r\nimport { Observable } from 'rxjs';\r\nimport { FeatureManagement } from '../models';\r\n\r\n@Injectable({\r\n providedIn: 'root',\r\n})\r\nexport class FeatureManagementService {\r\n constructor(private rest: RestService, private store: Store) {}\r\n\r\n getFeatures(params: FeatureManagement.Provider): Observable<FeatureManagement.Features> {\r\n const request: Rest.Request<null> = {\r\n method: 'GET',\r\n url: '/api/abp/features',\r\n params,\r\n };\r\n return this.rest.request<FeatureManagement.Provider, FeatureManagement.Features>(request);\r\n }\r\n\r\n updateFeatures({\r\n features,\r\n providerKey,\r\n providerName,\r\n }: FeatureManagement.Provider & FeatureManagement.Features): Observable<null> {\r\n const request: Rest.Request<FeatureManagement.Features> = {\r\n method: 'PUT',\r\n url: '/api/abp/features',\r\n body: { features },\r\n params: { providerKey, providerName },\r\n };\r\n return this.rest.request<FeatureManagement.Features, null>(request);\r\n }\r\n}\r\n","import { Action, Selector, State, StateContext } from '@ngxs/store';\r\nimport { tap } from 'rxjs/operators';\r\nimport { GetFeatures, UpdateFeatures } from '../actions/feature-management.actions';\r\nimport { FeatureManagement } from '../models/feature-management';\r\nimport { FeatureManagementService } from '../services/feature-management.service';\r\n\r\n@State<FeatureManagement.State>({\r\n name: 'FeatureManagementState',\r\n defaults: { features: {} } as FeatureManagement.State,\r\n})\r\nexport class FeatureManagementState {\r\n @Selector()\r\n static getFeatures({ features }: FeatureManagement.State) {\r\n return features || [];\r\n }\r\n\r\n constructor(private featureManagementService: FeatureManagementService) {}\r\n\r\n @Action(GetFeatures)\r\n getFeatures({ patchState }: StateContext<FeatureManagement.State>, { payload }: GetFeatures) {\r\n return this.featureManagementService.getFeatures(payload).pipe(\r\n tap(({ features }) =>\r\n patchState({\r\n features,\r\n }),\r\n ),\r\n );\r\n }\r\n\r\n @Action(UpdateFeatures)\r\n updateFeatures(_, { payload }: UpdateFeatures) {\r\n return this.featureManagementService.updateFeatures(payload);\r\n }\r\n}\r\n","import { Component, EventEmitter, Input, OnChanges, Output, SimpleChanges } from '@angular/core';\r\nimport { Select, Store } from '@ngxs/store';\r\nimport { Observable } from 'rxjs';\r\nimport { GetFeatures, UpdateFeatures } from '../../actions';\r\nimport { FeatureManagement } from '../../models/feature-management';\r\nimport { FeatureManagementState } from '../../states';\r\nimport { FormGroup, FormControl } from '@angular/forms';\r\nimport { pluck, finalize } from 'rxjs/operators';\r\n\r\n@Component({\r\n selector: 'abp-feature-management',\r\n templateUrl: './feature-management.component.html',\r\n})\r\nexport class FeatureManagementComponent {\r\n @Input()\r\n providerKey: string;\r\n\r\n @Input()\r\n providerName: string;\r\n\r\n protected _visible;\r\n\r\n @Input()\r\n get visible(): boolean {\r\n return this._visible;\r\n }\r\n\r\n set visible(value: boolean) {\r\n this._visible = value;\r\n this.visibleChange.emit(value);\r\n\r\n if (value) this.openModal();\r\n }\r\n\r\n @Output() readonly visibleChange = new EventEmitter<boolean>();\r\n\r\n @Select(FeatureManagementState.getFeatures)\r\n features$: Observable<FeatureManagement.Feature[]>;\r\n\r\n modalBusy = false;\r\n\r\n form: FormGroup;\r\n\r\n constructor(private store: Store) {}\r\n\r\n openModal() {\r\n if (!this.providerKey || !this.providerName) {\r\n throw new Error('Provider Key and Provider Name are required.');\r\n }\r\n\r\n this.getFeatures();\r\n }\r\n\r\n getFeatures() {\r\n this.store\r\n .dispatch(\r\n new GetFeatures({\r\n providerKey: this.providerKey,\r\n providerName: this.providerName,\r\n }),\r\n )\r\n .pipe(pluck('FeatureManagementState', 'features'))\r\n .subscribe(features => {\r\n this.buildForm(features);\r\n });\r\n }\r\n\r\n buildForm(features) {\r\n const formGroupObj = {};\r\n\r\n for (let i = 0; i < features.length; i++) {\r\n formGroupObj[i] = new FormControl(features[i].value === 'false' ? null : features[i].value);\r\n }\r\n\r\n this.form = new FormGroup(formGroupObj);\r\n }\r\n\r\n save() {\r\n if (this.modalBusy) return;\r\n\r\n this.modalBusy = true;\r\n\r\n let features = this.store.selectSnapshot(FeatureManagementState.getFeatures);\r\n\r\n features = features.map((feature, i) => ({\r\n name: feature.name,\r\n value: !this.form.value[i] || this.form.value[i] === 'false' ? null : this.form.value[i],\r\n }));\r\n\r\n this.store\r\n .dispatch(\r\n new UpdateFeatures({\r\n providerKey: this.providerKey,\r\n providerName: this.providerName,\r\n features,\r\n }),\r\n )\r\n .pipe(finalize(() => (this.modalBusy = false)))\r\n .subscribe(() => {\r\n this.visible = false;\r\n });\r\n }\r\n}\r\n","import { CoreModule } from '@abp/ng.core';\r\nimport { ThemeSharedModule } from '@abp/ng.theme.shared';\r\nimport { NgModule } from '@angular/core';\r\nimport { FeatureManagementComponent } from './components/feature-management/feature-management.component';\r\nimport { NgxsModule } from '@ngxs/store';\r\nimport { FeatureManagementState } from './states/feature-management.state';\r\n\r\n@NgModule({\r\n declarations: [FeatureManagementComponent],\r\n imports: [CoreModule, ThemeSharedModule, NgxsModule.forFeature([FeatureManagementState])],\r\n exports: [FeatureManagementComponent],\r\n})\r\nexport class FeatureManagementModule {}\r\n"],"names":["tslib_1.__dec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