mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-17 02:51:36 -05:00
Committer work: Import fixes and improvements (#5357)
* can make imports, but need to change success and failure views * fixed error handling UX * removed unused function * cr comments * fix typo * requested change
This commit is contained in:
@@ -99,24 +99,17 @@ export class FlatFileWizard {
|
|||||||
|
|
||||||
this.importAnotherFileButton.hidden = true;
|
this.importAnotherFileButton.hidden = true;
|
||||||
this.wizard.customButtons = [this.importAnotherFileButton];
|
this.wizard.customButtons = [this.importAnotherFileButton];
|
||||||
|
|
||||||
this.wizard.onPageChanged(async (event) => {
|
this.wizard.onPageChanged(async (event) => {
|
||||||
let idx = event.newPage;
|
let newPageIdx = event.newPage;
|
||||||
|
let lastPageIdx = event.lastPage;
|
||||||
let page = pages.get(idx);
|
let newPage = pages.get(newPageIdx);
|
||||||
|
let lastPage = pages.get(lastPageIdx);
|
||||||
if (page) {
|
if (lastPage) {
|
||||||
page.setupNavigationValidator();
|
await lastPage.onPageLeave();
|
||||||
page.onPageEnter();
|
|
||||||
}
|
}
|
||||||
});
|
if (newPage) {
|
||||||
|
newPage.setupNavigationValidator();
|
||||||
this.wizard.onPageChanged(async (event) => {
|
await newPage.onPageEnter();
|
||||||
let idx = event.lastPage;
|
|
||||||
|
|
||||||
let page = pages.get(idx);
|
|
||||||
if (page) {
|
|
||||||
page.onPageLeave();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -127,7 +127,7 @@ export class ModifyColumnsPage extends ImportPage {
|
|||||||
|
|
||||||
public setupNavigationValidator() {
|
public setupNavigationValidator() {
|
||||||
this.instance.registerNavigationValidator((info) => {
|
this.instance.registerNavigationValidator((info) => {
|
||||||
return !this.loading.loading;
|
return !this.loading.loading && this.table.data && this.table.data.length > 0;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,14 +11,21 @@ import { ImportDataModel } from '../api/models';
|
|||||||
import { ImportPage } from '../api/importPage';
|
import { ImportPage } from '../api/importPage';
|
||||||
import { FlatFileProvider } from '../../services/contracts';
|
import { FlatFileProvider } from '../../services/contracts';
|
||||||
import { FlatFileWizard } from '../flatFileWizard';
|
import { FlatFileWizard } from '../flatFileWizard';
|
||||||
|
import { PerformanceObserver } from 'perf_hooks';
|
||||||
|
|
||||||
const localize = nls.loadMessageBundle();
|
const localize = nls.loadMessageBundle();
|
||||||
|
|
||||||
export class ProsePreviewPage extends ImportPage {
|
export class ProsePreviewPage extends ImportPage {
|
||||||
|
|
||||||
|
private readonly successTitle: string = localize('flatFileImport.prosePreviewMessage', 'This operation analyzed the input file structure to generate the preview below for up to the first 50 rows.');
|
||||||
|
private readonly failureTitle: string = localize('flatFileImport.prosePreviewMessageFail', 'This operation was unsuccessful. Please try a different input file.');
|
||||||
|
|
||||||
private table: azdata.TableComponent;
|
private table: azdata.TableComponent;
|
||||||
private loading: azdata.LoadingComponent;
|
private loading: azdata.LoadingComponent;
|
||||||
private form: azdata.FormContainer;
|
private form: azdata.FormContainer;
|
||||||
private refresh: azdata.ButtonComponent;
|
private refresh: azdata.ButtonComponent;
|
||||||
|
private resultTextComponent: azdata.TextComponent;
|
||||||
|
private isSuccess: boolean;
|
||||||
|
|
||||||
public constructor(instance: FlatFileWizard, wizardPage: azdata.window.WizardPage, model: ImportDataModel, view: azdata.ModelView, provider: FlatFileProvider) {
|
public constructor(instance: FlatFileWizard, wizardPage: azdata.window.WizardPage, model: ImportDataModel, view: azdata.ModelView, provider: FlatFileProvider) {
|
||||||
super(instance, wizardPage, model, view, provider);
|
super(instance, wizardPage, model, view, provider);
|
||||||
@@ -32,15 +39,24 @@ export class ProsePreviewPage extends ImportPage {
|
|||||||
}).component();
|
}).component();
|
||||||
|
|
||||||
this.refresh.onDidClick(async () => {
|
this.refresh.onDidClick(async () => {
|
||||||
this.onPageEnter();
|
await this.onPageEnter();
|
||||||
});
|
});
|
||||||
|
|
||||||
this.loading = this.view.modelBuilder.loadingComponent().component();
|
this.loading = this.view.modelBuilder.loadingComponent().component();
|
||||||
|
|
||||||
|
this.resultTextComponent = this.view.modelBuilder.text()
|
||||||
|
.withProperties({
|
||||||
|
value: this.isSuccess ? this.successTitle : this.failureTitle
|
||||||
|
}).component();
|
||||||
|
|
||||||
this.form = this.view.modelBuilder.formContainer().withFormItems([
|
this.form = this.view.modelBuilder.formContainer().withFormItems([
|
||||||
|
{
|
||||||
|
component: this.resultTextComponent,
|
||||||
|
title: ''
|
||||||
|
},
|
||||||
{
|
{
|
||||||
component: this.table,
|
component: this.table,
|
||||||
title: localize('flatFileImport.prosePreviewMessage', 'This operation analyzed the input file structure to generate the preview below for up to the first 50 rows.'),
|
title: '',
|
||||||
actions: [this.refresh]
|
actions: [this.refresh]
|
||||||
}
|
}
|
||||||
]).component();
|
]).component();
|
||||||
@@ -54,11 +70,23 @@ export class ProsePreviewPage extends ImportPage {
|
|||||||
|
|
||||||
async onPageEnter(): Promise<boolean> {
|
async onPageEnter(): Promise<boolean> {
|
||||||
this.loading.loading = true;
|
this.loading.loading = true;
|
||||||
await this.handleProse();
|
let proseResult = await this.handleProse();
|
||||||
await this.populateTable(this.model.proseDataPreview, this.model.proseColumns.map(c => c.columnName));
|
|
||||||
this.loading.loading = false;
|
this.loading.loading = false;
|
||||||
|
if (proseResult) {
|
||||||
|
await this.populateTable(this.model.proseDataPreview, this.model.proseColumns.map(c => c.columnName));
|
||||||
|
this.isSuccess = true;
|
||||||
|
if (this.form) {
|
||||||
|
this.resultTextComponent.value = this.successTitle;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
|
} else {
|
||||||
|
await this.populateTable([], []);
|
||||||
|
this.isSuccess = false;
|
||||||
|
if (this.form) {
|
||||||
|
this.resultTextComponent.value = this.failureTitle;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async onPageLeave(): Promise<boolean> {
|
async onPageLeave(): Promise<boolean> {
|
||||||
@@ -73,19 +101,30 @@ export class ProsePreviewPage extends ImportPage {
|
|||||||
|
|
||||||
public setupNavigationValidator() {
|
public setupNavigationValidator() {
|
||||||
this.instance.registerNavigationValidator((info) => {
|
this.instance.registerNavigationValidator((info) => {
|
||||||
|
if (info) {
|
||||||
|
// Prose Preview to Modify Columns
|
||||||
|
if (info.lastPage === 1 && info.newPage === 2) {
|
||||||
|
return !this.loading.loading && this.table.data && this.table.data.length > 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
return !this.loading.loading;
|
return !this.loading.loading;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private async handleProse() {
|
private async handleProse(): Promise<boolean> {
|
||||||
await this.provider.sendPROSEDiscoveryRequest({
|
return this.provider.sendPROSEDiscoveryRequest({
|
||||||
filePath: this.model.filePath,
|
filePath: this.model.filePath,
|
||||||
tableName: this.model.table,
|
tableName: this.model.table,
|
||||||
schemaName: this.model.schema,
|
schemaName: this.model.schema,
|
||||||
fileType: this.model.fileType
|
fileType: this.model.fileType
|
||||||
}).then((result) => {
|
}).then((result) => {
|
||||||
|
if (result) {
|
||||||
|
this.model.proseDataPreview = null;
|
||||||
|
if (result.dataPreview) {
|
||||||
this.model.proseDataPreview = result.dataPreview;
|
this.model.proseDataPreview = result.dataPreview;
|
||||||
|
}
|
||||||
this.model.proseColumns = [];
|
this.model.proseColumns = [];
|
||||||
|
if (result.columnInfo) {
|
||||||
result.columnInfo.forEach((column) => {
|
result.columnInfo.forEach((column) => {
|
||||||
this.model.proseColumns.push({
|
this.model.proseColumns.push({
|
||||||
columnName: column.name,
|
columnName: column.name,
|
||||||
@@ -94,6 +133,10 @@ export class ProsePreviewPage extends ImportPage {
|
|||||||
nullable: column.isNullable
|
nullable: column.isNullable
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -119,5 +162,4 @@ export class ProsePreviewPage extends ImportPage {
|
|||||||
private async emptyTable() {
|
private async emptyTable() {
|
||||||
this.table.updateProperties([]);
|
this.table.updateProperties([]);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user