From 2765de4432147edadbb49b5bb76b314becc7501e Mon Sep 17 00:00:00 2001 From: Fabio Di Stasio Date: Fri, 7 Jan 2022 13:15:15 +0100 Subject: [PATCH 1/5] feat: POINT field support --- package.json | 3 + src/common/fieldTypes.js | 8 ++- src/renderer/components/BaseMap.vue | 66 +++++++++++++++++++ .../components/WorkspaceTabQueryTable.vue | 4 +- .../components/WorkspaceTabQueryTableRow.vue | 54 +++++++++++++-- src/renderer/index.js | 1 + src/renderer/scss/_data-types.scss | 1 + 7 files changed, 131 insertions(+), 6 deletions(-) create mode 100644 src/renderer/components/BaseMap.vue diff --git a/package.json b/package.json index 57917b26..0da8dd9d 100644 --- a/package.json +++ b/package.json @@ -105,6 +105,8 @@ "dependencies": { "@electron/remote": "^2.0.1", "@mdi/font": "^6.1.95", + "@turf/centroid": "^6.5.0", + "@turf/helpers": "^6.5.0", "@vscode/vscode-languagedetection": "^1.0.21", "ace-builds": "^1.4.13", "better-sqlite3": "^7.4.4", @@ -113,6 +115,7 @@ "electron-updater": "^4.3.9", "electron-window-state": "^5.0.3", "faker": "^5.5.3", + "leaflet": "^1.7.1", "marked": "^4.0.0", "moment": "^2.29.1", "mysql2": "^2.3.2", diff --git a/src/common/fieldTypes.js b/src/common/fieldTypes.js index d3a8a1db..e5013eb2 100644 --- a/src/common/fieldTypes.js +++ b/src/common/fieldTypes.js @@ -8,7 +8,9 @@ export const TEXT = [ export const LONG_TEXT = [ 'TEXT', 'MEDIUMTEXT', - 'LONGTEXT' + 'LONGTEXT', + 'JSON', + 'VARBINARY' ]; export const ARRAY = [ @@ -82,3 +84,7 @@ export const BIT = [ 'BIT', 'BIT VARYING' ]; + +export const SPATIAL = [ + 'POINT' +]; diff --git a/src/renderer/components/BaseMap.vue b/src/renderer/components/BaseMap.vue new file mode 100644 index 00000000..93e92dd9 --- /dev/null +++ b/src/renderer/components/BaseMap.vue @@ -0,0 +1,66 @@ + + + + diff --git a/src/renderer/components/WorkspaceTabQueryTable.vue b/src/renderer/components/WorkspaceTabQueryTable.vue index 97057456..45b46638 100644 --- a/src/renderer/components/WorkspaceTabQueryTable.vue +++ b/src/renderer/components/WorkspaceTabQueryTable.vue @@ -410,7 +410,9 @@ export default { `${this.fields[0].table}.${this.selectedCell.field}`, `${this.fields[0].tableAlias}.${this.selectedCell.field}` ].includes(prop)); - const valueToCopy = row[cellName]; + let valueToCopy = row[cellName]; + if (typeof valueToCopy === 'object') + valueToCopy = JSON.stringify(valueToCopy); navigator.clipboard.writeText(valueToCopy); }, copyRow () { diff --git a/src/renderer/components/WorkspaceTabQueryTableRow.vue b/src/renderer/components/WorkspaceTabQueryTableRow.vue index b31ac667..dab9b60f 100644 --- a/src/renderer/components/WorkspaceTabQueryTableRow.vue +++ b/src/renderer/components/WorkspaceTabQueryTableRow.vue @@ -123,6 +123,21 @@ + + + + Date: Fri, 7 Jan 2022 17:42:54 +0100 Subject: [PATCH 2/5] feat(MySQL): support to LINESTRING, POLYGON and GEOMETRY fields --- package.json | 1 - src/common/data-types/mysql.js | 16 ++++---- src/common/fieldTypes.js | 5 ++- src/common/libs/getArrayDepth.js | 10 +++++ src/renderer/components/BaseMap.vue | 58 ++++++++++++++++++++--------- src/renderer/scss/_data-types.scss | 3 ++ 6 files changed, 66 insertions(+), 27 deletions(-) create mode 100644 src/common/libs/getArrayDepth.js diff --git a/package.json b/package.json index 0da8dd9d..a476a8cb 100644 --- a/package.json +++ b/package.json @@ -105,7 +105,6 @@ "dependencies": { "@electron/remote": "^2.0.1", "@mdi/font": "^6.1.95", - "@turf/centroid": "^6.5.0", "@turf/helpers": "^6.5.0", "@vscode/vscode-languagedetection": "^1.0.21", "ace-builds": "^1.4.13", diff --git a/src/common/data-types/mysql.js b/src/common/data-types/mysql.js index 78e3d2c9..0130b277 100644 --- a/src/common/data-types/mysql.js +++ b/src/common/data-types/mysql.js @@ -218,56 +218,56 @@ module.exports = [ types: [ { name: 'POINT', - length: true, + length: false, collation: false, unsigned: false, zerofill: false }, { name: 'LINESTRING', - length: true, + length: false, collation: false, unsigned: false, zerofill: false }, { name: 'POLYGON', - length: true, + length: false, collation: false, unsigned: false, zerofill: false }, { name: 'GEOMETRY', - length: true, + length: false, collation: false, unsigned: false, zerofill: false }, { name: 'MULTIPOINT', - length: true, + length: false, collation: false, unsigned: false, zerofill: false }, { name: 'MULTILINESTRING', - length: true, + length: false, collation: false, unsigned: false, zerofill: false }, { name: 'MULTIPOLYGON', - length: true, + length: false, collation: false, unsigned: false, zerofill: false }, { name: 'GEOMETRYCOLLECTION', - length: true, + length: false, collation: false, unsigned: false, zerofill: false diff --git a/src/common/fieldTypes.js b/src/common/fieldTypes.js index e5013eb2..8287965b 100644 --- a/src/common/fieldTypes.js +++ b/src/common/fieldTypes.js @@ -86,5 +86,8 @@ export const BIT = [ ]; export const SPATIAL = [ - 'POINT' + 'POINT', + 'LINESTRING', + 'POLYGON', + 'GEOMETRY' ]; diff --git a/src/common/libs/getArrayDepth.js b/src/common/libs/getArrayDepth.js new file mode 100644 index 00000000..04e62e77 --- /dev/null +++ b/src/common/libs/getArrayDepth.js @@ -0,0 +1,10 @@ +/** + * + * @param {any[]} array + * @returns {number} + */ +export function getArrayDepth (array) { + return Array.isArray(array) + ? 1 + Math.max(0, ...array.map(getArrayDepth)) + : 0; +} diff --git a/src/renderer/components/BaseMap.vue b/src/renderer/components/BaseMap.vue index 93e92dd9..26178817 100644 --- a/src/renderer/components/BaseMap.vue +++ b/src/renderer/components/BaseMap.vue @@ -3,8 +3,8 @@ diff --git a/src/renderer/components/WorkspaceTabQueryTableRow.vue b/src/renderer/components/WorkspaceTabQueryTableRow.vue index 576ebd54..6fe51f13 100644 --- a/src/renderer/components/WorkspaceTabQueryTableRow.vue +++ b/src/renderer/components/WorkspaceTabQueryTableRow.vue @@ -135,7 +135,7 @@ Date: Sat, 29 Jan 2022 09:51:33 +0100 Subject: [PATCH 5/5] test: temporary fix on Windows tests --- package.json | 2 +- tests/app.spec.js | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 499a4d9d..66d8d4d2 100644 --- a/package.json +++ b/package.json @@ -150,7 +150,7 @@ "html-webpack-plugin": "^5.5.0", "mini-css-extract-plugin": "~2.4.5", "node-loader": "^2.0.0", - "playwright": "^1.16.3", + "playwright": "^1.18.1", "progress-webpack-plugin": "^1.0.12", "sass": "^1.42.1", "sass-loader": "^12.3.0", diff --git a/tests/app.spec.js b/tests/app.spec.js index c2e6238f..3d5c0f31 100644 --- a/tests/app.spec.js +++ b/tests/app.spec.js @@ -1,18 +1,26 @@ const { _electron: electron } = require('playwright'); const { strict: assert } = require('assert'); +const isWindows = process.platform === 'win32'; +async function wait (ms) { + return new Promise(resolve => { + setTimeout(resolve, ms); + }); +} + (async () => { console.log('Starting tests'); // Launch Electron app. const electronApp = await electron.launch({ args: ['dist/main.js'] }); + if (isWindows) await wait(5000); + /** * App main window state * @type {{isVisible: boolean; isDevToolsOpened: boolean; isCrashed: boolean}} */ const windowState = await electronApp.evaluate(({ BrowserWindow }) => { const mainWindow = BrowserWindow.getAllWindows()[0]; - const getState = () => ({ isVisible: mainWindow.isVisible(), isDevToolsOpened: mainWindow.webContents.isDevToolsOpened()