From 2f706622bf8482e1c166057f1ddc875e89b5b057 Mon Sep 17 00:00:00 2001 From: marikaris Date: Thu, 2 May 2024 15:58:50 +0200 Subject: [PATCH] Revert "Feat: M10506 UI linkfile edit" --- .../armadillo/storage/ParquetUtils.java | 14 +- ui/src/api/api.ts | 27 +- ui/src/components/FileExplorer.vue | 10 - ui/src/components/SimpleTable.vue | 17 +- ui/src/components/VariableSelector.vue | 17 +- ui/src/components/ViewEditor.vue | 47 +- ui/src/helpers/utils.ts | 4 - ui/src/types/types.d.ts | 11 +- ui/src/views/ProjectsExplorer.vue | 242 +++-------- ui/tests/unit/components/SimpleTable.spec.ts | 16 +- .../unit/components/VariableSelector.spec.ts | 6 - ui/tests/unit/helpers/utils.spec.ts | 10 +- ui/tests/unit/views/ProjectExplorer.spec.ts | 8 - ui/yarn.lock | 406 +++++++++--------- 14 files changed, 307 insertions(+), 528 deletions(-) diff --git a/armadillo/src/main/java/org/molgenis/armadillo/storage/ParquetUtils.java b/armadillo/src/main/java/org/molgenis/armadillo/storage/ParquetUtils.java index c3823950d..152e5afbc 100644 --- a/armadillo/src/main/java/org/molgenis/armadillo/storage/ParquetUtils.java +++ b/armadillo/src/main/java/org/molgenis/armadillo/storage/ParquetUtils.java @@ -20,7 +20,8 @@ public class ParquetUtils { public static List> previewRecords( Path path, int rowLimit, int columnLimit, String[] variables) throws IOException { List> result = new ArrayList<>(); - try (ParquetFileReader reader = getFileReader(path)) { + LocalInputFile file = new LocalInputFile(path); + try (ParquetFileReader reader = ParquetFileReader.open(file)) { MessageType schema = getSchemaFromReader(reader); RecordReader recordReader = getRecordReader(schema, reader); List columns = getColumnsFromSchema(schema); @@ -72,13 +73,9 @@ private static RecordReader getRecordReader(MessageType schema, ParquetFi return columnIO.getRecordReader(store, new GroupRecordConverter(schema)); } - private static ParquetFileReader getFileReader(Path path) throws IOException { - LocalInputFile file = new LocalInputFile(path); - return ParquetFileReader.open(file); - } - public static List getColumns(Path path) throws IOException { - try (ParquetFileReader reader = getFileReader(path)) { + LocalInputFile file = new LocalInputFile(path); + try (ParquetFileReader reader = ParquetFileReader.open(file)) { var schema = getSchemaFromReader(reader); return getColumnsFromSchema(schema); } catch (IOException e) { @@ -87,7 +84,8 @@ public static List getColumns(Path path) throws IOException { } public static Map retrieveDimensions(Path path) throws FileNotFoundException { - try (ParquetFileReader reader = getFileReader(path)) { + LocalInputFile file = new LocalInputFile(path); + try (ParquetFileReader reader = ParquetFileReader.open(file)) { MessageType schema = getSchemaFromReader(reader); int numberOfColumns = schema.getFields().size(); long numberOfRows = reader.getRecordCount(); diff --git a/ui/src/api/api.ts b/ui/src/api/api.ts index a467584d5..dd522e04c 100644 --- a/ui/src/api/api.ts +++ b/ui/src/api/api.ts @@ -1,9 +1,5 @@ import { ApiError } from "@/helpers/errors"; -import { - encodeUriComponent, - objectDeepCopy, - sanitizeObject, -} from "@/helpers/utils"; +import { objectDeepCopy, sanitizeObject } from "@/helpers/utils"; import { Principal, Profile, @@ -223,10 +219,7 @@ export async function getProject(projectId: string): Promise { } export async function deleteObject(project: string, name: string) { - return delete_( - "/storage/projects/" + project + "/objects", - encodeUriComponent(name) - ); + return delete_("/storage/projects/" + project + "/objects", name); } export async function getProfiles(): Promise { @@ -261,11 +254,7 @@ export async function uploadIntoProject( } export async function previewObject(projectId: string, object: string) { - return get( - `/storage/projects/${projectId}/objects/${encodeUriComponent( - object - )}/preview` - ); + return get(`/storage/projects/${projectId}/objects/${object}/preview`); } export async function logout() { @@ -286,20 +275,14 @@ export async function authenticate(auth: Auth) { } export async function getFileDetails(project: string, object: string) { - return get( - `/storage/projects/${project}/objects/${encodeUriComponent(object)}/info` - ); + return get(`/storage/projects/${project}/objects/${object}/info`); } export async function getTableVariables( project: string, object: string ): Promise { - return get( - `/storage/projects/${project}/objects/${encodeUriComponent( - object - )}/variables` - ); + return get(`/storage/projects/${project}/objects/${object}/variables`); } export async function createLinkFile( diff --git a/ui/src/components/FileExplorer.vue b/ui/src/components/FileExplorer.vue index cef65abca..9cc13f9bc 100644 --- a/ui/src/components/FileExplorer.vue +++ b/ui/src/components/FileExplorer.vue @@ -25,7 +25,6 @@ rowIcon="table" rowIconAlt="file-earmark" :altIconCondition="isNonTableType" - :preselectedItem="selectedFile" selectionColor="primary" > @@ -67,18 +66,9 @@ export default defineComponent({ selectedFolder.value = newVal as string; } ); - watch( - () => route.params.fileId, - (newVal) => { - selectedFile.value = newVal as string; - } - ); onMounted(() => { if (route.params.folderId) { selectedFolder.value = route.params.folderId as string; - if (route.params.fileId) { - selectedFile.value = route.params.fileId as string; - } } watch( () => folderComponent.value?.selectedItem, diff --git a/ui/src/components/SimpleTable.vue b/ui/src/components/SimpleTable.vue index 5c3d0050a..1edc5d082 100644 --- a/ui/src/components/SimpleTable.vue +++ b/ui/src/components/SimpleTable.vue @@ -62,9 +62,22 @@ export default defineComponent({ }, computed: { maxNumberCharacters() { + // don't question the logic, it's a formula that figures out how many characters fit in each header label + // but if you do question it: + // maxWidth/200 spreads out nicely for 10 columns, to get 200 when the length of columns is 10, we do it times 20 (20 * l) + // for 5 columns, this leaves a lot of whitespace. There maxWidth/50, rather than 100, fits better. + // therefore, we need to substract 50 from the 20 * l if the number of columns is 5 and 0 if the number of columns is 1 + // to get that: (10 / l - 1) * 50, that's what we substract from the 20 * l + // example (l = 10): + // 20 * 10 = 200 + // 10 / 10 - 1 = 0 -> 0 * 50 = 0 + // 200 - 0 = 200 + // example (l = 5): + // 20 * 5 = 100 + // 10 / 5 - 1 = 1 -> 1 * 50 = 50 + // 100 - 50 = 50 const l = this.tableKeys.length; - // max width divided by number of characters * fontsize to evenly spread headers - return Math.floor(this.maxWidth / (l * 16)); + return Math.ceil(this.maxWidth / (20 * l - (10 / l - 1) * 50)); }, dataToPreview() { // converting ints to in, otherwise the id numbers look awkward diff --git a/ui/src/components/VariableSelector.vue b/ui/src/components/VariableSelector.vue index 70d66931c..19209ab4f 100644 --- a/ui/src/components/VariableSelector.vue +++ b/ui/src/components/VariableSelector.vue @@ -42,37 +42,28 @@