Files
azuredatastudio/extensions/resource-deployment/src/ui/model.ts
Alan Ren a0e31fc723 wizard for deploying bdc (#7183)
* wip

* wip2

* wip eod 820

* wip 822

* text component improvements and misc changes

* aria-label

* targetClusterPage wip

* target cluster page

* target cluster page

* wip 827

* wip deployment profile page

* profile page

* service settings page

* wip 0903

* 0909 wip

* 0910

* 0911

* sql instance and working directory

* notebooks

* docker version on windows

* EULA env var

* 917 updates

* address comments

* use async file access

* fix the summary page display issue for ad auth

* add save json file buttons

* use promise for private methds

* review feedbacks

* refactor

* pass json to notebooks

* fix no tool scenario

* bypass tool check if installed

* update hint text

* update notebooks

* workaround azdata first time use

* comments

* accept eula and some text update

* fix the error in package.json

* promise instead of thenable

* comments

* fix typo
2019-09-25 10:04:13 -07:00

44 lines
1.7 KiB
TypeScript

/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
export class Model {
private propValueObject: { [s: string]: string | undefined } = {};
public setPropertyValue(property: string, value: string | number | boolean | undefined): void {
if (typeof value === 'boolean') {
this.propValueObject[property] = value ? 'true' : 'false';
} else if (typeof value === 'number') {
this.propValueObject[property] = value.toString();
} else {
this.propValueObject[property] = value;
}
}
public getIntegerValue(propName: string, defaultValue: number = 0): number {
const value = this.propValueObject[propName];
return value === undefined ? defaultValue : Number.parseInt(value);
}
public getStringValue(propName: string, defaultValue?: string): string | undefined {
const value = this.propValueObject[propName];
return value === undefined ? defaultValue : value;
}
public getBooleanValue(propName: string, defaultValue: boolean = false): boolean {
const value = this.propValueObject[propName];
return value === undefined ? defaultValue : value === 'true';
}
public setEnvironmentVariables(): void {
Object.keys(this.propValueObject).filter(propertyName => propertyName.startsWith('AZDATA_NB_VAR_')).forEach(propertyName => {
const value = this.getStringValue(propertyName);
if (value !== undefined && value !== '') {
process.env[propertyName] = value;
}
process.env[propertyName] = value === undefined ? '' : value;
});
}
}