From d50f8d58c1b1ef0ddef1f2fdbce4b18d009e56cc Mon Sep 17 00:00:00 2001 From: Roni Choudhury Date: Fri, 13 Nov 2020 11:05:19 -0500 Subject: [PATCH 1/5] Add rudimentary stepper plus stand-in content --- src/components/TableDialog.vue | 82 ++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) diff --git a/src/components/TableDialog.vue b/src/components/TableDialog.vue index 8a6a8cfd..fbfb40dd 100644 --- a/src/components/TableDialog.vue +++ b/src/components/TableDialog.vue @@ -16,6 +16,84 @@ + + + + + Select Dataset + + + + + + Set Column Types + + + + + + Finish + + + + + +

hi

+ + + Next + +
+ + +

hii

+ + + Back + + + + Next + +
+ + +

hiii

+ + + Back + + + + Finish + +
+
+
+ = ref(1); + // Type recommendation const columnType: Ref<{[key: string]: CSVColumnType}> = ref({}); @@ -217,6 +298,7 @@ export default defineComponent({ } return { + step, columnType, multinetTypes, fileName, From 60299ca6845a33ce45e07a791e5864a3c310b61f Mon Sep 17 00:00:00 2001 From: Roni Choudhury Date: Fri, 13 Nov 2020 13:32:53 -0500 Subject: [PATCH 2/5] Move "create table" dialog content to inside stepper --- src/components/TableDialog.vue | 186 +++++++++++++++------------------ 1 file changed, 86 insertions(+), 100 deletions(-) diff --git a/src/components/TableDialog.vue b/src/components/TableDialog.vue index fbfb40dd..8ed8579d 100644 --- a/src/components/TableDialog.vue +++ b/src/components/TableDialog.vue @@ -47,14 +47,92 @@ -

hi

- - - Next - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Next + + + + + +
@@ -93,98 +171,6 @@
- - - - Create Table - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Create - - - - - From 45c365a9ecd6a5f87aaf4c4129e56e974337040a Mon Sep 17 00:00:00 2001 From: Roni Choudhury Date: Fri, 13 Nov 2020 15:39:46 -0500 Subject: [PATCH 3/5] Show a data preview table with datatype selectors --- src/components/TableDialog.vue | 63 ++++++++++++++++++++++++---------- src/utils/files.ts | 19 ++++++++-- 2 files changed, 60 insertions(+), 22 deletions(-) diff --git a/src/components/TableDialog.vue b/src/components/TableDialog.vue index 8ed8579d..94f92c59 100644 --- a/src/components/TableDialog.vue +++ b/src/components/TableDialog.vue @@ -97,22 +97,6 @@ /> - - - - - - @@ -136,7 +120,31 @@ -

hii

+ + + = ref(1); + const rowSample: Ref> = ref([]); + const headers = computed(() => { + if (rowSample.value.length === 0) { + return []; + } + + const keys = Object.keys(rowSample.value[0]); + + return keys.map((key) => ({ + text: key, + value: key, + })); + }); // Type recommendation const columnType: Ref<{[key: string]: CSVColumnType}> = ref({}); @@ -232,9 +253,11 @@ export default defineComponent({ } const typeRecs = await csvFileTypeRecommendations(file); - columnType.value = Array.from(typeRecs.keys()).reduce( - (acc, key) => ({ ...acc, [key]: typeRecs.get(key) }), {}, + columnType.value = Array.from(typeRecs.typeRecs.keys()).reduce( + (acc, key) => ({ ...acc, [key]: typeRecs.typeRecs.get(key) }), {}, ); + + rowSample.value = [...typeRecs.rowSample]; } // Upload options @@ -285,6 +308,8 @@ export default defineComponent({ return { step, + headers, + rowSample, columnType, multinetTypes, fileName, diff --git a/src/utils/files.ts b/src/utils/files.ts index 6e5986ca..78795e0c 100644 --- a/src/utils/files.ts +++ b/src/utils/files.ts @@ -46,10 +46,16 @@ interface TypeScore { total: number; } -async function csvFileTypeRecommendations(file: File): Promise> { - const parsePromise: Promise> = new Promise((resolve) => { +interface Recommendation { + typeRecs: Map; + rowSample: Array<{}>; +} + +async function csvFileTypeRecommendations(file: File): Promise { + const parsePromise: Promise = new Promise((resolve) => { const columnTypes = new Map(); const typeRecs = new Map(); + const rowSample = [] as Array<{}>; Papa.parse(file, { header: true, @@ -58,6 +64,10 @@ async function csvFileTypeRecommendations(file: File): Promise { if (!columnTypes.has(key)) { columnTypes.set(key, { @@ -121,7 +131,10 @@ async function csvFileTypeRecommendations(file: File): Promise Date: Fri, 13 Nov 2020 15:43:44 -0500 Subject: [PATCH 4/5] Enable old "create table" behavior at end of stepper --- src/components/TableDialog.vue | 30 ++---------------------------- 1 file changed, 2 insertions(+), 28 deletions(-) diff --git a/src/components/TableDialog.vue b/src/components/TableDialog.vue index 94f92c59..71035f0c 100644 --- a/src/components/TableDialog.vue +++ b/src/components/TableDialog.vue @@ -34,15 +34,6 @@ > Set Column Types - - - - - Finish - @@ -155,26 +146,9 @@ - Next - -
- - -

hiii

- - - Back - - - - Finish + Create Table
From 38cf495ae4083aff28624430eb8cd268ef900b53 Mon Sep 17 00:00:00 2001 From: Jared Tomeck Date: Thu, 19 Nov 2020 13:14:06 -0500 Subject: [PATCH 5/5] Improve upload preview table styling --- src/components/TableDialog.vue | 48 ++++++++++++++++++++++------------ 1 file changed, 32 insertions(+), 16 deletions(-) diff --git a/src/components/TableDialog.vue b/src/components/TableDialog.vue index 71035f0c..60f923cb 100644 --- a/src/components/TableDialog.vue +++ b/src/components/TableDialog.vue @@ -1,7 +1,7 @@