mirror of
https://github.com/Fabio286/antares.git
synced 2025-06-05 21:59:22 +02:00
Compare commits
24 Commits
v0.7.22
...
v0.7.24-be
Author | SHA1 | Date | |
---|---|---|---|
f4f385589f | |||
0565ae1204 | |||
258fbc81f7 | |||
8d8650fbe7 | |||
af2812f2b0 | |||
|
d163cbfac8 | ||
|
4537d96f3e | ||
099a71a189 | |||
e7efb9c616 | |||
a752dcb6a9 | |||
|
c1e58eb695 | ||
|
f7204dc0ae | ||
|
6b56c60b68 | ||
1875e895ae | |||
2064294119 | |||
62e3115860 | |||
9aef287a98 | |||
65ec4c5da6 | |||
e19118982b | |||
11f130d91c | |||
|
0bb5cedda6 | ||
de9dac3e8a | |||
dd5b41716a | |||
86acb390ac |
@@ -266,6 +266,15 @@
|
||||
"contributions": [
|
||||
"translation"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "bagusindrayana",
|
||||
"name": "Bagus Indrayana",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/36830534?v=4",
|
||||
"profile": "https://github.com/bagusindrayana",
|
||||
"contributions": [
|
||||
"code"
|
||||
]
|
||||
}
|
||||
],
|
||||
"contributorsPerLine": 7,
|
||||
|
1
.husky/commit-msg
Normal file
1
.husky/commit-msg
Normal file
@@ -0,0 +1 @@
|
||||
npx --no -- commitlint --edit $1
|
1
.husky/pre-commit
Normal file
1
.husky/pre-commit
Normal file
@@ -0,0 +1 @@
|
||||
npm run lint
|
@@ -5,14 +5,14 @@
|
||||
],
|
||||
"fix": true,
|
||||
"formatter": "verbose",
|
||||
"customSyntax": "postcss-html",
|
||||
"plugins": [
|
||||
"stylelint-scss"
|
||||
],
|
||||
"rules": {
|
||||
"at-rule-no-unknown": null,
|
||||
"no-descending-specificity": null,
|
||||
"font-family-no-missing-generic-family-keyword": null,
|
||||
"declaration-colon-newline-after": "always-multi-line"
|
||||
"font-family-no-missing-generic-family-keyword": null
|
||||
},
|
||||
"syntax": "scss"
|
||||
}
|
40
CHANGELOG.md
40
CHANGELOG.md
@@ -2,6 +2,46 @@
|
||||
|
||||
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
||||
|
||||
### [0.7.24-beta.0](https://github.com/antares-sql/antares/compare/v0.7.23...v0.7.24-beta.0) (2024-04-12)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* add shortcut open,save, and save as file ([6b56c60](https://github.com/antares-sql/antares/commit/6b56c60b68647bc7182548a137cccc3413e3fbd5))
|
||||
* add translation for open,save, and save as file ([f7204dc](https://github.com/antares-sql/antares/commit/f7204dc0ae721534eaefbde097d1c26c1d72ad41))
|
||||
* open,save, and save as file in query tab ([c1e58eb](https://github.com/antares-sql/antares/commit/c1e58eb695de78fbf1d2b26c608692f0962373df))
|
||||
* unsaved file reminder closing file tabs ([8d8650f](https://github.com/antares-sql/antares/commit/8d8650fbe76c79fd66be857d049b3baaa9ab1f9f))
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **translation:** missing translation for "Open notes" shortcut ([0565ae1](https://github.com/antares-sql/antares/commit/0565ae12042901b9d67fe3e0ea269562ec444994))
|
||||
|
||||
### [0.7.23](https://github.com/antares-sql/antares/compare/v0.7.23-beta.1...v0.7.23) (2024-04-07)
|
||||
|
||||
### [0.7.23-beta.1](https://github.com/antares-sql/antares/compare/v0.7.23-beta.0...v0.7.23-beta.1) (2024-04-02)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* add the page reference in the export file name, closes [#772](https://github.com/antares-sql/antares/issues/772) ([2064294](https://github.com/antares-sql/antares/commit/2064294119ed9dfab2a9968dfb5b35d52e2ae03b))
|
||||
* move connections out of folder from context menu, related to [#773](https://github.com/antares-sql/antares/issues/773) ([62e3115](https://github.com/antares-sql/antares/commit/62e311586073ae7ee4896305198c7168f637c1af))
|
||||
* move connections to folders from context menu, related to [#773](https://github.com/antares-sql/antares/issues/773) ([9aef287](https://github.com/antares-sql/antares/commit/9aef287a983754158cdbdc9b2a72db9ab82f76c8))
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* bad format of timestamp fields on CSV export, fixes 776 ([65ec4c5](https://github.com/antares-sql/antares/commit/65ec4c5da6187a7ab2dfff59326cd12bfa788c3b))
|
||||
|
||||
### [0.7.23-beta.0](https://github.com/antares-sql/antares/compare/v0.7.22...v0.7.23-beta.0) (2024-03-21)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* CSV export does not escape strings when needed, fixes [#770](https://github.com/antares-sql/antares/issues/770) ([dd5b417](https://github.com/antares-sql/antares/commit/dd5b41716a10cf9500f2c611b232f5b5b0756a68))
|
||||
* query result sort not working with aliased tables, fixes [#765](https://github.com/antares-sql/antares/issues/765) ([de9dac3](https://github.com/antares-sql/antares/commit/de9dac3e8abf3b3261f8c54c88cf2386a5be2207))
|
||||
* shortcut not working on mac os ([0bb5ced](https://github.com/antares-sql/antares/commit/0bb5cedda6a67ccbeea8c127b799f533395101a2))
|
||||
|
||||
### [0.7.22](https://github.com/antares-sql/antares/compare/v0.7.22-beta.2...v0.7.22) (2024-02-26)
|
||||
|
||||
|
||||
|
@@ -148,6 +148,9 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
|
||||
<td align="center" valign="top" width="14.28%"><a href="https://github.com/Lawondyss"><img src="https://avatars.githubusercontent.com/u/272130?v=4?s=100" width="100px;" alt="Ladislav Vondráček"/><br /><sub><b>Ladislav Vondráček</b></sub></a><br /><a href="#translation-Lawondyss" title="Translation">🌍</a></td>
|
||||
<td align="center" valign="top" width="14.28%"><a href="https://github.com/zvlad"><img src="https://avatars.githubusercontent.com/u/9055134?v=4?s=100" width="100px;" alt="Vladyslav"/><br /><sub><b>Vladyslav</b></sub></a><br /><a href="#translation-zvlad" title="Translation">🌍</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center" valign="top" width="14.28%"><a href="https://github.com/bagusindrayana"><img src="https://avatars.githubusercontent.com/u/36830534?v=4?s=100" width="100px;" alt="Bagus Indrayana"/><br /><sub><b>Bagus Indrayana</b></sub></a><br /><a href="https://github.com/antares-sql/antares/commits?author=bagusindrayana" title="Code">💻</a></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
33
commitlint.config.js
Normal file
33
commitlint.config.js
Normal file
@@ -0,0 +1,33 @@
|
||||
module.exports = {
|
||||
extends: ['@commitlint/config-conventional'],
|
||||
rules: {
|
||||
// TODO Add Scope Enum Here
|
||||
// 'scope-enum': [2, 'always', ['yourscope', 'yourscope']],
|
||||
'type-enum': [
|
||||
2,
|
||||
'always',
|
||||
[
|
||||
'feat',
|
||||
'fix',
|
||||
'docs',
|
||||
'chore',
|
||||
'style',
|
||||
'refactor',
|
||||
'build',
|
||||
'ci',
|
||||
'test',
|
||||
'revert',
|
||||
'perf'
|
||||
]
|
||||
],
|
||||
'subject-case': [
|
||||
2,
|
||||
'never',
|
||||
[
|
||||
'upper-case',
|
||||
'pascal-case',
|
||||
'start-case'
|
||||
]
|
||||
]
|
||||
}
|
||||
};
|
2259
package-lock.json
generated
2259
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "antares",
|
||||
"productName": "Antares",
|
||||
"version": "0.7.22",
|
||||
"version": "0.7.24-beta.0",
|
||||
"description": "A modern, fast and productivity driven SQL client with a focus in UX.",
|
||||
"license": "MIT",
|
||||
"repository": "https://github.com/antares-sql/antares.git",
|
||||
@@ -25,7 +25,8 @@
|
||||
"lint": "eslint . --ext .js,.ts,.vue && stylelint \"./src/**/*.{css,scss,sass,vue}\"",
|
||||
"lint:fix": "eslint . --ext .js,.ts,.vue --fix && stylelint \"./src/**/*.{css,scss,sass,vue}\" --fix",
|
||||
"contributors:add": "all-contributors add",
|
||||
"contributors:generate": "all-contributors generate"
|
||||
"contributors:generate": "all-contributors generate",
|
||||
"prepare": "husky"
|
||||
},
|
||||
"author": "Fabio Di Stasio <info@fabiodistasio.it>",
|
||||
"main": "./dist/main.js",
|
||||
@@ -179,6 +180,8 @@
|
||||
"@babel/eslint-parser": "~7.15.7",
|
||||
"@babel/preset-env": "~7.15.8",
|
||||
"@babel/preset-typescript": "~7.16.7",
|
||||
"@commitlint/cli": "~19.0.3",
|
||||
"@commitlint/config-conventional": "~19.0.3",
|
||||
"@playwright/test": "~1.28.1",
|
||||
"@types/better-sqlite3": "~7.5.0",
|
||||
"@types/leaflet": "~1.7.9",
|
||||
@@ -198,6 +201,7 @@
|
||||
"eslint-plugin-promise": "~5.2.0",
|
||||
"eslint-plugin-simple-import-sort": "~10.0.0",
|
||||
"eslint-plugin-vue": "~8.0.3",
|
||||
"husky": "~9.0.11",
|
||||
"playwright": "~1.28.1",
|
||||
"playwright-core": "~1.28.1",
|
||||
"standard-version": "~9.3.1",
|
||||
|
@@ -6,6 +6,9 @@ export const shortcutEvents: Record<string, { l18n: string; l18nParam?: string |
|
||||
'kill-query': { l18n: 'database.killQuery', context: 'tab' },
|
||||
'query-history': { l18n: 'database.queryHistory', context: 'tab' },
|
||||
'clear-query': { l18n: 'database.clearQuery', context: 'tab' },
|
||||
// 'save-file': { l18n: 'application.saveFile', context: 'tab' },
|
||||
'open-file': { l18n: 'application.openFile', context: 'tab' },
|
||||
'save-file-as': { l18n: 'application.saveFileAs', context: 'tab' },
|
||||
'next-tab': { l18n: 'application.nextTab' },
|
||||
'prev-tab': { l18n: 'application.previousTab' },
|
||||
'open-all-connections': { l18n: 'application.openAllConnections' },
|
||||
@@ -16,7 +19,7 @@ export const shortcutEvents: Record<string, { l18n: string; l18nParam?: string |
|
||||
'save-content': { l18n: 'application.saveContent' },
|
||||
'create-connection': { l18n: 'connection.createNewConnection' },
|
||||
'open-settings': { l18n: 'application.openSettings' },
|
||||
'open-scratchpad': { l18n: 'application.openScratchpad' }
|
||||
'open-scratchpad': { l18n: 'application.openNotes' }
|
||||
};
|
||||
|
||||
interface ShortcutRecord {
|
||||
@@ -119,6 +122,21 @@ const shortcuts: ShortcutRecord[] = [
|
||||
event: 'toggle-console',
|
||||
keys: ['CommandOrControl+`'],
|
||||
os: ['darwin', 'linux', 'win32']
|
||||
},
|
||||
// {
|
||||
// event: 'save-file',
|
||||
// keys: ['CommandOrControl+S'],
|
||||
// os: ['darwin', 'linux', 'win32']
|
||||
// },
|
||||
{
|
||||
event: 'open-file',
|
||||
keys: ['CommandOrControl+O'],
|
||||
os: ['darwin', 'linux', 'win32']
|
||||
},
|
||||
{
|
||||
event: 'save-file-as',
|
||||
keys: ['Shift+CommandOrControl+S'],
|
||||
os: ['darwin', 'linux', 'win32']
|
||||
}
|
||||
];
|
||||
|
||||
|
@@ -1,5 +1,6 @@
|
||||
import { app, dialog, ipcMain, safeStorage } from 'electron';
|
||||
import * as Store from 'electron-store';
|
||||
import * as fs from 'fs';
|
||||
|
||||
import { validateSender } from '../libs/misc/validateSender';
|
||||
import { ShortcutRegister } from '../libs/ShortcutRegister';
|
||||
@@ -52,6 +53,11 @@ export default () => {
|
||||
return dialog.showOpenDialog(options);
|
||||
});
|
||||
|
||||
ipcMain.handle('show-save-dialog', (event, options) => {
|
||||
if (!validateSender(event.senderFrame)) return { status: 'error', response: 'Unauthorized process' };
|
||||
return dialog.showSaveDialog(options);
|
||||
});
|
||||
|
||||
ipcMain.handle('get-download-dir-path', (event) => {
|
||||
if (!validateSender(event.senderFrame)) return { status: 'error', response: 'Unauthorized process' };
|
||||
return app.getPath('downloads');
|
||||
@@ -80,4 +86,26 @@ export default () => {
|
||||
const shortCutRegister = ShortcutRegister.getInstance();
|
||||
shortCutRegister.unregister();
|
||||
});
|
||||
|
||||
ipcMain.handle('read-file', (event, filePath) => {
|
||||
if (!validateSender(event.senderFrame)) return { status: 'error', response: 'Unauthorized process' };
|
||||
try {
|
||||
const content = fs.readFileSync(filePath, 'utf-8');
|
||||
return content;
|
||||
}
|
||||
catch (error) {
|
||||
return { status: 'error', response: error.toString() };
|
||||
}
|
||||
});
|
||||
|
||||
ipcMain.handle('write-file', (event, filePath, content) => {
|
||||
if (!validateSender(event.senderFrame)) return { status: 'error', response: 'Unauthorized process' };
|
||||
try {
|
||||
fs.writeFileSync(filePath, content, 'utf-8');
|
||||
return { status: 'success' };
|
||||
}
|
||||
catch (error) {
|
||||
return { status: 'error', response: error.toString() };
|
||||
}
|
||||
});
|
||||
};
|
||||
|
@@ -70,23 +70,21 @@ export class ShortcutRegister {
|
||||
}
|
||||
|
||||
private setLocalShortcuts () {
|
||||
const isMenuVisible = process.platform === 'darwin';
|
||||
const submenu = [];
|
||||
for (const shortcut of this.shortcuts) {
|
||||
if (shortcut.os.includes(process.platform)) {
|
||||
for (const key of shortcut.keys) {
|
||||
try {
|
||||
this._menu.append(new MenuItem({
|
||||
label: '.',
|
||||
visible: false,
|
||||
submenu: [{
|
||||
label: String(key),
|
||||
submenu.push({
|
||||
label: String(shortcut.event),
|
||||
accelerator: key,
|
||||
visible: false,
|
||||
visible: isMenuVisible,
|
||||
click: () => {
|
||||
this._mainWindow.webContents.send(shortcut.event);
|
||||
if (isDevelopment) console.log('LOCAL EVENT:', shortcut);
|
||||
}
|
||||
}]
|
||||
}));
|
||||
});
|
||||
}
|
||||
catch (error) {
|
||||
if (isDevelopment) console.log(error);
|
||||
@@ -96,6 +94,11 @@ export class ShortcutRegister {
|
||||
}
|
||||
}
|
||||
}
|
||||
this._menu.append(new MenuItem({
|
||||
label: 'Shortcut',
|
||||
visible: isMenuVisible,
|
||||
submenu
|
||||
}));
|
||||
}
|
||||
|
||||
private setGlobalShortcuts () {
|
||||
|
@@ -127,8 +127,8 @@ app.on('ready', async () => {
|
||||
if (isWindows)
|
||||
mainWindow.show();
|
||||
|
||||
// if (isDevelopment)
|
||||
// mainWindow.webContents.openDevTools();
|
||||
if (isDevelopment && !isWindows)// Because on Windows you can open devtools from title-bar
|
||||
mainWindow.webContents.openDevTools();
|
||||
|
||||
process.on('uncaughtException', error => {
|
||||
mainWindow.webContents.send('unhandled-exception', error);
|
||||
|
@@ -14,7 +14,7 @@
|
||||
<div class="tile-icon">
|
||||
<BaseIcon
|
||||
:icon-name="note.type === 'query'
|
||||
? 'mdiStarOutline'
|
||||
? 'mdiHeartOutline'
|
||||
: note.type === 'todo'
|
||||
? note.isArchived
|
||||
? 'mdiCheckboxMarkedOutline'
|
||||
|
@@ -15,6 +15,56 @@
|
||||
:size="18"
|
||||
/> {{ t('connection.disconnect') }}</span>
|
||||
</div>
|
||||
<div v-if="!contextConnection.isFolder" class="context-element">
|
||||
<span class="d-flex">
|
||||
<BaseIcon
|
||||
class="text-light mt-1 mr-1"
|
||||
icon-name="mdiFolderMove"
|
||||
:size="18"
|
||||
/> {{ t('general.moveTo') }}</span>
|
||||
<BaseIcon
|
||||
class="text-light ml-1"
|
||||
icon-name="mdiChevronRight"
|
||||
:size="18"
|
||||
/>
|
||||
<div class="context-submenu">
|
||||
<div class="context-element" @click.stop="moveToFolder(null)">
|
||||
<span class="d-flex">
|
||||
<BaseIcon
|
||||
class="text-light mt-1 mr-1"
|
||||
icon-name="mdiFolderPlus"
|
||||
:size="18"
|
||||
/> {{ t('application.newFolder') }}</span>
|
||||
</div>
|
||||
<div
|
||||
v-for="folder in filteredFolders"
|
||||
:key="folder.uid"
|
||||
class="context-element"
|
||||
@click.stop="moveToFolder(folder.uid)"
|
||||
>
|
||||
<span class="d-flex">
|
||||
<BaseIcon
|
||||
class="text-light mt-1 mr-1"
|
||||
icon-name="mdiFolder"
|
||||
:size="18"
|
||||
:style="`color: ${folder.color}!important`"
|
||||
/> {{ folder.name || t('general.folder') }}</span>
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-if="isInFolder"
|
||||
class="context-element"
|
||||
@click="outOfFolder"
|
||||
>
|
||||
<span class="d-flex">
|
||||
<BaseIcon
|
||||
class="text-light mt-1 mr-1"
|
||||
icon-name="mdiFolderOff"
|
||||
:size="18"
|
||||
/> {{ t('application.outOfFolder') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="context-element" @click.stop="showAppearanceModal">
|
||||
<span class="d-flex">
|
||||
<BaseIcon
|
||||
@@ -79,6 +129,7 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { uidGen } from 'common/libs/uidGen';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { computed, Prop, ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
|
||||
@@ -98,9 +149,14 @@ const {
|
||||
getConnectionByUid,
|
||||
getConnectionName,
|
||||
addConnection,
|
||||
deleteConnection
|
||||
deleteConnection,
|
||||
addFolder,
|
||||
addToFolder,
|
||||
removeFromFolders
|
||||
} = connectionsStore;
|
||||
|
||||
const { getFolders: folders } = storeToRefs(connectionsStore);
|
||||
|
||||
const workspacesStore = useWorkspacesStore();
|
||||
|
||||
const {
|
||||
@@ -121,6 +177,8 @@ const isConnectionEdit = ref(false);
|
||||
|
||||
const connectionName = computed(() => props.contextConnection.name || getConnectionName(props.contextConnection.uid) || t('general.folder', 1));
|
||||
const isConnected = computed(() => getWorkspace(props.contextConnection.uid)?.connectionStatus === 'connected');
|
||||
const filteredFolders = computed(() => folders.value.filter(f => !f.connections.includes(props.contextConnection.uid)));
|
||||
const isInFolder = computed(() => folders.value.some(f => f.connections.includes(props.contextConnection.uid)));
|
||||
|
||||
const confirmDeleteConnection = () => {
|
||||
if (isConnected.value)
|
||||
@@ -129,6 +187,27 @@ const confirmDeleteConnection = () => {
|
||||
closeContext();
|
||||
};
|
||||
|
||||
const moveToFolder = (folderUid?: string) => {
|
||||
if (!folderUid) {
|
||||
addFolder({
|
||||
connections: [props.contextConnection.uid]
|
||||
});
|
||||
}
|
||||
else {
|
||||
addToFolder({
|
||||
folder: folderUid,
|
||||
connection: props.contextConnection.uid
|
||||
});
|
||||
}
|
||||
|
||||
closeContext();
|
||||
};
|
||||
|
||||
const outOfFolder = () => {
|
||||
removeFromFolders(props.contextConnection.uid);
|
||||
closeContext();
|
||||
};
|
||||
|
||||
const duplicateConnection = () => {
|
||||
let connectionCopy = getConnectionByUid(props.contextConnection.uid);
|
||||
connectionCopy = {
|
||||
|
@@ -42,11 +42,11 @@
|
||||
>
|
||||
<BaseIcon
|
||||
class="mt-1 mr-1"
|
||||
icon-name="mdiCodeTags"
|
||||
:icon-name="element.filePath ? 'mdiFileCodeOutline' : 'mdiCodeTags'"
|
||||
:size="18"
|
||||
/>
|
||||
<span>
|
||||
<span>{{ cutText(element.content || 'Query', 20, true) }} #{{ element.index }}</span>
|
||||
<span>{{ cutText(element.elementName || element.content || 'Query', 20, true) }} #{{ element.index }}</span>
|
||||
<span
|
||||
class="btn btn-clear"
|
||||
:title="t('general.close')"
|
||||
|
@@ -101,7 +101,13 @@ const props = defineProps({
|
||||
selectedField: Object
|
||||
});
|
||||
|
||||
const emit = defineEmits(['close-context', 'duplicate-selected', 'delete-selected', 'add-new-index', 'add-to-index']);
|
||||
const emit = defineEmits([
|
||||
'close-context',
|
||||
'duplicate-selected',
|
||||
'delete-selected',
|
||||
'add-new-index',
|
||||
'add-to-index'
|
||||
]);
|
||||
|
||||
const hasPrimary = computed(() => props.indexes.some(index => index.type === 'PRIMARY'));
|
||||
|
||||
|
@@ -150,7 +150,13 @@ const props = defineProps({
|
||||
mode: String
|
||||
});
|
||||
|
||||
const emit = defineEmits(['add-new-index', 'add-to-index', 'rename-field', 'duplicate-field', 'remove-field']);
|
||||
const emit = defineEmits([
|
||||
'add-new-index',
|
||||
'add-to-index',
|
||||
'rename-field',
|
||||
'duplicate-field',
|
||||
'remove-field'
|
||||
]);
|
||||
|
||||
const workspacesStore = useWorkspacesStore();
|
||||
const consoleStore = useConsoleStore();
|
||||
|
@@ -19,7 +19,10 @@
|
||||
<div ref="resizer" class="query-area-resizer" />
|
||||
<div ref="queryAreaFooter" class="workspace-query-runner-footer">
|
||||
<div class="workspace-query-buttons">
|
||||
<div @mouseenter="setCancelButtonVisibility(true)" @mouseleave="setCancelButtonVisibility(false)">
|
||||
<div
|
||||
@mouseenter="setCancelButtonVisibility(true)"
|
||||
@mouseleave="setCancelButtonVisibility(false)"
|
||||
>
|
||||
<button
|
||||
v-if="showCancel && isQuering"
|
||||
class="btn btn-primary btn-sm cancellable"
|
||||
@@ -109,7 +112,7 @@
|
||||
:title="t('general.save')"
|
||||
@click="saveQuery()"
|
||||
>
|
||||
<BaseIcon icon-name="mdiContentSaveOutline" :size="24" />
|
||||
<BaseIcon icon-name="mdiHeartPlusOutline" :size="24" />
|
||||
</button>
|
||||
<button
|
||||
class="btn btn-dark btn-sm"
|
||||
@@ -117,7 +120,31 @@
|
||||
:title="t('database.savedQueries')"
|
||||
@click="openSavedModal()"
|
||||
>
|
||||
<BaseIcon icon-name="mdiStarOutline" :size="24" />
|
||||
<BaseIcon icon-name="mdiNotebookHeartOutline" :size="24" />
|
||||
</button>
|
||||
</div>
|
||||
<div class="btn-group">
|
||||
<button
|
||||
class="btn btn-dark btn-sm mr-0"
|
||||
:disabled="!filePath || lastSavedQuery === query"
|
||||
:title="t('application.saveFile')"
|
||||
@click="saveFile()"
|
||||
>
|
||||
<BaseIcon icon-name="mdiContentSaveCheckOutline" :size="24" />
|
||||
</button>
|
||||
<button
|
||||
class="btn btn-dark btn-sm mr-0"
|
||||
:title="t('application.saveFileAs')"
|
||||
@click="saveFileAs()"
|
||||
>
|
||||
<BaseIcon icon-name="mdiContentSavePlusOutline" :size="24" />
|
||||
</button>
|
||||
<button
|
||||
class="btn btn-dark btn-sm"
|
||||
:title="t('application.openFile')"
|
||||
@click="openFile()"
|
||||
>
|
||||
<BaseIcon icon-name="mdiFolderOpenOutline" :size="24" />
|
||||
</button>
|
||||
</div>
|
||||
<div class="dropdown table-dropdown pr-2">
|
||||
@@ -251,7 +278,7 @@ import { uidGen } from 'common/libs/uidGen';
|
||||
import { ipcRenderer } from 'electron';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { format } from 'sql-formatter';
|
||||
import { Component, computed, onBeforeUnmount, onMounted, Prop, Ref, ref, watch } from 'vue';
|
||||
import { Component, computed, onBeforeUnmount, onMounted, Prop, Ref, ref, toRaw, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
|
||||
import BaseIcon from '@/components/BaseIcon.vue';
|
||||
@@ -262,6 +289,7 @@ import QueryEditor from '@/components/QueryEditor.vue';
|
||||
import WorkspaceTabQueryEmptyState from '@/components/WorkspaceTabQueryEmptyState.vue';
|
||||
import WorkspaceTabQueryTable from '@/components/WorkspaceTabQueryTable.vue';
|
||||
import { useResultTables } from '@/composables/useResultTables';
|
||||
import Application from '@/ipc-api/Application';
|
||||
import Schema from '@/ipc-api/Schema';
|
||||
import { useApplicationStore } from '@/stores/application';
|
||||
import { useConsoleStore } from '@/stores/console';
|
||||
@@ -302,14 +330,18 @@ const {
|
||||
getWorkspace,
|
||||
changeBreadcrumbs,
|
||||
updateTabContent,
|
||||
setUnsavedChanges
|
||||
setUnsavedChanges,
|
||||
newTab
|
||||
} = workspacesStore;
|
||||
|
||||
const queryEditor: Ref<Component & { editor: Ace.Editor; $el: HTMLElement }> = ref(null);
|
||||
const queryAreaFooter: Ref<HTMLDivElement> = ref(null);
|
||||
const resizer: Ref<HTMLDivElement> = ref(null);
|
||||
const queryName = ref('');
|
||||
const query = ref('');
|
||||
const filePath = ref('');
|
||||
const lastQuery = ref('');
|
||||
const lastSavedQuery = ref('');
|
||||
const isCancelling = ref(false);
|
||||
const showCancel = ref(false);
|
||||
const autocommit = ref(true);
|
||||
@@ -333,17 +365,41 @@ const databaseSchemas = computed(() => {
|
||||
});
|
||||
const hasResults = computed(() => results.value.length && results.value[0].rows);
|
||||
const hasAffected = computed(() => affectedCount.value || (!resultsCount.value && affectedCount.value !== null));
|
||||
const isChanged = computed(() => {
|
||||
return filePath.value && lastSavedQuery.value !== query.value;
|
||||
});
|
||||
|
||||
watch(query, (val) => {
|
||||
clearTimeout(debounceTimeout.value);
|
||||
|
||||
debounceTimeout.value = setTimeout(() => {
|
||||
updateTabContent({
|
||||
elementName: queryName.value,
|
||||
filePath: filePath.value,
|
||||
uid: props.connection.uid,
|
||||
tab: props.tab.uid,
|
||||
type: 'query',
|
||||
schema: selectedSchema.value,
|
||||
content: val
|
||||
|
||||
});
|
||||
|
||||
isQuerySaved.value = false;
|
||||
}, 200);
|
||||
});
|
||||
|
||||
watch(queryName, (val) => {
|
||||
clearTimeout(debounceTimeout.value);
|
||||
|
||||
debounceTimeout.value = setTimeout(() => {
|
||||
updateTabContent({
|
||||
elementName: val,
|
||||
filePath: filePath.value,
|
||||
uid: props.connection.uid,
|
||||
tab: props.tab.uid,
|
||||
type: 'query',
|
||||
schema: selectedSchema.value,
|
||||
content: query.value
|
||||
});
|
||||
|
||||
isQuerySaved.value = false;
|
||||
@@ -377,6 +433,10 @@ watch(() => props.tab.content, () => {
|
||||
queryEditor.value.editor.session.setValue(query.value);
|
||||
});
|
||||
|
||||
watch(isChanged, (val) => {
|
||||
setUnsavedChanges({ uid: props.connection.uid, tUid: props.tabUid, isChanged: val });
|
||||
});
|
||||
|
||||
const runQuery = async (query: string) => {
|
||||
if (!query || isQuering.value) return;
|
||||
isQuering.value = true;
|
||||
@@ -529,7 +589,8 @@ const saveQuery = () => {
|
||||
type: 'query',
|
||||
date: new Date(),
|
||||
note: query.value,
|
||||
isArchived: false
|
||||
isArchived: false,
|
||||
title: queryName.value
|
||||
});
|
||||
isQuerySaved.value = true;
|
||||
};
|
||||
@@ -596,6 +657,8 @@ const rollbackTab = async () => {
|
||||
defineExpose({ resizeResults });
|
||||
|
||||
query.value = props.tab.content as string;
|
||||
queryName.value = props.tab.elementName as string;
|
||||
filePath.value = props.tab.filePath as string;
|
||||
selectedSchema.value = props.tab.schema || breadcrumbsSchema.value;
|
||||
|
||||
window.addEventListener('resize', onWindowResize);
|
||||
@@ -630,6 +693,72 @@ const historyListener = () => {
|
||||
openHistoryModal();
|
||||
};
|
||||
|
||||
const openFileListener = () => {
|
||||
const hasModalOpen = !!document.querySelectorAll('.modal.active').length;
|
||||
if (props.isSelected && !hasModalOpen)
|
||||
openFile();
|
||||
};
|
||||
|
||||
const saveFileAsListener = () => {
|
||||
const hasModalOpen = !!document.querySelectorAll('.modal.active').length;
|
||||
if (props.isSelected && !hasModalOpen)
|
||||
saveFileAs();
|
||||
};
|
||||
|
||||
const saveContentListener = () => {
|
||||
const hasModalOpen = !!document.querySelectorAll('.modal.active').length;
|
||||
if (props.isSelected && !hasModalOpen && filePath)
|
||||
saveFile();
|
||||
};
|
||||
|
||||
const openFile = async () => {
|
||||
const result = await Application.showOpenDialog({ properties: ['openFile'], filters: [{ name: 'SQL', extensions: ['sql', 'txt'] }] });
|
||||
if (result && !result.canceled) {
|
||||
const file = result.filePaths[0];
|
||||
const content = await Application.readFile(file);
|
||||
const fileName = file.split('/').pop().split('\\').pop();
|
||||
if (props.tab.filePath && props.tab.filePath !== file) {
|
||||
newTab({
|
||||
uid: props.connection.uid,
|
||||
type: 'query',
|
||||
filePath: file,
|
||||
content: '',
|
||||
schema: selectedSchema.value,
|
||||
elementName: fileName
|
||||
});
|
||||
}
|
||||
else {
|
||||
filePath.value = file;
|
||||
queryName.value = fileName;
|
||||
query.value = content;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const saveFileAs = async () => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const result: any = await Application.showSaveDialog({ filters: [{ name: 'SQL', extensions: ['sql'] }], defaultPath: `${queryName.value || 'query'}.sql` });
|
||||
if (result && !result.canceled) {
|
||||
await Application.writeFile(result.filePath, query.value);
|
||||
addNotification({ status: 'success', message: t('general.actionSuccessful', { action: t('application.saveFile') }) });
|
||||
queryName.value = result.filePath.split('/').pop().split('\\').pop();
|
||||
filePath.value = result.filePath;
|
||||
lastSavedQuery.value = toRaw(query.value);
|
||||
}
|
||||
};
|
||||
|
||||
const saveFile = async () => {
|
||||
await Application.writeFile(filePath.value, query.value);
|
||||
addNotification({ status: 'success', message: t('general.actionSuccessful', { action: t('application.saveFile') }) });
|
||||
lastSavedQuery.value = toRaw(query.value);
|
||||
};
|
||||
|
||||
const loadFileContent = async (file: string) => {
|
||||
const content = await Application.readFile(file);
|
||||
query.value = content;
|
||||
lastSavedQuery.value = content;
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
const localResizer = resizer.value;
|
||||
|
||||
@@ -638,6 +767,9 @@ onMounted(() => {
|
||||
ipcRenderer.on('kill-query', killQueryListener);
|
||||
ipcRenderer.on('clear-query', clearQueryListener);
|
||||
ipcRenderer.on('query-history', historyListener);
|
||||
ipcRenderer.on('open-file', openFileListener);
|
||||
ipcRenderer.on('save-file-as', saveFileAsListener);
|
||||
ipcRenderer.on('save-content', saveContentListener);
|
||||
|
||||
localResizer.addEventListener('mousedown', (e: MouseEvent) => {
|
||||
e.preventDefault();
|
||||
@@ -648,6 +780,9 @@ onMounted(() => {
|
||||
|
||||
if (props.tab.autorun)
|
||||
runQuery(query.value);
|
||||
|
||||
if (props.tab.filePath)
|
||||
loadFileContent(props.tab.filePath);
|
||||
});
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
@@ -663,6 +798,9 @@ onBeforeUnmount(() => {
|
||||
ipcRenderer.removeListener('kill-query', killQueryListener);
|
||||
ipcRenderer.removeListener('clear-query', clearQueryListener);
|
||||
ipcRenderer.removeListener('query-history', historyListener);
|
||||
ipcRenderer.removeListener('open-file', openFileListener);
|
||||
ipcRenderer.removeListener('save-file-as', saveFileAsListener);
|
||||
ipcRenderer.removeListener('save-content', saveContentListener);
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -721,4 +859,4 @@ onBeforeUnmount(() => {
|
||||
min-height: 200px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</style>filePathsfilePathsfilePaths
|
||||
|
@@ -31,7 +31,7 @@
|
||||
:class="{ 'active': resultsetIndex === index }"
|
||||
@click="selectResultset(index)"
|
||||
>
|
||||
<a>{{ result.fields ? result.fields[0]?.table : '' }} ({{ result.rows.length }})</a>
|
||||
<a>{{ result.fields ? result.fields[0]?.tableAlias ?? result.fields[0]?.table : `${t('general.results')} #${index}` }} ({{ result.rows.length }})</a>
|
||||
</li>
|
||||
</ul>
|
||||
<div ref="table" class="table table-hover">
|
||||
@@ -44,7 +44,7 @@
|
||||
:title="`${field.type} ${fieldLength(field) ? `(${fieldLength(field)})` : ''}`"
|
||||
>
|
||||
<div ref="columnResize" class="column-resizable">
|
||||
<div class="table-column-title" @click="sort(field.name)">
|
||||
<div class="table-column-title" @click="sort(field)">
|
||||
<div v-if="field.key" :title="keyName(field.key)">
|
||||
<BaseIcon
|
||||
icon-name="mdiKey"
|
||||
@@ -56,8 +56,8 @@
|
||||
</div>
|
||||
<span>{{ field.alias || field.name }}</span>
|
||||
<BaseIcon
|
||||
v-if="isSortable && currentSort === field.name || currentSort === `${field.table}.${field.name}`"
|
||||
:icon-name="currentSortDir === 'asc' ? 'mdiSortAscending' : 'mdiSortDescending'"
|
||||
v-if="isSortable && currentSort[resultsetIndex]?.field === field.name || currentSort[resultsetIndex]?.field === `${field.tableAlias || field.table}.${field.name}`"
|
||||
:icon-name="currentSort[resultsetIndex].dir === 'asc' ? 'mdiSortAscending' : 'mdiSortDescending'"
|
||||
:size="18"
|
||||
class="sort-icon ml-1"
|
||||
/>
|
||||
@@ -292,6 +292,10 @@ const props = defineProps({
|
||||
results: Array as Prop<QueryResult[]>,
|
||||
connUid: String,
|
||||
mode: String as Prop<'table' | 'query'>,
|
||||
page: {
|
||||
type: Number,
|
||||
required: false
|
||||
},
|
||||
isSelected: Boolean,
|
||||
elementType: { type: String, default: 'table' }
|
||||
});
|
||||
@@ -314,8 +318,7 @@ const hasFocus = ref(false);
|
||||
const contextEvent = ref(null);
|
||||
const selectedCell = ref(null);
|
||||
const selectedRows = ref([]);
|
||||
const currentSort = ref('');
|
||||
const currentSortDir = ref('asc');
|
||||
const currentSort: Ref<{field: string; dir: 'asc' | 'desc'}[]> = ref([]);
|
||||
const resultsetIndex = ref(0);
|
||||
const scrollElement = ref(null);
|
||||
const rowHeight = ref(23);
|
||||
@@ -358,14 +361,16 @@ const isHardSort = computed(() => {
|
||||
});
|
||||
|
||||
const sortedResults = computed(() => {
|
||||
if (currentSort.value && !isHardSort.value) {
|
||||
if (currentSort.value[resultsetIndex.value] && !isHardSort.value) {
|
||||
const sortObj = currentSort.value[resultsetIndex.value];
|
||||
|
||||
return [...localResults.value].sort((a: any, b: any) => {
|
||||
let modifier = 1;
|
||||
let valA = typeof a[currentSort.value] === 'string' ? a[currentSort.value].toLowerCase() : a[currentSort.value];
|
||||
let valA = typeof a[sortObj.field] === 'string' ? a[sortObj.field].toLowerCase() : a[sortObj.field];
|
||||
if (!isNaN(valA)) valA = Number(valA);
|
||||
let valB = typeof b[currentSort.value] === 'string' ? b[currentSort.value].toLowerCase() : b[currentSort.value];
|
||||
let valB = typeof b[sortObj.field] === 'string' ? b[sortObj.field].toLowerCase() : b[sortObj.field];
|
||||
if (!isNaN(valB)) valB = Number(valB);
|
||||
if (currentSortDir.value === 'desc') modifier = -1;
|
||||
if (sortObj.dir === 'desc') modifier = -1;
|
||||
if (valA < valB) return -1 * modifier;
|
||||
if (valA > valB) return 1 * modifier;
|
||||
return 0;
|
||||
@@ -784,32 +789,42 @@ const contextMenu = (event: MouseEvent, cell: any) => {
|
||||
isContext.value = true;
|
||||
};
|
||||
|
||||
const sort = (field: string) => {
|
||||
const sort = (field: TableField) => {
|
||||
if (!isSortable.value) return;
|
||||
|
||||
selectedRows.value = [];
|
||||
let fieldName = field.name;
|
||||
const hasTableInFieldname = Object.keys(localResults.value[0]).find(k => k !== '_antares_id').includes('.');
|
||||
|
||||
if (props.mode === 'query')
|
||||
field = `${getTable(resultsetIndex.value)}.${field}`;
|
||||
if (props.mode === 'query' && hasTableInFieldname)
|
||||
fieldName = `${field.tableAlias || field.table}.${field.name}`;
|
||||
|
||||
if (field === currentSort.value) {
|
||||
if (currentSortDir.value === 'asc')
|
||||
currentSortDir.value = 'desc';
|
||||
if (fieldName === currentSort.value[resultsetIndex.value]?.field) {
|
||||
if (currentSort.value[resultsetIndex.value].dir === 'asc')
|
||||
currentSort.value[resultsetIndex.value].dir = 'desc';
|
||||
else
|
||||
resetSort();
|
||||
}
|
||||
else {
|
||||
currentSortDir.value = 'asc';
|
||||
currentSort.value = field;
|
||||
currentSort.value[resultsetIndex.value] = {
|
||||
field: fieldName,
|
||||
dir: 'asc'
|
||||
};
|
||||
}
|
||||
|
||||
if (isHardSort.value)
|
||||
emit('hard-sort', { field: currentSort.value, dir: currentSortDir.value });
|
||||
if (isHardSort.value) {
|
||||
emit('hard-sort', {
|
||||
field: currentSort.value[resultsetIndex.value].field,
|
||||
dir: currentSort.value[resultsetIndex.value].dir
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const resetSort = () => {
|
||||
currentSort.value = '';
|
||||
currentSortDir.value = 'asc';
|
||||
currentSort.value[resultsetIndex.value] = {
|
||||
field: null,
|
||||
dir: 'asc'
|
||||
};
|
||||
};
|
||||
|
||||
const selectResultset = (index: number) => {
|
||||
@@ -857,6 +872,7 @@ const downloadTable = (format: 'csv' | 'json' | 'sql' | 'php', table: string, po
|
||||
},
|
||||
client: workspaceClient.value,
|
||||
table,
|
||||
page: props.page,
|
||||
sqlOptions: popup ? { ...sqlExportOptions.value } : null,
|
||||
csvOptions: popup ? { ...csvExportOptions.value } : null
|
||||
});
|
||||
|
@@ -202,6 +202,7 @@
|
||||
v-if="results"
|
||||
ref="queryTable"
|
||||
:results="results"
|
||||
:page="page"
|
||||
:tab-uid="tabUid"
|
||||
:conn-uid="connection.uid"
|
||||
:is-selected="isSelected"
|
||||
|
@@ -79,7 +79,8 @@ export const enUS = {
|
||||
search: 'Search',
|
||||
title: 'Title',
|
||||
archive: 'Archive', // verb
|
||||
undo: 'Undo'
|
||||
undo: 'Undo',
|
||||
moveTo: 'Move to'
|
||||
},
|
||||
connection: { // Database connection
|
||||
connection: 'Connection',
|
||||
@@ -332,7 +333,7 @@ export const enUS = {
|
||||
wrapLongLines: 'Wrap long lines',
|
||||
markdownSupported: 'Markdown supported',
|
||||
plantATree: 'Plant a Tree',
|
||||
dataTabPageSize: 'DATA tab page size',
|
||||
dataTabPageSize: 'Results per page',
|
||||
noOpenTabs: 'There are no open tabs, navigate on the left bar or:',
|
||||
restorePreviousSession: 'Restore previous session',
|
||||
closeTab: 'Close tab',
|
||||
@@ -363,6 +364,8 @@ export const enUS = {
|
||||
editFolder: 'Edit folder',
|
||||
folderName: 'Folder name',
|
||||
deleteFolder: 'Delete folder',
|
||||
newFolder: 'New folder',
|
||||
outOfFolder: 'Out of folder',
|
||||
editConnectionAppearance: 'Edit connection appearance',
|
||||
defaultCopyType: 'Default copy type',
|
||||
showTableSize: 'Show table size in sidebar',
|
||||
@@ -396,7 +399,12 @@ export const enUS = {
|
||||
editNote: 'Edit note',
|
||||
showArchivedNotes: 'Show archived notes',
|
||||
hideArchivedNotes: 'Hide archived notes',
|
||||
tag: 'Tag' // Note tag
|
||||
tag: 'Tag', // Note tag,
|
||||
saveFile: 'Save file',
|
||||
saveFileAs: 'Save file as',
|
||||
openFile: 'Open file',
|
||||
openNotes: 'Open notes'
|
||||
|
||||
},
|
||||
faker: { // Faker.js methods, used in random generated content
|
||||
address: 'Address',
|
||||
|
@@ -8,6 +8,10 @@ export default class {
|
||||
return ipcRenderer.invoke('show-open-dialog', unproxify(options));
|
||||
}
|
||||
|
||||
static showSaveDialog (options: OpenDialogOptions): Promise<OpenDialogReturnValue> {
|
||||
return ipcRenderer.invoke('show-save-dialog', unproxify(options));
|
||||
}
|
||||
|
||||
static getDownloadPathDirectory (): Promise<string> {
|
||||
return ipcRenderer.invoke('get-download-dir-path');
|
||||
}
|
||||
@@ -27,4 +31,12 @@ export default class {
|
||||
static unregisterShortcuts () {
|
||||
return ipcRenderer.invoke('unregister-shortcuts');
|
||||
}
|
||||
|
||||
static readFile (path: string): Promise<string> {
|
||||
return ipcRenderer.invoke('read-file', path);
|
||||
}
|
||||
|
||||
static writeFile (path: string, content: unknown) {
|
||||
return ipcRenderer.invoke('write-file', path, content);
|
||||
}
|
||||
}
|
||||
|
@@ -1,11 +1,13 @@
|
||||
import { ClientCode } from 'common/interfaces/antares';
|
||||
import { jsonToSqlInsert } from 'common/libs/sqlUtils';
|
||||
import * as json2php from 'json2php';
|
||||
import * as moment from 'moment';
|
||||
|
||||
export const exportRows = (args: {
|
||||
type: 'csv' | 'json'| 'sql' | 'php';
|
||||
content: object[];
|
||||
table: string;
|
||||
page?: number;
|
||||
client?: ClientCode;
|
||||
fields?: {
|
||||
[key: string]: {type: string; datePrecision: number};
|
||||
@@ -31,7 +33,7 @@ export const exportRows = (args: {
|
||||
const csv = [];
|
||||
const sd = args.csvOptions.stringDelimiter === 'single'
|
||||
? '\''
|
||||
: args.csvOptions.stringDelimiter === 'single'
|
||||
: args.csvOptions.stringDelimiter === 'double'
|
||||
? '"'
|
||||
: '';
|
||||
|
||||
@@ -41,6 +43,7 @@ export const exportRows = (args: {
|
||||
for (const row of args.content) {
|
||||
csv.push(Object.values(row).map(col => {
|
||||
if (typeof col === 'string') return `${sd}${col}${sd}`;
|
||||
if (col instanceof Date) return `${sd}${moment(col).format('YYYY-MM-DD HH:mm:ss')}${sd}`;
|
||||
if (col instanceof Buffer) return col.toString('base64');
|
||||
if (col instanceof Uint8Array) return Buffer.from(col).toString('base64');
|
||||
return col;
|
||||
@@ -81,7 +84,7 @@ export const exportRows = (args: {
|
||||
|
||||
const file = new Blob([content], { type: mime });
|
||||
const downloadLink = document.createElement('a');
|
||||
downloadLink.download = `${args.sqlOptions?.targetTable || args.table}.${args.type}`;
|
||||
downloadLink.download = `${args.sqlOptions?.targetTable || args.table}${args.page ? `-${args.page}` : ''}.${args.type}`;
|
||||
downloadLink.href = window.URL.createObjectURL(file);
|
||||
downloadLink.style.display = 'none';
|
||||
document.body.appendChild(downloadLink);
|
||||
|
@@ -415,8 +415,7 @@
|
||||
box-shadow: 0 0 1px 0 #000;
|
||||
|
||||
.settingbar-top-elements {
|
||||
overflow-x: hidden;
|
||||
overflow-y: overlay;
|
||||
overflow: hidden overlay;
|
||||
max-height: calc((100vh - 3.5rem) - #{$excluding-size});
|
||||
}
|
||||
|
||||
|
@@ -164,8 +164,7 @@
|
||||
box-shadow: 0 0 1px 0 #000;
|
||||
|
||||
.settingbar-top-elements {
|
||||
overflow-x: hidden;
|
||||
overflow-y: overlay;
|
||||
overflow: hidden overlay;
|
||||
max-height: calc((100vh - 3.5rem) - #{$excluding-size});
|
||||
}
|
||||
|
||||
|
@@ -90,8 +90,12 @@ export const useConnectionsStore = defineStore('connections', {
|
||||
});
|
||||
persistentStore.set('connectionsOrder', this.connectionsOrder);
|
||||
},
|
||||
addFolder (params: {after: string; connections: [string, string]}) {
|
||||
const index = this.connectionsOrder.findIndex((conn: SidebarElement) => conn.uid === params.after);
|
||||
addFolder (params: {after?: string; connections: [string, string?]}) {
|
||||
const index = params.after
|
||||
? this.connectionsOrder.findIndex((conn: SidebarElement) => conn.uid === params.after)
|
||||
: this.connectionsOrder.length;
|
||||
|
||||
this.removeFromFolders(...params.connections);
|
||||
|
||||
this.connectionsOrder.splice(index, 0, {
|
||||
isFolder: true,
|
||||
@@ -102,7 +106,18 @@ export const useConnectionsStore = defineStore('connections', {
|
||||
});
|
||||
persistentStore.set('connectionsOrder', this.connectionsOrder);
|
||||
},
|
||||
removeFromFolders (...connections: string[]) { // Removes connections from folders
|
||||
this.connectionsOrder = (this.connectionsOrder as SidebarElement[]).map(el => {
|
||||
if (el.isFolder)
|
||||
el.connections = el.connections.filter(uid => !connections.includes(uid));
|
||||
return el;
|
||||
});
|
||||
|
||||
this.clearEmptyFolders();
|
||||
},
|
||||
addToFolder (params: {folder: string; connection: string}) {
|
||||
this.removeFromFolders(params.connection);
|
||||
|
||||
this.connectionsOrder = this.connectionsOrder.map((conn: SidebarElement) => {
|
||||
if (conn.uid === params.folder)
|
||||
conn.connections.push(params.connection);
|
||||
@@ -113,11 +128,7 @@ export const useConnectionsStore = defineStore('connections', {
|
||||
this.clearEmptyFolders();
|
||||
},
|
||||
deleteConnection (connection: SidebarElement | ConnectionParams) {
|
||||
this.connectionsOrder = (this.connectionsOrder as SidebarElement[]).map(el => { // Removes connection from folders
|
||||
if (el.isFolder && el.connections.includes(connection.uid))
|
||||
el.connections = el.connections.filter(uid => uid !== connection.uid);
|
||||
return el;
|
||||
});
|
||||
this.removeFromFolders(connection.uid);
|
||||
this.connectionsOrder = (this.connectionsOrder as SidebarElement[]).filter(el => el.uid !== connection.uid);
|
||||
this.lastConnections = (this.lastConnections as SidebarElement[]).filter(el => el.uid !== connection.uid);
|
||||
|
||||
|
@@ -37,6 +37,7 @@ export interface WorkspaceTab {
|
||||
isChanged?: boolean;
|
||||
content?: string;
|
||||
autorun?: boolean;
|
||||
filePath?: string;
|
||||
}
|
||||
|
||||
export interface WorkspaceStructure {
|
||||
@@ -66,7 +67,7 @@ export interface Workspace {
|
||||
uid: string;
|
||||
client?: ClientCode;
|
||||
database?: string;
|
||||
connectionStatus: 'connected' | 'disconnected' | 'failed';
|
||||
connectionStatus: 'connected' | 'connecting' | 'disconnected' | 'failed';
|
||||
selectedTab: string;
|
||||
searchTerm: string;
|
||||
tabs: WorkspaceTab[];
|
||||
@@ -492,7 +493,7 @@ export const useWorkspacesStore = defineStore('workspaces', {
|
||||
}
|
||||
: workspace);
|
||||
},
|
||||
_addTab ({ uid, tab, content, type, autorun, schema, database, elementName, elementType }: WorkspaceTab) {
|
||||
_addTab ({ uid, tab, content, type, autorun, schema, database, elementName, elementType, filePath }: WorkspaceTab) {
|
||||
if (type === 'query')
|
||||
tabIndex[uid] = tabIndex[uid] ? ++tabIndex[uid] : 1;
|
||||
|
||||
@@ -506,7 +507,8 @@ export const useWorkspacesStore = defineStore('workspaces', {
|
||||
elementName,
|
||||
elementType,
|
||||
content: content || '',
|
||||
autorun: !!autorun
|
||||
autorun: !!autorun,
|
||||
filePath: filePath || ''
|
||||
};
|
||||
|
||||
this.workspaces = (this.workspaces as Workspace[]).map(workspace => {
|
||||
@@ -522,14 +524,14 @@ export const useWorkspacesStore = defineStore('workspaces', {
|
||||
|
||||
persistentStore.set(uid, (this.workspaces as Workspace[]).find(workspace => workspace.uid === uid).tabs);
|
||||
},
|
||||
_replaceTab ({ uid, tab: tUid, type, schema, content, elementName, elementType }: WorkspaceTab) {
|
||||
_replaceTab ({ uid, tab: tUid, type, schema, content, elementName, elementType, filePath }: WorkspaceTab) {
|
||||
this.workspaces = (this.workspaces as Workspace[]).map(workspace => {
|
||||
if (workspace.uid === uid) {
|
||||
return {
|
||||
...workspace,
|
||||
tabs: workspace.tabs.map(tab => {
|
||||
if (tab.uid === tUid)
|
||||
return { ...tab, type, schema, content, elementName, elementType };
|
||||
return { ...tab, type, schema, content, elementName, elementType, filePath };
|
||||
|
||||
return tab;
|
||||
})
|
||||
@@ -541,7 +543,7 @@ export const useWorkspacesStore = defineStore('workspaces', {
|
||||
|
||||
persistentStore.set(uid, (this.workspaces as Workspace[]).find(workspace => workspace.uid === uid).tabs);
|
||||
},
|
||||
newTab ({ uid, content, type, autorun, schema, elementName, elementType }: WorkspaceTab) {
|
||||
newTab ({ uid, content, type, autorun, schema, elementName, elementType, filePath }: WorkspaceTab) {
|
||||
let tabUid;
|
||||
const workspaceTabs = (this.workspaces as Workspace[]).find(workspace => workspace.uid === uid);
|
||||
|
||||
@@ -562,7 +564,8 @@ export const useWorkspacesStore = defineStore('workspaces', {
|
||||
database: workspaceTabs.database,
|
||||
schema,
|
||||
elementName,
|
||||
elementType
|
||||
elementType,
|
||||
filePath
|
||||
});
|
||||
break;
|
||||
case 'temp-data':
|
||||
@@ -594,21 +597,22 @@ export const useWorkspacesStore = defineStore('workspaces', {
|
||||
type: tab.type.replace('temp-', ''),
|
||||
schema: tab.schema,
|
||||
elementName: tab.elementName,
|
||||
elementType: tab.elementType
|
||||
elementType: tab.elementType,
|
||||
filePath: tab.filePath
|
||||
});
|
||||
|
||||
tabUid = uidGen('T');
|
||||
this._addTab({ uid, tab: tabUid, content, type, autorun, database: workspaceTabs.database, schema, elementName, elementType });
|
||||
this._addTab({ uid, tab: tabUid, content, type, autorun, database: workspaceTabs.database, schema, elementName, elementType, filePath });
|
||||
}
|
||||
else {
|
||||
this._replaceTab({ uid, tab: tab.uid, type, schema, elementName, elementType });
|
||||
this._replaceTab({ uid, tab: tab.uid, type, schema, elementName, elementType, filePath });
|
||||
tabUid = tab.uid;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
tabUid = uidGen('T');
|
||||
this._addTab({ uid, tab: tabUid, content, type, autorun, database: workspaceTabs.database, schema, elementName, elementType });
|
||||
this._addTab({ uid, tab: tabUid, content, type, autorun, database: workspaceTabs.database, schema, elementName, elementType, filePath });
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -635,7 +639,8 @@ export const useWorkspacesStore = defineStore('workspaces', {
|
||||
database: workspaceTabs.database,
|
||||
schema,
|
||||
elementName,
|
||||
elementType
|
||||
elementType,
|
||||
filePath
|
||||
});
|
||||
tabUid = existentTab.uid;
|
||||
}
|
||||
@@ -649,7 +654,8 @@ export const useWorkspacesStore = defineStore('workspaces', {
|
||||
database: workspaceTabs.database,
|
||||
schema,
|
||||
elementName,
|
||||
elementType
|
||||
elementType,
|
||||
filePath
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -664,7 +670,8 @@ export const useWorkspacesStore = defineStore('workspaces', {
|
||||
database: workspaceTabs.database,
|
||||
schema,
|
||||
elementName,
|
||||
elementType
|
||||
elementType,
|
||||
filePath
|
||||
});
|
||||
break;
|
||||
}
|
||||
@@ -687,8 +694,8 @@ export const useWorkspacesStore = defineStore('workspaces', {
|
||||
this.selectTab({ uid, tab: workspace.tabs[workspace.tabs.length - 1].uid });
|
||||
}
|
||||
},
|
||||
updateTabContent ({ uid, tab, type, schema, content }: WorkspaceTab) {
|
||||
this._replaceTab({ uid, tab, type, schema, content });
|
||||
updateTabContent ({ uid, tab, type, schema, content, elementName, filePath }: WorkspaceTab) {
|
||||
this._replaceTab({ uid, tab, type, schema, content, elementName, filePath });
|
||||
},
|
||||
renameTabs ({ uid, schema, elementName, elementNewName }: WorkspaceTab) {
|
||||
this.workspaces = (this.workspaces as Workspace[]).map(workspace => {
|
||||
|
Reference in New Issue
Block a user