diff --git a/DbViewer.TestApi/Controllers/DbViewerApiController.cs b/DbViewer.TestApi/Controllers/DbViewerApiController.cs index 608fdc01..c1ba0131 100644 --- a/DbViewer.TestApi/Controllers/DbViewerApiController.cs +++ b/DbViewer.TestApi/Controllers/DbViewerApiController.cs @@ -32,11 +32,11 @@ public DbViewerApiController(SchemaRegistryProvider schemaRegistryProvider) [Route("{objectIdentifier}/count")] public Task CountObjects(string objectIdentifier, [FromBody] ObjectSearchRequest query) => impl.CountObjects(objectIdentifier, query, IsSuperUser()); - [HttpGet] - [Route("{objectIdentifier}/download/{queryString}")] - public async Task DownloadObjects(string objectIdentifier, string queryString) + [HttpPost] + [Route("{objectIdentifier}/download")] + public async Task DownloadObjects(string objectIdentifier, [FromForm] string data) { - var fileInfo = await impl.DownloadObjects(objectIdentifier, queryString, IsSuperUser()).ConfigureAwait(false); + var fileInfo = await impl.DownloadObjects(objectIdentifier, data, IsSuperUser()).ConfigureAwait(false); return File(fileInfo.Content, fileInfo.ContentType, fileInfo.Name); } diff --git a/DbViewer.TestApi/TypeScriptConfiguration/InternalApiTypeBuildingContext.cs b/DbViewer.TestApi/TypeScriptConfiguration/InternalApiTypeBuildingContext.cs index be97f708..6a652af7 100644 --- a/DbViewer.TestApi/TypeScriptConfiguration/InternalApiTypeBuildingContext.cs +++ b/DbViewer.TestApi/TypeScriptConfiguration/InternalApiTypeBuildingContext.cs @@ -81,13 +81,7 @@ private static TypeScriptClassMemberDefinition BuildApiImplMember(IMethodInfo me Result = GetMethodResult(methodInfo, buildAndImportType), Body = {isUrlMethod ? GenerateGetUrlCall(methodInfo) : CreateCall(methodInfo)} }; - functionDefinition.Arguments.AddRange( - methodInfo.GetParameters().Select(x => new TypeScriptArgumentDeclaration - { - Name = x.Name, - Type = buildAndImportType(x.ParameterType) - }) - ); + functionDefinition.Arguments.AddRange(GetArguments(methodInfo, buildAndImportType)); return new TypeScriptClassMemberDefinition { Name = GetMethodName(methodInfo), @@ -224,14 +218,21 @@ private static TypeScriptExpression GenerateConstructGetParams(IParameterInfo[] private static TypeScriptInterfaceFunctionMember BuildApiInterfaceMember(IMethodInfo methodInfo, Func buildAndImportType) { var result = new TypeScriptInterfaceFunctionMember(GetMethodName(methodInfo), GetMethodResult(methodInfo, buildAndImportType)); - result.Arguments.AddRange( - methodInfo.GetParameters().Select(x => new TypeScriptArgumentDeclaration - { - Name = x.Name, - Type = buildAndImportType(x.ParameterType) - }) - ); + result.Arguments.AddRange(GetArguments(methodInfo, buildAndImportType)); return result; } + + private static TypeScriptArgumentDeclaration[] GetArguments(IMethodInfo methodInfo, Func buildAndImportType) + { + var isUrlMethod = IsUrlMethod(methodInfo); + return methodInfo.GetParameters() + .Where(x => !isUrlMethod || !x.ParameterType.GetAttributes(TypeInfo.From()).Any()) + .Select(x => new TypeScriptArgumentDeclaration + { + Name = x.Name, + Type = buildAndImportType(x.ParameterType) + }) + .ToArray(); + } } } \ No newline at end of file diff --git a/db-viewer-ui/src/Components/ObjectTableLayoutHeader/DownloadButton.tsx b/db-viewer-ui/src/Components/ObjectTableLayoutHeader/DownloadButton.tsx new file mode 100644 index 00000000..0a39e762 --- /dev/null +++ b/db-viewer-ui/src/Components/ObjectTableLayoutHeader/DownloadButton.tsx @@ -0,0 +1,40 @@ +import DownloadIcon from "@skbkontur/react-icons/Download"; +import { Button } from "@skbkontur/react-ui"; +import React from "react"; + +import { Condition } from "../../Domain/Api/DataTypes/Condition"; +import { Sort } from "../../Domain/Api/DataTypes/Sort"; + +import { Spinner } from "./Spinner"; + +interface DownloadButtonProps { + action: string; + conditions: Condition[]; + sorts: Sort[]; + hiddenColumns: string[]; +} + +export function DownloadButton({ action, conditions, sorts, hiddenColumns }: DownloadButtonProps): JSX.Element { + const [downloading, setDownloading] = React.useState(false); + return ( +
console.info(e)}> + + +
+ ); +} diff --git a/db-viewer-ui/src/Containers/ObjectTableContainer.tsx b/db-viewer-ui/src/Containers/ObjectTableContainer.tsx index 29d29e5f..83b1a9de 100644 --- a/db-viewer-ui/src/Containers/ObjectTableContainer.tsx +++ b/db-viewer-ui/src/Containers/ObjectTableContainer.tsx @@ -1,5 +1,5 @@ import { ColumnStack, Fit, RowStack } from "@skbkontur/react-stack-layout"; -import { Link, Loader, Paging } from "@skbkontur/react-ui"; +import { Button, Link, Loader, Paging } from "@skbkontur/react-ui"; import isEqual from "lodash/isEqual"; import qs from "qs"; import React from "react"; @@ -8,6 +8,7 @@ import { RouteComponentProps, withRouter } from "react-router"; import { ErrorHandlingContainer } from "../Components/ErrorHandling/ErrorHandlingContainer"; import { CommonLayout } from "../Components/Layouts/CommonLayout"; import { ObjectTable } from "../Components/ObjectTable/ObjectTable"; +import { DownloadButton } from "../Components/ObjectTableLayoutHeader/DownloadButton"; import { ObjectTableLayoutHeader } from "../Components/ObjectTableLayoutHeader/ObjectTableLayoutHeader"; import { Condition } from "../Domain/Api/DataTypes/Condition"; import { CountResult } from "../Domain/Api/DataTypes/CountResult"; @@ -99,7 +100,7 @@ class ObjectTableContainerInternal extends React.Component + {metaInformation && ( + + )}