Adding support for sql vm and some target page UI fixes. (#14571)

* Added SQL VM dropdown
Fixed the icons in cards

* Added a better api for sql vms

* Making some PR related changes
1. Using map instead of foreach
This commit is contained in:
Aasim Khan
2021-03-05 13:32:29 -08:00
committed by GitHub
parent df06afa2ab
commit 63c59ed920
9 changed files with 151 additions and 65 deletions

View File

@@ -150,7 +150,7 @@ export class IntergrationRuntimePage extends MigrationWizardPage {
public async populateMigrationController(): Promise<void> {
this.migrationControllerDropdown.loading = true;
try {
this.migrationControllerDropdown.values = await this.migrationStateModel.getMigrationControllerValues(this.migrationStateModel._targetSubscription, this.migrationStateModel._targetManagedInstance);
this.migrationControllerDropdown.values = await this.migrationStateModel.getMigrationControllerValues(this.migrationStateModel._targetSubscription, this.migrationStateModel._targetServerInstance);
if (this.migrationStateModel._migrationController) {
this.migrationControllerDropdown.value = {
name: this.migrationStateModel._migrationController.id,

View File

@@ -30,7 +30,8 @@ export class SKURecommendationPage extends MigrationWizardPage {
private _chooseTargetComponent: azdata.FormComponent<azdata.DivContainer> | undefined;
private _azureSubscriptionText: azdata.FormComponent<azdata.TextComponent> | undefined;
private _managedInstanceSubscriptionDropdown!: azdata.DropDownComponent;
private _managedInstanceDropdown!: azdata.DropDownComponent;
private _resourceDropdownLabel!: azdata.TextComponent;
private _resourceDropdown!: azdata.DropDownComponent;
private _view: azdata.ModelView | undefined;
private _rbg!: azdata.RadioCardGroupComponent;
@@ -48,20 +49,27 @@ export class SKURecommendationPage extends MigrationWizardPage {
this._managedInstanceSubscriptionDropdown.onValueChanged((e) => {
if (e.selected) {
this.migrationStateModel._targetSubscription = this.migrationStateModel.getSubscription(e.index);
this.migrationStateModel._targetManagedInstance = undefined!;
this.migrationStateModel._targetServerInstance = undefined!;
this.migrationStateModel._migrationController = undefined!;
this.populateManagedInstanceDropdown();
this.populateResourceInstanceDropdown();
}
});
const managedInstanceDropdownLabel = view.modelBuilder.text().withProps({
this._resourceDropdownLabel = view.modelBuilder.text().withProps({
value: constants.MANAGED_INSTANCE
}).component();
this._managedInstanceDropdown = view.modelBuilder.dropDown().component();
this._managedInstanceDropdown.onValueChanged((e) => {
if (e.selected) {
this._resourceDropdown = view.modelBuilder.dropDown().component();
this._resourceDropdown.onValueChanged((e) => {
if (e.selected &&
e.selected !== constants.NO_MANAGED_INSTANCE_FOUND &&
e.selected !== constants.NO_VIRTUAL_MACHINE_FOUND) {
this.migrationStateModel._migrationControllers = undefined!;
this.migrationStateModel._targetManagedInstance = this.migrationStateModel.getManagedInstance(e.index);
if (this._rbg.selectedCardId === 'AzureSQLVM') {
this.migrationStateModel._targetServerInstance = this.migrationStateModel.getVirtualMachine(e.index);
} else {
this.migrationStateModel._targetServerInstance = this.migrationStateModel.getManagedInstance(e.index);
}
}
});
@@ -69,8 +77,8 @@ export class SKURecommendationPage extends MigrationWizardPage {
[
managedInstanceSubscriptionDropdownLabel,
this._managedInstanceSubscriptionDropdown,
managedInstanceDropdownLabel,
this._managedInstanceDropdown
this._resourceDropdownLabel,
this._resourceDropdown
]
).withLayout({
flexFlow: 'column'
@@ -151,41 +159,49 @@ export class SKURecommendationPage extends MigrationWizardPage {
this._rbg = this._view!.modelBuilder.radioCardGroup().withProperties<azdata.RadioCardGroupComponentProperties>({
cards: [],
cardWidth: '600px',
cardHeight: '60px',
cardHeight: '40px',
orientation: azdata.Orientation.Vertical,
iconHeight: '30px',
iconWidth: '30px'
}).component();
products.forEach((product) => {
const imagePath = path.resolve(this.migrationStateModel.getExtensionPath(), 'media', product.icon ?? 'ads.svg');
let dbCount = 0;
if (product.type === 'AzureSQLVM') {
dbCount = 0;
} else {
dbCount = this.migrationStateModel._migrationDbs.length;
}
const imagePath = path.resolve(this.migrationStateModel.getExtensionPath(), 'images', product.icon ?? 'ads.svg');
const dbCount = this.migrationStateModel._migrationDbs.length;
const descriptions: azdata.RadioCardDescription[] = [
{
textValue: product.name,
linkDisplayValue: 'Learn more',
displayLinkCodicon: true,
textStyles: {
'font-size': '1rem',
'font-weight': 550,
'font-size': '14px',
'font-weight': 'bold',
'line-height': '20px'
},
linkDisplayValue: 'Learn more',
linkStyles: {
'font-size': '14px',
'line-height': '20px'
},
displayLinkCodicon: true,
linkCodiconStyles: {
'font-size': '1em',
'color': 'royalblue'
}
'font-size': '14px',
'line-height': '20px'
},
},
{
textValue: `${dbCount} databases will be migrated`,
textStyles: {
'font-size': '13px',
'line-height': '18px'
},
linkStyles: {
'font-size': '14px',
'line-height': '20px'
},
linkDisplayValue: 'View/Change',
displayLinkCodicon: true,
linkCodiconStyles: {
'font-size': '1em',
'color': 'royalblue'
'font-size': '13px',
'line-height': '18px'
}
}
];
@@ -206,10 +222,7 @@ export class SKURecommendationPage extends MigrationWizardPage {
});
this._rbg.onSelectionChanged((value) => {
if (value.cardId === 'AzureSQLVM') {
vscode.window.showInformationMessage('Feature coming soon');
this._rbg.selectedCardId = 'AzureSQLMI';
}
this.populateResourceInstanceDropdown();
});
this._rbg.selectedCardId = 'AzureSQLMI';
@@ -220,7 +233,10 @@ export class SKURecommendationPage extends MigrationWizardPage {
private createAzureSubscriptionText(view: azdata.ModelView): azdata.FormComponent<azdata.TextComponent> {
const component = view.modelBuilder.text().withProperties<azdata.TextComponentProperties>({
value: 'Select an Azure subscription and an Azure SQL Managed Instance for your target.', //TODO: Localize
CSSStyles: {
'font-size': '13px',
'line-height': '18px'
}
});
return {
@@ -232,7 +248,7 @@ export class SKURecommendationPage extends MigrationWizardPage {
private async populateSubscriptionDropdown(): Promise<void> {
if (!this.migrationStateModel._targetSubscription) {
this._managedInstanceSubscriptionDropdown.loading = true;
this._managedInstanceDropdown.loading = true;
this._resourceDropdown.loading = true;
try {
this._managedInstanceSubscriptionDropdown.values = await this.migrationStateModel.getSubscriptionsDropdownValues();
} catch (e) {
@@ -243,16 +259,21 @@ export class SKURecommendationPage extends MigrationWizardPage {
}
}
private async populateManagedInstanceDropdown(): Promise<void> {
if (!this.migrationStateModel._targetManagedInstance) {
this._managedInstanceDropdown.loading = true;
try {
this._managedInstanceDropdown.values = await this.migrationStateModel.getManagedInstanceValues(this.migrationStateModel._targetSubscription);
} catch (e) {
console.log(e);
} finally {
this._managedInstanceDropdown.loading = false;
private async populateResourceInstanceDropdown(): Promise<void> {
this._resourceDropdown.loading = true;
try {
if (this._rbg.selectedCardId === 'AzureSQLVM') {
this._resourceDropdownLabel.value = constants.AZURE_SQL_DATABASE_VIRTUAL_MACHINE;
this._resourceDropdown.values = await this.migrationStateModel.getSqlVirtualMachineValues(this.migrationStateModel._targetSubscription);
} else {
this._resourceDropdownLabel.value = constants.AZURE_SQL_DATABASE_MANAGED_INSTANCE;
this._resourceDropdown.values = await this.migrationStateModel.getManagedInstanceValues(this.migrationStateModel._targetSubscription);
}
} catch (e) {
console.log(e);
} finally {
this._resourceDropdown.loading = false;
}
}
@@ -278,7 +299,8 @@ export class SKURecommendationPage extends MigrationWizardPage {
if ((<azdata.CategoryValue>this._managedInstanceSubscriptionDropdown.value).displayName === constants.NO_SUBSCRIPTIONS_FOUND) {
errors.push(constants.INVALID_SUBSCRIPTION_ERROR);
}
if ((<azdata.CategoryValue>this._managedInstanceDropdown.value).displayName === constants.NO_MANAGED_INSTANCE_FOUND) {
const resourceDropdownValue = (<azdata.CategoryValue>this._resourceDropdown.value).displayName;
if (resourceDropdownValue === constants.NO_MANAGED_INSTANCE_FOUND || resourceDropdownValue === constants.NO_VIRTUAL_MACHINE_FOUND) {
errors.push(constants.INVALID_STORAGE_ACCOUNT_ERROR);
}
@@ -317,6 +339,8 @@ export class SKURecommendationPage extends MigrationWizardPage {
};
const textValue: string = `${count} databases will be migrated`;
this._rbg.cards[0].descriptions[1].textValue = textValue;
this._rbg.cards[1].descriptions[1].textValue = textValue;
this._rbg.updateProperties({
cards: this._rbg.cards
});

View File

@@ -39,9 +39,9 @@ export class SummaryPage extends MigrationWizardPage {
createHeadingTextComponent(this._view, constants.AZURE_ACCOUNT_LINKED),
createHeadingTextComponent(this._view, this.migrationStateModel._azureAccount.displayInfo.displayName),
createHeadingTextComponent(this._view, constants.MIGRATION_TARGET),
createInformationRow(this._view, constants.TYPE, constants.SUMMARY_MI_TYPE),
createInformationRow(this._view, constants.TYPE, (this.migrationStateModel._targetServerInstance.type === 'microsoft.compute/virtualmachines') ? constants.SUMMARY_VM_TYPE : constants.SUMMARY_MI_TYPE),
createInformationRow(this._view, constants.SUBSCRIPTION, this.migrationStateModel._targetSubscription.name),
createInformationRow(this._view, constants.SUMMARY_MI_TYPE, this.migrationStateModel._targetManagedInstance.name),
createInformationRow(this._view, constants.SUMMARY_MI_TYPE, this.migrationStateModel._targetServerInstance.name),
createInformationRow(this._view, constants.SUMMARY_DATABASE_COUNT_LABEL, this.migrationStateModel._migrationDbs.length.toString()),
createHeadingTextComponent(this._view, constants.DATABASE_BACKUP_PAGE_TITLE),
this.createNetworkContainerRows(),

View File

@@ -32,7 +32,7 @@ export class TempTargetSelectionPage extends MigrationWizardPage {
this._managedInstanceSubscriptionDropdown.onValueChanged((e) => {
if (e.selected) {
this.migrationStateModel._targetSubscription = this.migrationStateModel.getSubscription(e.index);
this.migrationStateModel._targetManagedInstance = undefined!;
this.migrationStateModel._targetServerInstance = undefined!;
this.migrationStateModel._migrationController = undefined!;
this.populateManagedInstanceDropdown();
}
@@ -49,7 +49,7 @@ export class TempTargetSelectionPage extends MigrationWizardPage {
this._managedInstanceDropdown.onValueChanged((e) => {
if (e.selected) {
this.migrationStateModel._migrationControllers = undefined!;
this.migrationStateModel._targetManagedInstance = this.migrationStateModel.getManagedInstance(e.index);
this.migrationStateModel._targetServerInstance = this.migrationStateModel.getManagedInstance(e.index);
}
});
@@ -97,7 +97,7 @@ export class TempTargetSelectionPage extends MigrationWizardPage {
}
private async populateManagedInstanceDropdown(): Promise<void> {
if (!this.migrationStateModel._targetManagedInstance) {
if (!this.migrationStateModel._targetServerInstance) {
this._managedInstanceDropdown.loading = true;
try {
this._managedInstanceDropdown.values = await this.migrationStateModel.getManagedInstanceValues(this.migrationStateModel._targetSubscription);