mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-14 01:25:37 -05:00
* Adding server name to wizard and dialog title Surfacing async errors Fixing a bunch of strings to match the mockup * Adding auto refresh for migration status * Removing errors for sql vm migration * using new logic to get sql server username * Fixing help links * Removing unncessary await
71 lines
2.0 KiB
TypeScript
71 lines
2.0 KiB
TypeScript
/*---------------------------------------------------------------------------------------------
|
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
|
*--------------------------------------------------------------------------------------------*/
|
|
|
|
import { getMigrationStatus, DatabaseMigration, startMigrationCutover, stopMigration, getMigrationAsyncOperationDetails, AzureAsyncOperationResource } from '../../api/azure';
|
|
import { MigrationContext } from '../../models/migrationLocalStorage';
|
|
|
|
export enum MigrationStatus {
|
|
Failed = 'Failed',
|
|
Succeeded = 'Succeeded',
|
|
InProgress = 'InProgress',
|
|
Canceled = 'Canceled'
|
|
}
|
|
|
|
export class MigrationCutoverDialogModel {
|
|
|
|
public migrationStatus!: DatabaseMigration;
|
|
public migrationOpStatus!: AzureAsyncOperationResource;
|
|
|
|
constructor(public _migration: MigrationContext) {
|
|
}
|
|
|
|
public async fetchStatus(): Promise<void> {
|
|
if (this._migration.asyncUrl) {
|
|
this.migrationOpStatus = (await getMigrationAsyncOperationDetails(
|
|
this._migration.azureAccount,
|
|
this._migration.subscription,
|
|
this._migration.asyncUrl
|
|
));
|
|
}
|
|
this.migrationStatus = (await getMigrationStatus(
|
|
this._migration.azureAccount,
|
|
this._migration.subscription,
|
|
this._migration.migrationContext
|
|
));
|
|
// Logging status to help debugging.
|
|
console.log(this.migrationStatus);
|
|
}
|
|
|
|
public async startCutover(): Promise<DatabaseMigration | undefined> {
|
|
try {
|
|
if (this.migrationStatus) {
|
|
return await startMigrationCutover(
|
|
this._migration.azureAccount,
|
|
this._migration.subscription,
|
|
this.migrationStatus
|
|
);
|
|
}
|
|
} catch (error) {
|
|
console.log(error);
|
|
}
|
|
return undefined!;
|
|
}
|
|
|
|
public async cancelMigration(): Promise<void> {
|
|
try {
|
|
if (this.migrationStatus) {
|
|
await stopMigration(
|
|
this._migration.azureAccount,
|
|
this._migration.subscription,
|
|
this.migrationStatus
|
|
);
|
|
}
|
|
} catch (error) {
|
|
console.log(error);
|
|
}
|
|
return undefined!;
|
|
}
|
|
}
|