src/app/services/startup-check.service.ts
| providedIn | root |
Properties |
Methods |
|
| Public setSteps | ||||||
setSteps(steps: StartupStep[])
|
||||||
|
Defined in src/app/services/startup-check.service.ts:89
|
||||||
|
Parameters :
Returns :
void
|
| Public setTagDetails | ||||||
setTagDetails(details: StartupStepDetail[])
|
||||||
|
Defined in src/app/services/startup-check.service.ts:80
|
||||||
|
Shows the
Parameters :
Returns :
void
|
| Public updateStep | ||||||||||||
updateStep(index: number, status: StartupStepStatus, detail?: string)
|
||||||||||||
|
Defined in src/app/services/startup-check.service.ts:68
|
||||||||||||
|
Parameters :
Returns :
void
|
| Private steps |
Type : StartupStep[]
|
Default value : [
{ label: 'Checking app location', status: 'pending' },
{ label: 'Checking Viya deploy', status: 'pending' },
{ label: 'Loading startup service', status: 'pending' },
{ label: 'SASjs tag', status: 'pending' }
]
|
|
Defined in src/app/services/startup-check.service.ts:59
|
| Public steps$ |
Type : unknown
|
Default value : new BehaviorSubject<StartupStep[]>([...this.steps])
|
|
Defined in src/app/services/startup-check.service.ts:66
|
import { Injectable } from '@angular/core'
import { BehaviorSubject } from 'rxjs'
export type StartupStepStatus = 'pending' | 'in_progress' | 'done' | 'error'
/** A name/value pair shown under a startup step. */
export interface StartupStepDetail {
name: string
value: string
}
export interface StartupStep {
label: string
status: StartupStepStatus
detail?: string
/** Rendered as a grid under the label. */
details?: StartupStepDetail[]
}
/**
* Index of the `<sasjs>` tag dump within the startup steps. It is appended
* after the three startup checks so the indices the startup flow already drives
* (sas.service / app.service) are unchanged.
*/
export const SASJS_TAG_STEP = 3
/**
* Canonical spelling of the `<sasjs>` tag attributes. HTML lower-cases attribute
* names in the DOM, so they are mapped back for display.
*/
const TAG_ATTRIBUTE_NAMES: Record<string, string> = {
serverurl: 'serverUrl',
apploc: 'appLoc',
servertype: 'serverType',
loginmechanism: 'loginMechanism',
admingroup: 'adminGroup',
dcpath: 'dcPath',
debug: 'debug',
usecomputeapi: 'useComputeApi',
runastask: 'runAsTask',
contextname: 'contextName',
hotlicencekey: 'hotLicenceKey'
}
/**
* Reads the attributes of the `<sasjs>` tag for display in the startup checks.
* Every attribute is shown - including ones the parser does not know about, so a
* misspelt one is visible and a wrong value is exactly the misconfiguration this
* dump exists to expose.
*/
export const getSasjsTagDetails = (element: Element): StartupStepDetail[] =>
Array.from(element.attributes).map((attribute) => ({
name: TAG_ATTRIBUTE_NAMES[attribute.name.toLowerCase()] || attribute.name,
value: attribute.value || '(empty)'
}))
@Injectable({ providedIn: 'root' })
export class StartupCheckService {
private steps: StartupStep[] = [
{ label: 'Checking app location', status: 'pending' },
{ label: 'Checking Viya deploy', status: 'pending' },
{ label: 'Loading startup service', status: 'pending' },
{ label: 'SASjs tag', status: 'pending' }
]
public steps$ = new BehaviorSubject<StartupStep[]>([...this.steps])
public updateStep(index: number, status: StartupStepStatus, detail?: string) {
if (index >= 0 && index < this.steps.length) {
this.steps[index] = {
...this.steps[index],
status,
detail: detail ?? this.steps[index].detail
}
this.steps$.next([...this.steps])
}
}
/** Shows the `<sasjs>` tag contents on the boot screen. */
public setTagDetails(details: StartupStepDetail[]) {
this.steps[SASJS_TAG_STEP] = {
...this.steps[SASJS_TAG_STEP],
status: 'done',
details
}
this.steps$.next([...this.steps])
}
public setSteps(steps: StartupStep[]) {
this.steps = steps
this.steps$.next([...this.steps])
}
}