mirror of
https://github.com/dbeaver/cloudbeaver.git
synced 2026-09-24 16:04:36 +08:00
fix: after merge
This commit is contained in:
@@ -30,5 +30,5 @@ export function StaticImage({
|
||||
|
||||
const url = icon[0] === '/' ? icon : `${staticEndpoint}/images/${icon}`;
|
||||
|
||||
return <img className={className} src={url} title={title} onClick={onClick} alt={icon}/>;
|
||||
return <img className={className} src={url} title={title} onClick={onClick}/>;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
mutation asyncExportTaskStatus(
|
||||
$taskId: String!
|
||||
) {
|
||||
taskInfo: asyncTaskStatus(
|
||||
id: $taskId
|
||||
) {
|
||||
id
|
||||
running
|
||||
taskResult
|
||||
error {
|
||||
message
|
||||
errorCode
|
||||
stackTrace
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -852,6 +852,16 @@ export type ChangeSessionLanguageMutation = Pick<
|
||||
"changeSessionLanguage"
|
||||
>;
|
||||
|
||||
export type AsyncExportTaskStatusMutationVariables = {
|
||||
taskId: Scalars["String"];
|
||||
};
|
||||
|
||||
export type AsyncExportTaskStatusMutation = {
|
||||
taskInfo: Pick<AsyncTaskInfo, "id" | "running" | "taskResult"> & {
|
||||
error: Maybe<Pick<ServerError, "message" | "errorCode" | "stackTrace">>;
|
||||
};
|
||||
};
|
||||
|
||||
export type ExportDataFromContainerQueryVariables = {
|
||||
connectionId: Scalars["ID"];
|
||||
containerNodePath: Scalars["ID"];
|
||||
@@ -1485,6 +1495,20 @@ export const ChangeSessionLanguageDocument = gql`
|
||||
changeSessionLanguage(locale: $locale)
|
||||
}
|
||||
`;
|
||||
export const AsyncExportTaskStatusDocument = gql`
|
||||
mutation asyncExportTaskStatus($taskId: String!) {
|
||||
taskInfo: asyncTaskStatus(id: $taskId) {
|
||||
id
|
||||
running
|
||||
taskResult
|
||||
error {
|
||||
message
|
||||
errorCode
|
||||
stackTrace
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
export const ExportDataFromContainerDocument = gql`
|
||||
query exportDataFromContainer(
|
||||
$connectionId: ID!
|
||||
@@ -2040,6 +2064,14 @@ export function getSdk(client: GraphQLClient) {
|
||||
variables,
|
||||
);
|
||||
},
|
||||
asyncExportTaskStatus(
|
||||
variables: AsyncExportTaskStatusMutationVariables,
|
||||
): Promise<AsyncExportTaskStatusMutation> {
|
||||
return client.request<AsyncExportTaskStatusMutation>(
|
||||
print(AsyncExportTaskStatusDocument),
|
||||
variables,
|
||||
);
|
||||
},
|
||||
exportDataFromContainer(
|
||||
variables: ExportDataFromContainerQueryVariables,
|
||||
): Promise<ExportDataFromContainerQuery> {
|
||||
|
||||
@@ -36,13 +36,6 @@ export class DataExportMenuService {
|
||||
}
|
||||
|
||||
private exportData(context: IMenuContext<TableViewerModel>) {
|
||||
console.log({
|
||||
connectionId: context.data.connectionId,
|
||||
contextId: context.data.executionContext?.contextId,
|
||||
containerNodePath: context.data.containerNodePath,
|
||||
resultId: context.data.resultId,
|
||||
sourceName: context.data.sourceName,
|
||||
});
|
||||
this.commonDialogService.open(DataExportDialog, {
|
||||
connectionId: context.data.connectionId,
|
||||
contextId: context.data.executionContext?.contextId,
|
||||
|
||||
@@ -72,6 +72,7 @@ export class DataExportService {
|
||||
const taskId = await process.start(connectionId, containerNodePath, parameters);
|
||||
if (taskId) {
|
||||
this.exportProcesses.set(taskId, process);
|
||||
// this.notificationService.logInfo({ title: 'We prepare your file for export. Please wait' });
|
||||
await process.promise;
|
||||
window.open(this.download(taskId), '_blank');
|
||||
return taskId;
|
||||
|
||||
@@ -25,8 +25,9 @@ export enum DataExportStep {
|
||||
export class DataExportController implements IInitializableController {
|
||||
@observable step = DataExportStep.DataTransferProcessor
|
||||
get isLoading() {
|
||||
return !this.dataExportService.processors.isLoaded();
|
||||
return this.dataExportService.processors.isLoading();
|
||||
}
|
||||
@observable isExporting = false
|
||||
@observable processor: DataTransferProcessorInfo | null = null
|
||||
|
||||
@computed get processors(): DataTransferProcessorInfo[] {
|
||||
@@ -41,41 +42,52 @@ export class DataExportController implements IInitializableController {
|
||||
@observable properties: IProperty[] = []
|
||||
|
||||
private context!: IExportContext;
|
||||
private close!: () => void;
|
||||
|
||||
constructor(
|
||||
private dataExportService: DataExportService,
|
||||
private notificationService: NotificationService
|
||||
) { }
|
||||
|
||||
init(context: IExportContext) {
|
||||
init(context: IExportContext, close: () => void) {
|
||||
this.context = context;
|
||||
this.close = close;
|
||||
this.loadProcessors();
|
||||
}
|
||||
|
||||
export = () => {
|
||||
if (!this.processor) {
|
||||
export = async () => {
|
||||
if (!this.processor || this.isExporting) {
|
||||
return;
|
||||
}
|
||||
this.isExporting = true;
|
||||
|
||||
if (this.context.containerNodePath) {
|
||||
this.dataExportService.exportFromContainer(
|
||||
this.context.connectionId,
|
||||
this.context.containerNodePath,
|
||||
{
|
||||
processorId: this.processor.id,
|
||||
processorProperties: this.processorProperties,
|
||||
}
|
||||
);
|
||||
} else if (this.context.contextId && this.context.resultId) {
|
||||
this.dataExportService.exportFromResults(
|
||||
this.context.connectionId,
|
||||
this.context.contextId,
|
||||
this.context.resultId,
|
||||
{
|
||||
processorId: this.processor.id,
|
||||
processorProperties: this.processorProperties,
|
||||
}
|
||||
);
|
||||
try {
|
||||
if (this.context.containerNodePath) {
|
||||
await this.dataExportService.exportFromContainer(
|
||||
this.context.connectionId,
|
||||
this.context.containerNodePath,
|
||||
{
|
||||
processorId: this.processor.id,
|
||||
processorProperties: this.processorProperties,
|
||||
}
|
||||
);
|
||||
} else if (this.context.contextId && this.context.resultId) {
|
||||
await this.dataExportService.exportFromResults(
|
||||
this.context.connectionId,
|
||||
this.context.contextId,
|
||||
this.context.resultId,
|
||||
{
|
||||
processorId: this.processor.id,
|
||||
processorProperties: this.processorProperties,
|
||||
}
|
||||
);
|
||||
}
|
||||
this.close();
|
||||
} catch (exception) {
|
||||
this.notificationService.logException(exception, 'Can\'t export');
|
||||
} finally {
|
||||
this.isExporting = false;
|
||||
close();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ import { ProcessorSelectDialog } from './ProcessorSelectDialog';
|
||||
|
||||
export const DataExportDialog: DialogComponent<IExportContext, null> = observer(
|
||||
function DataExportDialog(props) {
|
||||
const controller = useController(DataExportController, props.payload);
|
||||
const controller = useController(DataExportController, props.payload, props.rejectDialog);
|
||||
|
||||
if (controller.step === DataExportStep.Configure && controller.processor) {
|
||||
return (
|
||||
@@ -26,7 +26,7 @@ export const DataExportDialog: DialogComponent<IExportContext, null> = observer(
|
||||
processor={controller.processor}
|
||||
properties={controller.properties}
|
||||
processorProperties={controller.processorProperties}
|
||||
isExporting={false}
|
||||
isExporting={controller.isExporting}
|
||||
onBack={() => controller.setStep(DataExportStep.DataTransferProcessor)}
|
||||
onClose={props.rejectDialog}
|
||||
onExport={controller.export}
|
||||
|
||||
@@ -24,6 +24,9 @@ const styles = css`
|
||||
PropertiesTable {
|
||||
flex: 1;
|
||||
}
|
||||
message {
|
||||
margin: auto;
|
||||
}
|
||||
`;
|
||||
|
||||
type ProcessorSelectDialogProps = {
|
||||
@@ -62,7 +65,7 @@ export const ProcessorConfigureDialog = observer(
|
||||
}
|
||||
onReject={onClose}
|
||||
>
|
||||
{isExporting && <Loader />}
|
||||
{isExporting && <message as="div">We prepare your file for export. Please wait...</message>}
|
||||
{!isExporting && (
|
||||
<PropertiesTable
|
||||
properties={properties}
|
||||
|
||||
@@ -47,7 +47,7 @@ export class ExportFromContainerProcess extends Deferred<string> {
|
||||
}
|
||||
} catch (e) {
|
||||
this.onError(e);
|
||||
return;
|
||||
throw e;
|
||||
}
|
||||
|
||||
this.statusUpdateProcess();
|
||||
@@ -80,7 +80,7 @@ export class ExportFromContainerProcess extends Deferred<string> {
|
||||
}
|
||||
// run the first check immediately because usually the query execution is fast
|
||||
try {
|
||||
const { taskInfo } = await this.graphQLService.gql.asyncTaskStatus({ taskId: this.taskId });
|
||||
const { taskInfo } = await this.graphQLService.gql.asyncExportTaskStatus({ taskId: this.taskId });
|
||||
this.applyResult(taskInfo);
|
||||
if (this.isFinished) {
|
||||
return;
|
||||
|
||||
@@ -49,7 +49,7 @@ export class ExportFromResultsProcess extends Deferred<string> {
|
||||
}
|
||||
} catch (e) {
|
||||
this.onError(e);
|
||||
return;
|
||||
throw e;
|
||||
}
|
||||
|
||||
this.statusUpdateProcess();
|
||||
@@ -82,7 +82,7 @@ export class ExportFromResultsProcess extends Deferred<string> {
|
||||
}
|
||||
// run the first check immediately because usually the query execution is fast
|
||||
try {
|
||||
const { taskInfo } = await this.graphQLService.gql.asyncTaskStatus({ taskId: this.taskId });
|
||||
const { taskInfo } = await this.graphQLService.gql.asyncExportTaskStatus({ taskId: this.taskId });
|
||||
this.applyResult(taskInfo);
|
||||
if (this.isFinished) {
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user