add js docs for the installer context api
This commit is contained in:
@@ -1,8 +1,13 @@
|
||||
import { BehaviorSubject, ReplaySubject } from 'rxjs';
|
||||
import { BehaviorSubject, Observable, ReplaySubject } from 'rxjs';
|
||||
|
||||
import { getInstallSettings, postInstallSetup } from '../core/api/fetcher';
|
||||
import type { PostInstallRequest, ProblemDetails, UmbracoInstaller } from '../core/models';
|
||||
|
||||
/**
|
||||
* Context API for the installer
|
||||
* @export
|
||||
* @class UmbInstallerContext
|
||||
*/
|
||||
export class UmbInstallerContext {
|
||||
private _data = new BehaviorSubject<PostInstallRequest>({
|
||||
user: { name: '', email: '', password: '', subscribeToNewsletter: false },
|
||||
@@ -23,44 +28,100 @@ export class UmbInstallerContext {
|
||||
this._loadInstallerSettings();
|
||||
}
|
||||
|
||||
public currentStepChanges() {
|
||||
return this._currentStep;
|
||||
/**
|
||||
* Observable method to get the current step in the installation process
|
||||
* @public
|
||||
* @return {*} {Observable<number>}
|
||||
* @memberof UmbInstallerContext
|
||||
*/
|
||||
public currentStepChanges(): Observable<number> {
|
||||
return this.currentStep;
|
||||
}
|
||||
|
||||
public installStatusChanges() {
|
||||
return this._installStatus;
|
||||
/**
|
||||
* Observable method to get the install status in the installation process
|
||||
* @public
|
||||
* @return {*} {(Observable<ProblemDetails | null>)}
|
||||
* @memberof UmbInstallerContext
|
||||
*/
|
||||
public installStatusChanges(): Observable<ProblemDetails | null> {
|
||||
return this.installStatus;
|
||||
}
|
||||
|
||||
public nextStep() {
|
||||
/**
|
||||
* Increment the current step in the installation process
|
||||
* @public
|
||||
* @memberof UmbInstallerContext
|
||||
*/
|
||||
public nextStep(): void {
|
||||
this._currentStep.next(this._currentStep.getValue() + 1);
|
||||
}
|
||||
|
||||
public prevStep() {
|
||||
/**
|
||||
* Decrements the current step in the installation process
|
||||
* @public
|
||||
* @memberof UmbInstallerContext
|
||||
*/
|
||||
public prevStep(): void {
|
||||
this._currentStep.next(this._currentStep.getValue() - 1);
|
||||
}
|
||||
|
||||
public reset() {
|
||||
/**
|
||||
* Reset the installation process
|
||||
* @public
|
||||
* @memberof UmbInstallerContext
|
||||
*/
|
||||
public reset(): void {
|
||||
this._currentStep.next(1);
|
||||
this._installStatus.next(null);
|
||||
}
|
||||
|
||||
public appendData(data: any) {
|
||||
/**
|
||||
* Set the data for the installation process
|
||||
* @public
|
||||
* @param {Partial<PostInstallRequest>} data
|
||||
* @memberof UmbInstallerContext
|
||||
*/
|
||||
public appendData(data: Partial<PostInstallRequest>): void {
|
||||
this._data.next({ ...this.getData(), ...data });
|
||||
}
|
||||
|
||||
public getData() {
|
||||
/**
|
||||
* Get the data for the installation process
|
||||
* @public
|
||||
* @return {*} {PostInstallRequest}
|
||||
* @memberof UmbInstallerContext
|
||||
*/
|
||||
public getData(): PostInstallRequest {
|
||||
return this._data.getValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Post the installation data to the API
|
||||
* @public
|
||||
* @return {*}
|
||||
* @memberof UmbInstallerContext
|
||||
*/
|
||||
public requestInstall() {
|
||||
// TODO: The post install will probably return a user in the future, so we have to set that context somewhere to let the client know that it is authenticated
|
||||
return postInstallSetup(this.getData());
|
||||
}
|
||||
|
||||
public setInstallStatus(status: ProblemDetails | null) {
|
||||
/**
|
||||
* Set the install status
|
||||
* @public
|
||||
* @param {(ProblemDetails | null)} status
|
||||
* @memberof UmbInstallerContext
|
||||
*/
|
||||
public setInstallStatus(status: ProblemDetails | null): void {
|
||||
this._installStatus.next(status);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load installer settings from the API
|
||||
* @private
|
||||
* @memberof UmbInstallerContext
|
||||
*/
|
||||
private _loadInstallerSettings() {
|
||||
getInstallSettings({}).then(({ data }) => {
|
||||
this._settings.next(data);
|
||||
|
||||
Reference in New Issue
Block a user