mirror of
https://github.com/Fabio286/antares.git
synced 2025-06-05 21:59:22 +02:00
Compare commits
262 Commits
v0.7.21-be
...
revert-982
Author | SHA1 | Date | |
---|---|---|---|
e6983d205e | |||
d93ae90373 | |||
86f50521d0 | |||
c966cc4266 | |||
85e516dec0 | |||
|
0b07ee1a87 | ||
|
838810981c | ||
|
b3cf20101b | ||
6c9792f512 | |||
994aa69fd0 | |||
8f84892f07 | |||
a95a76480c | |||
1d1be55d3d | |||
d912faa850 | |||
ba63b049a3 | |||
fcd7e404ba | |||
8eb4d2e114 | |||
acea18e6f0 | |||
973b0fc4be | |||
4adbc575c2 | |||
eb706c3e51 | |||
971df3a989 | |||
3129bf4baa | |||
c6d67cef01 | |||
1d7053ce03 | |||
41e797f9e2 | |||
704f70819b | |||
49a3589536 | |||
49ada059bc | |||
8003d3eb1e | |||
48cfa67889 | |||
9cda38e9d1 | |||
72f8d4249f | |||
0f93d70417 | |||
580bef76ba | |||
7595e89223 | |||
7af44d4a2c | |||
0479e5307c | |||
d03c1b90ce | |||
d34e56a517 | |||
0f35814ca0 | |||
96ae09feca | |||
e3b30359bf | |||
f3c3284fd1 | |||
27387f18a1 | |||
8e54f7b801 | |||
70aae2f194 | |||
592d7b3517 | |||
2b743a2c79 | |||
|
e493db5112 | ||
|
d3d7ab38c0 | ||
7a66c11868 | |||
8544bb5378 | |||
6709a75298 | |||
f25f6659d5 | |||
8d0ff4953e | |||
|
fbe28f0ff0 | ||
0d8bcf5cd6 | |||
|
47ac729d2f | ||
|
450c4c47f3 | ||
|
110dcd335a | ||
|
0029967619 | ||
34848e8dc3 | |||
c32add76e8 | |||
|
507dc7d55b | ||
4a2b5926f4 | |||
ed90b12a7b | |||
|
00ce76a12e | ||
|
77b3a8a354 | ||
d3ae45ec94 | |||
ad4478a822 | |||
|
ba5dd9ff15 | ||
|
5aab824fe9 | ||
87ab58c50f | |||
e986f287c6 | |||
|
39a30e48dd | ||
46165d2f4f | |||
|
d0e56e4eb6 | ||
|
c803c072d1 | ||
232211811b | |||
|
fb9c258cc1 | ||
8de99dae7b | |||
2bd69c6263 | |||
4d1a81033d | |||
5887eea2ed | |||
6c69583c90 | |||
|
03461522b7 | ||
|
11807e3bb6 | ||
a54b8d719c | |||
d1f68da495 | |||
d666281daa | |||
481ae842dd | |||
|
acf5d459e2 | ||
2ee9cfcf0b | |||
f0d312fb59 | |||
c97ade949c | |||
38af648440 | |||
ccbcffc7f0 | |||
dfa7cf9905 | |||
6365e07534 | |||
24605d01e1 | |||
f083a8a185 | |||
|
f639bc7983 | ||
|
5e51997e5b | ||
|
1e3c9edb50 | ||
60e1e59505 | |||
dba490f226 | |||
b6c5dff15c | |||
d2da8c2446 | |||
b54d2c9f5e | |||
9a0ad80bb5 | |||
2f3f5de8d6 | |||
b2c046fd38 | |||
|
bbc29a6335 | ||
|
b6c337638c | ||
2120a59d41 | |||
2cda4a1fa1 | |||
76c8cd1beb | |||
14aeebed9c | |||
|
1a1118452a | ||
|
4b0f596405 | ||
|
eb749f0f66 | ||
|
d78e59dd09 | ||
7969294a93 | |||
2ae016f0b6 | |||
b4f33bc474 | |||
f185463866 | |||
3fa0bd3cd1 | |||
|
0d3ef39822 | ||
|
a02913f4e5 | ||
f9f993cbcd | |||
|
ebd1a75445 | ||
4201532081 | |||
|
c5cb586358 | ||
|
c111b2c0f5 | ||
b70ed124eb | |||
010147b553 | |||
da8cc39157 | |||
37d44c95ee | |||
4df4c6197d | |||
|
0506b653d7 | ||
5fd9fe48a2 | |||
b6a7124f33 | |||
|
5855ab0921 | ||
c2b602785a | |||
97279742e9 | |||
6cb21ff792 | |||
72bacdeabf | |||
c434855879 | |||
ba0ffcc6f5 | |||
8e7965a0f9 | |||
4aab84fbd5 | |||
|
74e97e660d | ||
|
f5d236b521 | ||
|
e794d207ad | ||
f99a3cc054 | |||
59f7d3c670 | |||
8f2daa0f1c | |||
141d5bb69c | |||
171b6f924a | |||
f7419d8e9c | |||
5b1cd70e25 | |||
3e223b475e | |||
4a38656b7e | |||
25b7ae57c6 | |||
4b5718e9b7 | |||
780d83deaa | |||
e952f9f5f8 | |||
49f1a8ef2e | |||
121aa21a6d | |||
cb25963a67 | |||
3a47607a5f | |||
7494ff6fcf | |||
838491bfd4 | |||
0b9898f3e7 | |||
a973ec3c60 | |||
d0c50f17ca | |||
b4cdd58973 | |||
9947479fdc | |||
4a1697d633 | |||
b7dfd5cb8c | |||
0ec9d3cfc1 | |||
|
4f615b26cf | ||
|
86a1e05197 | ||
3fa9873d20 | |||
37a160a03f | |||
2385a8207c | |||
|
243984e697 | ||
d1bb50b2bb | |||
8501fa2e81 | |||
25123e34ef | |||
bd4502ee47 | |||
b2f9d475a2 | |||
|
93de974b09 | ||
|
949bf4cbcb | ||
|
bb3c87b2cf | ||
40bf9a040a | |||
|
978b55fdb1 | ||
|
098d4e96d6 | ||
957cb9e1a5 | |||
09c274a724 | |||
9bcd874e80 | |||
ece2ee05cc | |||
058fc2fc0b | |||
33bbc0e7e6 | |||
23c59b4d4e | |||
6600197b82 | |||
33203aeb04 | |||
f4f385589f | |||
0565ae1204 | |||
258fbc81f7 | |||
8d8650fbe7 | |||
af2812f2b0 | |||
|
d163cbfac8 | ||
|
4537d96f3e | ||
099a71a189 | |||
e7efb9c616 | |||
a752dcb6a9 | |||
|
c1e58eb695 | ||
|
f7204dc0ae | ||
|
6b56c60b68 | ||
1875e895ae | |||
2064294119 | |||
62e3115860 | |||
9aef287a98 | |||
65ec4c5da6 | |||
e19118982b | |||
11f130d91c | |||
|
0bb5cedda6 | ||
de9dac3e8a | |||
dd5b41716a | |||
86acb390ac | |||
2884ec3dd6 | |||
b542a09c01 | |||
6d94a04b67 | |||
8500fc40a1 | |||
586f901bae | |||
04e4d21e20 | |||
fd3dd03eb2 | |||
d3f71e65ce | |||
90b9b87b1d | |||
e9b42c3edb | |||
259d051a21 | |||
876d5ea481 | |||
6d002efaf5 | |||
58be1abf5f | |||
da56905572 | |||
d698f2798a | |||
9a41511c42 | |||
|
30ada13663 | ||
14eeaccb07 | |||
1a0c5da2f1 | |||
bb36e98beb | |||
8928510fb5 | |||
eb5d3f14f1 | |||
33c127b090 | |||
4e98dc21d8 | |||
20b27343cd | |||
3b9228a723 | |||
ab0f91b448 | |||
dbf38fd99c | |||
97ece32988 |
@@ -266,6 +266,105 @@
|
||||
"contributions": [
|
||||
"translation"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "bagusindrayana",
|
||||
"name": "Bagus Indrayana",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/36830534?v=4",
|
||||
"profile": "https://github.com/bagusindrayana",
|
||||
"contributions": [
|
||||
"code"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "penguinlab",
|
||||
"name": "Naoki Ishikawa",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/10959317?v=4",
|
||||
"profile": "https://github.com/penguinlab",
|
||||
"contributions": [
|
||||
"translation"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "mangas",
|
||||
"name": "Filipe Azevedo",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/1640325?v=4",
|
||||
"profile": "https://fazevedo.dev",
|
||||
"contributions": [
|
||||
"code"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "zwei-c",
|
||||
"name": "CHANG, CHIH WEI",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/55912811?v=4",
|
||||
"profile": "https://github.com/zwei-c",
|
||||
"contributions": [
|
||||
"translation"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "mirrorb",
|
||||
"name": "GaoChun",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/34116207?v=4",
|
||||
"profile": "https://github.com/mirrorb",
|
||||
"contributions": [
|
||||
"code"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "LeviEyal",
|
||||
"name": "Eyal Levi",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/48846533?v=4",
|
||||
"profile": "https://github.com/LeviEyal",
|
||||
"contributions": [
|
||||
"translation"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "SawGoD",
|
||||
"name": "Nikita Karelikov",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/67802757?v=4",
|
||||
"profile": "http://telegram.dog/SawGoD",
|
||||
"contributions": [
|
||||
"translation"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "carvalhods",
|
||||
"name": "David Carvalho",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/6569255?v=4",
|
||||
"profile": "https://github.com/carvalhods",
|
||||
"contributions": [
|
||||
"platform"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "r4f4dev",
|
||||
"name": "r4f4dev",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/65920592?v=4",
|
||||
"profile": "https://github.com/r4f4dev",
|
||||
"contributions": [
|
||||
"translation"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "salvymc",
|
||||
"name": "Salvatore Forino",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/10051897?v=4",
|
||||
"profile": "https://github.com/salvymc",
|
||||
"contributions": [
|
||||
"code"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "JoseGonzalez84",
|
||||
"name": "José González",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/16820141?v=4",
|
||||
"profile": "https://gadev.com.es/",
|
||||
"contributions": [
|
||||
"translation"
|
||||
]
|
||||
}
|
||||
],
|
||||
"contributorsPerLine": 7,
|
||||
|
@@ -2,4 +2,5 @@ node_modules
|
||||
assets
|
||||
out
|
||||
dist
|
||||
build
|
||||
build
|
||||
misc
|
4
.github/FUNDING.yml
vendored
4
.github/FUNDING.yml
vendored
@@ -1,6 +1,6 @@
|
||||
# These are supported funding model platforms
|
||||
|
||||
github: [fabio286]
|
||||
github: [antares-sql,fabio286]
|
||||
patreon: #fabio286
|
||||
open_collective: # Replace with a single Open Collective username
|
||||
ko_fi: # Replace with a single Ko-fi username
|
||||
@@ -9,4 +9,4 @@ community_bridge: # Replace with a single Community Bridge project-name e.g., cl
|
||||
liberapay: # Replace with a single Liberapay username
|
||||
issuehunt: # Replace with a single IssueHunt username
|
||||
otechie: # Replace with a single Otechie username
|
||||
custom: ['https://paypal.me/fabiodistasio']
|
||||
custom: ['https://paypal.me/fabiodistasio']
|
||||
|
8
.github/workflows/build-beta.yml
vendored
8
.github/workflows/build-beta.yml
vendored
@@ -19,17 +19,19 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Check out Git repository
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
ref: beta
|
||||
|
||||
- name: Install Node.js
|
||||
uses: actions/setup-node@v3
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 20
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm i
|
||||
run: |
|
||||
npm i
|
||||
npm install "dmg-license" --save-optional
|
||||
|
||||
- name: "Build"
|
||||
run: npm run build
|
||||
|
8
.github/workflows/build.yml
vendored
8
.github/workflows/build.yml
vendored
@@ -25,17 +25,19 @@ jobs:
|
||||
exit 0
|
||||
|
||||
- name: Check out Git repository
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
ref: master
|
||||
|
||||
- name: Install Node.js
|
||||
uses: actions/setup-node@v3
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 20
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm i
|
||||
run: |
|
||||
npm i
|
||||
npm install "dmg-license" --save-optional
|
||||
|
||||
- name: "Build"
|
||||
run: npm run build
|
||||
|
2
.github/workflows/codeql-analysis.yml
vendored
2
.github/workflows/codeql-analysis.yml
vendored
@@ -25,7 +25,7 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
# We must fetch at least the immediate parents so that if this is
|
||||
# a pull request then we can checkout the head.
|
||||
|
@@ -8,12 +8,12 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Check out Git repository
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
ref: master
|
||||
|
||||
- name: Install Node.js
|
||||
uses: actions/setup-node@v3
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 20
|
||||
|
||||
@@ -24,7 +24,7 @@ jobs:
|
||||
run: npm run build -- --arm64 --linux deb AppImage
|
||||
|
||||
- name: Upload Artifact
|
||||
uses: actions/upload-artifact@v3
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: linux-build
|
||||
retention-days: 3
|
||||
|
8
.github/workflows/create-artifact-linux.yml
vendored
8
.github/workflows/create-artifact-linux.yml
vendored
@@ -5,13 +5,13 @@ on:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- name: Check out Git repository
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install Node.js
|
||||
uses: actions/setup-node@v3
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 20
|
||||
|
||||
@@ -22,7 +22,7 @@ jobs:
|
||||
run: npm run build
|
||||
|
||||
- name: Upload Artifact
|
||||
uses: actions/upload-artifact@v3
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: linux-build
|
||||
retention-days: 3
|
||||
|
12
.github/workflows/create-artifact-macos.yml
vendored
12
.github/workflows/create-artifact-macos.yml
vendored
@@ -8,20 +8,21 @@ jobs:
|
||||
runs-on: macos-latest
|
||||
steps:
|
||||
- name: Check out Git repository
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install Node.js
|
||||
uses: actions/setup-node@v3
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 20
|
||||
|
||||
- name: npm install & build
|
||||
run: |
|
||||
npm install
|
||||
npm install "dmg-license" --save-optional
|
||||
npm run build
|
||||
|
||||
- name: Upload Artifact
|
||||
uses: actions/upload-artifact@v3
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: macos-build
|
||||
retention-days: 3
|
||||
@@ -38,17 +39,18 @@ jobs:
|
||||
ref: beta
|
||||
|
||||
- name: Install Node.js
|
||||
uses: actions/setup-node@v3
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 20
|
||||
|
||||
- name: npm install & build
|
||||
run: |
|
||||
npm install
|
||||
npm install "dmg-license" --save-optional
|
||||
npm run build
|
||||
|
||||
- name: Upload Artifact
|
||||
uses: actions/upload-artifact@v3
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: macos-build-beta
|
||||
retention-days: 3
|
||||
|
32
.github/workflows/create-artifact-windows-appx.yml
vendored
Normal file
32
.github/workflows/create-artifact-windows-appx.yml
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
name: Create artifact [WINDOWS APPX]
|
||||
|
||||
on:
|
||||
workflow_dispatch: {}
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: windows-2022
|
||||
steps:
|
||||
- name: Check out Git repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 20
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm i
|
||||
|
||||
- name: "Build"
|
||||
run: npm run build:appx
|
||||
|
||||
- name: Upload Artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: windows-build
|
||||
retention-days: 3
|
||||
path: |
|
||||
build
|
||||
!build/*-unpacked
|
||||
!build/.icon-ico
|
50
.github/workflows/create-generated-sources.yml
vendored
Normal file
50
.github/workflows/create-generated-sources.yml
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
name: Create generated-rources.json
|
||||
|
||||
on:
|
||||
workflow_dispatch: {}
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
# Install flatpak-node-generator
|
||||
- name: Install Python
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: '3.11'
|
||||
|
||||
- name: Install pipx
|
||||
uses: CfirTsabari/actions-pipx@v1
|
||||
|
||||
- name: Install flatpak-node-generator
|
||||
run: |
|
||||
cd ../
|
||||
git clone https://github.com/flatpak/flatpak-builder-tools.git
|
||||
cd flatpak-builder-tools/node
|
||||
pipx install .
|
||||
|
||||
# Install Antares
|
||||
- name: Check out Git repository
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Install Node.js
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 20
|
||||
|
||||
# - name: Delete old package-lock.json
|
||||
# run: rm package-lock.json
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm i --lockfile-version 2
|
||||
|
||||
- name: Generate generated-sources.json
|
||||
run: flatpak-node-generator npm -r package-lock.json --electron-node-headers
|
||||
|
||||
- name: Upload Artifact
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: generated-sources
|
||||
retention-days: 3
|
||||
path: |
|
||||
generated-sources.json
|
4
.github/workflows/test-builds.yml
vendored
4
.github/workflows/test-builds.yml
vendored
@@ -17,12 +17,12 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Check out Git repository
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
ref: develop
|
||||
|
||||
- name: Install Node.js
|
||||
uses: actions/setup-node@v3
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 20
|
||||
|
||||
|
11
.github/workflows/test-e2e-win.yml
vendored
11
.github/workflows/test-e2e-win.yml
vendored
@@ -1,9 +1,10 @@
|
||||
name: Test end-to-end
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- develop
|
||||
workflow_dispatch: {}
|
||||
# push:
|
||||
# branches:
|
||||
# - develop
|
||||
|
||||
jobs:
|
||||
release:
|
||||
@@ -15,10 +16,10 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Check out Git repository
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install Node.js
|
||||
uses: actions/setup-node@v3
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 20
|
||||
|
||||
|
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"
|
||||
}
|
439
CHANGELOG.md
439
CHANGELOG.md
@@ -2,6 +2,445 @@
|
||||
|
||||
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.35-beta.1](https://github.com/antares-sql/antares/compare/v0.7.35-beta.0...v0.7.35-beta.1) (2025-04-28)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* handle id type correctly in update-table-cell where clause, fixes [#974](https://github.com/antares-sql/antares/issues/974) ([8f84892](https://github.com/antares-sql/antares/commit/8f84892f079e5eb56c69170eb4f7bbbebd1fda72))
|
||||
* if webcontents with id 1 not found use first webcontents ([b3cf201](https://github.com/antares-sql/antares/commit/b3cf20101b938a4b47c454c7a94b32b3820bce8e))
|
||||
* improve SQL parameter escaping in update-table-cell, ensuring correct handling of id types ([994aa69](https://github.com/antares-sql/antares/commit/994aa69fd00afc7e24e593b1a6c6667535e090c2))
|
||||
* **MySQL:** handle absence of CHECK_CONSTRAINTS table, fixes [#981](https://github.com/antares-sql/antares/issues/981) ([86f5052](https://github.com/antares-sql/antares/commit/86f50521d05da0afdc9506d74e6ab007e2ae0a84))
|
||||
|
||||
### [0.7.35-beta.0](https://github.com/antares-sql/antares/compare/v0.7.34...v0.7.35-beta.0) (2025-04-04)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* custom connection icon disappears during connection, fixes [#939](https://github.com/antares-sql/antares/issues/939) ([1d1be55](https://github.com/antares-sql/antares/commit/1d1be55d3d4ea621364c37e75de616046371feeb))
|
||||
* escape SQL parameters in update and delete for where clauses, fixes [#964](https://github.com/antares-sql/antares/issues/964) ([ba63b04](https://github.com/antares-sql/antares/commit/ba63b049a3a059e77256141dc7b761efbbbf8c1e))
|
||||
* improved handling of query comments, fixes [#963](https://github.com/antares-sql/antares/issues/963) and [#580](https://github.com/antares-sql/antares/issues/580) ([d912faa](https://github.com/antares-sql/antares/commit/d912faa85042219315c9c5658d7f20fda560af44))
|
||||
* use custom elements wrapper for foreign column and description in query ([973b0fc](https://github.com/antares-sql/antares/commit/973b0fc4be1dac25757e430e4520d6fc2212f93b))
|
||||
|
||||
|
||||
### Improvements
|
||||
|
||||
* **translation:** update Spanish translations, closes [#962](https://github.com/antares-sql/antares/issues/962) ([acea18e](https://github.com/antares-sql/antares/commit/acea18e6f061adab7e79d1249e0e68555a620db5))
|
||||
|
||||
### [0.7.34](https://github.com/antares-sql/antares/compare/v0.7.33...v0.7.34) (2025-02-14)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* issue with some SSH connections, definitely ([eb706c3](https://github.com/antares-sql/antares/commit/eb706c3e51e9cb7577febd291a33594c0650a34a))
|
||||
|
||||
### [0.7.33](https://github.com/antares-sql/antares/compare/v0.7.32...v0.7.33) (2025-02-14)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* issue with some SSH connections, fixes [#947](https://github.com/antares-sql/antares/issues/947) ([3129bf4](https://github.com/antares-sql/antares/commit/3129bf4baa5e72b1d79df986605fd5fad1dce291))
|
||||
|
||||
### [0.7.32](https://github.com/antares-sql/antares/compare/v0.7.31...v0.7.32) (2025-02-14)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* black background with light theme, fixes [#945](https://github.com/antares-sql/antares/issues/945) ([1d7053c](https://github.com/antares-sql/antares/commit/1d7053ce032efec8377d9500f2e24618f6381ab4))
|
||||
* enhance SVG support in connection customization, fixes [#939](https://github.com/antares-sql/antares/issues/939) ([49a3589](https://github.com/antares-sql/antares/commit/49a3589536d2e75a14125be7b874e29b60fb56c4))
|
||||
* improve error handling in SSH connection ([704f708](https://github.com/antares-sql/antares/commit/704f70819b21a42194d8f68cf9b58ba337f1ada7))
|
||||
* **PostgreSQL:** error with materialized view tabs ([41e797f](https://github.com/antares-sql/antares/commit/41e797f9e27db66370d3ae7750c057f708af76f9))
|
||||
|
||||
### [0.7.31](https://github.com/antares-sql/antares/compare/v0.7.31-beta.5...v0.7.31) (2025-02-11)
|
||||
|
||||
### [0.7.31-beta.5](https://github.com/antares-sql/antares/compare/v0.7.31-beta.4...v0.7.31-beta.5) (2025-02-09)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **devtoolsInstaller:** improve file path handling and increase chromium version ([7595e89](https://github.com/antares-sql/antares/commit/7595e892238d2a93c454e9c1f236915fb458eed1))
|
||||
* improve BLOB primary fields management, fixes [#938](https://github.com/antares-sql/antares/issues/938) ([72f8d42](https://github.com/antares-sql/antares/commit/72f8d4249f7f587d3e92b46cf7709ddab42107d4))
|
||||
* **Linux:** restored AppImage auto updates ([0479e53](https://github.com/antares-sql/antares/commit/0479e5307c9a9d5f791e1c61fa772d331f6f7f1f))
|
||||
* replace 'this.addNotification' with 'addNotification' in useResultTables.ts ([580bef7](https://github.com/antares-sql/antares/commit/580bef76ba390fc85df0892265f31392b80301bd))
|
||||
* unable to delete rows from context menu ([0f93d70](https://github.com/antares-sql/antares/commit/0f93d70417871f02f9f64f203f6654fa1bf2004b))
|
||||
|
||||
|
||||
### Improvements
|
||||
|
||||
* improve button styles of notes ([48cfa67](https://github.com/antares-sql/antares/commit/48cfa67889bd83228c109b7966c4acea4e542fc6))
|
||||
* **MySQL:** long loading in table settings when no checks present ([9cda38e](https://github.com/antares-sql/antares/commit/9cda38e9d10e3000473863560d8be8f426a5ed17))
|
||||
|
||||
### [0.7.31-beta.4](https://github.com/antares-sql/antares/compare/v0.7.31-beta.3...v0.7.31-beta.4) (2025-01-31)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **Linux:** missing window management icons ([d34e56a](https://github.com/antares-sql/antares/commit/d34e56a517784dea16a7a53bc2249072a3b96596))
|
||||
|
||||
### [0.7.31-beta.3](https://github.com/antares-sql/antares/compare/v0.7.31-beta.2...v0.7.31-beta.3) (2025-01-31)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* implement a better query splitter for SQL queries, fixes [#926](https://github.com/antares-sql/antares/issues/926) ([96ae09f](https://github.com/antares-sql/antares/commit/96ae09fecad0c1fc8926d5dcf64cc779abe5ed49))
|
||||
* **Linux:** update title bar for better Linux experience ([8e54f7b](https://github.com/antares-sql/antares/commit/8e54f7b80135768a33934bc9336239dee38401a5))
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **MySQL:** adjust utf8mb3 encoding to resolve compatibility issue, fixes [#646](https://github.com/antares-sql/antares/issues/646) ([27387f1](https://github.com/antares-sql/antares/commit/27387f18a107fc6c09afec5f85134496ce764355))
|
||||
|
||||
### [0.7.31-beta.2](https://github.com/antares-sql/antares/compare/v0.7.31-beta.1...v0.7.31-beta.2) (2025-01-30)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* add developer tools and refresh buttons to console in development mode ([592d7b3](https://github.com/antares-sql/antares/commit/592d7b35170f8437ebc15221c97985e889fccb40))
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* fail to fill cell to datetime column(Postgre) fixes [#924](https://github.com/antares-sql/antares/issues/924) ([d3d7ab3](https://github.com/antares-sql/antares/commit/d3d7ab38c029fc5ec23767c6c86c49a96e4e329c))
|
||||
* reorder condition when format the update data ([e493db5](https://github.com/antares-sql/antares/commit/e493db5112478ff121e4e77f69c21747c5d2e032))
|
||||
|
||||
### [0.7.31-beta.1](https://github.com/antares-sql/antares/compare/v0.7.31-beta.0...v0.7.31-beta.1) (2025-01-22)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* zoom in/out and fullscreen shortcuts ([47ac729](https://github.com/antares-sql/antares/commit/47ac729d2f5cced2c503358f7d45a1795f232a20))
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* cannot update column value with composite primary key and JSON column, fixes [#916](https://github.com/antares-sql/antares/issues/916) ([0029967](https://github.com/antares-sql/antares/commit/002996761997444ff689bf2384dae64ccb9ef8f7))
|
||||
* fail to duplicate JSON row ([507dc7d](https://github.com/antares-sql/antares/commit/507dc7d55b342240bf18fd58e6bc71709e8e33a0))
|
||||
* saved connections lost opening a second window after first app run ([4a2b592](https://github.com/antares-sql/antares/commit/4a2b5926f4783d0b9b1e28485e9293a25ddd31f3))
|
||||
|
||||
|
||||
### Improvements
|
||||
|
||||
* **translation:** update spanish translation ([d3ae45e](https://github.com/antares-sql/antares/commit/d3ae45ec94b3538e84ac3013b285034caea695cf))
|
||||
|
||||
### [0.7.31-beta.0](https://github.com/antares-sql/antares/compare/v0.7.30...v0.7.31-beta.0) (2025-01-06)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **language:** add uzbek language support ([fb9c258](https://github.com/antares-sql/antares/commit/fb9c258cc10e4d85242ca533a66a95f4101d472c))
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* prevent delete confirmation modal from triggering on non-delete key presses, fixes [#906](https://github.com/antares-sql/antares/issues/906) ([8de99da](https://github.com/antares-sql/antares/commit/8de99dae7b6eb72bd6833c607d3c3a5db9508ebb))
|
||||
|
||||
### [0.7.30](https://github.com/antares-sql/antares/compare/v0.7.30-beta.1...v0.7.30) (2024-12-04)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* issue saving queries as file ([a54b8d7](https://github.com/antares-sql/antares/commit/a54b8d719c6454500b885050c9ce6feaf7cfae1f))
|
||||
|
||||
### [0.7.30-beta.1](https://github.com/antares-sql/antares/compare/v0.7.30-beta.0...v0.7.30-beta.1) (2024-11-15)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* missing support check for table check features ([2ee9cfc](https://github.com/antares-sql/antares/commit/2ee9cfcf0bbcf86e8a194d2eff78801300ce7cb3))
|
||||
|
||||
|
||||
### Improvements
|
||||
|
||||
* **PostgreSQL:** improved support of connection strings, closes [#893](https://github.com/antares-sql/antares/issues/893) ([f0d312f](https://github.com/antares-sql/antares/commit/f0d312fb59fd98d6e4501bc407959b91eb0650f2))
|
||||
|
||||
### [0.7.30-beta.0](https://github.com/antares-sql/antares/compare/v0.7.29...v0.7.30-beta.0) (2024-10-25)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **MySQL:** check constraints management support ([6365e07](https://github.com/antares-sql/antares/commit/6365e075349e00caa1454cce862e918f2069878f))
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* incorrect behavior in sorting tables with null/empty values, fixes [#883](https://github.com/antares-sql/antares/issues/883) ([b6c5dff](https://github.com/antares-sql/antares/commit/b6c5dff15c165261e9a11a389ed415e59c7b7628))
|
||||
* incorrect behavior sorting tables with numeric values ([60e1e59](https://github.com/antares-sql/antares/commit/60e1e595057c3ba7f36e0f829dba11b470e1069b))
|
||||
* **MySQL:** routines do not return results, fixes [#885](https://github.com/antares-sql/antares/issues/885) ([dba490f](https://github.com/antares-sql/antares/commit/dba490f22634f87d3af5a3a4c0866fc3095c9842))
|
||||
|
||||
|
||||
### Improvements
|
||||
|
||||
* added more notifications in debug console ([dfa7cf9](https://github.com/antares-sql/antares/commit/dfa7cf9905a4d0a79eaed823a14477574b329dfa))
|
||||
|
||||
### [0.7.29](https://github.com/antares-sql/antares/compare/v0.7.29-beta.3...v0.7.29) (2024-10-14)
|
||||
|
||||
### [0.7.29-beta.3](https://github.com/antares-sql/antares/compare/v0.7.29-beta.2...v0.7.29-beta.3) (2024-10-08)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **translation:** add hebrew translation, closes [#878](https://github.com/antares-sql/antares/issues/878) ([2f3f5de](https://github.com/antares-sql/antares/commit/2f3f5de8d6b02cfbf5217adfcb09a61e13d1e901))
|
||||
|
||||
|
||||
### Improvements
|
||||
|
||||
* **MySQL:** made some common errors related to corrupted tables non-blocking, closes [#877](https://github.com/antares-sql/antares/issues/877) ([9a0ad80](https://github.com/antares-sql/antares/commit/9a0ad80bb55f84bd6c90cc1e9b63b33512d336a8))
|
||||
|
||||
### [0.7.29-beta.2](https://github.com/antares-sql/antares/compare/v0.7.29-beta.1...v0.7.29-beta.2) (2024-10-02)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **UI:** new context menu and some minor improvements to query tabs, closes [#867](https://github.com/antares-sql/antares/issues/867) ([14aeebe](https://github.com/antares-sql/antares/commit/14aeebed9cd8e475548f5e0ade105f4b11954cb2))
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **MySQL:** incorrect representation of the DATE if the year is prior to 1900, fixes [#860](https://github.com/antares-sql/antares/issues/860) ([7969294](https://github.com/antares-sql/antares/commit/7969294a93a51861c57d4396c7a0d89ecc7e8a84))
|
||||
* **MySQL:** missing exported values for DEFAULT_GENERATED table fields, fixes [#854](https://github.com/antares-sql/antares/issues/854) ([2cda4a1](https://github.com/antares-sql/antares/commit/2cda4a1fa1c80f3567e160caf0b93bc19d76fbaa))
|
||||
* **PostgreSQL:** error changing the comment for a specific table name ([eb749f0](https://github.com/antares-sql/antares/commit/eb749f0f66bf6547053e30b1503c8b2990ae5950))
|
||||
* **PostgreSQL:** unable to change table comment to empty ([d78e59d](https://github.com/antares-sql/antares/commit/d78e59dd0910d3ea6ec5183a8748420b2db57050))
|
||||
|
||||
### [0.7.29-beta.1](https://github.com/antares-sql/antares/compare/v0.7.29-beta.0...v0.7.29-beta.1) (2024-09-28)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **PostgreSQL:** table and field comments ([ebd1a75](https://github.com/antares-sql/antares/commit/ebd1a7544594eb4498560cc64de4b94146ee8439))
|
||||
* **translation:** traditional chinese translation, closes [#869](https://github.com/antares-sql/antares/issues/869) ([b70ed12](https://github.com/antares-sql/antares/commit/b70ed124eb753091a6afe637d75e59ee9771c8eb))
|
||||
|
||||
### [0.7.29-beta.0](https://github.com/antares-sql/antares/compare/v0.7.28...v0.7.29-beta.0) (2024-09-23)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* cancel button when waiting to connect database, closes [#830](https://github.com/antares-sql/antares/issues/830) ([b6a7124](https://github.com/antares-sql/antares/commit/b6a7124f33397a2ae7da654b5867f6982ac5810e))
|
||||
* update czech translation ([0506b65](https://github.com/antares-sql/antares/commit/0506b653d74d8cd5e848bc2ec4d29d4b0247c880))
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* mismatch between table field columns and results with duplicate fields, fixes [#848](https://github.com/antares-sql/antares/issues/848) ([da8cc39](https://github.com/antares-sql/antares/commit/da8cc39157a4b507d3d377ee1e888b8f8a52b7c5))
|
||||
|
||||
|
||||
### Improvements
|
||||
|
||||
* **UI:** hide edit/delete functions in readonly mode ([37d44c9](https://github.com/antares-sql/antares/commit/37d44c95ee559f3ee1345e91fca5e2c1e86c5fbf))
|
||||
|
||||
### [0.7.28](https://github.com/antares-sql/antares/compare/v0.7.28-beta.0...v0.7.28) (2024-08-20)
|
||||
|
||||
### [0.7.28-beta.0](https://github.com/antares-sql/antares/compare/v0.7.27...v0.7.28-beta.0) (2024-08-06)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* add missing Dutch strings ([e794d20](https://github.com/antares-sql/antares/commit/e794d207ad75e0f5380f57df579912893e5edb6a))
|
||||
* **translation:** Add more faker translations ([74e97e6](https://github.com/antares-sql/antares/commit/74e97e660df089ed8273565942118e112f6b3220))
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* disabled column sort during loadings ([72bacde](https://github.com/antares-sql/antares/commit/72bacdeabf833880482a839c4735505573d33bdc))
|
||||
* html tags searching in history or saved queries, fixes [#847](https://github.com/antares-sql/antares/issues/847) ([6cb21ff](https://github.com/antares-sql/antares/commit/6cb21ff7926c74469b421c47b434612b3894b4c2))
|
||||
* **PostgreSQL:** issue exporting tables with primary keys ([c434855](https://github.com/antares-sql/antares/commit/c434855879de16f83e17784e38e931decdd94873))
|
||||
* **PostgreSQL:** wrong export formato of JSON fields ([8e7965a](https://github.com/antares-sql/antares/commit/8e7965a0f94a17ed73d5c8913f66e4e9cf0b11c7))
|
||||
* **translation:** Spelling error ([f5d236b](https://github.com/antares-sql/antares/commit/f5d236b521a3534754de0b1031513f8eb83b3cc0))
|
||||
* wrong password message importing app data ([ba0ffcc](https://github.com/antares-sql/antares/commit/ba0ffcc6f56c5506c1768c05d43bb07f7b090a68))
|
||||
|
||||
### [0.7.27](https://github.com/antares-sql/antares/compare/v0.7.26...v0.7.27) (2024-07-16)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* issue with new console and languages different than english, fixes [#837](https://github.com/antares-sql/antares/issues/837) ([59f7d3c](https://github.com/antares-sql/antares/commit/59f7d3c67083ac7e32bd29c9b7e6e044f2060c2f))
|
||||
|
||||
### [0.7.26](https://github.com/antares-sql/antares/compare/v0.7.26-beta.1...v0.7.26) (2024-07-15)
|
||||
|
||||
### [0.7.26-beta.1](https://github.com/antares-sql/antares/compare/v0.7.26-beta.0...v0.7.26-beta.1) (2024-07-11)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* custom SVG icons for connections, closes [#663](https://github.com/antares-sql/antares/issues/663) ([171b6f9](https://github.com/antares-sql/antares/commit/171b6f924acc7d7696f4f850a704af0baf616b87))
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* table name in column list on export as SQL features, fixes [#822](https://github.com/antares-sql/antares/issues/822) ([f7419d8](https://github.com/antares-sql/antares/commit/f7419d8e9c4fe8ea80dbf9b2612ff44a66f50365))
|
||||
|
||||
### [0.7.26-beta.0](https://github.com/antares-sql/antares/compare/v0.7.25...v0.7.26-beta.0) (2024-07-01)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* in-app debug console, closes [#824](https://github.com/antares-sql/antares/issues/824) ([3e223b4](https://github.com/antares-sql/antares/commit/3e223b475ea57b24a6782feeabecad9c5596e271))
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **PostgreSQL:** issue with ssl enabled and connection strings, fixes [#786](https://github.com/antares-sql/antares/issues/786) ([4a38656](https://github.com/antares-sql/antares/commit/4a38656b7e1094d3a9df28ce263c272f2014adb7))
|
||||
|
||||
|
||||
### Improvements
|
||||
|
||||
* **UI:** improved all connections modal, closes [#761](https://github.com/antares-sql/antares/issues/761) ([25b7ae5](https://github.com/antares-sql/antares/commit/25b7ae57c6a4be9e825dddc7a52a49b67e03771b))
|
||||
|
||||
### [0.7.25](https://github.com/antares-sql/antares/compare/v0.7.25-beta.2...v0.7.25) (2024-06-19)
|
||||
|
||||
### [0.7.25-beta.2](https://github.com/antares-sql/antares/compare/v0.7.25-beta.1...v0.7.25-beta.2) (2024-06-16)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **PostgreSQL:** support to materialized views, closes [#804](https://github.com/antares-sql/antares/issues/804) ([0b9898f](https://github.com/antares-sql/antares/commit/0b9898f3e714d2cb24d100f55dd3858a644de162))
|
||||
|
||||
|
||||
### Improvements
|
||||
|
||||
* **UI:** views grouped in folders ([a973ec3](https://github.com/antares-sql/antares/commit/a973ec3c60398cb16685a4f991c43ec4ee74c986))
|
||||
|
||||
### [0.7.25-beta.1](https://github.com/antares-sql/antares/compare/v0.7.25-beta.0...v0.7.25-beta.1) (2024-06-08)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* issue switching table after using a filter, fixes[#691](https://github.com/antares-sql/antares/issues/691) ([4a1697d](https://github.com/antares-sql/antares/commit/4a1697d63351b9990efff5804b95d92ac2fc9783))
|
||||
|
||||
### [0.7.25-beta.0](https://github.com/antares-sql/antares/compare/v0.7.24...v0.7.25-beta.0) (2024-05-26)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* update japanese translation ([bb3c87b](https://github.com/antares-sql/antares/commit/bb3c87b2cf6fa38e3cfb68317c02aa350aae7887))
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* missing resizebars on mouse over ([25123e3](https://github.com/antares-sql/antares/commit/25123e34ef860d8bf019c496097e68e0101c9ab9))
|
||||
* **PostgreSQL:** unable to search for databases, fixes [#798](https://github.com/antares-sql/antares/issues/798) ([d1bb50b](https://github.com/antares-sql/antares/commit/d1bb50b2bb48d3445080990c28fdc656cf27a6d3))
|
||||
|
||||
### [0.7.24](https://github.com/antares-sql/antares/compare/v0.7.24-beta.1...v0.7.24) (2024-05-03)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* missing accent color change ([09c274a](https://github.com/antares-sql/antares/commit/09c274a724b5020efc650aaf7eecb2404343a6fc))
|
||||
|
||||
### [0.7.24-beta.1](https://github.com/antares-sql/antares/compare/v0.7.24-beta.0...v0.7.24-beta.1) (2024-04-30)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* accent color based on folder color, closes [#762](https://github.com/antares-sql/antares/issues/762) ([058fc2f](https://github.com/antares-sql/antares/commit/058fc2fc0b34cde5aa19233a4a999ef3624dae71))
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **PostgreSQL:** better handle connection errors, should fix [#794](https://github.com/antares-sql/antares/issues/794) ([33bbc0e](https://github.com/antares-sql/antares/commit/33bbc0e7e6be370c944e979a34ab2cb19562d1e3))
|
||||
* **PostgreSQL:** issue with similar tabs on differend databases ([23c59b4](https://github.com/antares-sql/antares/commit/23c59b4d4e8f250acad75f54d157c7c162e1c4f8))
|
||||
|
||||
|
||||
### Improvements
|
||||
|
||||
* **UI:** hide "insert row" button in read-only mode, closes [#695](https://github.com/antares-sql/antares/issues/695) ([6600197](https://github.com/antares-sql/antares/commit/6600197b8286ced4c79378883594d21e69a83d8c))
|
||||
* **UI:** improvements on light theme ([ece2ee0](https://github.com/antares-sql/antares/commit/ece2ee05cc90a58c1926e882e3ccf4f057f02d68))
|
||||
|
||||
### [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)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* delete record modal pressing del when editing a field, fixes [#767](https://github.com/antares-sql/antares/issues/767) ([586f901](https://github.com/antares-sql/antares/commit/586f901bae9a80c0e53ac1d804cbae3f05e26d8e))
|
||||
|
||||
### [0.7.22-beta.2](https://github.com/antares-sql/antares/compare/v0.7.22-beta.1...v0.7.22-beta.2) (2024-02-18)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **MySQL:** option to enable single connection mode ([d3f71e6](https://github.com/antares-sql/antares/commit/d3f71e65cef88838f03f95a4b34e197fb61878f8))
|
||||
|
||||
### [0.7.22-beta.1](https://github.com/antares-sql/antares/compare/v0.7.22-beta.0...v0.7.22-beta.1) (2024-02-12)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* update dutch translation + fix spelling mistake ([30ada13](https://github.com/antares-sql/antares/commit/30ada13663e88f89beb3dd7291010837059585d5))
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* some issues related to previous commit ([259d051](https://github.com/antares-sql/antares/commit/259d051a21e334496d3a52b662f1855ba9a9046d))
|
||||
* unable to edit tables containing SET fields, fixes [#755](https://github.com/antares-sql/antares/issues/755) ([d698f27](https://github.com/antares-sql/antares/commit/d698f2798a2423f86e6d786dd3ab80439b372a08))
|
||||
|
||||
|
||||
### Improvements
|
||||
|
||||
* **MySQL:** improvements in connection handling ([876d5ea](https://github.com/antares-sql/antares/commit/876d5ea48185334e9e2fc981c4282a9c42d22b10))
|
||||
|
||||
### [0.7.22-beta.0](https://github.com/antares-sql/antares/compare/v0.7.21...v0.7.22-beta.0) (2024-02-04)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **UI:** resizable textarea in new/edito note, closes [#747](https://github.com/antares-sql/antares/issues/747) ([1a0c5da](https://github.com/antares-sql/antares/commit/1a0c5da2f14b99d6f5581b2bf6e916d67d097245))
|
||||
|
||||
|
||||
### Improvements
|
||||
|
||||
* **UI:** improved notes, fixes [#746](https://github.com/antares-sql/antares/issues/746) ([bb36e98](https://github.com/antares-sql/antares/commit/bb36e98bebc5e1e55735e98d272428df2ab682e8))
|
||||
|
||||
### [0.7.21](https://github.com/antares-sql/antares/compare/v0.7.21-beta.1...v0.7.21) (2024-01-13)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **SQLite:** enable schema reloat button on sidebar ([20b2734](https://github.com/antares-sql/antares/commit/20b27343cd95998bd83403b7556ea35fcad9fa1b))
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **SQLite:** unable to change integer fields length to 0, fixes [#732](https://github.com/antares-sql/antares/issues/732) ([3b9228a](https://github.com/antares-sql/antares/commit/3b9228a7230dcd9f47f5794a83b60d28207bdce1))
|
||||
|
||||
### [0.7.21-beta.1](https://github.com/antares-sql/antares/compare/v0.7.21-beta.0...v0.7.21-beta.1) (2024-01-06)
|
||||
|
||||
|
||||
|
43
README.md
43
README.md
@@ -1,13 +1,13 @@
|
||||
|
||||
<!-- markdownlint-disable -->
|
||||
<p align="center">
|
||||
<img width="800" src="https://raw.githubusercontent.com/Fabio286/antares/master/docs/gh-logo.png">
|
||||
<img width="800" src="https://raw.githubusercontent.com/antares-sql/antares/master/docs/gh-logo.png">
|
||||
</p>
|
||||
<!-- markdownlint-restore -->
|
||||
|
||||
# Antares SQL Client
|
||||
|
||||
    [](https://twitter.com/AntaresSQL) [](https://www.treedom.net/en/user/fabio-di-stasio/event/antares-for-the-planet)
|
||||
    [](https://www.treedom.net/en/user/fabio-di-stasio/event/antares-for-the-planet)
|
||||
|
||||
Antares is an SQL client based on [Electron.js](https://github.com/electron/electron) and [Vue.js](https://github.com/vuejs/vue) that aims to become a useful tool, especially for developers.
|
||||
Our target is to support as many databases as possible, and all major operating systems, including the ARM versions.
|
||||
@@ -16,8 +16,8 @@ Our target is to support as many databases as possible, and all major operating
|
||||
However, there are all the features necessary to have a pleasant database management experience, so give it a chance and send us your feedback, we would really appreciate it.
|
||||
We are actively working on it, hoping to provide new cool features, improvements and fixes as soon as possible.
|
||||
|
||||
🔗 If you are curious to try Antares you can download and install the [latest release](https://github.com/Fabio286/antares/releases/latest).
|
||||
👁 To stay tuned for new releases follow Antares SQL on [Mastodon](https://fosstodon.org/@AntaresSQL) or [Twitter](https://twitter.com/AntaresSQL).
|
||||
🔗 If you are curious to try Antares you can download and install the [latest release](https://github.com/antares-sql/antares/releases/latest).
|
||||
👁 To stay tuned for new releases follow Antares SQL on [Mastodon](https://fosstodon.org/@AntaresSQL).
|
||||
🌟 Don't forget to **leave a star** if you appreciate this project.
|
||||
|
||||
🗳️ Polls:
|
||||
@@ -60,7 +60,7 @@ On Linux you can simply download and run the `.AppImage` distribution, install f
|
||||
|
||||
### Windows
|
||||
|
||||
On Windows you can choose between downloading the app from Microsoft Store or downloading the `.exe` from our [website](https://antares-sql.app/downloads) or [this github repo](https://github.com/Fabio286/antares/releases/latest). Distributions that are not from Microsoft Store are not signed with a certificate, so to install you need to click on "More info" and then "Run anyway" on SmartScreen prompt.
|
||||
On Windows you can choose between downloading the app from Microsoft Store or downloading the `.exe` from our [website](https://antares-sql.app/downloads) or [this github repo](https://github.com/antares-sql/antares/releases/latest). Distributions that are not from Microsoft Store are not signed with a certificate, so to install you need to click on "More info" and then "Run anyway" on SmartScreen prompt.
|
||||
|
||||
### MacOS
|
||||
|
||||
@@ -71,17 +71,6 @@ On macOS you can run `.dmg` distribution following [this guide](https://support.
|
||||
[<img height='56' alt='Download on Flathub' src='https://dl.flathub.org/assets/badges/flathub-badge-en.svg'/>](https://flathub.org/apps/it.fabiodistasio.AntaresSQL) [](https://snapcraft.io/antares) [](https://aur.archlinux.org/packages/antares-sql-bin) [<img src="https://developer.microsoft.com/store/badges/images/English_get-it-from-MS.png" style="height: 56px">](https://www.microsoft.com/p/antares-sql-client/9nhtb9sq51r1?cid=storebadge&ocid=badge&rtc=1&activetab=pivot:overviewtab)
|
||||
🚀 **[Other Downloads](https://github.com/antares-sql/antares/releases/latest)**
|
||||
|
||||
## Coming soon
|
||||
|
||||
This is a roadmap with major features will come in near future.
|
||||
|
||||
- Database tools.
|
||||
- Users management (add/edit/delete).
|
||||
- More context menu shortcuts.
|
||||
- More keyboard shortcuts.
|
||||
- Support for other databases.
|
||||
- Apple Silicon distribution
|
||||
|
||||
## Currently supported
|
||||
|
||||
### Databases
|
||||
@@ -90,6 +79,7 @@ This is a roadmap with major features will come in near future.
|
||||
- [x] PostgreSQL
|
||||
- [x] SQLite
|
||||
- [x] Firebird SQL
|
||||
- [ ] DuckDB
|
||||
- [ ] SQL Server
|
||||
- [ ] More...
|
||||
|
||||
@@ -109,9 +99,9 @@ This is a roadmap with major features will come in near future.
|
||||
|
||||
## How to contribute
|
||||
|
||||
- 🌍 [Translate Antares](https://github.com/Fabio286/antares/wiki/Translate-Antares)
|
||||
- 📖 [Contributors Guide](https://github.com/Fabio286/antares/wiki/Contributors-Guide)
|
||||
- 🚧 [Project Board](https://github.com/antares-sql/antares/projects/1)
|
||||
- 🌍 [Translate Antares](https://github.com/antares-sql/antares/wiki/Translate-Antares)
|
||||
- 📖 [Contributors Guide](https://github.com/antares-sql/antares/wiki/Contributors-Guide)
|
||||
- 🚧 [Project Board](https://github.com/orgs/antares-sql/projects/3/views/2)
|
||||
|
||||
## Contributors ✨
|
||||
|
||||
@@ -158,6 +148,21 @@ 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>
|
||||
<td align="center" valign="top" width="14.28%"><a href="https://github.com/penguinlab"><img src="https://avatars.githubusercontent.com/u/10959317?v=4?s=100" width="100px;" alt="Naoki Ishikawa"/><br /><sub><b>Naoki Ishikawa</b></sub></a><br /><a href="#translation-penguinlab" title="Translation">🌍</a></td>
|
||||
<td align="center" valign="top" width="14.28%"><a href="https://fazevedo.dev"><img src="https://avatars.githubusercontent.com/u/1640325?v=4?s=100" width="100px;" alt="Filipe Azevedo"/><br /><sub><b>Filipe Azevedo</b></sub></a><br /><a href="https://github.com/antares-sql/antares/commits?author=mangas" title="Code">💻</a></td>
|
||||
<td align="center" valign="top" width="14.28%"><a href="https://github.com/zwei-c"><img src="https://avatars.githubusercontent.com/u/55912811?v=4?s=100" width="100px;" alt="CHANG, CHIH WEI"/><br /><sub><b>CHANG, CHIH WEI</b></sub></a><br /><a href="#translation-zwei-c" title="Translation">🌍</a></td>
|
||||
<td align="center" valign="top" width="14.28%"><a href="https://github.com/mirrorb"><img src="https://avatars.githubusercontent.com/u/34116207?v=4?s=100" width="100px;" alt="GaoChun"/><br /><sub><b>GaoChun</b></sub></a><br /><a href="https://github.com/antares-sql/antares/commits?author=mirrorb" title="Code">💻</a></td>
|
||||
<td align="center" valign="top" width="14.28%"><a href="https://github.com/LeviEyal"><img src="https://avatars.githubusercontent.com/u/48846533?v=4?s=100" width="100px;" alt="Eyal Levi"/><br /><sub><b>Eyal Levi</b></sub></a><br /><a href="#translation-LeviEyal" title="Translation">🌍</a></td>
|
||||
<td align="center" valign="top" width="14.28%"><a href="http://telegram.dog/SawGoD"><img src="https://avatars.githubusercontent.com/u/67802757?v=4?s=100" width="100px;" alt="Nikita Karelikov"/><br /><sub><b>Nikita Karelikov</b></sub></a><br /><a href="#translation-SawGoD" title="Translation">🌍</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center" valign="top" width="14.28%"><a href="https://github.com/carvalhods"><img src="https://avatars.githubusercontent.com/u/6569255?v=4?s=100" width="100px;" alt="David Carvalho"/><br /><sub><b>David Carvalho</b></sub></a><br /><a href="#platform-carvalhods" title="Packaging/porting to new platform">📦</a></td>
|
||||
<td align="center" valign="top" width="14.28%"><a href="https://github.com/r4f4dev"><img src="https://avatars.githubusercontent.com/u/65920592?v=4?s=100" width="100px;" alt="r4f4dev"/><br /><sub><b>r4f4dev</b></sub></a><br /><a href="#translation-r4f4dev" title="Translation">🌍</a></td>
|
||||
<td align="center" valign="top" width="14.28%"><a href="https://github.com/salvymc"><img src="https://avatars.githubusercontent.com/u/10051897?v=4?s=100" width="100px;" alt="Salvatore Forino"/><br /><sub><b>Salvatore Forino</b></sub></a><br /><a href="https://github.com/antares-sql/antares/commits?author=salvymc" title="Code">💻</a></td>
|
||||
<td align="center" valign="top" width="14.28%"><a href="https://gadev.com.es/"><img src="https://avatars.githubusercontent.com/u/16820141?v=4?s=100" width="100px;" alt="José González"/><br /><sub><b>José González</b></sub></a><br /><a href="#translation-JoseGonzalez84" title="Translation">🌍</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'
|
||||
]
|
||||
]
|
||||
}
|
||||
};
|
12615
package-lock.json
generated
12615
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
83
package.json
83
package.json
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "antares",
|
||||
"productName": "Antares",
|
||||
"version": "0.7.21-beta.1",
|
||||
"version": "0.7.35-beta.1",
|
||||
"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",
|
||||
@@ -118,45 +119,70 @@
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
"@electron/remote": "~2.0.1",
|
||||
"@electron/remote": "~2.1.2",
|
||||
"@fabio286/ssh2-promise": "~1.0.4-b",
|
||||
"@faker-js/faker": "~6.1.2",
|
||||
"@jamescoyle/vue-icon": "~0.1.2",
|
||||
"@mdi/js": "~7.2.96",
|
||||
"@turf/helpers": "~6.5.0",
|
||||
"@vue/compiler-sfc": "~3.2.33",
|
||||
"@vueuse/core": "~10.4.1",
|
||||
"ace-builds": "~1.24.1",
|
||||
"better-sqlite3": "^8.0.1",
|
||||
"ace-builds": "~1.34.1",
|
||||
"babel-loader": "~8.2.3",
|
||||
"better-sqlite3": "~10.0.0",
|
||||
"chalk": "~4.1.2",
|
||||
"ciaplu": "^2.2.0",
|
||||
"cpu-features": "^0.0.10",
|
||||
"cross-env": "~7.0.2",
|
||||
"css-loader": "~6.5.0",
|
||||
"electron-log": "~5.0.1",
|
||||
"electron-store": "~8.1.0",
|
||||
"electron-updater": "~4.6.5",
|
||||
"electron-window-state": "~5.0.3",
|
||||
"encoding": "~0.1.13",
|
||||
"file-loader": "~6.2.0",
|
||||
"floating-vue": "~2.0.0-beta.20",
|
||||
"html-webpack-plugin": "~5.5.0",
|
||||
"json2php": "~0.0.7",
|
||||
"leaflet": "~1.7.1",
|
||||
"marked": "~4.0.19",
|
||||
"moment": "~2.29.4",
|
||||
"mysql2": "~3.5.2",
|
||||
"node-firebird": "~1.1.4",
|
||||
"pg": "~8.11.1",
|
||||
"pg-connection-string": "~2.5.0",
|
||||
"marked": "~12.0.0",
|
||||
"mini-css-extract-plugin": "~2.4.5",
|
||||
"moment": "~2.30.1",
|
||||
"mysql2": "~3.9.7",
|
||||
"node-firebird": "~1.1.8",
|
||||
"node-loader": "~2.0.0",
|
||||
"pg": "~8.11.5",
|
||||
"pg-query-stream": "~4.2.3",
|
||||
"pgsql-ast-parser": "~7.2.1",
|
||||
"pinia": "~2.1.6",
|
||||
"pinia": "~2.1.7",
|
||||
"postcss-html": "~1.5.0",
|
||||
"progress-webpack-plugin": "~1.0.12",
|
||||
"rimraf": "~3.0.2",
|
||||
"sass": "~1.42.1",
|
||||
"sass-loader": "~12.3.0",
|
||||
"source-map-support": "~0.5.20",
|
||||
"spectre.css": "~0.5.9",
|
||||
"sql-formatter": "~13.0.0",
|
||||
"sql-highlight": "~4.4.0",
|
||||
"style-loader": "~3.3.1",
|
||||
"tree-kill": "~1.2.2",
|
||||
"ts-loader": "~9.2.8",
|
||||
"typescript": "~4.6.3",
|
||||
"unzip-crx-3": "~0.2.0",
|
||||
"v-mask": "~2.3.0",
|
||||
"vue": "~3.3.4",
|
||||
"vue-i18n": "~9.2.2",
|
||||
"vuedraggable": "~4.1.0"
|
||||
"vue": "~3.4.27",
|
||||
"vue-i18n": "~9.13.1",
|
||||
"vue-loader": "~16.8.3",
|
||||
"vuedraggable": "~4.1.0",
|
||||
"webpack": "^5.91.0",
|
||||
"webpack-cli": "~4.9.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@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",
|
||||
@@ -166,14 +192,9 @@
|
||||
"@types/ssh2": "~1.11.6",
|
||||
"@typescript-eslint/eslint-plugin": "~5.18.0",
|
||||
"@typescript-eslint/parser": "~5.18.0",
|
||||
"@vue/compiler-sfc": "~3.2.33",
|
||||
"all-contributors-cli": "~6.20.0",
|
||||
"babel-loader": "~8.2.3",
|
||||
"chalk": "~4.1.2",
|
||||
"cross-env": "~7.0.2",
|
||||
"css-loader": "~6.5.0",
|
||||
"electron": "~22.3.27",
|
||||
"electron-builder": "~24.6.4",
|
||||
"electron": "~30.0.8",
|
||||
"electron-builder": "~24.13.3",
|
||||
"eslint": "~7.32.0",
|
||||
"eslint-config-standard": "~16.0.3",
|
||||
"eslint-plugin-import": "~2.24.2",
|
||||
@@ -181,32 +202,16 @@
|
||||
"eslint-plugin-promise": "~5.2.0",
|
||||
"eslint-plugin-simple-import-sort": "~10.0.0",
|
||||
"eslint-plugin-vue": "~8.0.3",
|
||||
"file-loader": "~6.2.0",
|
||||
"html-webpack-plugin": "~5.5.0",
|
||||
"mini-css-extract-plugin": "~2.4.5",
|
||||
"node-loader": "~2.0.0",
|
||||
"husky": "~9.0.11",
|
||||
"playwright": "~1.28.1",
|
||||
"playwright-core": "~1.28.1",
|
||||
"postcss-html": "~1.5.0",
|
||||
"progress-webpack-plugin": "~1.0.12",
|
||||
"rimraf": "~3.0.2",
|
||||
"sass": "~1.42.1",
|
||||
"sass-loader": "~12.3.0",
|
||||
"standard-version": "~9.3.1",
|
||||
"style-loader": "~3.3.1",
|
||||
"stylelint": "^15.11.0",
|
||||
"stylelint-config-recommended-vue": "~1.5.0",
|
||||
"stylelint-config-standard": "~34.0.0",
|
||||
"stylelint-scss": "~5.3.0",
|
||||
"tree-kill": "~1.2.2",
|
||||
"ts-loader": "~9.2.8",
|
||||
"ts-node": "~10.9.1",
|
||||
"typescript": "~4.6.3",
|
||||
"unzip-crx-3": "~0.2.0",
|
||||
"vue-eslint-parser": "~8.3.0",
|
||||
"vue-loader": "~16.8.3",
|
||||
"webpack": "~5.72.0",
|
||||
"webpack-cli": "~4.9.1",
|
||||
"webpack-dev-server": "~4.11.1",
|
||||
"xvfb-maybe": "~0.2.1"
|
||||
}
|
||||
|
@@ -1,5 +1,5 @@
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-nocheck
|
||||
// @ts-check
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const https = require('https');
|
||||
@@ -7,13 +7,18 @@ const unzip = require('unzip-crx-3');
|
||||
const { antares } = require('../package.json');
|
||||
|
||||
const extensionID = antares.devtoolsId;
|
||||
const chromiumVersion = '124';
|
||||
const destFolder = path.resolve(__dirname, `../misc/${extensionID}`);
|
||||
const filePath = path.resolve(__dirname, `${destFolder}${extensionID}.crx`);
|
||||
const fileUrl = `https://clients2.google.com/service/update2/crx?response=redirect&acceptformat=crx2,crx3&x=id%3D${extensionID}%26uc&prodversion=32`;
|
||||
const filePath = path.resolve(__dirname, `${destFolder}/${extensionID}.crx`);
|
||||
const fileUrl = `https://clients2.google.com/service/update2/crx?response=redirect&acceptformat=crx2,crx3&x=id%3D${extensionID}%26uc&prodversion=${chromiumVersion}`;
|
||||
|
||||
if (!fs.existsSync(destFolder))
|
||||
fs.mkdirSync(destFolder, { recursive: true });
|
||||
|
||||
const fileStream = fs.createWriteStream(filePath);
|
||||
|
||||
const downloadFile = url => {
|
||||
return new Promise((resolve, reject) => {
|
||||
return /** @type {Promise<void>} */(new Promise((resolve, reject) => {
|
||||
const request = https.get(url);
|
||||
|
||||
request.on('response', response => {
|
||||
@@ -33,7 +38,7 @@ const downloadFile = url => {
|
||||
});
|
||||
request.on('error', reject);
|
||||
request.end();
|
||||
});
|
||||
}));
|
||||
};
|
||||
|
||||
(async () => {
|
||||
|
@@ -19,6 +19,7 @@ export const defaults: Customizations = {
|
||||
sshConnection: false,
|
||||
fileConnection: false,
|
||||
cancelQueries: false,
|
||||
singleConnectionMode: false,
|
||||
// Tools
|
||||
processesList: false,
|
||||
usersManagement: false,
|
||||
@@ -54,6 +55,7 @@ export const defaults: Customizations = {
|
||||
tableArray: false,
|
||||
tableRealCount: false,
|
||||
tableDuplicate: false,
|
||||
tableCheck: false,
|
||||
viewSettings: false,
|
||||
triggerSettings: false,
|
||||
triggerFunctionSettings: false,
|
||||
|
@@ -29,6 +29,7 @@ export const customizations: Customizations = {
|
||||
sslConnection: true,
|
||||
sshConnection: true,
|
||||
cancelQueries: true,
|
||||
singleConnectionMode: true,
|
||||
// Tools
|
||||
processesList: true,
|
||||
// Structure
|
||||
@@ -46,6 +47,7 @@ export const customizations: Customizations = {
|
||||
tableTruncateDisableFKCheck: true,
|
||||
tableDuplicate: true,
|
||||
tableDdl: true,
|
||||
tableCheck: true,
|
||||
viewAdd: true,
|
||||
triggerAdd: true,
|
||||
routineAdd: true,
|
||||
|
@@ -31,6 +31,7 @@ export const customizations: Customizations = {
|
||||
schemas: true,
|
||||
tables: true,
|
||||
views: true,
|
||||
materializedViews: true,
|
||||
triggers: true,
|
||||
triggerFunctions: true,
|
||||
routines: true,
|
||||
@@ -42,6 +43,7 @@ export const customizations: Customizations = {
|
||||
tableDuplicate: true,
|
||||
tableDdl: true,
|
||||
viewAdd: true,
|
||||
materializedViewAdd: true,
|
||||
triggerAdd: true,
|
||||
triggerFunctionAdd: true,
|
||||
routineAdd: true,
|
||||
@@ -52,6 +54,7 @@ export const customizations: Customizations = {
|
||||
databaseEdit: false,
|
||||
tableSettings: true,
|
||||
viewSettings: true,
|
||||
materializedViewSettings: true,
|
||||
triggerSettings: true,
|
||||
triggerFunctionSettings: true,
|
||||
routineSettings: true,
|
||||
@@ -59,6 +62,7 @@ export const customizations: Customizations = {
|
||||
indexes: true,
|
||||
foreigns: true,
|
||||
nullable: true,
|
||||
comment: true,
|
||||
tableArray: true,
|
||||
procedureSql: '$procedure$\r\n\r\n$procedure$',
|
||||
procedureContext: true,
|
||||
|
@@ -18,7 +18,7 @@ export type Importer = MySQLImporter | PostgreSQLImporter
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
export interface IpcResponse<T = any> {
|
||||
status: 'success' | 'error';
|
||||
status: 'success' | 'error' | 'abort';
|
||||
response?: T;
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ export interface ClientParams {
|
||||
| { databasePath: string; readonly: boolean };
|
||||
poolSize?: number;
|
||||
logger?: () => void;
|
||||
querySplitter?: (sql: string, clieng?: string) => string[];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -52,10 +53,12 @@ export interface ConnectionParams {
|
||||
password: string;
|
||||
ask: boolean;
|
||||
readonly: boolean;
|
||||
singleConnectionMode: boolean;
|
||||
ssl: boolean;
|
||||
cert?: string;
|
||||
key?: string;
|
||||
ca?: string;
|
||||
connString?: string;
|
||||
untrustedConnection: boolean;
|
||||
ciphers?: string;
|
||||
ssh: boolean;
|
||||
@@ -158,6 +161,13 @@ export interface TableForeign {
|
||||
oldName?: string;
|
||||
}
|
||||
|
||||
export interface TableCheck {
|
||||
// eslint-disable-next-line camelcase
|
||||
_antares_id?: string;
|
||||
name: string;
|
||||
clause: string;
|
||||
}
|
||||
|
||||
export interface CreateTableParams {
|
||||
/** Connection UID */
|
||||
uid?: string;
|
||||
@@ -165,6 +175,7 @@ export interface CreateTableParams {
|
||||
fields: TableField[];
|
||||
foreigns: TableForeign[];
|
||||
indexes: TableIndex[];
|
||||
checks?: TableCheck[];
|
||||
options: TableOptions;
|
||||
}
|
||||
|
||||
@@ -192,6 +203,11 @@ export interface AlterTableParams {
|
||||
changes: TableForeign[];
|
||||
deletions: TableForeign[];
|
||||
};
|
||||
checkChanges?: {
|
||||
additions: TableCheck[];
|
||||
changes: TableCheck[];
|
||||
deletions: TableCheck[];
|
||||
};
|
||||
options: TableOptions;
|
||||
}
|
||||
|
||||
@@ -363,7 +379,7 @@ export interface QueryBuilderObject {
|
||||
offset: number;
|
||||
join: string[];
|
||||
update: string[];
|
||||
insert: {[key: string]: string | boolean | number }[];
|
||||
insert: Record<string, string | boolean | number>[];
|
||||
delete: boolean;
|
||||
}
|
||||
|
||||
|
@@ -19,6 +19,7 @@ export interface Customizations {
|
||||
sshConnection?: boolean;
|
||||
fileConnection?: boolean;
|
||||
cancelQueries?: boolean;
|
||||
singleConnectionMode?: boolean;
|
||||
// Tools
|
||||
processesList?: boolean;
|
||||
usersManagement?: boolean;
|
||||
@@ -27,6 +28,7 @@ export interface Customizations {
|
||||
schemas?: boolean;
|
||||
tables?: boolean;
|
||||
views?: boolean;
|
||||
materializedViews?: boolean;
|
||||
triggers?: boolean;
|
||||
triggerFunctions?: boolean;
|
||||
routines?: boolean;
|
||||
@@ -41,9 +43,12 @@ export interface Customizations {
|
||||
tableArray?: boolean;
|
||||
tableRealCount?: boolean;
|
||||
tableTruncateDisableFKCheck?: boolean;
|
||||
tableCheck?: boolean;
|
||||
tableDdl?: boolean;
|
||||
viewAdd?: boolean;
|
||||
viewSettings?: boolean;
|
||||
materializedViewAdd?: boolean;
|
||||
materializedViewSettings?: boolean;
|
||||
triggerAdd?: boolean;
|
||||
triggerFunctionAdd?: boolean;
|
||||
routineAdd?: boolean;
|
||||
|
@@ -13,7 +13,7 @@ export interface ExportOptions {
|
||||
includeContent: boolean;
|
||||
includeDropStatement: boolean;
|
||||
}[];
|
||||
includes: {[key: string]: boolean};
|
||||
includes: Record<string, boolean>;
|
||||
outputFormat: 'sql' | 'sql.zip';
|
||||
outputFile: string;
|
||||
sqlInsertAfter: number;
|
||||
|
@@ -18,7 +18,7 @@ export interface TableDeleteParams {
|
||||
primary?: string;
|
||||
field: string;
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
rows: {[key: string]: any};
|
||||
rows: Record<string, any>;
|
||||
}
|
||||
|
||||
export type TableFilterOperator = '=' | '!=' | '>' | '<' | '>=' | '<=' | 'IN' | 'NOT IN' | 'LIKE' | 'NOT LIKE' | 'RLIKE' | 'NOT RLIKE' | 'BETWEEN' | 'IS NULL' | 'IS NOT NULL'
|
||||
@@ -35,17 +35,16 @@ export interface InsertRowsParams {
|
||||
uid: string;
|
||||
schema: string;
|
||||
table: string;
|
||||
row: {[key: string]: {
|
||||
group: string;
|
||||
method: string;
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
params: any;
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
value: any;
|
||||
length: number;
|
||||
};
|
||||
};
|
||||
row: Record<string, {
|
||||
group: string;
|
||||
method: string;
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
params: any;
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
value: any;
|
||||
length: number;
|
||||
}>;
|
||||
repeat: number;
|
||||
fields: {[key: string]: string};
|
||||
fields: Record<string, string>;
|
||||
locale: UsableLocale;
|
||||
}
|
||||
|
@@ -1,3 +1,5 @@
|
||||
import { match } from 'ciaplu';
|
||||
|
||||
function isJSON (str: string) {
|
||||
try {
|
||||
if (!['{', '['].includes(str.trim()[0]))
|
||||
@@ -176,17 +178,13 @@ function isMD (str: string) {
|
||||
}
|
||||
|
||||
export function langDetector (str: string) {
|
||||
if (!str || !str.trim().length)
|
||||
return 'text';
|
||||
if (isJSON(str))
|
||||
return 'json';
|
||||
if (isHTML(str))
|
||||
return 'html';
|
||||
if (isSVG(str))
|
||||
return 'svg';
|
||||
if (isXML(str))
|
||||
return 'xml';
|
||||
if (isMD(str))
|
||||
return 'markdown';
|
||||
return 'text';
|
||||
return match(str)
|
||||
.when(() => !str || !str.trim().length, () => 'text')
|
||||
.when(isJSON, () => 'json')
|
||||
.when(isHTML, () => 'html')
|
||||
.when(isSVG, () => 'svg')
|
||||
.when(isXML, () => 'xml')
|
||||
.when(isMD, () => 'markdown')
|
||||
.otherwise(() => 'text')
|
||||
.return();
|
||||
}
|
||||
|
@@ -1,45 +1,25 @@
|
||||
import { match } from 'ciaplu';
|
||||
|
||||
export function mimeFromHex (hex: string) {
|
||||
switch (hex.substring(0, 4)) { // 2 bytes
|
||||
case '424D':
|
||||
return { ext: 'bmp', mime: 'image/bmp' };
|
||||
case '1F8B':
|
||||
return { ext: 'tar.gz', mime: 'application/gzip' };
|
||||
case '0B77':
|
||||
return { ext: 'ac3', mime: 'audio/vnd.dolby.dd-raw' };
|
||||
case '7801':
|
||||
return { ext: 'dmg', mime: 'application/x-apple-diskimage' };
|
||||
case '4D5A':
|
||||
return { ext: 'exe', mime: 'application/x-msdownload' };
|
||||
case '1FA0':
|
||||
case '1F9D':
|
||||
return { ext: 'Z', mime: 'application/x-compress' };
|
||||
default:
|
||||
switch (hex.substring(0, 6)) { // 3 bytes
|
||||
case 'FFD8FF':
|
||||
return { ext: 'jpg', mime: 'image/jpeg' };
|
||||
case '4949BC':
|
||||
return { ext: 'jxr', mime: 'image/vnd.ms-photo' };
|
||||
case '425A68':
|
||||
return { ext: 'bz2', mime: 'application/x-bzip2' };
|
||||
default:
|
||||
switch (hex) { // 4 bites
|
||||
case '89504E47':
|
||||
return { ext: 'png', mime: 'image/png' };
|
||||
case '47494638':
|
||||
return { ext: 'gif', mime: 'image/gif' };
|
||||
case '25504446':
|
||||
return { ext: 'pdf', mime: 'application/pdf' };
|
||||
case '504B0304':
|
||||
return { ext: 'zip', mime: 'application/zip' };
|
||||
case '425047FB':
|
||||
return { ext: 'bpg', mime: 'image/bpg' };
|
||||
case '4D4D002A':
|
||||
return { ext: 'tif', mime: 'image/tiff' };
|
||||
case '00000100':
|
||||
return { ext: 'ico', mime: 'image/x-icon' };
|
||||
default:
|
||||
return { ext: '', mime: 'unknown ' + hex };
|
||||
}
|
||||
}
|
||||
}
|
||||
return match(hex.substring(0, 4)) // 2 bytes
|
||||
.with('424D', () => ({ ext: 'bmp', mime: 'image/bmp' }))
|
||||
.with('1F8B', () => ({ ext: 'tar.gz', mime: 'application/gzip' }))
|
||||
.with('0B77', () => ({ ext: 'ac3', mime: 'audio/vnd.dolby.dd-raw' }))
|
||||
.with('7801', () => ({ ext: 'dmg', mime: 'application/x-apple-diskimage' }))
|
||||
.with('4D5A', () => ({ ext: 'exe', mime: 'application/x-msdownload' }))
|
||||
.when((val) => ['1FA0', '1F9D'].includes(val), () => ({ ext: 'Z', mime: 'application/x-compress' }))
|
||||
.extracting(() => hex.substring(0, 6)) // 3 bytes
|
||||
.with('FFD8FF', () => ({ ext: 'jpg', mime: 'image/jpeg' }))
|
||||
.with('4949BC', () => ({ ext: 'jxr', mime: 'image/vnd.ms-photo' }))
|
||||
.with('425A68', () => ({ ext: 'bz2', mime: 'application/x-bzip2' }))
|
||||
.extracting(() => hex) // 4 bytes
|
||||
.with('89504E47', () => ({ ext: 'png', mime: 'image/png' }))
|
||||
.with('47494638', () => ({ ext: 'gif', mime: 'image/gif' }))
|
||||
.with('25504446', () => ({ ext: 'pdf', mime: 'application/pdf' }))
|
||||
.with('504B0304', () => ({ ext: 'zip', mime: 'application/zip' }))
|
||||
.with('425047FB', () => ({ ext: 'bpg', mime: 'image/bpg' }))
|
||||
.with('4D4D002A', () => ({ ext: 'tif', mime: 'image/tiff' }))
|
||||
.with('00000100', () => ({ ext: 'ico', mime: 'image/x-icon' }))
|
||||
.otherwise(() => ({ ext: '', mime: 'unknown ' + hex }))
|
||||
.return();
|
||||
}
|
||||
|
@@ -2,18 +2,162 @@
|
||||
/* eslint-disable no-useless-escape */
|
||||
import { lineString, point, polygon } from '@turf/helpers';
|
||||
import { BIT, BLOB, DATE, DATETIME, FLOAT, IS_MULTI_SPATIAL, NUMBER, SPATIAL, TEXT_SEARCH } from 'common/fieldTypes';
|
||||
import * as antares from 'common/interfaces/antares';
|
||||
import { ClientCode } from 'common/interfaces/antares';
|
||||
import * as moment from 'moment';
|
||||
|
||||
import customizations from '../customizations';
|
||||
import { ClientCode } from '../interfaces/antares';
|
||||
import { getArrayDepth } from './getArrayDepth';
|
||||
import hexToBinary, { HexChar } from './hexToBinary';
|
||||
|
||||
/**
|
||||
* Escapes a string fo SQL use
|
||||
* Splits a SQL string into multiple queries based on semicolons (;).
|
||||
* Handles BEGIN-END blocks, strings, comments, and PostgreSQL dollar-quoted tags.
|
||||
*
|
||||
* @param { String } string
|
||||
* @returns { String } Escaped string
|
||||
* @param {string} sql - The SQL string to split.
|
||||
* @param {ClientCode} dbType - The database type (e.g., 'pg', 'mysql').
|
||||
* @returns {string[]} - An array of separated SQL queries.
|
||||
*/
|
||||
export const querySplitter =(sql: string, dbType: ClientCode): string[] => {
|
||||
const queries: string[] = [];
|
||||
let currentQuery = '';
|
||||
let insideBlock = false;
|
||||
let insideString = false;
|
||||
let stringDelimiter: string | null = null;
|
||||
let insideDollarTag = false;
|
||||
let dollarTagDelimiter: string | null = null;
|
||||
|
||||
// Regex patterns for BEGIN-END blocks, dollar tags in PostgreSQL, and semicolons
|
||||
const beginRegex = /\bBEGIN\b/i;
|
||||
const endRegex = /\bEND\b;/i;
|
||||
const dollarTagRegex = /\$(\w+)?\$/; // Matches $tag$ or $$
|
||||
|
||||
// Split on semicolons, keeping semicolons attached to the lines
|
||||
const lines = sql.split(/(?<=;)/);
|
||||
|
||||
for (let line of lines) {
|
||||
line = line.trim();
|
||||
|
||||
if (!line) continue;
|
||||
|
||||
for (let i = 0; i < line.length; i++) {
|
||||
const char = line[i];
|
||||
|
||||
// Handle string boundaries
|
||||
if ((char === '\'' || char === '"') && (!insideString || char === stringDelimiter)) {
|
||||
if (!insideString) {
|
||||
insideString = true;
|
||||
stringDelimiter = char;
|
||||
}
|
||||
else {
|
||||
insideString = false;
|
||||
stringDelimiter = null;
|
||||
}
|
||||
}
|
||||
|
||||
currentQuery += char;
|
||||
|
||||
if (dbType === 'pg') {
|
||||
// Handle dollar-quoted blocks in PostgreSQL
|
||||
if (!insideString && line.slice(i).match(dollarTagRegex)) {
|
||||
const match = line.slice(i).match(dollarTagRegex);
|
||||
if (match) {
|
||||
const tag = match[0];
|
||||
if (!insideDollarTag) {
|
||||
insideDollarTag = true;
|
||||
dollarTagDelimiter = tag;
|
||||
currentQuery += tag;
|
||||
i += tag.length - 1;
|
||||
}
|
||||
else if (dollarTagDelimiter === tag) {
|
||||
insideDollarTag = false;
|
||||
dollarTagDelimiter = null;
|
||||
currentQuery += tag;
|
||||
i += tag.length - 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check BEGIN-END blocks
|
||||
if (!insideString && !insideDollarTag) {
|
||||
if (beginRegex.test(line))
|
||||
insideBlock = true;
|
||||
|
||||
if (insideBlock && endRegex.test(line))
|
||||
insideBlock = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Append the query if we encounter a semicolon outside a BEGIN-END block, outside a string, and outside dollar tags
|
||||
if (!insideBlock && !insideString && !insideDollarTag && /;\s*$/.test(line)) {
|
||||
queries.push(currentQuery.trim());
|
||||
currentQuery = '';
|
||||
}
|
||||
}
|
||||
|
||||
// Add any remaining query
|
||||
if (currentQuery.trim())
|
||||
queries.push(currentQuery.trim());
|
||||
|
||||
return queries;
|
||||
};
|
||||
|
||||
/**
|
||||
* Removes all comments (both single-line and multi-line) from a SQL string.
|
||||
*
|
||||
* @param {string} sql - The SQL string to process.
|
||||
* @returns {string} - The SQL string without comments.
|
||||
*/
|
||||
export const removeComments = (sql: string): string => {
|
||||
let result = '';
|
||||
let insideSingleLineComment = false;
|
||||
let insideMultiLineComment = false;
|
||||
|
||||
for (let i = 0; i < sql.length; i++) {
|
||||
const char = sql[i];
|
||||
const nextChar = sql[i + 1] || '';
|
||||
|
||||
// Handle single-line comments (--)
|
||||
if (!insideMultiLineComment && char === '-' && nextChar === '-')
|
||||
insideSingleLineComment = true;
|
||||
|
||||
// Handle multi-line comments (/* */)
|
||||
if (!insideSingleLineComment && char === '/' && nextChar === '*') {
|
||||
insideMultiLineComment = true;
|
||||
i++; // Skip the '*' character
|
||||
continue;
|
||||
}
|
||||
|
||||
if (insideMultiLineComment && char === '*' && nextChar === '/') {
|
||||
insideMultiLineComment = false;
|
||||
i++; // Skip the '/' character
|
||||
continue;
|
||||
}
|
||||
|
||||
// Skip characters inside comments
|
||||
if (insideSingleLineComment) {
|
||||
if (char === '\n')
|
||||
insideSingleLineComment = false;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (insideMultiLineComment)
|
||||
continue;
|
||||
|
||||
// Append non-comment characters to the result
|
||||
result += char;
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
/**
|
||||
* Escapes a string for safe use in SQL queries.
|
||||
*
|
||||
* @param {string} string - The string to escape.
|
||||
* @returns {string} - The escaped string.
|
||||
*/
|
||||
export const sqlEscaper = (string: string): string => {
|
||||
// eslint-disable-next-line no-control-regex
|
||||
@@ -26,6 +170,12 @@ export const sqlEscaper = (string: string): string => {
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Converts a value into a GeoJSON object based on its type.
|
||||
*
|
||||
* @param {any} val - The value to convert.
|
||||
* @returns {object} - The generated GeoJSON object.
|
||||
*/
|
||||
export const objectToGeoJSON = (val: any) => {
|
||||
if (Array.isArray(val)) {
|
||||
if (getArrayDepth(val) === 1)
|
||||
@@ -37,21 +187,31 @@ export const objectToGeoJSON = (val: any) => {
|
||||
return point([val.x, val.y]);
|
||||
};
|
||||
|
||||
/**
|
||||
* Escapes and wraps a string in quotes for safe use in SQL queries.
|
||||
*
|
||||
* @param {string} val - The string to process.
|
||||
* @param {ClientCode} client - The database type (e.g., 'pg', 'mysql').
|
||||
* @returns {string} - The escaped and quoted string.
|
||||
*/
|
||||
export const escapeAndQuote = (val: string, client: ClientCode) => {
|
||||
const { stringsWrapper: sw } = customizations[client];
|
||||
// eslint-disable-next-line no-control-regex
|
||||
const CHARS_TO_ESCAPE = /[\0\b\t\n\r\x1a"'\\]/g;
|
||||
const CHARS_ESCAPE_MAP: {[key: string]: string} = {
|
||||
const CHARS_TO_ESCAPE = sw === '"' ? /[\0\b\t\n\r\x1a"'\\]/g : /[\0\b\t\n\r\x1a'\\]/g;
|
||||
const CHARS_ESCAPE_MAP: Record<string, string> = {
|
||||
'\0': '\\0',
|
||||
'\b': '\\b',
|
||||
'\t': '\\t',
|
||||
'\n': '\\n',
|
||||
'\r': '\\r',
|
||||
'\x1a': '\\Z',
|
||||
'"': '\\"',
|
||||
'\'': '\\\'',
|
||||
'\\': '\\\\'
|
||||
};
|
||||
|
||||
if (sw === '"')
|
||||
CHARS_ESCAPE_MAP['"'] = '\\"';
|
||||
|
||||
let chunkIndex = CHARS_TO_ESCAPE.lastIndex = 0;
|
||||
let escapedVal = '';
|
||||
let match;
|
||||
@@ -70,11 +230,17 @@ export const escapeAndQuote = (val: string, client: ClientCode) => {
|
||||
return `${sw}${escapedVal}${sw}`;
|
||||
};
|
||||
|
||||
/**
|
||||
* Converts a value into a SQL string based on the field type and database type.
|
||||
*
|
||||
* @param {object} args - Arguments containing the value, database type, and field type.
|
||||
* @returns {string} - The generated SQL string.
|
||||
*/
|
||||
export const valueToSqlString = (args: {
|
||||
val: any;
|
||||
client: ClientCode;
|
||||
field: {type: string; datePrecision?: number; precision?: number | false; isArray?: boolean};
|
||||
}): string => {
|
||||
val: any;
|
||||
client: ClientCode;
|
||||
field: { type: string; datePrecision?: number; precision?: number | false; isArray?: boolean };
|
||||
}): string => {
|
||||
let parsedValue;
|
||||
const { val, client, field } = args;
|
||||
const { stringsWrapper: sw } = customizations[client];
|
||||
@@ -97,10 +263,19 @@ export const valueToSqlString = (args: {
|
||||
}
|
||||
else if ('isArray' in field && field.isArray) {
|
||||
let localVal;
|
||||
if (Array.isArray(val))
|
||||
localVal = JSON.stringify(val).replaceAll('[', '{').replaceAll(']', '}');
|
||||
else
|
||||
localVal = typeof val === 'string' ? val.replaceAll('[', '{').replaceAll(']', '}') : '';
|
||||
if (Array.isArray(val)) {
|
||||
localVal = JSON
|
||||
.stringify(val)
|
||||
.replaceAll('[', '{')
|
||||
.replaceAll(']', '}');
|
||||
}
|
||||
else {
|
||||
localVal = typeof val === 'string'
|
||||
? val
|
||||
.replaceAll('[', '{')
|
||||
.replaceAll(']', '}')
|
||||
: '';
|
||||
}
|
||||
parsedValue = `'${localVal}'`;
|
||||
}
|
||||
else if (TEXT_SEARCH.includes(field.type))
|
||||
@@ -152,18 +327,24 @@ export const valueToSqlString = (args: {
|
||||
return parsedValue;
|
||||
};
|
||||
|
||||
/**
|
||||
* Converts a JSON array into an SQL INSERT query.
|
||||
*
|
||||
* @param {object} args - Arguments containing the JSON data, database type, fields, and options.
|
||||
* @returns {string} - The generated SQL INSERT query.
|
||||
*/
|
||||
export const jsonToSqlInsert = (args: {
|
||||
json: { [key: string]: any}[];
|
||||
client: ClientCode;
|
||||
fields: { [key: string]: {type: string; datePrecision: number}};
|
||||
table: string;
|
||||
options?: {sqlInsertAfter: number; sqlInsertDivider: 'bytes' | 'rows'};
|
||||
}) => {
|
||||
json: Record<string, any>[];
|
||||
client: ClientCode;
|
||||
fields: Record<string, { type: string; datePrecision: number }>;
|
||||
table: string;
|
||||
options?: { sqlInsertAfter: number; sqlInsertDivider: 'bytes' | 'rows' };
|
||||
}) => {
|
||||
const { client, json, fields, table, options } = args;
|
||||
const sqlInsertAfter = options && options.sqlInsertAfter ? options.sqlInsertAfter : 1;
|
||||
const sqlInsertDivider = options && options.sqlInsertDivider ? options.sqlInsertDivider : 'rows';
|
||||
const { elementsWrapper: ew } = customizations[client];
|
||||
const fieldNames = Object.keys(json[0]).map(key => `${ew}${key}${ew}`);
|
||||
const fieldNames = Object.keys(json[0]).map(key => `${ew}${key.split('.').pop()}${ew}`);
|
||||
let insertStmt = `INSERT INTO ${ew}${table}${ew} (${fieldNames.join(', ')}) VALUES `;
|
||||
let insertsString = '';
|
||||
let queryLength = 0;
|
||||
@@ -180,7 +361,7 @@ export const jsonToSqlInsert = (args: {
|
||||
(sqlInsertDivider === 'bytes' && queryLength >= sqlInsertAfter * 1024) ||
|
||||
(sqlInsertDivider === 'rows' && rowsWritten === sqlInsertAfter)
|
||||
) {
|
||||
insertsString += insertStmt+';';
|
||||
insertsString += insertStmt + ';';
|
||||
insertStmt = `\nINSERT INTO ${ew}${table}${ew} (${fieldNames.join(', ')}) VALUES `;
|
||||
rowsWritten = 0;
|
||||
}
|
||||
@@ -193,7 +374,31 @@ export const jsonToSqlInsert = (args: {
|
||||
}
|
||||
|
||||
if (rowsWritten > 0)
|
||||
insertsString += insertStmt+';';
|
||||
insertsString += insertStmt + ';';
|
||||
|
||||
return insertsString;
|
||||
};
|
||||
|
||||
/**
|
||||
* Formats a JSON value for use in an SQL WHERE clause.
|
||||
*
|
||||
* @param {object} jsonValue - The JSON value to format.
|
||||
* @param {ClientCode} clientType - The database type (e.g., 'pg', 'mysql').
|
||||
* @returns {string} - The formatted SQL WHERE clause.
|
||||
*/
|
||||
export const formatJsonForSqlWhere = (jsonValue: object, clientType: antares.ClientCode) => {
|
||||
const formattedValue = JSON.stringify(jsonValue);
|
||||
|
||||
switch (clientType) {
|
||||
case 'mysql':
|
||||
return ` = CAST('${formattedValue}' AS JSON)`;
|
||||
case 'maria':
|
||||
return ` = '${formattedValue}'`;
|
||||
case 'pg':
|
||||
return `::text = '${formattedValue}'`;
|
||||
case 'firebird':
|
||||
case 'sqlite':
|
||||
default:
|
||||
return ` = '${formattedValue}'`;
|
||||
}
|
||||
};
|
||||
|
@@ -1,26 +1,34 @@
|
||||
export const shortcutEvents: { [key: string]: { l18n: string; l18nParam?: string | number; context?: 'tab' }} = {
|
||||
'run-or-reload': { l18n: 'application.runOrReload', context: 'tab' },
|
||||
'open-new-tab': { l18n: 'application.openNewTab', context: 'tab' },
|
||||
'close-tab': { l18n: 'application.closeTab', context: 'tab' },
|
||||
'format-query': { l18n: 'database.formatQuery', context: 'tab' },
|
||||
'kill-query': { l18n: 'database.killQuery', context: 'tab' },
|
||||
'query-history': { l18n: 'database.queryHistory', context: 'tab' },
|
||||
'clear-query': { l18n: 'database.clearQuery', context: 'tab' },
|
||||
'next-tab': { l18n: 'application.nextTab' },
|
||||
'prev-tab': { l18n: 'application.previousTab' },
|
||||
'open-all-connections': { l18n: 'application.openAllConnections' },
|
||||
'open-filter': { l18n: 'application.openFilter' },
|
||||
'next-page': { l18n: 'application.nextResultsPage' },
|
||||
'prev-page': { l18n: 'application.previousResultsPage' },
|
||||
'toggle-console': { l18n: 'application.toggleConsole' },
|
||||
'save-content': { l18n: 'application.saveContent' },
|
||||
'create-connection': { l18n: 'connection.createNewConnection' },
|
||||
'open-settings': { l18n: 'application.openSettings' },
|
||||
'open-scratchpad': { l18n: 'application.openScratchpad' }
|
||||
export const shortcutEvents: Record<string, { i18n: string; i18nParam?: string | number; context?: 'tab' | 'main' }> = {
|
||||
'run-or-reload': { i18n: 'application.runOrReload', context: 'tab' },
|
||||
'open-new-tab': { i18n: 'application.openNewTab', context: 'tab' },
|
||||
'close-tab': { i18n: 'application.closeTab', context: 'tab' },
|
||||
'format-query': { i18n: 'database.formatQuery', context: 'tab' },
|
||||
'kill-query': { i18n: 'database.killQuery', context: 'tab' },
|
||||
'query-history': { i18n: 'database.queryHistory', context: 'tab' },
|
||||
'clear-query': { i18n: 'database.clearQuery', context: 'tab' },
|
||||
// 'save-file': { i18n: 'application.saveFile', context: 'tab' },
|
||||
'open-file': { i18n: 'application.openFile', context: 'tab' },
|
||||
'save-file-as': { i18n: 'application.saveFileAs', context: 'tab' },
|
||||
'next-tab': { i18n: 'application.nextTab' },
|
||||
'prev-tab': { i18n: 'application.previousTab' },
|
||||
'open-all-connections': { i18n: 'application.openAllConnections' },
|
||||
'open-filter': { i18n: 'application.openFilter' },
|
||||
'next-page': { i18n: 'application.nextResultsPage' },
|
||||
'prev-page': { i18n: 'application.previousResultsPage' },
|
||||
'toggle-console': { i18n: 'application.toggleConsole' },
|
||||
'save-content': { i18n: 'application.saveContent' },
|
||||
'create-connection': { i18n: 'connection.createNewConnection' },
|
||||
'open-settings': { i18n: 'application.openSettings' },
|
||||
'open-scratchpad': { i18n: 'application.openNotes' },
|
||||
setFullScreen: { i18n: 'application.fullScreen', context: 'main' },
|
||||
setZoomIn: { i18n: 'application.zoomIn', context: 'main' },
|
||||
setZoomOut: { i18n: 'application.zoomOut', context: 'main' },
|
||||
setZoomReset: { i18n: 'application.zoomReset', context: 'main' }
|
||||
};
|
||||
|
||||
interface ShortcutRecord {
|
||||
event: string;
|
||||
isFunction?: boolean;
|
||||
keys: Electron.Accelerator[] | string[];
|
||||
/** Needed for default shortcuts */
|
||||
os: NodeJS.Platform[];
|
||||
@@ -35,6 +43,30 @@ const shortcuts: ShortcutRecord[] = [
|
||||
keys: ['F5'],
|
||||
os: ['darwin', 'linux', 'win32']
|
||||
},
|
||||
{
|
||||
event: 'setFullScreen',
|
||||
isFunction: true,
|
||||
keys: ['F11'],
|
||||
os: ['darwin', 'linux', 'win32']
|
||||
},
|
||||
{
|
||||
event: 'setZoomIn',
|
||||
isFunction: true,
|
||||
keys: ['CommandOrControl+='],
|
||||
os: ['darwin', 'linux', 'win32']
|
||||
},
|
||||
{
|
||||
event: 'setZoomOut',
|
||||
isFunction: true,
|
||||
keys: ['CommandOrControl+-'],
|
||||
os: ['darwin', 'linux', 'win32']
|
||||
},
|
||||
{
|
||||
event: 'setZoomReset',
|
||||
isFunction: true,
|
||||
keys: ['CommandOrControl+0'],
|
||||
os: ['darwin', 'linux', 'win32']
|
||||
},
|
||||
{
|
||||
event: 'save-content',
|
||||
keys: ['CommandOrControl+S'],
|
||||
@@ -119,13 +151,28 @@ 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']
|
||||
}
|
||||
];
|
||||
|
||||
for (let i = 1; i <= 9; i++) {
|
||||
shortcutEvents[`select-tab-${i}`] = {
|
||||
l18n: 'application.selectTabNumber',
|
||||
l18nParam: i
|
||||
i18n: 'application.selectTabNumber',
|
||||
i18nParam: i
|
||||
};
|
||||
|
||||
shortcuts.push({
|
||||
|
@@ -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, encoding }) => {
|
||||
if (!validateSender(event.senderFrame)) return { status: 'error', response: 'Unauthorized process' };
|
||||
try {
|
||||
const content = fs.readFileSync(filePath, encoding);
|
||||
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() };
|
||||
}
|
||||
});
|
||||
};
|
||||
|
@@ -5,17 +5,28 @@ import { SslOptions } from 'mysql2';
|
||||
|
||||
import { ClientsFactory } from '../libs/ClientsFactory';
|
||||
import { validateSender } from '../libs/misc/validateSender';
|
||||
const isAborting: Record<string, boolean> = {};
|
||||
|
||||
export default (connections: {[key: string]: antares.Client}) => {
|
||||
export default (connections: Record<string, antares.Client>) => {
|
||||
ipcMain.handle('test-connection', async (event, conn: antares.ConnectionParams) => {
|
||||
if (!validateSender(event.senderFrame)) return { status: 'error', response: 'Unauthorized process' };
|
||||
|
||||
let isLocalAborted = false;
|
||||
const abortChecker = setInterval(() => { // Intercepts abort request
|
||||
if (isAborting[conn.uid]) {
|
||||
isAborting[conn.uid] = false;
|
||||
isLocalAborted = true;
|
||||
clearInterval(abortChecker);
|
||||
}
|
||||
}, 50);
|
||||
|
||||
const params = {
|
||||
host: conn.host,
|
||||
port: +conn.port,
|
||||
user: conn.user,
|
||||
password: conn.password,
|
||||
readonly: conn.readonly,
|
||||
connectionString: conn.connString,
|
||||
database: '',
|
||||
schema: '',
|
||||
databasePath: '',
|
||||
@@ -53,9 +64,9 @@ export default (connections: {[key: string]: antares.Client}) => {
|
||||
username: conn.sshUser,
|
||||
password: conn.sshPass,
|
||||
port: conn.sshPort ? conn.sshPort : 22,
|
||||
privateKey: conn.sshKey ? fs.readFileSync(conn.sshKey).toString() : null,
|
||||
privateKey: conn.sshKey ? fs.readFileSync(conn.sshKey).toString() : undefined,
|
||||
passphrase: conn.sshPassphrase,
|
||||
keepaliveInterval: conn.sshKeepAliveInterval ? conn.sshKeepAliveInterval*1000 : null
|
||||
keepaliveInterval: conn.sshKeepAliveInterval ? conn.sshKeepAliveInterval*1000 : undefined
|
||||
};
|
||||
}
|
||||
|
||||
@@ -65,19 +76,28 @@ export default (connections: {[key: string]: antares.Client}) => {
|
||||
client: conn.client,
|
||||
params
|
||||
});
|
||||
await connection.connect();
|
||||
|
||||
if (conn.client === 'firebird')
|
||||
connection.raw('SELECT rdb$get_context(\'SYSTEM\', \'DB_NAME\') FROM rdb$database');
|
||||
else
|
||||
await connection.select('1+1').run();
|
||||
await connection.connect();
|
||||
if (isLocalAborted) {
|
||||
connection.destroy();
|
||||
return;
|
||||
}
|
||||
|
||||
await connection.ping();
|
||||
|
||||
connection.destroy();
|
||||
clearInterval(abortChecker);
|
||||
|
||||
return { status: 'success' };
|
||||
}
|
||||
catch (err) {
|
||||
return { status: 'error', response: err.toString() };
|
||||
catch (error) {
|
||||
clearInterval(abortChecker);
|
||||
if (error instanceof AggregateError)
|
||||
throw new Error(error.errors.reduce((acc, curr) => acc +' | '+ curr.message, ''));
|
||||
else if (!isLocalAborted)
|
||||
return { status: 'error', response: error.toString() };
|
||||
else
|
||||
return { status: 'abort', response: 'Connection aborted' };
|
||||
}
|
||||
});
|
||||
|
||||
@@ -88,6 +108,15 @@ export default (connections: {[key: string]: antares.Client}) => {
|
||||
ipcMain.handle('connect', async (event, conn: antares.ConnectionParams) => {
|
||||
if (!validateSender(event.senderFrame)) return { status: 'error', response: 'Unauthorized process' };
|
||||
|
||||
let isLocalAborted = false;
|
||||
const abortChecker = setInterval(() => { // Intercepts abort request
|
||||
if (isAborting[conn.uid]) {
|
||||
isAborting[conn.uid] = false;
|
||||
isLocalAborted = true;
|
||||
clearInterval(abortChecker);
|
||||
}
|
||||
}, 50);
|
||||
|
||||
const params = {
|
||||
host: conn.host,
|
||||
port: +conn.port,
|
||||
@@ -95,6 +124,7 @@ export default (connections: {[key: string]: antares.Client}) => {
|
||||
password: conn.password,
|
||||
application_name: 'Antares SQL',
|
||||
readonly: conn.readonly,
|
||||
connectionString: conn.connString,
|
||||
database: '',
|
||||
schema: '',
|
||||
databasePath: '',
|
||||
@@ -146,22 +176,40 @@ export default (connections: {[key: string]: antares.Client}) => {
|
||||
uid: conn.uid,
|
||||
client: conn.client,
|
||||
params,
|
||||
poolSize: 5
|
||||
poolSize: conn.singleConnectionMode ? 0 : 5
|
||||
});
|
||||
|
||||
await connection.connect();
|
||||
if (isLocalAborted) {
|
||||
connection.destroy();
|
||||
return { status: 'abort', response: 'Connection aborted' };
|
||||
}
|
||||
|
||||
const structure = await connection.getStructure(new Set());
|
||||
if (isLocalAborted) {
|
||||
connection.destroy();
|
||||
return { status: 'abort', response: 'Connection aborted' };
|
||||
}
|
||||
|
||||
connections[conn.uid] = connection;
|
||||
clearInterval(abortChecker);
|
||||
|
||||
return { status: 'success', response: structure };
|
||||
}
|
||||
catch (err) {
|
||||
return { status: 'error', response: err.toString() };
|
||||
clearInterval(abortChecker);
|
||||
|
||||
if (!isLocalAborted)
|
||||
return { status: 'error', response: err.toString() };
|
||||
else
|
||||
return { status: 'abort', response: 'Connection aborted' };
|
||||
}
|
||||
});
|
||||
|
||||
ipcMain.on('abort-connection', (event, uid) => {
|
||||
isAborting[uid] = true;
|
||||
});
|
||||
|
||||
ipcMain.handle('disconnect', (event, uid) => {
|
||||
if (!validateSender(event.senderFrame)) return { status: 'error', response: 'Unauthorized process' };
|
||||
|
||||
|
@@ -3,7 +3,7 @@ import { ipcMain } from 'electron';
|
||||
|
||||
import { validateSender } from '../libs/misc/validateSender';
|
||||
|
||||
export default (connections: {[key: string]: antares.Client}) => {
|
||||
export default (connections: Record<string, antares.Client>) => {
|
||||
ipcMain.handle('get-databases', async (event, uid) => {
|
||||
if (!validateSender(event.senderFrame)) return { status: 'error', response: 'Unauthorized process' };
|
||||
|
||||
|
@@ -3,7 +3,7 @@ import { ipcMain } from 'electron';
|
||||
|
||||
import { validateSender } from '../libs/misc/validateSender';
|
||||
|
||||
export default (connections: {[key: string]: antares.Client}) => {
|
||||
export default (connections: Record<string, antares.Client>) => {
|
||||
ipcMain.handle('get-function-informations', async (event, params) => {
|
||||
if (!validateSender(event.senderFrame)) return { status: 'error', response: 'Unauthorized process' };
|
||||
|
||||
|
@@ -13,7 +13,7 @@ import updates from './updates';
|
||||
import users from './users';
|
||||
import views from './views';
|
||||
|
||||
const connections: {[key: string]: antares.Client} = {};
|
||||
const connections: Record<string, antares.Client> = {};
|
||||
|
||||
export default () => {
|
||||
connection(connections);
|
||||
|
@@ -3,7 +3,7 @@ import { ipcMain } from 'electron';
|
||||
|
||||
import { validateSender } from '../libs/misc/validateSender';
|
||||
|
||||
export default (connections: {[key: string]: antares.Client}) => {
|
||||
export default (connections: Record<string, antares.Client>) => {
|
||||
ipcMain.handle('get-routine-informations', async (event, params) => {
|
||||
if (!validateSender(event.senderFrame)) return { status: 'error', response: 'Unauthorized process' };
|
||||
|
||||
|
@@ -3,7 +3,7 @@ import { ipcMain } from 'electron';
|
||||
|
||||
import { validateSender } from '../libs/misc/validateSender';
|
||||
|
||||
export default (connections: {[key: string]: antares.Client}) => {
|
||||
export default (connections: Record<string, antares.Client>) => {
|
||||
ipcMain.handle('get-scheduler-informations', async (event, params) => {
|
||||
if (!validateSender(event.senderFrame)) return { status: 'error', response: 'Unauthorized process' };
|
||||
|
||||
|
@@ -6,7 +6,7 @@ import { Worker } from 'worker_threads';
|
||||
|
||||
import { validateSender } from '../libs/misc/validateSender';
|
||||
|
||||
export default (connections: {[key: string]: antares.Client}) => {
|
||||
export default (connections: Record<string, antares.Client>) => {
|
||||
let exporter: Worker = null;
|
||||
let importer: Worker = null;
|
||||
|
||||
@@ -183,6 +183,7 @@ export default (connections: {[key: string]: antares.Client}) => {
|
||||
const result = await connections[uid].raw(query, {
|
||||
nest: true,
|
||||
details: true,
|
||||
comments: false,
|
||||
schema,
|
||||
tabUid,
|
||||
autocommit
|
||||
@@ -251,7 +252,7 @@ export default (connections: {[key: string]: antares.Client}) => {
|
||||
setTimeout(() => { // Ensures that writing thread has finished
|
||||
exporter?.terminate();
|
||||
exporter = null;
|
||||
}, 2000);
|
||||
}, 500);
|
||||
resolve({ status: 'success', response: payload });
|
||||
break;
|
||||
case 'cancel':
|
||||
|
@@ -3,14 +3,14 @@ import { ARRAY, BIT, BLOB, BOOLEAN, DATE, DATETIME, FLOAT, LONG_TEXT, NUMBER, TE
|
||||
import * as antares from 'common/interfaces/antares';
|
||||
import { InsertRowsParams } from 'common/interfaces/tableApis';
|
||||
import { fakerCustom } from 'common/libs/fakerCustom';
|
||||
import { sqlEscaper } from 'common/libs/sqlUtils';
|
||||
import { formatJsonForSqlWhere, sqlEscaper } from 'common/libs/sqlUtils';
|
||||
import { ipcMain } from 'electron';
|
||||
import * as fs from 'fs';
|
||||
import * as moment from 'moment';
|
||||
|
||||
import { validateSender } from '../libs/misc/validateSender';
|
||||
|
||||
export default (connections: {[key: string]: antares.Client}) => {
|
||||
export default (connections: Record<string, antares.Client>) => {
|
||||
ipcMain.handle('get-table-columns', async (event, params) => {
|
||||
if (!validateSender(event.senderFrame)) return { status: 'error', response: 'Unauthorized process' };
|
||||
|
||||
@@ -87,6 +87,19 @@ export default (connections: {[key: string]: antares.Client}) => {
|
||||
}
|
||||
});
|
||||
|
||||
ipcMain.handle('get-table-checks', async (event, params) => {
|
||||
if (!validateSender(event.senderFrame)) return { status: 'error', response: 'Unauthorized process' };
|
||||
|
||||
try {
|
||||
const result = await connections[params.uid].getTableChecks(params);
|
||||
|
||||
return { status: 'success', response: result };
|
||||
}
|
||||
catch (err) {
|
||||
return { status: 'error', response: err.toString() };
|
||||
}
|
||||
});
|
||||
|
||||
ipcMain.handle('get-table-ddl', async (event, params) => {
|
||||
if (!validateSender(event.senderFrame)) return { status: 'error', response: 'Unauthorized process' };
|
||||
|
||||
@@ -122,7 +135,7 @@ export default (connections: {[key: string]: antares.Client}) => {
|
||||
try { // TODO: move to client classes
|
||||
let escapedParam;
|
||||
let reload = false;
|
||||
const id = typeof params.id === 'number' ? params.id : `${sw}${params.id}${sw}`;
|
||||
const id = typeof params.id === 'number' ? params.id : `${sw}${sqlEscaper(params.id)}${sw}`;
|
||||
|
||||
if ([...NUMBER, ...FLOAT].includes(params.type))
|
||||
escapedParam = params.content;
|
||||
@@ -220,9 +233,10 @@ export default (connections: {[key: string]: antares.Client}) => {
|
||||
|
||||
for (const key in orgRow) {
|
||||
if (typeof orgRow[key] === 'string')
|
||||
orgRow[key] = `'${orgRow[key]}'`;
|
||||
|
||||
if (orgRow[key] === null)
|
||||
orgRow[key] = ` = '${sqlEscaper(orgRow[key])}'`;
|
||||
else if (typeof orgRow[key] === 'object' && orgRow[key] !== null)
|
||||
orgRow[key] = formatJsonForSqlWhere(orgRow[key], connections[params.uid]._client);
|
||||
else if (orgRow[key] === null)
|
||||
orgRow[key] = `IS ${orgRow[key]}`;
|
||||
else
|
||||
orgRow[key] = `= ${orgRow[key]}`;
|
||||
@@ -249,7 +263,7 @@ export default (connections: {[key: string]: antares.Client}) => {
|
||||
|
||||
if (params.primary) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const idString = params.rows.map((row: {[key: string]: any}) => {
|
||||
const idString = params.rows.map((row: Record<string, any>) => {
|
||||
const fieldName = Object.keys(row)[0].includes('.') ? `${params.table}.${params.primary}` : params.primary;
|
||||
|
||||
return typeof row[fieldName] === 'string'
|
||||
@@ -276,7 +290,7 @@ export default (connections: {[key: string]: antares.Client}) => {
|
||||
for (const row of params.rows) {
|
||||
for (const key in row) {
|
||||
if (typeof row[key] === 'string')
|
||||
row[key] = `'${row[key]}'`;
|
||||
row[key] = `'${sqlEscaper(row[key])}'`;
|
||||
|
||||
if (row[key] === null)
|
||||
row[key] = 'IS NULL';
|
||||
@@ -304,10 +318,10 @@ export default (connections: {[key: string]: antares.Client}) => {
|
||||
if (!validateSender(event.senderFrame)) return { status: 'error', response: 'Unauthorized process' };
|
||||
|
||||
try { // TODO: move to client classes
|
||||
const rows: {[key: string]: string | number | boolean | Date | Buffer}[] = [];
|
||||
const rows: Record<string, string | number | boolean | Date | Buffer>[] = [];
|
||||
|
||||
for (let i = 0; i < +params.repeat; i++) {
|
||||
const insertObj: {[key: string]: string | number | boolean | Date | Buffer} = {};
|
||||
const insertObj: Record<string, string | number | boolean | Date | Buffer> = {};
|
||||
|
||||
for (const key in params.row) {
|
||||
const type = params.fields[key];
|
||||
@@ -367,7 +381,7 @@ export default (connections: {[key: string]: antares.Client}) => {
|
||||
insertObj[key] = escapedParam;
|
||||
}
|
||||
else { // Faker value
|
||||
const parsedParams: {[key: string]: string | number | boolean | Date | Buffer} = {};
|
||||
const parsedParams: Record<string, string | number | boolean | Date | Buffer> = {};
|
||||
let fakeValue;
|
||||
|
||||
if (params.locale)
|
||||
@@ -426,23 +440,24 @@ export default (connections: {[key: string]: antares.Client}) => {
|
||||
|
||||
ipcMain.handle('get-foreign-list', async (event, { uid, schema, table, column, description }) => {
|
||||
if (!validateSender(event.senderFrame)) return { status: 'error', response: 'Unauthorized process' };
|
||||
const { elementsWrapper: ew } = customizations[connections[uid]._client];
|
||||
|
||||
try {
|
||||
const query = connections[uid]
|
||||
.select(`${column} AS foreign_column`)
|
||||
.select(`${ew}${column}${ew} AS foreign_column`)
|
||||
.schema(schema)
|
||||
.from(table)
|
||||
.orderBy('foreign_column ASC');
|
||||
|
||||
if (description)
|
||||
query.select(`LEFT(${description}, 20) AS foreign_description`);
|
||||
query.select(`LEFT(${ew}${description}${ew}, 20) AS foreign_description`);
|
||||
|
||||
const results = await query.run<{[key: string]: string}>();
|
||||
const results = await query.run<Record<string, string>>();
|
||||
|
||||
const parsedResults: {[key: string]: string}[] = [];
|
||||
const parsedResults: Record<string, string>[] = [];
|
||||
|
||||
for (const row of results.rows) {
|
||||
const remappedRow: {[key: string]: string} = {};
|
||||
const remappedRow: Record<string, string> = {};
|
||||
|
||||
for (const key in row)
|
||||
remappedRow[key.toLowerCase()] = row[key];// Thanks Firebird -.-
|
||||
|
@@ -3,7 +3,7 @@ import { ipcMain } from 'electron';
|
||||
|
||||
import { validateSender } from '../libs/misc/validateSender';
|
||||
|
||||
export default (connections: {[key: string]: antares.Client}) => {
|
||||
export default (connections: Record<string, antares.Client>) => {
|
||||
ipcMain.handle('get-trigger-informations', async (event, params) => {
|
||||
if (!validateSender(event.senderFrame)) return { status: 'error', response: 'Unauthorized process' };
|
||||
|
||||
|
@@ -3,7 +3,7 @@ import { ipcMain } from 'electron';
|
||||
|
||||
import { validateSender } from '../libs/misc/validateSender';
|
||||
|
||||
export default (connections: {[key: string]: antares.Client}) => {
|
||||
export default (connections: Record<string, antares.Client>) => {
|
||||
ipcMain.handle('get-users', async (event, uid) => {
|
||||
if (!validateSender(event.senderFrame)) return { status: 'error', response: 'Unauthorized process' };
|
||||
|
||||
|
@@ -3,7 +3,7 @@ import { ipcMain } from 'electron';
|
||||
|
||||
import { validateSender } from '../libs/misc/validateSender';
|
||||
|
||||
export default (connections: {[key: string]: antares.Client}) => {
|
||||
export default (connections: Record<string, antares.Client>) => {
|
||||
ipcMain.handle('get-view-informations', async (event, params) => {
|
||||
if (!validateSender(event.senderFrame)) return { status: 'error', response: 'Unauthorized process' };
|
||||
|
||||
@@ -51,4 +51,52 @@ export default (connections: {[key: string]: antares.Client}) => {
|
||||
return { status: 'error', response: err.toString() };
|
||||
}
|
||||
});
|
||||
|
||||
ipcMain.handle('get-materialized-view-informations', async (event, params) => {
|
||||
if (!validateSender(event.senderFrame)) return { status: 'error', response: 'Unauthorized process' };
|
||||
|
||||
try {
|
||||
const result = await connections[params.uid].getMaterializedViewInformations(params);
|
||||
return { status: 'success', response: result };
|
||||
}
|
||||
catch (err) {
|
||||
return { status: 'error', response: err.toString() };
|
||||
}
|
||||
});
|
||||
|
||||
ipcMain.handle('drop-materialized-view', async (event, params) => {
|
||||
if (!validateSender(event.senderFrame)) return { status: 'error', response: 'Unauthorized process' };
|
||||
|
||||
try {
|
||||
await connections[params.uid].dropMaterializedView(params);
|
||||
return { status: 'success' };
|
||||
}
|
||||
catch (err) {
|
||||
return { status: 'error', response: err.toString() };
|
||||
}
|
||||
});
|
||||
|
||||
ipcMain.handle('alter-materialized-view', async (event, params) => {
|
||||
if (!validateSender(event.senderFrame)) return { status: 'error', response: 'Unauthorized process' };
|
||||
|
||||
try {
|
||||
await connections[params.uid].alterView(params);
|
||||
return { status: 'success' };
|
||||
}
|
||||
catch (err) {
|
||||
return { status: 'error', response: err.toString() };
|
||||
}
|
||||
});
|
||||
|
||||
ipcMain.handle('create-materialized-view', async (event, params) => {
|
||||
if (!validateSender(event.senderFrame)) return { status: 'error', response: 'Unauthorized process' };
|
||||
|
||||
try {
|
||||
await connections[params.uid].createMaterializedView(params);
|
||||
return { status: 'success' };
|
||||
}
|
||||
catch (err) {
|
||||
return { status: 'error', response: err.toString() };
|
||||
}
|
||||
});
|
||||
};
|
||||
|
@@ -70,23 +70,29 @@ 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),
|
||||
accelerator: key,
|
||||
visible: false,
|
||||
click: () => {
|
||||
this._mainWindow.webContents.send(shortcut.event);
|
||||
if (isDevelopment) console.log('LOCAL EVENT:', shortcut);
|
||||
submenu.push({
|
||||
label: String(shortcut.event),
|
||||
accelerator: key,
|
||||
visible: isMenuVisible,
|
||||
click: () => {
|
||||
if (shortcut.isFunction) {
|
||||
if (shortcut.event in this) {
|
||||
type exporterMethods = 'setFullScreen' | 'setZoomIn' | 'setZoomOut' | 'setZoomReset';
|
||||
this[shortcut.event as exporterMethods]();
|
||||
}
|
||||
}
|
||||
}]
|
||||
}));
|
||||
else
|
||||
this._mainWindow.webContents.send(shortcut.event);
|
||||
|
||||
if (isDevelopment) console.log('LOCAL EVENT:', shortcut);
|
||||
}
|
||||
});
|
||||
}
|
||||
catch (error) {
|
||||
if (isDevelopment) console.log(error);
|
||||
@@ -96,6 +102,11 @@ export class ShortcutRegister {
|
||||
}
|
||||
}
|
||||
}
|
||||
this._menu.append(new MenuItem({
|
||||
label: 'Shortcut',
|
||||
visible: isMenuVisible,
|
||||
submenu
|
||||
}));
|
||||
}
|
||||
|
||||
private setGlobalShortcuts () {
|
||||
@@ -118,6 +129,24 @@ export class ShortcutRegister {
|
||||
}
|
||||
}
|
||||
|
||||
setFullScreen () {
|
||||
this._mainWindow.setFullScreen(!this._mainWindow.isFullScreen());
|
||||
}
|
||||
|
||||
setZoomIn () {
|
||||
const currentZoom = this._mainWindow.webContents.getZoomLevel();
|
||||
this._mainWindow.webContents.setZoomLevel(currentZoom + 1);
|
||||
}
|
||||
|
||||
setZoomOut () {
|
||||
const currentZoom = this._mainWindow.webContents.getZoomLevel();
|
||||
this._mainWindow.webContents.setZoomLevel(currentZoom - 1);
|
||||
}
|
||||
|
||||
setZoomReset () {
|
||||
this._mainWindow.webContents.setZoomLevel(0);
|
||||
}
|
||||
|
||||
reload () {
|
||||
this.unregister();
|
||||
this.init();
|
||||
|
@@ -1,17 +1,10 @@
|
||||
import * as antares from 'common/interfaces/antares';
|
||||
import { querySplitter } from 'common/libs/sqlUtils';
|
||||
import mysql from 'mysql2/promise';
|
||||
import * as pg from 'pg';
|
||||
import SSH2Promise = require('@fabio286/ssh2-promise');
|
||||
|
||||
const queryLogger = ({ sql, cUid }: {sql: string; cUid: string}) => {
|
||||
// Remove comments, newlines and multiple spaces
|
||||
const escapedSql = sql.replace(/(\/\*(.|[\r\n])*?\*\/)|(--(.*|[\r\n]))/gm, '').replace(/\s\s+/g, ' ');
|
||||
if (process.type !== undefined) {
|
||||
const mainWindow = require('electron').webContents.fromId(1);
|
||||
mainWindow.send('query-log', { cUid, sql: escapedSql, date: new Date() });
|
||||
}
|
||||
if (process.env.NODE_ENV === 'development' && process.type === 'browser') console.log(escapedSql);
|
||||
};
|
||||
import { ipcLogger, LoggerLevel } from '../misc/ipcLogger';
|
||||
|
||||
/**
|
||||
* As Simple As Possible Query Builder Core
|
||||
@@ -22,7 +15,8 @@ export abstract class BaseClient {
|
||||
protected _params: mysql.ConnectionOptions | pg.ClientConfig | { databasePath: string; readonly: boolean};
|
||||
protected _poolSize: number;
|
||||
protected _ssh?: SSH2Promise;
|
||||
protected _logger: (args: {sql: string; cUid: string}) => void;
|
||||
protected _logger: (args: {content: string; cUid: string; level: LoggerLevel}) => void;
|
||||
protected _querySplitter: (sql: string, client: antares.ClientCode) => string[];
|
||||
protected _queryDefaults: antares.QueryBuilderObject;
|
||||
protected _query: antares.QueryBuilderObject;
|
||||
|
||||
@@ -31,7 +25,8 @@ export abstract class BaseClient {
|
||||
this._cUid = args.uid;
|
||||
this._params = args.params;
|
||||
this._poolSize = args.poolSize || undefined;
|
||||
this._logger = args.logger || queryLogger;
|
||||
this._logger = args.logger || ipcLogger;
|
||||
this._querySplitter = args.querySplitter || querySplitter;
|
||||
|
||||
this._queryDefaults = {
|
||||
schema: '',
|
||||
@@ -136,7 +131,7 @@ export abstract class BaseClient {
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
insert (arr: {[key: string]: any}[]) {
|
||||
insert (arr: Record<string, any>[]) {
|
||||
this._query.insert = [...this._query.insert, ...arr];
|
||||
return this;
|
||||
}
|
||||
@@ -178,6 +173,10 @@ export abstract class BaseClient {
|
||||
throw new Error('Method "dropSchema" not implemented');
|
||||
}
|
||||
|
||||
getTableChecks (...args: any) {
|
||||
throw new Error('Method "getTableDll" not implemented');
|
||||
}
|
||||
|
||||
getTableDll (...args: any) {
|
||||
throw new Error('Method "getTableDll" not implemented');
|
||||
}
|
||||
@@ -234,6 +233,18 @@ export abstract class BaseClient {
|
||||
throw new Error('Method "getVariables" not implemented');
|
||||
}
|
||||
|
||||
getMaterializedViewInformations (...args: any) {
|
||||
throw new Error('Method "getMaterializedViewInformations" not implemented');
|
||||
}
|
||||
|
||||
dropMaterializedView (...args: any) {
|
||||
throw new Error('Method "dropMaterializedView" not implemented');
|
||||
}
|
||||
|
||||
createMaterializedView (...args: any) {
|
||||
throw new Error('Method "createMaterializedView" not implemented');
|
||||
}
|
||||
|
||||
getEventInformations (...args: any) {
|
||||
throw new Error('Method "getEventInformations" not implemented');
|
||||
}
|
||||
|
@@ -1,6 +1,7 @@
|
||||
import dataTypes from 'common/data-types/firebird';
|
||||
import { FLOAT, NUMBER } from 'common/fieldTypes';
|
||||
import * as antares from 'common/interfaces/antares';
|
||||
import { removeComments } from 'common/libs/sqlUtils';
|
||||
import * as firebird from 'node-firebird';
|
||||
import * as path from 'path';
|
||||
|
||||
@@ -13,7 +14,7 @@ export class FirebirdSQLClient extends BaseClient {
|
||||
protected _connection?: firebird.Database | firebird.ConnectionPool;
|
||||
_params: firebird.Options;
|
||||
|
||||
private _types: {[key: number]: string} ={
|
||||
private _types: Record<number, string> ={
|
||||
452: 'CHAR', // Array of char
|
||||
448: 'VARCHAR',
|
||||
500: 'SMALLINT',
|
||||
@@ -109,6 +110,10 @@ export class FirebirdSQLClient extends BaseClient {
|
||||
return firebird.pool(this._poolSize, { ...this._params, blobAsText: true });
|
||||
}
|
||||
|
||||
ping () {
|
||||
return this.raw('SELECT rdb$get_context(\'SYSTEM\', \'DB_NAME\') FROM rdb$database');
|
||||
}
|
||||
|
||||
destroy () {
|
||||
if (this._poolSize)
|
||||
return (this._connection as firebird.ConnectionPool).destroy();
|
||||
@@ -241,10 +246,10 @@ export class FirebirdSQLClient extends BaseClient {
|
||||
name: db.name,
|
||||
size: schemaSize,
|
||||
tables: remappedTables,
|
||||
functions: [],
|
||||
functions: [] as null[],
|
||||
procedures: remappedProcedures,
|
||||
triggers: remappedTriggers,
|
||||
schedulers: []
|
||||
schedulers: [] as null[]
|
||||
};
|
||||
});
|
||||
}
|
||||
@@ -333,7 +338,7 @@ export class FirebirdSQLClient extends BaseClient {
|
||||
|
||||
return {
|
||||
name: field.FIELD_NAME.trim(),
|
||||
key: null,
|
||||
key: null as null,
|
||||
type: fieldType,
|
||||
schema: schema,
|
||||
table: table,
|
||||
@@ -342,14 +347,14 @@ export class FirebirdSQLClient extends BaseClient {
|
||||
datePrecision: field.FIELD_NAME.trim() === 'TIMESTAMP' ? 4 : null,
|
||||
charLength: ![...NUMBER, ...FLOAT].includes(fieldType) ? field.FIELD_LENGTH : null,
|
||||
nullable: !field.NOT_NULL,
|
||||
unsigned: null,
|
||||
zerofill: null,
|
||||
unsigned: null as null,
|
||||
zerofill: null as null,
|
||||
order: field.FIELD_POSITION+1,
|
||||
default: defaultValue,
|
||||
charset: field.CHARSET,
|
||||
collation: null,
|
||||
collation: null as null,
|
||||
autoIncrement: false,
|
||||
onUpdate: null,
|
||||
onUpdate: null as null,
|
||||
comment: field.DESCRIPTION?.trim()
|
||||
};
|
||||
});
|
||||
@@ -453,7 +458,7 @@ export class FirebirdSQLClient extends BaseClient {
|
||||
table: table,
|
||||
field: field.FKCOLUMN_NAME.trim(),
|
||||
position: field.KEY_SEQ,
|
||||
constraintPosition: null,
|
||||
constraintPosition: null as null,
|
||||
constraintName: field.FK_NAME.trim(),
|
||||
refSchema: schema,
|
||||
refTable: field.PKTABLE_NAME.trim(),
|
||||
@@ -1020,7 +1025,7 @@ export class FirebirdSQLClient extends BaseClient {
|
||||
alias: string;
|
||||
}
|
||||
|
||||
this._logger({ cUid: this._cUid, sql });
|
||||
this._logger({ cUid: this._cUid, content: sql, level: 'query' });
|
||||
|
||||
args = {
|
||||
nest: false,
|
||||
@@ -1032,14 +1037,12 @@ export class FirebirdSQLClient extends BaseClient {
|
||||
};
|
||||
|
||||
if (!args.comments)
|
||||
sql = sql.replace(/(\/\*(.|[\r\n])*?\*\/)|(--(.*|[\r\n]))/gm, '');// Remove comments
|
||||
sql = removeComments(sql);
|
||||
|
||||
const resultsArr = [];
|
||||
let paramsArr = [];
|
||||
const queries = args.split
|
||||
? sql.split(/((?:[^;'"]*(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*')[^;'"]*)+)|;/gm)
|
||||
.filter(Boolean)
|
||||
.map(q => q.trim())
|
||||
? this._querySplitter(sql, 'firebird')
|
||||
: [sql];
|
||||
|
||||
let connection: firebird.Database | firebird.Transaction;
|
||||
|
@@ -2,9 +2,12 @@ import SSH2Promise = require('@fabio286/ssh2-promise');
|
||||
import SSHConfig from '@fabio286/ssh2-promise/lib/sshConfig';
|
||||
import dataTypes from 'common/data-types/mysql';
|
||||
import * as antares from 'common/interfaces/antares';
|
||||
import { removeComments } from 'common/libs/sqlUtils';
|
||||
import * as mysql from 'mysql2/promise';
|
||||
|
||||
import * as EncodingToCharset from '../../../../node_modules/mysql2/lib/constants/encoding_charset.js';
|
||||
import { BaseClient } from './BaseClient';
|
||||
EncodingToCharset.utf8mb3 = 192; // To fix https://github.com/sidorares/node-mysql2/issues/1398 until not included in mysql2
|
||||
|
||||
export class MySQLClient extends BaseClient {
|
||||
private _schema?: string;
|
||||
@@ -12,10 +15,11 @@ export class MySQLClient extends BaseClient {
|
||||
private _connectionsToCommit: Map<string, mysql.Connection | mysql.PoolConnection>;
|
||||
private _keepaliveTimer: NodeJS.Timer;
|
||||
private _keepaliveMs: number;
|
||||
private sqlMode?: string[];
|
||||
_connection?: mysql.Connection | mysql.Pool;
|
||||
_params: mysql.ConnectionOptions & {schema: string; ssl?: mysql.SslOptions; ssh?: SSHConfig; readonly: boolean};
|
||||
|
||||
private types: {[key: number]: string} = {
|
||||
private types: Record<number, string> = {
|
||||
0: 'DECIMAL',
|
||||
1: 'TINYINT',
|
||||
2: 'SMALLINT',
|
||||
@@ -58,6 +62,10 @@ export class MySQLClient extends BaseClient {
|
||||
this._keepaliveMs = 10*60*1000;
|
||||
}
|
||||
|
||||
private get isPool () {
|
||||
return 'getConnection' in this._connection;
|
||||
}
|
||||
|
||||
private _getType (field: mysql.FieldPacket & { columnType?: number; columnLength?: number }) {
|
||||
let name = this.types[field.columnType];
|
||||
let length = field.columnLength;
|
||||
@@ -156,6 +164,8 @@ export class MySQLClient extends BaseClient {
|
||||
|
||||
this._ssh = new SSH2Promise({
|
||||
...this._params.ssh,
|
||||
reconnect: true,
|
||||
reconnectTries: 3,
|
||||
debug: process.env.NODE_ENV !== 'production' ? (s) => console.log(s) : null
|
||||
});
|
||||
|
||||
@@ -164,13 +174,13 @@ export class MySQLClient extends BaseClient {
|
||||
remotePort: this._params.port
|
||||
});
|
||||
|
||||
dbConfig.host = (this._ssh.config as SSHConfig[] & { host: string }).host;
|
||||
dbConfig.host = undefined;
|
||||
dbConfig.port = tunnel.localPort;
|
||||
}
|
||||
catch (err) {
|
||||
if (this._ssh) {
|
||||
this._ssh.close();
|
||||
this._ssh.closeTunnel();
|
||||
this._ssh.close();
|
||||
}
|
||||
throw err;
|
||||
}
|
||||
@@ -181,9 +191,36 @@ export class MySQLClient extends BaseClient {
|
||||
|
||||
async connect () {
|
||||
if (!this._poolSize)
|
||||
this._connection = await this.getConnection();
|
||||
this._connection = await this.getSingleConnection();
|
||||
else
|
||||
this._connection = await this.getConnectionPool();
|
||||
|
||||
// ANSI_QUOTES check
|
||||
const [response] = await this._connection.query<mysql.RowDataPacket[]>('SHOW GLOBAL VARIABLES LIKE \'%sql_mode%\'');
|
||||
this.sqlMode = response[0]?.Value?.split(',');
|
||||
const hasAnsiQuotes = this.sqlMode.includes('ANSI') || this.sqlMode.includes('ANSI_QUOTES');
|
||||
|
||||
if (hasAnsiQuotes)
|
||||
await this._connection.query(`SET SESSION sql_mode = '${this.sqlMode.filter((m: string) => !['ANSI', 'ANSI_QUOTES'].includes(m)).join(',')}'`);
|
||||
|
||||
if (this._params.readonly)
|
||||
await this._connection.query('SET SESSION TRANSACTION READ ONLY');
|
||||
|
||||
if (this._poolSize) {
|
||||
const hasAnsiQuotes = this.sqlMode.includes('ANSI') || this.sqlMode.includes('ANSI_QUOTES');
|
||||
|
||||
this._connection.on('connection', conn => {
|
||||
if (this._params.readonly)
|
||||
conn.query('SET SESSION TRANSACTION READ ONLY');
|
||||
|
||||
if (hasAnsiQuotes)
|
||||
conn.query(`SET SESSION sql_mode = '${this.sqlMode.filter((m: string) => !['ANSI', 'ANSI_QUOTES'].includes(m)).join(',')}'`);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
ping () {
|
||||
return this.select('1+1').run();
|
||||
}
|
||||
|
||||
destroy () {
|
||||
@@ -191,34 +228,24 @@ export class MySQLClient extends BaseClient {
|
||||
clearInterval(this._keepaliveTimer);
|
||||
this._keepaliveTimer = undefined;
|
||||
if (this._ssh) {
|
||||
this._ssh.close();
|
||||
this._ssh.closeTunnel();
|
||||
this._ssh.close();
|
||||
}
|
||||
}
|
||||
|
||||
async getConnection () {
|
||||
async getSingleConnection () {
|
||||
const dbConfig = await this.getDbConfig();
|
||||
const connection = await mysql.createConnection({
|
||||
...dbConfig,
|
||||
typeCast: (field, next) => {
|
||||
if (field.type === 'DATETIME')
|
||||
return field.string();
|
||||
else
|
||||
return next();
|
||||
}
|
||||
dateStrings: true
|
||||
// typeCast: (field, next) => {
|
||||
// if (field.type === 'DATETIME')
|
||||
// return field.string();
|
||||
// else
|
||||
// return next();
|
||||
// }
|
||||
});
|
||||
|
||||
// ANSI_QUOTES check
|
||||
const [response] = await connection.query<mysql.RowDataPacket[]>('SHOW GLOBAL VARIABLES LIKE \'%sql_mode%\'');
|
||||
const sqlMode: string[] = response[0]?.Value?.split(',');
|
||||
const hasAnsiQuotes = sqlMode.includes('ANSI') || sqlMode.includes('ANSI_QUOTES');
|
||||
|
||||
if (this._params.readonly)
|
||||
await connection.query('SET SESSION TRANSACTION READ ONLY');
|
||||
|
||||
if (hasAnsiQuotes)
|
||||
await connection.query(`SET SESSION sql_mode = '${sqlMode.filter((m: string) => !['ANSI', 'ANSI_QUOTES'].includes(m)).join(',')}'`);
|
||||
|
||||
return connection;
|
||||
}
|
||||
|
||||
@@ -227,31 +254,14 @@ export class MySQLClient extends BaseClient {
|
||||
const connection = mysql.createPool({
|
||||
...dbConfig,
|
||||
connectionLimit: this._poolSize,
|
||||
typeCast: (field, next) => {
|
||||
if (field.type === 'DATETIME')
|
||||
return field.string();
|
||||
else
|
||||
return next();
|
||||
}
|
||||
});
|
||||
|
||||
// ANSI_QUOTES check
|
||||
const [res] = await connection.query<mysql.RowDataPacket[]>('SHOW GLOBAL VARIABLES LIKE \'%sql_mode%\'');
|
||||
const sqlMode: string[] = res[0]?.Value?.split(',');
|
||||
const hasAnsiQuotes = sqlMode.includes('ANSI') || sqlMode.includes('ANSI_QUOTES');
|
||||
|
||||
if (hasAnsiQuotes)
|
||||
await connection.query(`SET SESSION sql_mode = '${sqlMode.filter((m: string) => !['ANSI', 'ANSI_QUOTES'].includes(m)).join(',')}'`);
|
||||
|
||||
if (this._params.readonly)
|
||||
await connection.query('SET SESSION TRANSACTION READ ONLY');
|
||||
|
||||
connection.on('connection', conn => {
|
||||
if (this._params.readonly)
|
||||
conn.query('SET SESSION TRANSACTION READ ONLY');
|
||||
|
||||
if (hasAnsiQuotes)
|
||||
conn.query(`SET SESSION sql_mode = '${sqlMode.filter((m: string) => !['ANSI', 'ANSI_QUOTES'].includes(m)).join(',')}'`);
|
||||
enableKeepAlive: true,
|
||||
dateStrings: true
|
||||
// typeCast: (field, next) => {
|
||||
// if (field.type === 'DATETIME')
|
||||
// return field.string();
|
||||
// else
|
||||
// return next();
|
||||
// }
|
||||
});
|
||||
|
||||
this._keepaliveTimer = setInterval(async () => {
|
||||
@@ -261,6 +271,45 @@ export class MySQLClient extends BaseClient {
|
||||
return connection;
|
||||
}
|
||||
|
||||
async getConnection (args?: antares.QueryParams, retry?: boolean): Promise<mysql.Pool | mysql.PoolConnection | mysql.Connection> {
|
||||
let connection;
|
||||
|
||||
try {
|
||||
if (args && !args.autocommit && args.tabUid) { // autocommit OFF
|
||||
if (this._connectionsToCommit.has(args.tabUid))
|
||||
connection = this._connectionsToCommit.get(args.tabUid);
|
||||
else {
|
||||
connection = await this.getSingleConnection();
|
||||
await connection.query('SET SESSION autocommit=0');
|
||||
this._connectionsToCommit.set(args.tabUid, connection);
|
||||
}
|
||||
}
|
||||
else// autocommit ON
|
||||
connection = this.isPool ? await (this._connection as mysql.Pool).getConnection() : this._connection;
|
||||
|
||||
if (args && args.tabUid && this.isPool) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
this._runningConnections.set(args.tabUid, (connection as any).connection.connectionId);
|
||||
}
|
||||
|
||||
if (args && args.schema)
|
||||
await connection.query(`USE \`${args.schema}\``);
|
||||
|
||||
return connection;
|
||||
}
|
||||
catch (error) {
|
||||
if (error.code === 'ECONNRESET' && !retry) {
|
||||
this.destroy();
|
||||
await this.connect();
|
||||
return this.getConnection(args, true);
|
||||
}
|
||||
else if (error instanceof AggregateError)
|
||||
throw new Error(error.errors.reduce((acc, curr) => acc +' | '+ curr.message, ''));
|
||||
else
|
||||
throw new Error(error.message);
|
||||
}
|
||||
}
|
||||
|
||||
private async keepAlive () {
|
||||
try {
|
||||
const connection = await (this._connection as mysql.Pool).getConnection();
|
||||
@@ -312,10 +361,21 @@ export class MySQLClient extends BaseClient {
|
||||
if (this._params.schema)
|
||||
filteredDatabases = filteredDatabases.filter(db => db.Database === this._params.schema);
|
||||
|
||||
const { rows: functions } = await this.raw('SHOW FUNCTION STATUS');
|
||||
const { rows: procedures } = await this.raw('SHOW PROCEDURE STATUS');
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
let functions: any[] = [];
|
||||
let procedures: any[] = [];
|
||||
let schedulers: any[] = [];
|
||||
/* eslint-enable @typescript-eslint/no-explicit-any */
|
||||
|
||||
try {
|
||||
const { rows: functionRows } = await this.raw('SHOW FUNCTION STATUS');
|
||||
const { rows: procedureRows } = await this.raw('SHOW PROCEDURE STATUS');
|
||||
functions = functionRows;
|
||||
procedures = procedureRows;
|
||||
}
|
||||
catch (err) {
|
||||
this._logger({ content: err.sqlMessage, cUid: this._cUid, level: 'error' });
|
||||
}
|
||||
|
||||
try { // Avoid exception with event_scheduler DISABLED with MariaDB 10
|
||||
const { rows } = await this.raw('SELECT *, EVENT_SCHEMA AS `Db`, EVENT_NAME AS `Name` FROM information_schema.`EVENTS`');
|
||||
@@ -582,7 +642,7 @@ export class MySQLClient extends BaseClient {
|
||||
}
|
||||
})
|
||||
.filter(Boolean)
|
||||
.reduce((acc: {[key: string]: { name: string; type: string; length: string; default: string}}, curr) => {
|
||||
.reduce((acc: Record<string, { name: string; type: string; length: string; default: string}>, curr) => {
|
||||
acc[curr.name] = curr;
|
||||
return acc;
|
||||
}, {});
|
||||
@@ -591,7 +651,7 @@ export class MySQLClient extends BaseClient {
|
||||
return rows.map((field) => {
|
||||
const numLengthMatch = field.COLUMN_TYPE.match(/int\(([^)]+)\)/);
|
||||
const numLength = numLengthMatch ? +numLengthMatch.pop() : field.NUMERIC_PRECISION || null;
|
||||
const enumValues = /(enum)/.test(field.COLUMN_TYPE)
|
||||
const enumValues = /(enum|set)/.test(field.COLUMN_TYPE)
|
||||
? field.COLUMN_TYPE.match(/\(([^)]+)\)/)[0].slice(1, -1)
|
||||
: null;
|
||||
|
||||
@@ -621,7 +681,7 @@ export class MySQLClient extends BaseClient {
|
||||
charset: field.CHARACTER_SET_NAME,
|
||||
collation: field.COLLATION_NAME,
|
||||
autoIncrement: field.EXTRA.includes('auto_increment'),
|
||||
generated: field.EXTRA.toLowerCase().includes('generated'),
|
||||
generated: ['VIRTUAL GENERATED', 'VIRTUAL STORED'].includes(field.EXTRA),
|
||||
onUpdate: field.EXTRA.toLowerCase().includes('on update')
|
||||
? field.EXTRA.substr(field.EXTRA.indexOf('on update') + 9, field.EXTRA.length).trim()
|
||||
: '',
|
||||
@@ -636,6 +696,39 @@ export class MySQLClient extends BaseClient {
|
||||
return rows.length ? rows[0].count : 0;
|
||||
}
|
||||
|
||||
async getTableChecks ({ schema, table }: { schema: string; table: string }): Promise<antares.TableCheck[] | false> {
|
||||
const { rows: checkTableExists } = await this.raw('SELECT table_name FROM information_schema.tables WHERE table_schema = "information_schema" AND table_name = "CHECK_CONSTRAINTS"');
|
||||
|
||||
if (!checkTableExists.length)// check if CHECK_CONSTRAINTS table exists
|
||||
return false;
|
||||
|
||||
const { rows } = await this.raw(`
|
||||
SELECT
|
||||
CONSTRAINT_NAME as name,
|
||||
CHECK_CLAUSE as clausole
|
||||
FROM information_schema.CHECK_CONSTRAINTS
|
||||
WHERE CONSTRAINT_SCHEMA = "${schema}"
|
||||
AND CONSTRAINT_NAME IN (
|
||||
SELECT
|
||||
CONSTRAINT_NAME
|
||||
FROM
|
||||
information_schema.TABLE_CONSTRAINTS
|
||||
WHERE
|
||||
TABLE_SCHEMA = "${schema}"
|
||||
AND TABLE_NAME = "${table}"
|
||||
AND CONSTRAINT_TYPE = 'CHECK'
|
||||
)
|
||||
`);
|
||||
|
||||
if (rows.length) {
|
||||
return rows.map(row => ({
|
||||
name: row.name,
|
||||
clause: row.clausole
|
||||
}));
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
async getTableOptions ({ schema, table }: { schema: string; table: string }) {
|
||||
/* eslint-disable camelcase */
|
||||
interface TableOptionsResult {
|
||||
@@ -812,11 +905,13 @@ export class MySQLClient extends BaseClient {
|
||||
fields,
|
||||
foreigns,
|
||||
indexes,
|
||||
checks,
|
||||
options
|
||||
} = params;
|
||||
const newColumns: string[] = [];
|
||||
const newIndexes: string[] = [];
|
||||
const newForeigns: string[] = [];
|
||||
const newChecks: string[] = [];
|
||||
|
||||
let sql = `CREATE TABLE \`${schema}\`.\`${options.name}\``;
|
||||
|
||||
@@ -857,7 +952,13 @@ export class MySQLClient extends BaseClient {
|
||||
newForeigns.push(`CONSTRAINT \`${foreign.constraintName}\` FOREIGN KEY (\`${foreign.field}\`) REFERENCES \`${foreign.refTable}\` (\`${foreign.refField}\`) ON UPDATE ${foreign.onUpdate} ON DELETE ${foreign.onDelete}`);
|
||||
});
|
||||
|
||||
sql = `${sql} (${[...newColumns, ...newIndexes, ...newForeigns].join(', ')}) COMMENT='${options.comment}', COLLATE='${options.collation}', ENGINE=${options.engine}`;
|
||||
// ADD TABLE CHECKS
|
||||
checks.forEach(check => {
|
||||
if (!check.clause.trim().length) return;
|
||||
newChecks.push(`${check.name ? `CONSTRAINT \`${check.name}\` ` : ''}CHECK (${check.clause})`);
|
||||
});
|
||||
|
||||
sql = `${sql} (${[...newColumns, ...newIndexes, ...newForeigns, ...newChecks].join(', ')}) COMMENT='${options.comment}', COLLATE='${options.collation}', ENGINE=${options.engine}`;
|
||||
|
||||
return await this.raw(sql);
|
||||
}
|
||||
@@ -871,6 +972,7 @@ export class MySQLClient extends BaseClient {
|
||||
changes,
|
||||
indexChanges,
|
||||
foreignChanges,
|
||||
checkChanges,
|
||||
options
|
||||
} = params;
|
||||
|
||||
@@ -878,6 +980,7 @@ export class MySQLClient extends BaseClient {
|
||||
const alterColumnsAdd: string[] = [];
|
||||
const alterColumnsChange: string[] = [];
|
||||
const alterColumnsDrop: string[] = [];
|
||||
const alterQueryes: string[] = [];
|
||||
|
||||
// OPTIONS
|
||||
if ('comment' in options) alterColumnsChange.push(`COMMENT='${options.comment}'`);
|
||||
@@ -923,6 +1026,12 @@ export class MySQLClient extends BaseClient {
|
||||
alterColumnsAdd.push(`ADD CONSTRAINT \`${addition.constraintName}\` FOREIGN KEY (\`${addition.field}\`) REFERENCES \`${addition.refTable}\` (\`${addition.refField}\`) ON UPDATE ${addition.onUpdate} ON DELETE ${addition.onDelete}`);
|
||||
});
|
||||
|
||||
// ADD TABLE CHECKS
|
||||
checkChanges.additions.forEach(addition => {
|
||||
if (!addition.clause.trim().length) return;
|
||||
alterColumnsAdd.push(`ADD ${addition.name ? `CONSTRAINT \`${addition.name}\` ` : ''}CHECK (${addition.clause})`);
|
||||
});
|
||||
|
||||
// CHANGE FIELDS
|
||||
changes.forEach(change => {
|
||||
const typeInfo = this.getTypeInfo(change.type);
|
||||
@@ -934,9 +1043,9 @@ export class MySQLClient extends BaseClient {
|
||||
${change.zerofill ? 'ZEROFILL' : ''}
|
||||
${change.nullable ? 'NULL' : 'NOT NULL'}
|
||||
${change.autoIncrement ? 'AUTO_INCREMENT' : ''}
|
||||
${change.collation ? `COLLATE ${change.collation}` : ''}
|
||||
${change.default !== null ? `DEFAULT ${change.default || '\'\''}` : ''}
|
||||
${change.comment ? `COMMENT '${change.comment}'` : ''}
|
||||
${change.collation ? `COLLATE ${change.collation}` : ''}
|
||||
${change.onUpdate ? `ON UPDATE ${change.onUpdate}` : ''}
|
||||
${change.after ? `AFTER \`${change.after}\`` : 'FIRST'}`);
|
||||
});
|
||||
@@ -967,6 +1076,13 @@ export class MySQLClient extends BaseClient {
|
||||
alterColumnsChange.push(`ADD CONSTRAINT \`${change.constraintName}\` FOREIGN KEY (\`${change.field}\`) REFERENCES \`${change.refTable}\` (\`${change.refField}\`) ON UPDATE ${change.onUpdate} ON DELETE ${change.onDelete}`);
|
||||
});
|
||||
|
||||
// CHANGE CHECK TABLE
|
||||
checkChanges.changes.forEach(change => {
|
||||
if (!change.clause.trim().length) return;
|
||||
alterQueryes.push(`${sql} DROP CONSTRAINT \`${change.name}\``);
|
||||
alterQueryes.push(`${sql} ADD ${change.name ? `CONSTRAINT \`${change.name}\` ` : ''}CHECK (${change.clause})`);
|
||||
});
|
||||
|
||||
// DROP FIELDS
|
||||
deletions.forEach(deletion => {
|
||||
alterColumnsDrop.push(`DROP COLUMN \`${deletion.name}\``);
|
||||
@@ -985,7 +1101,11 @@ export class MySQLClient extends BaseClient {
|
||||
alterColumnsDrop.push(`DROP FOREIGN KEY \`${deletion.constraintName}\``);
|
||||
});
|
||||
|
||||
const alterQueryes = [];
|
||||
// DROP CHECK TABLE
|
||||
checkChanges.deletions.forEach(deletion => {
|
||||
alterQueryes.push(`${sql} DROP CONSTRAINT \`${deletion.name}\``);
|
||||
});
|
||||
|
||||
if (alterColumnsAdd.length) alterQueryes.push(sql+alterColumnsAdd.join(', '));
|
||||
if (alterColumnsChange.length) alterQueryes.push(sql+alterColumnsChange.join(', '));
|
||||
if (alterColumnsDrop.length) alterQueryes.push(sql+alterColumnsDrop.join(', '));
|
||||
@@ -1625,7 +1745,7 @@ export class MySQLClient extends BaseClient {
|
||||
}
|
||||
|
||||
async raw<T = antares.QueryResult> (sql: string, args?: antares.QueryParams) {
|
||||
this._logger({ cUid: this._cUid, sql });
|
||||
this._logger({ cUid: this._cUid, content: sql, level: 'query' });
|
||||
|
||||
args = {
|
||||
nest: false,
|
||||
@@ -1637,39 +1757,16 @@ export class MySQLClient extends BaseClient {
|
||||
};
|
||||
|
||||
if (!args.comments)
|
||||
sql = sql.replace(/(\/\*(.|[\r\n])*?\*\/)|(--(.*|[\r\n]))/gm, '');// Remove comments
|
||||
sql = removeComments(sql);
|
||||
|
||||
const nestTables = args.nest ? '.' : false;
|
||||
const resultsArr: antares.QueryResult[] = [];
|
||||
let paramsArr = [];
|
||||
const queries = args.split
|
||||
? sql.split(/((?:[^;'"]*(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*')[^;'"]*)+)|;/gm)
|
||||
.filter(Boolean)
|
||||
.map(q => q.trim())
|
||||
? this._querySplitter(sql, 'mysql')
|
||||
: [sql];
|
||||
|
||||
let connection: mysql.Connection | mysql.Pool | mysql.PoolConnection;
|
||||
const isPool = 'getConnection' in this._connection;
|
||||
|
||||
if (!args.autocommit && args.tabUid) { // autocommit OFF
|
||||
if (this._connectionsToCommit.has(args.tabUid))
|
||||
connection = this._connectionsToCommit.get(args.tabUid);
|
||||
else {
|
||||
connection = await this.getConnection();
|
||||
await connection.query('SET SESSION autocommit=0');
|
||||
this._connectionsToCommit.set(args.tabUid, connection);
|
||||
}
|
||||
}
|
||||
else// autocommit ON
|
||||
connection = isPool ? await (this._connection as mysql.Pool).getConnection() : this._connection;
|
||||
|
||||
if (args.tabUid && isPool) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
this._runningConnections.set(args.tabUid, (connection as any).connection.connectionId);
|
||||
}
|
||||
|
||||
if (args.schema)
|
||||
await connection.query(`USE \`${args.schema}\``);
|
||||
const connection = await this.getConnection(args);
|
||||
|
||||
for (const query of queries) {
|
||||
if (!query) continue;
|
||||
@@ -1682,9 +1779,10 @@ export class MySQLClient extends BaseClient {
|
||||
connection.query({ sql: query, nestTables }).then(async ([response, fields]) => {
|
||||
timeStop = new Date();
|
||||
const queryResult = response;
|
||||
const fieldsArr = fields ? Array.isArray(fields[0]) ? fields[0] : fields : false;// Some times fields are nested in an array
|
||||
|
||||
let remappedFields = fields
|
||||
? fields.map(field => {
|
||||
let remappedFields = fieldsArr
|
||||
? fieldsArr.map(field => {
|
||||
if (!field || Array.isArray(field))
|
||||
return undefined;
|
||||
|
||||
@@ -1729,7 +1827,7 @@ export class MySQLClient extends BaseClient {
|
||||
});
|
||||
}
|
||||
catch (err) {
|
||||
if (isPool && args.autocommit) {
|
||||
if (this.isPool && args.autocommit) {
|
||||
(connection as mysql.PoolConnection).release();
|
||||
this._runningConnections.delete(args.tabUid);
|
||||
}
|
||||
@@ -1741,7 +1839,7 @@ export class MySQLClient extends BaseClient {
|
||||
keysArr = keysArr ? [...keysArr, ...response] : response;
|
||||
}
|
||||
catch (err) {
|
||||
if (isPool && args.autocommit) {
|
||||
if (this.isPool && args.autocommit) {
|
||||
(connection as mysql.PoolConnection).release();
|
||||
this._runningConnections.delete(args.tabUid);
|
||||
}
|
||||
@@ -1753,13 +1851,13 @@ export class MySQLClient extends BaseClient {
|
||||
|
||||
resolve({
|
||||
duration: timeStop.getTime() - timeStart.getTime(),
|
||||
rows: Array.isArray(queryResult) ? queryResult.some(el => Array.isArray(el)) ? [] : queryResult : false,
|
||||
rows: Array.isArray(queryResult) ? queryResult.some(el => Array.isArray(el)) ? queryResult[0] : queryResult : false,
|
||||
report: !Array.isArray(queryResult) ? queryResult : false,
|
||||
fields: remappedFields,
|
||||
keys: keysArr
|
||||
});
|
||||
}).catch((err) => {
|
||||
if (isPool && args.autocommit) {
|
||||
if (this.isPool && args.autocommit) {
|
||||
(connection as mysql.PoolConnection).release();
|
||||
this._runningConnections.delete(args.tabUid);
|
||||
}
|
||||
@@ -1776,7 +1874,7 @@ export class MySQLClient extends BaseClient {
|
||||
});
|
||||
}
|
||||
|
||||
if (isPool && args.autocommit) {
|
||||
if (this.isPool && args.autocommit) {
|
||||
(connection as mysql.PoolConnection).release();
|
||||
this._runningConnections.delete(args.tabUid);
|
||||
}
|
||||
|
@@ -2,6 +2,7 @@ import SSH2Promise = require('@fabio286/ssh2-promise');
|
||||
import SSHConfig from '@fabio286/ssh2-promise/lib/sshConfig';
|
||||
import dataTypes from 'common/data-types/postgresql';
|
||||
import * as antares from 'common/interfaces/antares';
|
||||
import { removeComments } from 'common/libs/sqlUtils';
|
||||
import * as pg from 'pg';
|
||||
import * as pgAst from 'pgsql-ast-parser';
|
||||
import { ConnectionOptions } from 'tls';
|
||||
@@ -88,8 +89,8 @@ export class PostgreSQLClient extends BaseClient {
|
||||
private _keepaliveTimer: NodeJS.Timer;
|
||||
private _keepaliveMs: number;
|
||||
protected _connection?: pg.Client | pg.Pool;
|
||||
private types: {[key: string]: string} = {};
|
||||
private _arrayTypes: {[key: string]: string} = {
|
||||
private types: Record<string, string> = {};
|
||||
private _arrayTypes: Record<string, string> = {
|
||||
_int2: 'SMALLINT',
|
||||
_int4: 'INTEGER',
|
||||
_int8: 'BIGINT',
|
||||
@@ -155,6 +156,7 @@ export class PostgreSQLClient extends BaseClient {
|
||||
host: this._params.host,
|
||||
port: this._params.port,
|
||||
user: this._params.user,
|
||||
connectionString: this._params.connectionString,
|
||||
database: 'postgres' as string,
|
||||
password: this._params.password,
|
||||
ssl: null as ConnectionOptions
|
||||
@@ -168,6 +170,8 @@ export class PostgreSQLClient extends BaseClient {
|
||||
try {
|
||||
this._ssh = new SSH2Promise({
|
||||
...this._params.ssh,
|
||||
reconnect: true,
|
||||
reconnectTries: 3,
|
||||
debug: process.env.NODE_ENV !== 'production' ? (s) => console.log(s) : null
|
||||
});
|
||||
|
||||
@@ -176,7 +180,7 @@ export class PostgreSQLClient extends BaseClient {
|
||||
remotePort: this._params.port
|
||||
});
|
||||
|
||||
dbConfig.host = (this._ssh.config as SSHConfig[] & { host: string }).host;
|
||||
dbConfig.host = undefined;
|
||||
dbConfig.port = tunnel.localPort;
|
||||
}
|
||||
catch (err) {
|
||||
@@ -210,6 +214,10 @@ export class PostgreSQLClient extends BaseClient {
|
||||
if (this._params.readonly)
|
||||
await connection.query('SET SESSION CHARACTERISTICS AS TRANSACTION READ ONLY');
|
||||
|
||||
connection.on('error', err => { // Intercepts errors and converts to rejections
|
||||
Promise.reject(err);
|
||||
});
|
||||
|
||||
return connection;
|
||||
}
|
||||
|
||||
@@ -239,6 +247,10 @@ export class PostgreSQLClient extends BaseClient {
|
||||
return connection;
|
||||
}
|
||||
|
||||
ping () {
|
||||
return this.select('1+1').run();
|
||||
}
|
||||
|
||||
destroy () {
|
||||
this._connection.end();
|
||||
clearInterval(this._keepaliveTimer);
|
||||
@@ -331,6 +343,19 @@ export class PostgreSQLClient extends BaseClient {
|
||||
ORDER BY table_name
|
||||
`);
|
||||
|
||||
let { rows: matViews } = await this.raw<antares.QueryResult<ShowTableResult>>(`
|
||||
SELECT schemaname AS schema_name,
|
||||
matviewname AS table_name,
|
||||
matviewowner AS owner,
|
||||
ispopulated AS is_populated,
|
||||
definition,
|
||||
'materializedView' AS table_type
|
||||
FROM pg_matviews
|
||||
WHERE schemaname = '${db.database}'
|
||||
ORDER BY schema_name,
|
||||
table_name;
|
||||
`);
|
||||
|
||||
if (tables.length) {
|
||||
tables = tables.map(table => {
|
||||
table.Db = db.database;
|
||||
@@ -339,6 +364,14 @@ export class PostgreSQLClient extends BaseClient {
|
||||
tablesArr.push(...tables);
|
||||
}
|
||||
|
||||
if (matViews.length) {
|
||||
matViews = matViews.map(view => {
|
||||
view.Db = db.database;
|
||||
return view;
|
||||
});
|
||||
tablesArr.push(...matViews);
|
||||
}
|
||||
|
||||
let { rows: triggers } = await this.raw<antares.QueryResult<ShowTriggersResult>>(`
|
||||
SELECT
|
||||
pg_class.relname AS table_name,
|
||||
@@ -374,7 +407,11 @@ export class PostgreSQLClient extends BaseClient {
|
||||
|
||||
return {
|
||||
name: table.table_name,
|
||||
type: table.table_type === 'VIEW' ? 'view' : 'table',
|
||||
type: table.table_type === 'VIEW'
|
||||
? 'view'
|
||||
: table.table_type === 'materializedView'
|
||||
? 'materializedView'
|
||||
: 'table',
|
||||
rows: table.reltuples,
|
||||
size: tableSize,
|
||||
collation: table.Collation,
|
||||
@@ -430,7 +467,7 @@ export class PostgreSQLClient extends BaseClient {
|
||||
procedures: remappedProcedures,
|
||||
triggers: remappedTriggers,
|
||||
triggerFunctions: remappedTriggerFunctions,
|
||||
schedulers: []
|
||||
schedulers: [] as null[]
|
||||
};
|
||||
}
|
||||
else {
|
||||
@@ -465,16 +502,27 @@ export class PostgreSQLClient extends BaseClient {
|
||||
column_default: string;
|
||||
character_set_name: string;
|
||||
collation_name: string;
|
||||
column_comment: string;
|
||||
}
|
||||
/* eslint-enable camelcase */
|
||||
|
||||
const { rows } = await this
|
||||
.select('*')
|
||||
.schema('information_schema')
|
||||
.from('columns')
|
||||
.where({ table_schema: `= '${schema}'`, table_name: `= '${table}'` })
|
||||
.orderBy({ ordinal_position: 'ASC' })
|
||||
.run<TableColumnsResult>();
|
||||
// Table columns
|
||||
const { rows } = await this.raw<antares.QueryResult<TableColumnsResult>>(`
|
||||
WITH comments AS (
|
||||
SELECT attr.attname AS column, des.description AS comment, pgc.relname
|
||||
FROM pg_attribute AS attr, pg_description AS des, pg_class AS pgc
|
||||
WHERE pgc.oid = attr.attrelid
|
||||
AND des.objoid = pgc.oid
|
||||
AND pg_table_is_visible(pgc.oid)
|
||||
AND attr.attnum = des.objsubid
|
||||
)
|
||||
SELECT cols.*, comments.comment AS column_comment
|
||||
FROM "information_schema"."columns" AS cols
|
||||
LEFT JOIN comments ON comments.column = cols.column_name AND comments.relname = cols.table_name
|
||||
WHERE cols.table_schema = '${schema}'
|
||||
AND cols.table_name = '${table}'
|
||||
ORDER BY "ordinal_position" ASC
|
||||
`);
|
||||
|
||||
return rows.map(field => {
|
||||
let type = field.data_type;
|
||||
@@ -485,7 +533,7 @@ export class PostgreSQLClient extends BaseClient {
|
||||
|
||||
return {
|
||||
name: field.column_name,
|
||||
key: null,
|
||||
key: null as null,
|
||||
type: type.toUpperCase(),
|
||||
isArray,
|
||||
schema: field.table_schema,
|
||||
@@ -495,15 +543,15 @@ export class PostgreSQLClient extends BaseClient {
|
||||
datePrecision: field.datetime_precision,
|
||||
charLength: field.character_maximum_length,
|
||||
nullable: field.is_nullable.includes('YES'),
|
||||
unsigned: null,
|
||||
zerofill: null,
|
||||
unsigned: null as null,
|
||||
zerofill: null as null,
|
||||
order: field.ordinal_position,
|
||||
default: field.column_default,
|
||||
charset: field.character_set_name,
|
||||
collation: field.collation_name,
|
||||
autoIncrement: false,
|
||||
onUpdate: null,
|
||||
comment: ''
|
||||
onUpdate: null as null,
|
||||
comment: field.column_comment
|
||||
};
|
||||
});
|
||||
}
|
||||
@@ -562,8 +610,8 @@ export class PostgreSQLClient extends BaseClient {
|
||||
}
|
||||
/* eslint-enable camelcase */
|
||||
|
||||
if (schema !== 'public')
|
||||
await this.use(schema);
|
||||
// if (schema !== 'public')
|
||||
await this.use(schema);
|
||||
|
||||
const { rows } = await this.raw<antares.QueryResult<ShowIntexesResult>>(`WITH ndx_list AS (
|
||||
SELECT pg_index.indexrelid, pg_class.oid
|
||||
@@ -607,35 +655,7 @@ export class PostgreSQLClient extends BaseClient {
|
||||
}, {} as {table: string; schema: string}[]);
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
async getTableDll ({ schema, table }: { schema: string; table: string }) {
|
||||
// const { rows } = await this.raw<antares.QueryResult<{'ddl'?: string}>>(`
|
||||
// SELECT
|
||||
// 'CREATE TABLE ' || relname || E'\n(\n' ||
|
||||
// array_to_string(
|
||||
// array_agg(' ' || column_name || ' ' || type || ' '|| not_null)
|
||||
// , E',\n'
|
||||
// ) || E'\n);\n' AS ddl
|
||||
// FROM (
|
||||
// SELECT
|
||||
// a.attname AS column_name
|
||||
// , pg_catalog.format_type(a.atttypid, a.atttypmod) AS type
|
||||
// , CASE WHEN a.attnotnull THEN 'NOT NULL' ELSE 'NULL' END AS not_null
|
||||
// , c.relname
|
||||
// FROM pg_attribute a, pg_class c, pg_type t
|
||||
// WHERE a.attnum > 0
|
||||
// AND a.attrelid = c.oid
|
||||
// AND a.atttypid = t.oid
|
||||
// AND c.relname = '${table}'
|
||||
// ORDER BY a.attnum
|
||||
// ) AS tabledefinition
|
||||
// GROUP BY relname
|
||||
// `);
|
||||
|
||||
// if (rows.length)
|
||||
// return rows[0].ddl;
|
||||
// else return '';
|
||||
|
||||
/* eslint-disable camelcase */
|
||||
interface SequenceRecord {
|
||||
sequence_catalog: string;
|
||||
@@ -656,7 +676,7 @@ export class PostgreSQLClient extends BaseClient {
|
||||
let createSql = '';
|
||||
const sequences = [];
|
||||
const columnsSql = [];
|
||||
const arrayTypes: {[key: string]: string} = {
|
||||
const arrayTypes: Record<string, string> = {
|
||||
_int2: 'smallint',
|
||||
_int4: 'integer',
|
||||
_int8: 'bigint',
|
||||
@@ -677,6 +697,34 @@ export class PostgreSQLClient extends BaseClient {
|
||||
|
||||
if (!rows.length) return '';
|
||||
|
||||
const indexes = await this.getTableIndexes({ schema, table });
|
||||
const primaryKey = indexes
|
||||
.filter(i => i.type === 'PRIMARY')
|
||||
.reduce((acc, cur) => {
|
||||
if (!Object.keys(acc).length) {
|
||||
cur.column = `"${cur.column}"`;
|
||||
acc = cur;
|
||||
}
|
||||
else
|
||||
acc.column += `, "${cur.column}"`;
|
||||
return acc;
|
||||
}, {} as { name: string; column: string; type: string});
|
||||
|
||||
const remappedIndexes = indexes
|
||||
.filter(i => i.type !== 'PRIMARY')
|
||||
.reduce((acc, cur) => {
|
||||
const existingIndex = acc.findIndex(i => i.name === cur.name);
|
||||
|
||||
if (existingIndex >= 0)
|
||||
acc[existingIndex].column += `, "${cur.column}"`;
|
||||
else {
|
||||
cur.column = `"${cur.column}"`;
|
||||
acc.push(cur);
|
||||
}
|
||||
|
||||
return acc;
|
||||
}, [] as { name: string; column: string; type: string}[]);
|
||||
|
||||
for (const column of rows) {
|
||||
let fieldType = column.data_type;
|
||||
if (fieldType === 'USER-DEFINED') fieldType = `"${schema}".${column.udt_name}`;
|
||||
@@ -704,6 +752,9 @@ export class PostgreSQLClient extends BaseClient {
|
||||
columnsSql.push(columnArr.join(' '));
|
||||
}
|
||||
|
||||
if (primaryKey)
|
||||
columnsSql.push(`CONSTRAINT "${primaryKey.name}" PRIMARY KEY (${primaryKey.column})`);
|
||||
|
||||
// Table sequences
|
||||
for (let sequence of sequences) {
|
||||
if (sequence.includes('.')) sequence = sequence.split('.')[1];
|
||||
@@ -720,25 +771,22 @@ export class PostgreSQLClient extends BaseClient {
|
||||
INCREMENT BY ${rows[0].increment}
|
||||
MINVALUE ${rows[0].minimum_value}
|
||||
MAXVALUE ${rows[0].maximum_value}
|
||||
CACHE 1;\n`;
|
||||
CACHE 1;\n\n`;
|
||||
}
|
||||
}
|
||||
|
||||
// Table create
|
||||
createSql += `\nCREATE TABLE "${schema}"."${table}"(
|
||||
createSql += `CREATE TABLE "${schema}"."${table}"(
|
||||
${columnsSql.join(',\n ')}
|
||||
);\n`;
|
||||
|
||||
// Table indexes
|
||||
createSql += '\n';
|
||||
const { rows: indexes } = await this.select('*')
|
||||
.schema('pg_catalog')
|
||||
.from('pg_indexes')
|
||||
.where({ schemaname: `= '${schema}'`, tablename: `= '${table}'` })
|
||||
.run<{indexdef: string}>();
|
||||
|
||||
for (const index of indexes)
|
||||
createSql += `${index.indexdef};\n`;
|
||||
for (const index of remappedIndexes) {
|
||||
if (index.type !== 'PRIMARY')
|
||||
createSql += `CREATE ${index.type}${index.type === 'UNIQUE' ? ' INDEX' : ''} "${index.name}" ON "${schema}"."${table}" (${index.column});\n`;
|
||||
}
|
||||
|
||||
return createSql;
|
||||
}
|
||||
@@ -840,6 +888,7 @@ export class PostgreSQLClient extends BaseClient {
|
||||
const newIndexes: string[] = [];
|
||||
const manageIndexes: string[] = [];
|
||||
const newForeigns: string[] = [];
|
||||
const modifyComment: string[] = [];
|
||||
|
||||
let sql = `CREATE TABLE "${schema}"."${options.name}"`;
|
||||
|
||||
@@ -855,6 +904,8 @@ export class PostgreSQLClient extends BaseClient {
|
||||
${field.nullable ? 'NULL' : 'NOT NULL'}
|
||||
${field.default !== null ? `DEFAULT ${field.default || '\'\''}` : ''}
|
||||
${field.onUpdate ? `ON UPDATE ${field.onUpdate}` : ''}`);
|
||||
if (field.comment != null)
|
||||
modifyComment.push(`COMMENT ON COLUMN "${schema}"."${options.name}"."${field.name}" IS '${field.comment}'`);
|
||||
});
|
||||
|
||||
// ADD INDEX
|
||||
@@ -875,8 +926,12 @@ export class PostgreSQLClient extends BaseClient {
|
||||
newForeigns.push(`CONSTRAINT "${foreign.constraintName}" FOREIGN KEY ("${foreign.field}") REFERENCES "${schema}"."${foreign.refTable}" ("${foreign.refField}") ON UPDATE ${foreign.onUpdate} ON DELETE ${foreign.onDelete}`);
|
||||
});
|
||||
|
||||
sql = `${sql} (${[...newColumns, ...newIndexes, ...newForeigns].join(', ')})`;
|
||||
if (manageIndexes.length) sql = `${sql}; ${manageIndexes.join(';')}`;
|
||||
sql = `${sql} (${[...newColumns, ...newIndexes, ...newForeigns].join(', ')}); `;
|
||||
if (manageIndexes.length) sql = `${sql} ${manageIndexes.join(';')}; `;
|
||||
// TABLE COMMENT
|
||||
if (options.comment != null) sql = `${sql} COMMENT ON TABLE "${schema}"."${options.name}" IS '${options.comment}'; `;
|
||||
// FIELDS COMMENT
|
||||
if (modifyComment.length) sql = `${sql} ${modifyComment.join(';')}; `;
|
||||
|
||||
return await this.raw(sql);
|
||||
}
|
||||
@@ -901,6 +956,7 @@ export class PostgreSQLClient extends BaseClient {
|
||||
const renameColumns: string[] = [];
|
||||
const createSequences: string[] = [];
|
||||
const manageIndexes: string[] = [];
|
||||
const modifyComment: string[] = [];
|
||||
|
||||
// ADD FIELDS
|
||||
additions.forEach(addition => {
|
||||
@@ -914,6 +970,8 @@ export class PostgreSQLClient extends BaseClient {
|
||||
${addition.nullable ? 'NULL' : 'NOT NULL'}
|
||||
${addition.default !== null ? `DEFAULT ${addition.default || '\'\''}` : ''}
|
||||
${addition.onUpdate ? `ON UPDATE ${addition.onUpdate}` : ''}`);
|
||||
if (addition.comment != null)
|
||||
modifyComment.push(`COMMENT ON COLUMN "${schema}"."${table}"."${addition.name}" IS '${addition.comment}'`);
|
||||
});
|
||||
|
||||
// ADD INDEX
|
||||
@@ -966,6 +1024,8 @@ export class PostgreSQLClient extends BaseClient {
|
||||
|
||||
if (change.orgName !== change.name)
|
||||
renameColumns.push(`ALTER TABLE "${schema}"."${table}" RENAME COLUMN "${change.orgName}" TO "${change.name}"`);
|
||||
if (change.comment != null)
|
||||
modifyComment.push(`COMMENT ON COLUMN "${schema}"."${table}"."${change.name}" IS '${change.comment}'`);
|
||||
});
|
||||
|
||||
// CHANGE INDEX
|
||||
@@ -1013,8 +1073,11 @@ export class PostgreSQLClient extends BaseClient {
|
||||
if (alterColumns.length) sql += `ALTER TABLE "${schema}"."${table}" ${alterColumns.join(', ')}; `;
|
||||
if (createSequences.length) sql = `${createSequences.join(';')}; ${sql}`;
|
||||
if (manageIndexes.length) sql = `${manageIndexes.join(';')}; ${sql}`;
|
||||
// TABLE COMMENT
|
||||
if (options.comment != null) sql = `${sql} COMMENT ON TABLE "${schema}"."${table}" IS '${options.comment}'; `;
|
||||
// FIELDS COMMENT
|
||||
if (modifyComment.length) sql = `${sql} ${modifyComment.join(';')}; `;
|
||||
if (options.name) sql += `ALTER TABLE "${schema}"."${table}" RENAME TO "${options.name}"; `;
|
||||
|
||||
// RENAME
|
||||
if (renameColumns.length) sql = `${renameColumns.join(';')}; ${sql}`;
|
||||
|
||||
@@ -1052,11 +1115,32 @@ export class PostgreSQLClient extends BaseClient {
|
||||
})[0];
|
||||
}
|
||||
|
||||
async getMaterializedViewInformations ({ schema, view }: { schema: string; view: string }) {
|
||||
const sql = `SELECT "definition" FROM "pg_matviews" WHERE "matviewname"='${view}' AND "schemaname"='${schema}'`;
|
||||
const results = await this.raw(sql);
|
||||
|
||||
return results.rows.map(row => {
|
||||
return {
|
||||
algorithm: '',
|
||||
definer: '',
|
||||
security: '',
|
||||
updateOption: '',
|
||||
sql: row.definition,
|
||||
name: view
|
||||
};
|
||||
})[0];
|
||||
}
|
||||
|
||||
async dropView (params: { schema: string; view: string }) {
|
||||
const sql = `DROP VIEW "${params.schema}"."${params.view}"`;
|
||||
return await this.raw(sql);
|
||||
}
|
||||
|
||||
async dropMaterializedView (params: { schema: string; view: string }) {
|
||||
const sql = `DROP MATERIALIZED VIEW "${params.schema}"."${params.view}"`;
|
||||
return await this.raw(sql);
|
||||
}
|
||||
|
||||
async alterView ({ view }: { view: antares.AlterViewParams }) {
|
||||
let sql = `CREATE OR REPLACE VIEW "${view.schema}"."${view.oldName}" AS ${view.sql}`;
|
||||
|
||||
@@ -1066,11 +1150,25 @@ export class PostgreSQLClient extends BaseClient {
|
||||
return await this.raw(sql);
|
||||
}
|
||||
|
||||
async alterMaterializedView ({ view }: { view: antares.AlterViewParams }) {
|
||||
let sql = `CREATE OR REPLACE MATERIALIZED VIEW "${view.schema}"."${view.oldName}" AS ${view.sql}`;
|
||||
|
||||
if (view.name !== view.oldName)
|
||||
sql += `; ALTER VIEW "${view.schema}"."${view.oldName}" RENAME TO "${view.name}"`;
|
||||
|
||||
return await this.raw(sql);
|
||||
}
|
||||
|
||||
async createView (params: antares.CreateViewParams) {
|
||||
const sql = `CREATE VIEW "${params.schema}"."${params.name}" AS ${params.sql}`;
|
||||
return await this.raw(sql);
|
||||
}
|
||||
|
||||
async createMaterializedView (params: antares.CreateViewParams) {
|
||||
const sql = `CREATE MATERIALIZED VIEW "${params.schema}"."${params.name}" AS ${params.sql}`;
|
||||
return await this.raw(sql);
|
||||
}
|
||||
|
||||
async getTriggerInformations ({ schema, trigger }: { schema: string; trigger: string }) {
|
||||
const [table, triggerName] = trigger.split('.');
|
||||
|
||||
@@ -1155,9 +1253,9 @@ export class PostgreSQLClient extends BaseClient {
|
||||
return results.rows.map(async row => {
|
||||
if (!row.pg_get_functiondef) {
|
||||
return {
|
||||
definer: null,
|
||||
definer: null as null,
|
||||
sql: '',
|
||||
parameters: [],
|
||||
parameters: [] as null[],
|
||||
name: routine,
|
||||
comment: '',
|
||||
security: 'DEFINER',
|
||||
@@ -1206,8 +1304,8 @@ export class PostgreSQLClient extends BaseClient {
|
||||
name: routine,
|
||||
comment: '',
|
||||
security: row.pg_get_functiondef.includes('SECURITY DEFINER') ? 'DEFINER' : 'INVOKER',
|
||||
deterministic: null,
|
||||
dataAccess: null,
|
||||
deterministic: null as null,
|
||||
dataAccess: null as null,
|
||||
language: row.pg_get_functiondef.match(/(?<=LANGUAGE )(.*)(?<=[\S+\n\r\s])/gm)[0]
|
||||
};
|
||||
})[0];
|
||||
@@ -1271,9 +1369,9 @@ export class PostgreSQLClient extends BaseClient {
|
||||
return results.rows.map(async row => {
|
||||
if (!row.pg_get_functiondef) {
|
||||
return {
|
||||
definer: null,
|
||||
definer: null as null,
|
||||
sql: '',
|
||||
parameters: [],
|
||||
parameters: [] as null[],
|
||||
name: func,
|
||||
comment: '',
|
||||
security: 'DEFINER',
|
||||
@@ -1321,8 +1419,8 @@ export class PostgreSQLClient extends BaseClient {
|
||||
name: func,
|
||||
comment: '',
|
||||
security: row.pg_get_functiondef.includes('SECURITY DEFINER') ? 'DEFINER' : 'INVOKER',
|
||||
deterministic: null,
|
||||
dataAccess: null,
|
||||
deterministic: null as null,
|
||||
dataAccess: null as null,
|
||||
language: row.pg_get_functiondef.match(/(?<=LANGUAGE )(.*)(?<=[\S+\n\r\s])/gm)[0],
|
||||
returns: row.pg_get_functiondef.match(/(?<=RETURNS )(.*)(?<=[\S+\n\r\s])/gm)[0].replace('SETOF ', '').toUpperCase()
|
||||
};
|
||||
@@ -1551,7 +1649,7 @@ export class PostgreSQLClient extends BaseClient {
|
||||
}
|
||||
|
||||
async raw<T = antares.QueryResult> (sql: string, args?: antares.QueryParams) {
|
||||
this._logger({ cUid: this._cUid, sql });
|
||||
this._logger({ cUid: this._cUid, content: sql, level: 'query' });
|
||||
|
||||
args = {
|
||||
nest: false,
|
||||
@@ -1563,14 +1661,12 @@ export class PostgreSQLClient extends BaseClient {
|
||||
};
|
||||
|
||||
if (!args.comments)
|
||||
sql = sql.replace(/(\/\*(.|[\r\n])*?\*\/)|(--(.*|[\r\n]))/gm, '');// Remove comments
|
||||
sql = removeComments(sql);
|
||||
|
||||
const resultsArr: antares.QueryResult[] = [];
|
||||
let paramsArr = [];
|
||||
const queries = args.split
|
||||
? sql.split(/(?!\B'[^']*);(?![^']*'\B)/gm)
|
||||
.filter(Boolean)
|
||||
.map(q => q.trim())
|
||||
? this._querySplitter(sql, 'pg')
|
||||
: [sql];
|
||||
|
||||
let connection: pg.Client | pg.PoolClient;
|
||||
|
@@ -2,6 +2,7 @@ import * as sqlite from 'better-sqlite3';
|
||||
import dataTypes from 'common/data-types/sqlite';
|
||||
import { DATETIME, FLOAT, NUMBER, TIME } from 'common/fieldTypes';
|
||||
import * as antares from 'common/interfaces/antares';
|
||||
import { removeComments } from 'common/libs/sqlUtils';
|
||||
|
||||
import { BaseClient } from './BaseClient';
|
||||
|
||||
@@ -35,6 +36,10 @@ export class SQLiteClient extends BaseClient {
|
||||
});
|
||||
}
|
||||
|
||||
ping () {
|
||||
return this.select('1+1').run();
|
||||
}
|
||||
|
||||
destroy () {
|
||||
this._connection.close();
|
||||
}
|
||||
@@ -120,10 +125,10 @@ export class SQLiteClient extends BaseClient {
|
||||
name: db.name,
|
||||
size: schemaSize,
|
||||
tables: remappedTables,
|
||||
functions: [],
|
||||
procedures: [],
|
||||
functions: [] as null[],
|
||||
procedures: [] as null[],
|
||||
triggers: remappedTriggers,
|
||||
schedulers: []
|
||||
schedulers: [] as null[]
|
||||
};
|
||||
}
|
||||
else {
|
||||
@@ -162,22 +167,22 @@ export class SQLiteClient extends BaseClient {
|
||||
|
||||
return {
|
||||
name: field.name,
|
||||
key: null,
|
||||
key: null as null,
|
||||
type: type.trim(),
|
||||
schema: schema,
|
||||
table: table,
|
||||
numPrecision: [...NUMBER, ...FLOAT].includes(type) ? length : null,
|
||||
datePrecision: null,
|
||||
numLength: [...NUMBER, ...FLOAT].includes(type) ? length : null,
|
||||
datePrecision: null as null,
|
||||
charLength: ![...NUMBER, ...FLOAT].includes(type) ? length : null,
|
||||
nullable: !field.notnull,
|
||||
unsigned: null,
|
||||
zerofill: null,
|
||||
unsigned: null as null,
|
||||
zerofill: null as null,
|
||||
order: typeof field.cid === 'string' ? +field.cid + 1 : field.cid + 1,
|
||||
default: field.dflt_value,
|
||||
charset: null,
|
||||
collation: null,
|
||||
charset: null as null,
|
||||
collation: null as null,
|
||||
autoIncrement: false,
|
||||
onUpdate: null,
|
||||
onUpdate: null as null,
|
||||
comment: ''
|
||||
};
|
||||
});
|
||||
@@ -263,7 +268,7 @@ export class SQLiteClient extends BaseClient {
|
||||
table: table,
|
||||
field: field.from,
|
||||
position: field.id + 1,
|
||||
constraintPosition: null,
|
||||
constraintPosition: null as null,
|
||||
constraintName: field.id,
|
||||
refSchema: schema,
|
||||
refTable: field.table,
|
||||
@@ -608,7 +613,7 @@ export class SQLiteClient extends BaseClient {
|
||||
}
|
||||
|
||||
async raw<T = antares.QueryResult> (sql: string, args?: antares.QueryParams) {
|
||||
this._logger({ cUid: this._cUid, sql });// TODO: replace BLOB content with a placeholder
|
||||
this._logger({ cUid: this._cUid, content: sql, level: 'query' });// TODO: replace BLOB content with a placeholder
|
||||
|
||||
args = {
|
||||
nest: false,
|
||||
@@ -620,14 +625,12 @@ export class SQLiteClient extends BaseClient {
|
||||
};
|
||||
|
||||
if (!args.comments)
|
||||
sql = sql.replace(/(\/\*(.|[\r\n])*?\*\/)|(--(.*|[\r\n]))/gm, '');// Remove comments
|
||||
sql = removeComments(sql);
|
||||
|
||||
const resultsArr = [];
|
||||
let paramsArr = [];
|
||||
const queries = args.split
|
||||
? sql.split(/((?:[^;'"]*(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*')[^;'"]*)+)|;/gm)
|
||||
.filter(Boolean)
|
||||
.map(q => q.trim())
|
||||
? this._querySplitter(sql, 'sqlite')
|
||||
: [sql];
|
||||
|
||||
let connection: sqlite.Database;
|
||||
@@ -658,7 +661,7 @@ export class SQLiteClient extends BaseClient {
|
||||
let queryAllResult: any[];
|
||||
let affectedRows;
|
||||
let fields;
|
||||
const detectedTypes: {[key: string]: string} = {};
|
||||
const detectedTypes: Record<string, string> = {};
|
||||
|
||||
try {
|
||||
const stmt = connection.prepare(query);
|
||||
|
@@ -336,7 +336,8 @@ CREATE TABLE \`${view.Name}\`(
|
||||
const connection = await this._client.getConnection();
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const stream = (connection as any).connection.query(sql).stream();
|
||||
const dispose = () => connection.end();
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const dispose = () => (connection as any).release();
|
||||
|
||||
stream.on('end', dispose);
|
||||
stream.on('error', dispose);
|
||||
@@ -354,7 +355,7 @@ CREATE TABLE \`${view.Name}\`(
|
||||
escapeAndQuote (val: string) {
|
||||
// eslint-disable-next-line no-control-regex
|
||||
const CHARS_TO_ESCAPE = /[\0\b\t\n\r\x1a"'\\]/g;
|
||||
const CHARS_ESCAPE_MAP: {[key: string]: string} = {
|
||||
const CHARS_ESCAPE_MAP: Record<string, string> = {
|
||||
'\0': '\\0',
|
||||
'\b': '\\b',
|
||||
'\t': '\\t',
|
||||
|
@@ -39,115 +39,7 @@ SET row_security = off;\n\n\n`;
|
||||
}
|
||||
|
||||
async getCreateTable (tableName: string) {
|
||||
/* eslint-disable camelcase */
|
||||
interface SequenceRecord {
|
||||
sequence_catalog: string;
|
||||
sequence_schema: string;
|
||||
sequence_name: string;
|
||||
data_type: string;
|
||||
numeric_precision: number;
|
||||
numeric_precision_radix: number;
|
||||
numeric_scale: number;
|
||||
start_value: string;
|
||||
minimum_value: string;
|
||||
maximum_value: string;
|
||||
increment: string;
|
||||
cycle_option: string;
|
||||
}
|
||||
/* eslint-enable camelcase */
|
||||
|
||||
let createSql = '';
|
||||
const sequences = [];
|
||||
const columnsSql = [];
|
||||
const arrayTypes: {[key: string]: string} = {
|
||||
_int2: 'smallint',
|
||||
_int4: 'integer',
|
||||
_int8: 'bigint',
|
||||
_float4: 'real',
|
||||
_float8: 'double precision',
|
||||
_char: '"char"',
|
||||
_varchar: 'character varying'
|
||||
};
|
||||
|
||||
// Table columns
|
||||
const { rows } = await this._client.raw(`
|
||||
SELECT *
|
||||
FROM "information_schema"."columns"
|
||||
WHERE "table_schema" = '${this.schemaName}'
|
||||
AND "table_name" = '${tableName}'
|
||||
ORDER BY "ordinal_position" ASC
|
||||
`, { schema: 'information_schema' });
|
||||
|
||||
if (!rows.length) return '';
|
||||
|
||||
for (const column of rows) {
|
||||
let fieldType = column.data_type;
|
||||
if (fieldType === 'USER-DEFINED') fieldType = `"${this.schemaName}".${column.udt_name}`;
|
||||
else if (fieldType === 'ARRAY') {
|
||||
if (Object.keys(arrayTypes).includes(fieldType))
|
||||
fieldType = arrayTypes[column.udt_name] + '[]';
|
||||
else
|
||||
fieldType = column.udt_name.replaceAll('_', '') + '[]';
|
||||
}
|
||||
|
||||
const columnArr = [
|
||||
`"${column.column_name}"`,
|
||||
`${fieldType}${column.character_maximum_length ? `(${column.character_maximum_length})` : ''}`
|
||||
];
|
||||
|
||||
if (column.column_default) {
|
||||
columnArr.push(`DEFAULT ${column.column_default}`);
|
||||
if (column.column_default.includes('nextval')) {
|
||||
const sequenceName = column.column_default.split('\'')[1];
|
||||
sequences.push(sequenceName);
|
||||
}
|
||||
}
|
||||
if (column.is_nullable === 'NO') columnArr.push('NOT NULL');
|
||||
|
||||
columnsSql.push(columnArr.join(' '));
|
||||
}
|
||||
|
||||
// Table sequences
|
||||
for (let sequence of sequences) {
|
||||
if (sequence.includes('.')) sequence = sequence.split('.')[1];
|
||||
|
||||
const { rows } = await this._client
|
||||
.select('*')
|
||||
.schema('information_schema')
|
||||
.from('sequences')
|
||||
.where({ sequence_schema: `= '${this.schemaName}'`, sequence_name: `= '${sequence}'` })
|
||||
.run<SequenceRecord>();
|
||||
|
||||
if (rows.length) {
|
||||
createSql += `CREATE SEQUENCE "${this.schemaName}"."${sequence}"
|
||||
START WITH ${rows[0].start_value}
|
||||
INCREMENT BY ${rows[0].increment}
|
||||
MINVALUE ${rows[0].minimum_value}
|
||||
MAXVALUE ${rows[0].maximum_value}
|
||||
CACHE 1;\n`;
|
||||
|
||||
// createSql += `\nALTER TABLE "${sequence}" OWNER TO ${this._client._params.user};\n\n`;
|
||||
}
|
||||
}
|
||||
|
||||
// Table create
|
||||
createSql += `\nCREATE TABLE "${this.schemaName}"."${tableName}"(
|
||||
${columnsSql.join(',\n ')}
|
||||
);\n`;
|
||||
|
||||
// createSql += `\nALTER TABLE "${tableName}" OWNER TO ${this._client._params.user};\n\n`;
|
||||
|
||||
// Table indexes
|
||||
createSql += '\n';
|
||||
const { rows: indexes } = await this._client
|
||||
.select('*')
|
||||
.schema('pg_catalog')
|
||||
.from('pg_indexes')
|
||||
.where({ schemaname: `= '${this.schemaName}'`, tablename: `= '${tableName}'` })
|
||||
.run<{indexdef: string}>();
|
||||
|
||||
for (const index of indexes)
|
||||
createSql += `${index.indexdef};\n`;
|
||||
const createSql = await this._client.getTableDll({ schema: this.schemaName, table: tableName });
|
||||
|
||||
// Table foreigns
|
||||
const { rows: foreigns } = await this._client.raw(`
|
||||
@@ -440,7 +332,7 @@ SET row_security = off;\n\n\n`;
|
||||
escapeAndQuote (val: string) {
|
||||
// eslint-disable-next-line no-control-regex
|
||||
const CHARS_TO_ESCAPE = /[\0\b\t\n\r\x1a"'\\]/g;
|
||||
const CHARS_ESCAPE_MAP: {[key: string]: string} = {
|
||||
const CHARS_ESCAPE_MAP: Record<string, string> = {
|
||||
'\0': '\\0',
|
||||
'\b': '\\b',
|
||||
'\t': '\\t',
|
||||
|
20
src/main/libs/misc/ipcLogger.ts
Normal file
20
src/main/libs/misc/ipcLogger.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
export type LoggerLevel = 'query' | 'error'
|
||||
|
||||
export const ipcLogger = ({ content, cUid, level }: {content: string; cUid: string; level: LoggerLevel}) => {
|
||||
if (level === 'error') {
|
||||
if (process.type !== undefined) {
|
||||
const mainWindow = require('electron').webContents.fromId(1);
|
||||
mainWindow.send('non-blocking-exception', { cUid, message: content, date: new Date() });
|
||||
}
|
||||
if (process.env.NODE_ENV === 'development' && process.type === 'browser') console.log(content);
|
||||
}
|
||||
else if (level === 'query') {
|
||||
// Remove comments, newlines and multiple spaces
|
||||
const escapedSql = content.replace(/(\/\*(.|[\r\n])*?\*\/)|(--(.*|[\r\n]))/gm, '').replace(/\s\s+/g, ' ');
|
||||
if (process.type !== undefined) {
|
||||
const mainWindow = require('electron').webContents.fromId(1);
|
||||
mainWindow.send('query-log', { cUid, sql: escapedSql, date: new Date() });
|
||||
}
|
||||
if (process.env.NODE_ENV === 'development' && process.type === 'browser') console.log(escapedSql);
|
||||
}
|
||||
};
|
@@ -43,7 +43,8 @@ async function createMainWindow () {
|
||||
spellcheck: false
|
||||
},
|
||||
autoHideMenuBar: true,
|
||||
titleBarStyle: isLinux ? 'default' :'hidden',
|
||||
frame: !isLinux,
|
||||
titleBarStyle: 'hidden',
|
||||
titleBarOverlay: isWindows
|
||||
? {
|
||||
color: appTheme === 'dark' ? '#3f3f3f' : '#fff',
|
||||
@@ -127,15 +128,25 @@ app.on('ready', async () => {
|
||||
if (isWindows)
|
||||
mainWindow.show();
|
||||
|
||||
// if (isDevelopment)
|
||||
// if (isDevelopment && !isWindows)
|
||||
// mainWindow.webContents.openDevTools();
|
||||
|
||||
process.on('uncaughtException', error => {
|
||||
mainWindow.webContents.send('unhandled-exception', error);
|
||||
if (error instanceof AggregateError) {
|
||||
for (const e of error.errors)
|
||||
mainWindow.webContents.send('unhandled-exception', e);
|
||||
}
|
||||
else
|
||||
mainWindow.webContents.send('unhandled-exception', error);
|
||||
});
|
||||
|
||||
process.on('unhandledRejection', error => {
|
||||
mainWindow.webContents.send('unhandled-exception', error);
|
||||
if (error instanceof AggregateError) {
|
||||
for (const e of error.errors)
|
||||
mainWindow.webContents.send('unhandled-exception', e);
|
||||
}
|
||||
else
|
||||
mainWindow.webContents.send('unhandled-exception', error);
|
||||
});
|
||||
});
|
||||
|
||||
|
@@ -10,9 +10,7 @@
|
||||
:key="connection.uid"
|
||||
:connection="connection"
|
||||
/>
|
||||
<div class="connection-panel-wrapper p-relative">
|
||||
<WorkspaceAddConnectionPanel v-if="selectedWorkspace === 'NEW'" />
|
||||
</div>
|
||||
<WorkspaceAddConnectionPanel v-if="selectedWorkspace === 'NEW'" />
|
||||
</div>
|
||||
<TheFooter />
|
||||
<TheNotificationsBoard />
|
||||
@@ -48,6 +46,8 @@ import { useSchemaExportStore } from '@/stores/schemaExport';
|
||||
import { useSettingsStore } from '@/stores/settings';
|
||||
import { useWorkspacesStore } from '@/stores/workspaces';
|
||||
|
||||
import { useConsoleStore } from './stores/console';
|
||||
|
||||
const { t } = useI18n();
|
||||
|
||||
const TheTitleBar = defineAsyncComponent(() => import(/* webpackChunkName: "TheTitleBar" */'@/components/TheTitleBar.vue'));
|
||||
@@ -80,6 +80,8 @@ const schemaExportStore = useSchemaExportStore();
|
||||
const { hideExportModal } = schemaExportStore;
|
||||
const { isExportModal: isExportSchemaModal } = storeToRefs(schemaExportStore);
|
||||
|
||||
const consoleStore = useConsoleStore();
|
||||
|
||||
const isAllConnectionsModal: Ref<boolean> = ref(false);
|
||||
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
@@ -139,8 +141,11 @@ onMounted(() => {
|
||||
|
||||
while (node) {
|
||||
if (node.nodeName.match(/^(input|textarea)$/i) || node.isContentEditable) {
|
||||
InputMenu.popup({ window: getCurrentWindow() });
|
||||
break;
|
||||
if (!node.parentNode.className.split(' ').includes('editor-query')) {
|
||||
InputMenu.popup({ window: getCurrentWindow() });
|
||||
console.log(node.parentNode.className);
|
||||
break;
|
||||
}
|
||||
}
|
||||
node = node.parentNode;
|
||||
}
|
||||
@@ -152,6 +157,60 @@ onMounted(() => {
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Console messages
|
||||
const oldLog = console.log;
|
||||
const oldWarn = console.warn;
|
||||
const oldInfo = console.info;
|
||||
const oldError = console.error;
|
||||
|
||||
console.log = function (...args) {
|
||||
consoleStore.putLog('debug', {
|
||||
level: 'log',
|
||||
process: 'renderer',
|
||||
message: args.join(' '),
|
||||
date: new Date()
|
||||
});
|
||||
oldLog.apply(this, args);
|
||||
};
|
||||
|
||||
console.info = function (...args) {
|
||||
consoleStore.putLog('debug', {
|
||||
level: 'info',
|
||||
process: 'renderer',
|
||||
message: args.join(' '),
|
||||
date: new Date()
|
||||
});
|
||||
oldInfo.apply(this, args);
|
||||
};
|
||||
|
||||
console.warn = function (...args) {
|
||||
consoleStore.putLog('debug', {
|
||||
level: 'warn',
|
||||
process: 'renderer',
|
||||
message: args.join(' '),
|
||||
date: new Date()
|
||||
});
|
||||
oldWarn.apply(this, args);
|
||||
};
|
||||
|
||||
console.error = function (...args) {
|
||||
consoleStore.putLog('debug', {
|
||||
level: 'error',
|
||||
process: 'renderer',
|
||||
message: args.join(' '),
|
||||
date: new Date()
|
||||
});
|
||||
oldError.apply(this, args);
|
||||
};
|
||||
|
||||
window.addEventListener('unhandledrejection', (event) => {
|
||||
console.error(event.reason);
|
||||
});
|
||||
|
||||
window.addEventListener('error', (event) => {
|
||||
console.error(event.error, '| File name:', event.filename.split('/').pop().split('?')[0]);
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
|
@@ -56,8 +56,8 @@ const { t } = useI18n();
|
||||
|
||||
const props = defineProps({
|
||||
size: {
|
||||
type: String as PropType<'small' | 'medium' | '400' | 'large'>,
|
||||
validator: (prop: string) => ['small', 'medium', '400', 'large'].includes(prop),
|
||||
type: String as PropType<'small' | 'medium' | '400' | 'large' | 'resize'>,
|
||||
validator: (prop: string) => ['small', 'medium', '400', 'large', 'resize'].includes(prop),
|
||||
default: 'small'
|
||||
},
|
||||
hideFooter: {
|
||||
@@ -88,6 +88,8 @@ const modalSizeClass = computed(() => {
|
||||
return 'modal-sm';
|
||||
if (props.size === '400')
|
||||
return 'modal-400';
|
||||
if (props.size === 'resize')
|
||||
return 'modal-resize';
|
||||
else if (props.size === 'large')
|
||||
return 'modal-lg';
|
||||
else return '';
|
||||
@@ -120,6 +122,12 @@ onBeforeUnmount(() => {
|
||||
max-width: 400px;
|
||||
}
|
||||
|
||||
.modal-resize .modal-container {
|
||||
max-width: 95vw;
|
||||
max-height: 95vh;
|
||||
width: auto;
|
||||
}
|
||||
|
||||
.modal.modal-sm .modal-container {
|
||||
padding: 0;
|
||||
}
|
||||
|
@@ -1,11 +1,19 @@
|
||||
<template>
|
||||
<SvgIcon
|
||||
v-if="type === 'mdi'"
|
||||
:type="type"
|
||||
:path="iconPath"
|
||||
:size="size"
|
||||
:rotate="rotate"
|
||||
:class="iconFlip"
|
||||
/>
|
||||
<svg
|
||||
v-else
|
||||
:width="size"
|
||||
:height="size"
|
||||
:viewBox="`0 0 ${size} ${size}`"
|
||||
v-html="iconPath"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
@@ -13,6 +21,10 @@ import SvgIcon from '@jamescoyle/vue-icon';
|
||||
import * as Icons from '@mdi/js';
|
||||
import { computed, PropType } from 'vue';
|
||||
|
||||
import { useConnectionsStore } from '@/stores/connections';
|
||||
|
||||
const { getIconByUid } = useConnectionsStore();
|
||||
|
||||
const props = defineProps({
|
||||
iconName: {
|
||||
type: String,
|
||||
@@ -23,21 +35,31 @@ const props = defineProps({
|
||||
default: 48
|
||||
},
|
||||
type: {
|
||||
type: String,
|
||||
type: String as PropType<'mdi' | 'custom'>,
|
||||
default: () => 'mdi'
|
||||
},
|
||||
flip: {
|
||||
type: String as PropType<'horizontal' | 'vertical' | 'both'>,
|
||||
type: String as PropType<'horizontal' | 'vertical' | 'both' | null>,
|
||||
default: () => null
|
||||
},
|
||||
rotate: {
|
||||
type: Number,
|
||||
type: Number as PropType<number | null>,
|
||||
default: () => null
|
||||
}
|
||||
});
|
||||
|
||||
const iconPath = computed(() => {
|
||||
return (Icons as {[k:string]: string})[props.iconName];
|
||||
if (props.type === 'mdi')
|
||||
return (Icons as {[k:string]: string})[props.iconName];
|
||||
else if (props.type === 'custom') {
|
||||
const base64 = getIconByUid(props.iconName)?.base64;
|
||||
const svgString = Buffer
|
||||
.from(base64, 'base64')
|
||||
.toString('utf-8');
|
||||
|
||||
return svgString;
|
||||
}
|
||||
return null;
|
||||
});
|
||||
|
||||
const iconFlip = computed(() => {
|
||||
|
@@ -99,7 +99,7 @@ onMounted(() => {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
background: $primary-color;
|
||||
background: var(--primary-color);
|
||||
border-radius: 50%;
|
||||
box-shadow: 0 0 5px 1px darken($body-font-color-dark, 40%);
|
||||
}
|
||||
|
@@ -365,7 +365,11 @@ export default defineComponent({
|
||||
};
|
||||
|
||||
const handleWheelEvent = (e) => {
|
||||
if (!e.target.className.includes('select__')) deactivate();
|
||||
try {
|
||||
if (!e.target.className.includes('select__')) deactivate();
|
||||
}
|
||||
catch (_) {
|
||||
}
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
|
@@ -4,7 +4,11 @@
|
||||
:id="`editor-${id}`"
|
||||
class="editor"
|
||||
:class="editorClass"
|
||||
:style="{height: `${height}px`}"
|
||||
:style="{
|
||||
height: `${height}px`,
|
||||
width: width ? `${width}px` : null,
|
||||
resize: resizable ? 'both' : 'none'
|
||||
}"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
@@ -17,7 +21,7 @@ import 'ace-builds/webpack-resolver';
|
||||
|
||||
import { uidGen } from 'common/libs/uidGen';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { onMounted, watch } from 'vue';
|
||||
import { PropType, onMounted, watch } from 'vue';
|
||||
|
||||
import { useSettingsStore } from '@/stores/settings';
|
||||
|
||||
@@ -25,10 +29,12 @@ const props = defineProps({
|
||||
modelValue: String,
|
||||
mode: { type: String, default: 'text' },
|
||||
editorClass: { type: String, default: '' },
|
||||
resizable: { type: Boolean, default: false },
|
||||
autoFocus: { type: Boolean, default: false },
|
||||
readOnly: { type: Boolean, default: false },
|
||||
showLineNumbers: { type: Boolean, default: true },
|
||||
height: { type: Number, default: 200 }
|
||||
height: { type: Number, default: 200 },
|
||||
width: { type: [Number, Boolean] as PropType<number|false>, default: false }
|
||||
});
|
||||
const emit = defineEmits(['update:modelValue']);
|
||||
const settingsStore = useSettingsStore();
|
||||
@@ -132,8 +138,10 @@ onMounted(() => {
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.editor-wrapper {
|
||||
.editor {
|
||||
width: 100%;
|
||||
}
|
||||
.editor {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
max-width: 90vw;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
312
src/renderer/components/DebugConsole.vue
Normal file
312
src/renderer/components/DebugConsole.vue
Normal file
@@ -0,0 +1,312 @@
|
||||
<template>
|
||||
<div
|
||||
ref="wrapper"
|
||||
class="console-wrapper"
|
||||
@mouseenter="isHover = true"
|
||||
@mouseleave="isHover = false"
|
||||
>
|
||||
<div ref="resizer" class="console-resizer" />
|
||||
<div
|
||||
id="console"
|
||||
ref="queryConsole"
|
||||
class="console column col-12"
|
||||
:style="{height: localHeight ? localHeight+'px' : ''}"
|
||||
>
|
||||
<div class="console-header">
|
||||
<ul class="tab tab-block">
|
||||
<li class="tab-item" :class="{'active': selectedTab === 'query'}">
|
||||
<a class="tab-link" @click="selectedTab = 'query'">{{ t('application.executedQueries') }}</a>
|
||||
</li>
|
||||
<li class="tab-item" :class="{'active': selectedTab === 'debug'}">
|
||||
<a class="tab-link" @click="selectedTab = 'debug'">{{ t('application.debugConsole') }}</a>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="d-flex">
|
||||
<div
|
||||
v-if="isDevelopment"
|
||||
class="c-hand mr-2"
|
||||
@click="openDevTools()"
|
||||
>
|
||||
<BaseIcon icon-name="mdiBugPlayOutline" :size="22" />
|
||||
</div>
|
||||
<div
|
||||
v-if="isDevelopment"
|
||||
class="c-hand mr-2"
|
||||
@click="reload()"
|
||||
>
|
||||
<BaseIcon icon-name="mdiRefresh" :size="22" />
|
||||
</div>
|
||||
<button class="btn btn-clear mr-1" @click="resizeConsole(0)" />
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
v-show="selectedTab === 'query'"
|
||||
ref="queryConsoleBody"
|
||||
class="console-body"
|
||||
>
|
||||
<div
|
||||
v-for="(wLog, i) in workspaceQueryLogs"
|
||||
:key="i"
|
||||
class="console-log"
|
||||
tabindex="0"
|
||||
@contextmenu.prevent="contextMenu($event, wLog)"
|
||||
>
|
||||
<span class="console-log-datetime">{{ moment(wLog.date).format('HH:mm:ss') }}</span>: <code class="console-log-sql" v-html="highlight(wLog.sql, {html: true})" />
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
v-show="selectedTab === 'debug'"
|
||||
ref="logConsoleBody"
|
||||
class="console-body"
|
||||
>
|
||||
<div
|
||||
v-for="(log, i) in debugLogs"
|
||||
:key="i"
|
||||
class="console-log"
|
||||
tabindex="0"
|
||||
@contextmenu.prevent="contextMenu($event, log)"
|
||||
>
|
||||
<span class="console-log-datetime">{{ moment(log.date).format('HH:mm:ss') }}</span> <small>[{{ log.process.substring(0, 1).toUpperCase() }}]</small>: <span class="console-log-message" :class="`console-log-level-${log.level}`">{{ log.message }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<BaseContextMenu
|
||||
v-if="isContext"
|
||||
:context-event="contextEvent"
|
||||
@close-context="isContext = false"
|
||||
>
|
||||
<div class="context-element" @click="copyLog">
|
||||
<span class="d-flex">
|
||||
<BaseIcon
|
||||
class="text-light mt-1 mr-1"
|
||||
icon-name="mdiContentCopy"
|
||||
:size="18"
|
||||
/> {{ t('general.copy') }}</span>
|
||||
</div>
|
||||
</BaseContextMenu>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { getCurrentWindow } from '@electron/remote';
|
||||
import * as moment from 'moment';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { highlight } from 'sql-highlight';
|
||||
import { computed, nextTick, onMounted, Ref, ref, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
|
||||
import BaseContextMenu from '@/components/BaseContextMenu.vue';
|
||||
import BaseIcon from '@/components/BaseIcon.vue';
|
||||
import { copyText } from '@/libs/copyText';
|
||||
import { useConsoleStore } from '@/stores/console';
|
||||
|
||||
const { t } = useI18n();
|
||||
|
||||
const consoleStore = useConsoleStore();
|
||||
|
||||
const { resizeConsole, getLogsByWorkspace } = consoleStore;
|
||||
const {
|
||||
isConsoleOpen,
|
||||
consoleHeight,
|
||||
selectedTab,
|
||||
debugLogs
|
||||
} = storeToRefs(consoleStore);
|
||||
|
||||
const props = defineProps({
|
||||
uid: {
|
||||
type: String,
|
||||
default: null,
|
||||
required: false
|
||||
}
|
||||
});
|
||||
|
||||
const wrapper: Ref<HTMLInputElement> = ref(null);
|
||||
const queryConsole: Ref<HTMLInputElement> = ref(null);
|
||||
const queryConsoleBody: Ref<HTMLInputElement> = ref(null);
|
||||
const logConsoleBody: Ref<HTMLInputElement> = ref(null);
|
||||
const resizer: Ref<HTMLInputElement> = ref(null);
|
||||
const localHeight = ref(consoleHeight.value);
|
||||
const isHover = ref(false);
|
||||
const isContext = ref(false);
|
||||
const contextContent: Ref<string> = ref(null);
|
||||
const contextEvent: Ref<MouseEvent> = ref(null);
|
||||
const w = ref(getCurrentWindow());
|
||||
const isDevelopment = ref(process.env.NODE_ENV === 'development');
|
||||
|
||||
const resize = (e: MouseEvent) => {
|
||||
const el = queryConsole.value;
|
||||
let elementHeight = el.getBoundingClientRect().bottom - e.pageY;
|
||||
if (elementHeight > 400) elementHeight = 400;
|
||||
localHeight.value = elementHeight;
|
||||
};
|
||||
|
||||
const workspaceQueryLogs = computed(() => {
|
||||
return getLogsByWorkspace(props.uid);
|
||||
});
|
||||
|
||||
const stopResize = () => {
|
||||
if (localHeight.value < 0) localHeight.value = 0;
|
||||
resizeConsole(localHeight.value);
|
||||
window.removeEventListener('mousemove', resize);
|
||||
window.removeEventListener('mouseup', stopResize);
|
||||
};
|
||||
|
||||
const contextMenu = (event: MouseEvent, wLog: {date: Date; sql?: string; message?: string}) => {
|
||||
contextEvent.value = event;
|
||||
contextContent.value = wLog.sql || wLog.message;
|
||||
isContext.value = true;
|
||||
};
|
||||
|
||||
const copyLog = () => {
|
||||
copyText(contextContent.value);
|
||||
isContext.value = false;
|
||||
};
|
||||
|
||||
const openDevTools = () => {
|
||||
w.value.webContents.openDevTools();
|
||||
};
|
||||
|
||||
const reload = () => {
|
||||
w.value.reload();
|
||||
};
|
||||
|
||||
watch(workspaceQueryLogs, async () => {
|
||||
if (!isHover.value) {
|
||||
await nextTick();
|
||||
queryConsoleBody.value.scrollTop = queryConsoleBody.value.scrollHeight;
|
||||
}
|
||||
});
|
||||
|
||||
watch(() => debugLogs.value.length, async () => {
|
||||
if (!isHover.value) {
|
||||
await nextTick();
|
||||
logConsoleBody.value.scrollTop = logConsoleBody.value.scrollHeight;
|
||||
}
|
||||
});
|
||||
|
||||
watch(isConsoleOpen, async () => {
|
||||
queryConsoleBody.value.scrollTop = queryConsoleBody.value.scrollHeight;
|
||||
logConsoleBody.value.scrollTop = logConsoleBody.value.scrollHeight;
|
||||
});
|
||||
|
||||
watch(selectedTab, async () => {
|
||||
queryConsoleBody.value.scrollTop = queryConsoleBody.value.scrollHeight;
|
||||
logConsoleBody.value.scrollTop = logConsoleBody.value.scrollHeight;
|
||||
});
|
||||
|
||||
watch(consoleHeight, async (val) => {
|
||||
await nextTick();
|
||||
localHeight.value = val;
|
||||
});
|
||||
|
||||
onMounted(() => {
|
||||
queryConsoleBody.value.scrollTop = queryConsoleBody.value.scrollHeight;
|
||||
logConsoleBody.value.scrollTop = logConsoleBody.value.scrollHeight;
|
||||
|
||||
resizer.value.addEventListener('mousedown', (e: MouseEvent) => {
|
||||
e.preventDefault();
|
||||
|
||||
window.addEventListener('mousemove', resize);
|
||||
window.addEventListener('mouseup', stopResize);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
.console-wrapper {
|
||||
width: -webkit-fill-available;
|
||||
z-index: 9;
|
||||
margin-top: auto;
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
|
||||
.console-resizer {
|
||||
height: 4px;
|
||||
top: -1px;
|
||||
width: 100%;
|
||||
cursor: ns-resize;
|
||||
position: absolute;
|
||||
z-index: 99;
|
||||
transition: background 0.2s;
|
||||
|
||||
&:hover {
|
||||
background: var(--primary-color-dark);
|
||||
}
|
||||
}
|
||||
|
||||
.console {
|
||||
padding: 0;
|
||||
padding-bottom: $footer-height;
|
||||
|
||||
.console-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 0 4px;
|
||||
|
||||
.tab-block {
|
||||
margin-top: 0;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.tab-block,
|
||||
.tab-item {
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
.tab-link {
|
||||
padding: 0.2rem 0.6rem;
|
||||
cursor: pointer;
|
||||
white-space: nowrap;
|
||||
}
|
||||
}
|
||||
|
||||
.console-body {
|
||||
overflow: auto;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
max-height: 100%;
|
||||
padding: 0 6px 3px;
|
||||
|
||||
.console-log {
|
||||
padding: 1px 3px;
|
||||
margin: 1px 0;
|
||||
border-radius: $border-radius;
|
||||
user-select: text;
|
||||
|
||||
&-datetime {
|
||||
opacity: .6;
|
||||
font-size: 90%;
|
||||
}
|
||||
|
||||
&-sql {
|
||||
font-size: 95%;
|
||||
opacity: 0.8;
|
||||
font-weight: 700;
|
||||
|
||||
&:hover {
|
||||
user-select: text;
|
||||
}
|
||||
}
|
||||
|
||||
&-message {
|
||||
font-size: 95%;
|
||||
}
|
||||
|
||||
&-level {
|
||||
// &-log,
|
||||
// &-info {}
|
||||
&-warn {
|
||||
color: orange;
|
||||
}
|
||||
&-error {
|
||||
color: red;
|
||||
}
|
||||
}
|
||||
|
||||
small {
|
||||
opacity: .6;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
@@ -113,7 +113,7 @@ const selectedGroup: Ref<string> = ref('manual');
|
||||
const selectedMethod: Ref<string> = ref('');
|
||||
const selectedValue: Ref<string> = ref('');
|
||||
const debounceTimeout: Ref<NodeJS.Timeout> = ref(null);
|
||||
const methodParams: Ref<{[key: string]: string}> = ref({});
|
||||
const methodParams: Ref<Record<string, string>> = ref({});
|
||||
const enumArray: Ref<string[]> = ref(null);
|
||||
|
||||
const fakerGroups = computed(() => {
|
||||
@@ -127,7 +127,7 @@ const fakerGroups = computed(() => {
|
||||
localType.value = 'datetime';
|
||||
else if (TIME.includes(props.type))
|
||||
localType.value = 'time';
|
||||
else if (UUID.includes(props.type))
|
||||
else if (UUID.includes(props.type) || (BLOB.includes(props.type) && props.field.key === 'pri'))
|
||||
localType.value = 'uuid';
|
||||
else
|
||||
localType.value = 'none';
|
||||
@@ -177,7 +177,7 @@ const inputProps = () => {
|
||||
return { type: 'text', mask: datetimeMask };
|
||||
}
|
||||
|
||||
if (BLOB.includes(props.type))
|
||||
if (BLOB.includes(props.type) && props.field.key !== 'pri')
|
||||
return { type: 'file', mask: false };
|
||||
|
||||
if (BIT.includes(props.type))
|
||||
|
@@ -57,8 +57,22 @@
|
||||
>
|
||||
<div class="panel">
|
||||
<div class="panel-header p-2 text-center p-relative">
|
||||
<figure class="avatar avatar-lg pt-1 mb-1">
|
||||
<i class="settingbar-element-icon dbi" :class="[`dbi-${connection.client}`]" />
|
||||
<figure class="avatar avatar-lg pt-1 mb-1 bg-dark">
|
||||
<div
|
||||
v-if="connection.icon"
|
||||
class="settingbar-connection-icon"
|
||||
>
|
||||
<BaseIcon
|
||||
:icon-name="camelize(connection.icon)"
|
||||
:type="connection.hasCustomIcon ? 'custom' : 'mdi'"
|
||||
:size="42"
|
||||
/>
|
||||
</div>
|
||||
<div
|
||||
v-else
|
||||
class="settingbar-element-icon dbi ml-1"
|
||||
:class="[`dbi-${connection.client}`]"
|
||||
/>
|
||||
</figure>
|
||||
<div class="panel-title h6 text-ellipsis">
|
||||
{{ getConnectionName(connection.uid) }}
|
||||
@@ -136,7 +150,19 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="panel-footer text-center py-0">
|
||||
<div v-if="connection.ssl" class="chip bg-success mt-2">
|
||||
<div
|
||||
v-if="connection.folderName"
|
||||
class="chip mt-2 bg-dark"
|
||||
>
|
||||
<BaseIcon
|
||||
icon-name="mdiFolder"
|
||||
class="mr-1"
|
||||
:style="[connection.color ? `color: ${connection.color};`: '']"
|
||||
:size="18"
|
||||
/>
|
||||
{{ connection.folderName }}
|
||||
</div>
|
||||
<div v-if="connection.ssl" class="chip bg-dark mt-2">
|
||||
<BaseIcon
|
||||
icon-name="mdiShieldKey"
|
||||
class="mr-1"
|
||||
@@ -144,7 +170,7 @@
|
||||
/>
|
||||
SSL
|
||||
</div>
|
||||
<div v-if="connection.ssh" class="chip bg-success mt-2">
|
||||
<div v-if="connection.ssh" class="chip bg-dark mt-2">
|
||||
<BaseIcon
|
||||
icon-name="mdiConsoleNetwork"
|
||||
class="mr-1"
|
||||
@@ -152,7 +178,7 @@
|
||||
/>
|
||||
SSH
|
||||
</div>
|
||||
<div v-if="connection.readonly" class="chip bg-success mt-2">
|
||||
<div v-if="connection.readonly" class="chip bg-dark mt-2">
|
||||
<BaseIcon
|
||||
icon-name="mdiLock"
|
||||
class="mr-1"
|
||||
@@ -209,6 +235,7 @@ import { useI18n } from 'vue-i18n';
|
||||
import ConfirmModal from '@/components/BaseConfirmModal.vue';
|
||||
import BaseIcon from '@/components/BaseIcon.vue';
|
||||
import { useFocusTrap } from '@/composables/useFocusTrap';
|
||||
import { camelize } from '@/libs/camelize';
|
||||
import { useConnectionsStore } from '@/stores/connections';
|
||||
import { useWorkspacesStore } from '@/stores/workspaces';
|
||||
|
||||
@@ -218,7 +245,9 @@ const connectionsStore = useConnectionsStore();
|
||||
const workspacesStore = useWorkspacesStore();
|
||||
|
||||
const { connections,
|
||||
lastConnections
|
||||
connectionsOrder,
|
||||
lastConnections,
|
||||
getFolders: folders
|
||||
} = storeToRefs(connectionsStore);
|
||||
const { getSelected: selectedWorkspace } = storeToRefs(workspacesStore);
|
||||
|
||||
@@ -236,7 +265,8 @@ const clients = new Map([
|
||||
['mysql', 'MySQL'],
|
||||
['maria', 'MariaDB'],
|
||||
['pg', 'PostgreSQL'],
|
||||
['sqlite', 'SQLite']
|
||||
['sqlite', 'SQLite'],
|
||||
['firebird', 'Firebird SQL']
|
||||
]);
|
||||
|
||||
const searchTerm = ref('');
|
||||
@@ -244,12 +274,20 @@ const isConfirmModal = ref(false);
|
||||
const connectionHover: Ref<string> = ref(null);
|
||||
const selectedConnection: Ref<ConnectionParams> = ref(null);
|
||||
|
||||
const sortedConnections = computed(() => {
|
||||
const remappedConnections = computed(() => {
|
||||
return connections.value
|
||||
.map(c => {
|
||||
const connTime = lastConnections.value.find((lc) => lc.uid === c.uid)?.time || 0;
|
||||
const connIcon = connectionsOrder.value.find((co) => co.uid === c.uid).icon;
|
||||
const connHasCustomIcon = connectionsOrder.value.find((co) => co.uid === c.uid).hasCustomIcon;
|
||||
const folder = folders.value.find(f => f.connections.includes(c.uid));
|
||||
|
||||
return {
|
||||
...c,
|
||||
icon: connIcon,
|
||||
color: folder?.color,
|
||||
folderName: folder?.name,
|
||||
hasCustomIcon: connHasCustomIcon,
|
||||
time: connTime
|
||||
};
|
||||
})
|
||||
@@ -261,7 +299,7 @@ const sortedConnections = computed(() => {
|
||||
});
|
||||
|
||||
const filteredConnections = computed(() => {
|
||||
return sortedConnections.value.filter(connection => {
|
||||
return remappedConnections.value.filter(connection => {
|
||||
return connection.name?.toLocaleLowerCase().includes(searchTerm.value.toLocaleLowerCase()) ||
|
||||
connection.host?.toLocaleLowerCase().includes(searchTerm.value.toLocaleLowerCase()) ||
|
||||
connection.database?.toLocaleLowerCase().includes(searchTerm.value.toLocaleLowerCase()) ||
|
||||
@@ -360,7 +398,7 @@ onBeforeUnmount(() => {
|
||||
outline: none;
|
||||
|
||||
&:focus {
|
||||
box-shadow: 0 0 3px 0.1rem rgba($primary-color, 80%);
|
||||
box-shadow: 0 0 3px 0.1rem rgba(var(--primary-color), 80%);
|
||||
}
|
||||
|
||||
&:hover {
|
||||
|
@@ -73,7 +73,7 @@ const props = defineProps({
|
||||
const emit = defineEmits(['confirm', 'close']);
|
||||
|
||||
const firstInput: Ref<HTMLInputElement[]> = ref(null);
|
||||
const values: Ref<{[key: string]: string}> = ref({});
|
||||
const values: Ref<Record<string, string>> = ref({});
|
||||
|
||||
const inParameters = computed(() => {
|
||||
return props.localRoutine.parameters.filter(param => param.context === 'IN');
|
||||
|
@@ -49,18 +49,46 @@
|
||||
class="icon-box"
|
||||
:title="icon.name"
|
||||
:class="[{'selected': localConnection.icon === icon.code}]"
|
||||
@click="localConnection.icon = icon.code"
|
||||
@click="setIcon(icon.code)"
|
||||
/>
|
||||
<div
|
||||
v-else
|
||||
class="icon-box"
|
||||
:title="icon.name"
|
||||
:class="[`dbi dbi-${connection.client}`, {'selected': localConnection.icon === icon.code}]"
|
||||
@click="localConnection.icon = icon.code"
|
||||
:class="[`dbi dbi-${connection.client}`, {'selected': localConnection.icon === null}]"
|
||||
@click="setIcon(null)"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-3">
|
||||
<label class="form-label">{{ t('application.customIcon') }}</label>
|
||||
</div>
|
||||
<div class="col-9 icons-wrapper">
|
||||
<div
|
||||
v-for="icon in customIcons"
|
||||
:key="icon.uid"
|
||||
>
|
||||
<BaseIcon
|
||||
v-if="icon.uid"
|
||||
:icon-name="icon.uid"
|
||||
type="custom"
|
||||
:size="36"
|
||||
class="icon-box"
|
||||
:class="[{'selected': localConnection.icon === icon.uid}]"
|
||||
@click="setIcon(icon.uid, 'custom')"
|
||||
@contextmenu.prevent="contextMenu($event, icon.uid)"
|
||||
/>
|
||||
</div>
|
||||
<BaseIcon
|
||||
:icon-name="'mdiPlus'"
|
||||
:size="36"
|
||||
class="icon-box"
|
||||
@click="openFile"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
@@ -74,19 +102,46 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<BaseContextMenu
|
||||
v-if="isContext"
|
||||
:context-event="contextEvent"
|
||||
@close-context="isContext = false"
|
||||
>
|
||||
<div class="context-element" @click="removeIconHandler">
|
||||
<span class="d-flex">
|
||||
<BaseIcon
|
||||
class="text-light mt-1 mr-1"
|
||||
icon-name="mdiDelete"
|
||||
:size="18"
|
||||
/> {{ t('general.delete') }}</span>
|
||||
</div>
|
||||
</BaseContextMenu>
|
||||
</Teleport>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { onBeforeUnmount, PropType, Ref, ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
|
||||
import BaseContextMenu from '@/components/BaseContextMenu.vue';
|
||||
import BaseIcon from '@/components/BaseIcon.vue';
|
||||
import { useFocusTrap } from '@/composables/useFocusTrap';
|
||||
import Application from '@/ipc-api/Application';
|
||||
import { camelize } from '@/libs/camelize';
|
||||
import { unproxify } from '@/libs/unproxify';
|
||||
import { SidebarElement, useConnectionsStore } from '@/stores/connections';
|
||||
import { useNotificationsStore } from '@/stores/notifications';
|
||||
|
||||
const connectionsStore = useConnectionsStore();
|
||||
const { addNotification } = useNotificationsStore();
|
||||
|
||||
const { addIcon, removeIcon, updateConnectionOrder, getConnectionName } = connectionsStore;
|
||||
const { customIcons } = storeToRefs(connectionsStore);
|
||||
|
||||
const isContext = ref(false);
|
||||
const contextContent: Ref<string> = ref(null);
|
||||
const contextEvent: Ref<MouseEvent> = ref(null);
|
||||
|
||||
const { t } = useI18n();
|
||||
|
||||
@@ -99,8 +154,6 @@ const props = defineProps({
|
||||
|
||||
const emit = defineEmits(['close']);
|
||||
|
||||
const { updateConnectionOrder, getConnectionName } = connectionsStore;
|
||||
|
||||
const icons = [
|
||||
{ name: 'default', code: null },
|
||||
|
||||
@@ -160,14 +213,77 @@ const editFolderAppearance = () => {
|
||||
closeModal();
|
||||
};
|
||||
|
||||
const camelize = (text: string) => {
|
||||
const textArr = text.split('-');
|
||||
for (let i = 0; i < textArr.length; i++) {
|
||||
if (i === 0) continue;
|
||||
textArr[i] = textArr[i].charAt(0).toUpperCase() + textArr[i].slice(1);
|
||||
}
|
||||
const setIcon = (code: string, type?: 'mdi' | 'custom') => {
|
||||
localConnection.value.icon = code;
|
||||
localConnection.value.hasCustomIcon = type === 'custom';
|
||||
};
|
||||
|
||||
return textArr.join('');
|
||||
const removeIconHandler = () => {
|
||||
if (localConnection.value.icon === contextContent.value) {
|
||||
setIcon(null);
|
||||
updateConnectionOrder(localConnection.value);
|
||||
}
|
||||
removeIcon(contextContent.value);
|
||||
isContext.value = false;
|
||||
};
|
||||
|
||||
const adjustSVGContent = (svgContent: string) => {
|
||||
try {
|
||||
const parser = new DOMParser();
|
||||
const doc = parser.parseFromString(svgContent, 'image/svg+xml');
|
||||
|
||||
const parseError = doc.querySelector('parsererror');
|
||||
if (parseError) {
|
||||
addNotification({ status: 'error', message: parseError.textContent });
|
||||
return null;
|
||||
}
|
||||
|
||||
const svg = doc.documentElement;
|
||||
if (svg.tagName.toLowerCase() !== 'svg') {
|
||||
addNotification({ status: 'error', message: t('application.invalidFIle') });
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!svg.hasAttribute('viewBox')) {
|
||||
const width = svg.getAttribute('width') || '36';
|
||||
const height = svg.getAttribute('height') || '36';
|
||||
svg.setAttribute('viewBox', `0 0 ${width} ${height}`);
|
||||
}
|
||||
|
||||
svg.removeAttribute('width');
|
||||
svg.removeAttribute('height');
|
||||
|
||||
const serializer = new XMLSerializer();
|
||||
return serializer.serializeToString(svg);
|
||||
}
|
||||
catch (error) {
|
||||
addNotification({ status: 'error', message: error.stack });
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
const openFile = async () => {
|
||||
const result = await Application.showOpenDialog({
|
||||
properties: ['openFile'],
|
||||
filters: [{ name: '"SVG"', extensions: ['svg'] }]
|
||||
});
|
||||
|
||||
if (result && !result.canceled) {
|
||||
const file = result.filePaths[0];
|
||||
let content = await Application.readFile({ filePath: file, encoding: 'utf-8' });
|
||||
|
||||
content = adjustSVGContent(content);
|
||||
|
||||
const base64Content = Buffer.from(content).toString('base64');
|
||||
|
||||
addIcon(base64Content);
|
||||
}
|
||||
};
|
||||
|
||||
const contextMenu = (event: MouseEvent, iconUid: string) => {
|
||||
contextEvent.value = event;
|
||||
contextContent.value = iconUid;
|
||||
isContext.value = true;
|
||||
};
|
||||
|
||||
const closeModal = () => emit('close');
|
||||
@@ -204,7 +320,7 @@ onBeforeUnmount(() => {
|
||||
cursor: pointer;
|
||||
|
||||
&.selected {
|
||||
outline: 2px solid $primary-color;
|
||||
outline: 2px solid var(--primary-color);
|
||||
border-radius: 8px;
|
||||
}
|
||||
}
|
||||
|
@@ -282,7 +282,7 @@
|
||||
import { ClientCode, SchemaInfos } from 'common/interfaces/antares';
|
||||
import { Customizations } from 'common/interfaces/customizations';
|
||||
import { ExportOptions, ExportState } from 'common/interfaces/exporter';
|
||||
import { ipcRenderer } from 'electron';
|
||||
import { ipcRenderer, IpcRendererEvent } from 'electron';
|
||||
import * as moment from 'moment';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { computed, onBeforeUnmount, Ref, ref } from 'vue';
|
||||
@@ -293,6 +293,7 @@ import BaseSelect from '@/components/BaseSelect.vue';
|
||||
import { useFocusTrap } from '@/composables/useFocusTrap';
|
||||
import Application from '@/ipc-api/Application';
|
||||
import Schema from '@/ipc-api/Schema';
|
||||
import { useConsoleStore } from '@/stores/console';
|
||||
import { useNotificationsStore } from '@/stores/notifications';
|
||||
import { useSchemaExportStore } from '@/stores/schemaExport';
|
||||
import { useWorkspacesStore } from '@/stores/workspaces';
|
||||
@@ -327,7 +328,7 @@ const tables: Ref<{
|
||||
}[]> = ref([]);
|
||||
const options: Ref<Partial<ExportOptions>> = ref({
|
||||
schema: selectedSchema.value,
|
||||
includes: {} as {[key: string]: boolean},
|
||||
includes: {} as Record<string, boolean>,
|
||||
outputFormat: 'sql' as 'sql' | 'sql.zip',
|
||||
sqlInsertAfter: 250,
|
||||
sqlInsertDivider: 'bytes' as 'bytes' | 'rows'
|
||||
@@ -379,21 +380,34 @@ const startExport = async () => {
|
||||
|
||||
try {
|
||||
const { status, response } = await Schema.export(params);
|
||||
|
||||
if (status === 'success')
|
||||
progressStatus.value = response.cancelled ? t('general.aborted') : t('general.completed');
|
||||
else {
|
||||
progressStatus.value = response;
|
||||
addNotification({ status: 'error', message: response });
|
||||
useConsoleStore().putLog('debug', {
|
||||
level: 'error',
|
||||
process: 'worker',
|
||||
message: response,
|
||||
date: new Date()
|
||||
});
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
addNotification({ status: 'error', message: err.stack });
|
||||
useConsoleStore().putLog('debug', {
|
||||
level: 'error',
|
||||
process: 'worker',
|
||||
message: err.stack,
|
||||
date: new Date()
|
||||
});
|
||||
}
|
||||
|
||||
isExporting.value = false;
|
||||
};
|
||||
|
||||
const updateProgress = (event: Event, state: ExportState) => {
|
||||
const updateProgress = (event: IpcRendererEvent, state: ExportState) => {
|
||||
progressPercentage.value = Number((state.currentItemIndex / state.totalItems * 100).toFixed(1));
|
||||
switch (state.op) {
|
||||
case 'PROCESSING':
|
||||
|
@@ -142,7 +142,7 @@ const { getSelected: selectedWorkspace } = storeToRefs(workspacesStore);
|
||||
const { trapRef } = useFocusTrap({ disableAutofocus: true });
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const localRow: Ref<{[key: string]: any}> = ref({});
|
||||
const localRow: Ref<Record<string, any>> = ref({});
|
||||
const fieldsToExclude = ref([]);
|
||||
const nInserts = ref(1);
|
||||
const isInserting = ref(false);
|
||||
@@ -225,7 +225,7 @@ const insertRows = async () => {
|
||||
delete rowToInsert[key];
|
||||
});
|
||||
|
||||
const fieldTypes: {[key: string]: string} = {};
|
||||
const fieldTypes: Record<string, string> = {};
|
||||
props.fields.forEach(field => {
|
||||
fieldTypes[field.name] = field.type;
|
||||
});
|
||||
@@ -290,7 +290,7 @@ onMounted(() => {
|
||||
}
|
||||
}, 50);
|
||||
|
||||
const rowObj: {[key: string]: unknown} = {};
|
||||
const rowObj: Record<string, unknown> = {};
|
||||
|
||||
if (!props.rowToDuplicate) {
|
||||
// Set default values
|
||||
@@ -339,6 +339,8 @@ onMounted(() => {
|
||||
for (const field of props.fields) {
|
||||
if (typeof props.rowToDuplicate[field.name] !== 'object')
|
||||
rowObj[field.name] = { value: props.rowToDuplicate[field.name] };
|
||||
else if (field.type === 'JSON')
|
||||
rowObj[field.name] = { value: JSON.stringify(props.rowToDuplicate[field.name]) };
|
||||
|
||||
if (field.autoIncrement || !!field.onUpdate)// Disable by default auto increment or "on update" fields
|
||||
fieldsToExclude.value = [...fieldsToExclude.value, field.name];
|
||||
|
@@ -75,7 +75,7 @@
|
||||
<code
|
||||
class="cut-text"
|
||||
:title="query.sql"
|
||||
v-html="highlight(highlightWord(query.sql), {html: true})"
|
||||
v-html="highlight(query.sql, {html: true})"
|
||||
/>
|
||||
</div>
|
||||
<div class="tile-bottom-content">
|
||||
@@ -115,7 +115,7 @@
|
||||
<BaseIcon icon-name="mdiHistory" :size="48" />
|
||||
</div>
|
||||
<p class="empty-title h5">
|
||||
{{ t('database.thereIsNoQueriesYet') }}
|
||||
{{ t('database.thereAreNoQueriesYet') }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
@@ -210,17 +210,6 @@ const resizeResults = () => {
|
||||
const refreshScroller = () => resizeResults();
|
||||
const closeModal = () => emit('close');
|
||||
|
||||
const highlightWord = (string: string) => {
|
||||
string = string.replaceAll('<', '<').replaceAll('>', '>');
|
||||
|
||||
if (searchTerm.value) {
|
||||
const regexp = new RegExp(`(${searchTerm.value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')})`, 'gi');
|
||||
return string.replace(regexp, '<span class="text-primary text-bold">$1</span>');
|
||||
}
|
||||
else
|
||||
return string;
|
||||
};
|
||||
|
||||
const onKey = (e: KeyboardEvent) => {
|
||||
e.stopPropagation();
|
||||
if (e.key === 'Escape')
|
||||
@@ -287,7 +276,7 @@ onBeforeUnmount(() => {
|
||||
max-width: 100%;
|
||||
display: inline-block;
|
||||
font-size: 100%;
|
||||
// color: $primary-color;
|
||||
// color: var(--primary-color);
|
||||
opacity: 0.8;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
@@ -55,7 +55,7 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ImportState } from 'common/interfaces/importer';
|
||||
import { ipcRenderer } from 'electron';
|
||||
import { ipcRenderer, IpcRendererEvent } from 'electron';
|
||||
import * as moment from 'moment';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { computed, onBeforeUnmount, Ref, ref } from 'vue';
|
||||
@@ -63,6 +63,7 @@ import { useI18n } from 'vue-i18n';
|
||||
|
||||
import BaseIcon from '@/components/BaseIcon.vue';
|
||||
import Schema from '@/ipc-api/Schema';
|
||||
import { useConsoleStore } from '@/stores/console';
|
||||
import { useNotificationsStore } from '@/stores/notifications';
|
||||
import { useWorkspacesStore } from '@/stores/workspaces';
|
||||
|
||||
@@ -118,23 +119,35 @@ const startImport = async (file: string) => {
|
||||
else {
|
||||
progressStatus.value = response;
|
||||
addNotification({ status: 'error', message: response });
|
||||
useConsoleStore().putLog('debug', {
|
||||
level: 'error',
|
||||
process: 'worker',
|
||||
message: response,
|
||||
date: new Date()
|
||||
});
|
||||
}
|
||||
refreshSchema({ uid, schema: props.selectedSchema });
|
||||
completed.value = true;
|
||||
}
|
||||
catch (err) {
|
||||
addNotification({ status: 'error', message: err.stack });
|
||||
useConsoleStore().putLog('debug', {
|
||||
level: 'error',
|
||||
process: 'worker',
|
||||
message: err.stack,
|
||||
date: new Date()
|
||||
});
|
||||
}
|
||||
|
||||
isImporting.value = false;
|
||||
};
|
||||
|
||||
const updateProgress = (event: Event, state: ImportState) => {
|
||||
const updateProgress = (event: IpcRendererEvent, state: ImportState) => {
|
||||
progressPercentage.value = parseFloat(Number(state.percentage).toFixed(1));
|
||||
queryCount.value = Number(state.queryCount);
|
||||
};
|
||||
|
||||
const handleQueryError = (event: Event, err: { time: string; message: string }) => {
|
||||
const handleQueryError = (event: IpcRendererEvent, err: { time: string; message: string }) => {
|
||||
queryErrors.value.push(err);
|
||||
};
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<ConfirmModal
|
||||
size="medium"
|
||||
size="resize"
|
||||
:disable-autofocus="true"
|
||||
:close-on-confirm="!!localNote.note.length"
|
||||
:confirm-text="t('general.save')"
|
||||
@@ -52,6 +52,10 @@
|
||||
v-model="localNote.note"
|
||||
:mode="editorMode"
|
||||
:show-line-numbers="false"
|
||||
:auto-focus="true"
|
||||
:height="400"
|
||||
:width="640"
|
||||
:resizable="true"
|
||||
/>
|
||||
</div>
|
||||
</form>
|
||||
|
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<ConfirmModal
|
||||
size="medium"
|
||||
size="resize"
|
||||
:disable-autofocus="true"
|
||||
:close-on-confirm="!!newNote.note.length"
|
||||
:confirm-text="t('general.save')"
|
||||
@@ -52,6 +52,10 @@
|
||||
v-model="newNote.note"
|
||||
:mode="editorMode"
|
||||
:show-line-numbers="false"
|
||||
:auto-focus="true"
|
||||
:height="400"
|
||||
:width="640"
|
||||
:resizable="true"
|
||||
/>
|
||||
</div>
|
||||
</form>
|
||||
|
@@ -67,7 +67,7 @@ const props = defineProps({
|
||||
|
||||
const emit = defineEmits(['select-row', 'contextmenu', 'stop-refresh']);
|
||||
|
||||
const isInlineEditor: Ref<{[key: string]: boolean}> = ref({});
|
||||
const isInlineEditor: Ref<Record<string, boolean>> = ref({});
|
||||
const isInfoModal = ref(false);
|
||||
const editorMode = ref('sql');
|
||||
|
||||
|
@@ -409,14 +409,6 @@
|
||||
class="d-inline mr-1"
|
||||
:size="16"
|
||||
/> Mastodon</a> • <a
|
||||
class="c-hand"
|
||||
:style="'align-items: center; display: inline-flex;'"
|
||||
@click="openOutside('https://twitter.com/AntaresSQL')"
|
||||
><BaseIcon
|
||||
icon-name="mdiTwitter"
|
||||
class="d-inline mr-1"
|
||||
:size="16"
|
||||
/> Twitter</a> • <a
|
||||
class="c-hand"
|
||||
:style="'align-items: center; display: inline-flex;'"
|
||||
@click="openOutside('https://antares-sql.app/')"
|
||||
@@ -620,7 +612,7 @@ const otherContributors = computed(() => {
|
||||
return contributors
|
||||
.split(',')
|
||||
.filter(c => !c.includes(appAuthor))
|
||||
.sort((a, b) => a.toLowerCase().localeCompare(b.toLowerCase()));
|
||||
.sort((a, b) => a.toLowerCase().trim().localeCompare(b.toLowerCase()));
|
||||
});
|
||||
|
||||
const selectTab = (tab: string) => {
|
||||
@@ -711,7 +703,7 @@ onBeforeUnmount(() => {
|
||||
|
||||
&.selected {
|
||||
img {
|
||||
box-shadow: 0 0 0 3px $primary-color;
|
||||
box-shadow: 0 0 0 3px var(--primary-color);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -739,7 +731,7 @@ onBeforeUnmount(() => {
|
||||
|
||||
.badge-update::after {
|
||||
bottom: initial;
|
||||
background: $primary-color;
|
||||
background: var(--primary-color);
|
||||
}
|
||||
|
||||
.form-label {
|
||||
|
@@ -169,7 +169,7 @@ const emit = defineEmits(['close']);
|
||||
const { trapRef } = useFocusTrap();
|
||||
|
||||
const { getConnectionName } = useConnectionsStore();
|
||||
const { connectionsOrder, connections } = storeToRefs(useConnectionsStore());
|
||||
const { connectionsOrder, connections, customIcons } = storeToRefs(useConnectionsStore());
|
||||
const localConnections = unproxify<ConnectionParams[]>(connections.value);
|
||||
const localConnectionsOrder = unproxify<SidebarElement[]>(connectionsOrder.value);
|
||||
|
||||
@@ -246,7 +246,8 @@ const exportData = () => {
|
||||
|
||||
const exportObj = encrypt(JSON.stringify({
|
||||
connections: filteredConnections,
|
||||
connectionsOrder: filteredOrders
|
||||
connectionsOrder: filteredOrders,
|
||||
customIcons: customIcons.value
|
||||
}), options.value.passkey);
|
||||
|
||||
// console.log(exportObj, JSON.parse(decrypt(exportObj, options.value.passkey)));
|
||||
|
@@ -103,7 +103,7 @@ import { useI18n } from 'vue-i18n';
|
||||
import BaseIcon from '@/components/BaseIcon.vue';
|
||||
import BaseUploadInput from '@/components/BaseUploadInput.vue';
|
||||
import { unproxify } from '@/libs/unproxify';
|
||||
import { SidebarElement, useConnectionsStore } from '@/stores/connections';
|
||||
import { CustomIcon, SidebarElement, useConnectionsStore } from '@/stores/connections';
|
||||
import { useNotificationsStore } from '@/stores/notifications';
|
||||
|
||||
const { t } = useI18n();
|
||||
@@ -156,6 +156,7 @@ const importData = () => {
|
||||
const importObj: {
|
||||
connections: ConnectionParams[];
|
||||
connectionsOrder: SidebarElement[];
|
||||
customIcons: CustomIcon[];
|
||||
} = JSON.parse(decrypt(hash, options.value.passkey));
|
||||
|
||||
if (options.value.ignoreDuplicates) {
|
||||
@@ -205,7 +206,6 @@ const importData = () => {
|
||||
.includes(c.uid) ||
|
||||
(c.isFolder && c.connections.every(c => newConnectionsUid.includes(c))));
|
||||
}
|
||||
|
||||
importConnections(importObj);
|
||||
|
||||
addNotification({
|
||||
@@ -215,6 +215,7 @@ const importData = () => {
|
||||
closeModal();
|
||||
}
|
||||
catch (error) {
|
||||
console.error(error);
|
||||
addNotification({
|
||||
status: 'error',
|
||||
message: t('application.wrongImportPassword')
|
||||
@@ -222,6 +223,7 @@ const importData = () => {
|
||||
}
|
||||
}
|
||||
catch (error) {
|
||||
console.error(error);
|
||||
addNotification({
|
||||
status: 'error',
|
||||
message: t('application.wrongFileFormat')
|
||||
|
@@ -42,7 +42,7 @@
|
||||
tabindex="0"
|
||||
>
|
||||
<div class="td py-1">
|
||||
{{ t(shortcutEvents[shortcut.event].l18n, {param: shortcutEvents[shortcut.event].l18nParam}) }}
|
||||
{{ t(shortcutEvents[shortcut.event].i18n, {param: shortcutEvents[shortcut.event].i18nParam}) }}
|
||||
</div>
|
||||
<div
|
||||
class="td py-1"
|
||||
@@ -167,7 +167,7 @@
|
||||
</template>
|
||||
<template #body>
|
||||
<div class="mb-2">
|
||||
{{ t('general.deleteConfirm') }} <b>{{ t(shortcutEvents[shortcutToDelete.event].l18n, {param: shortcutEvents[shortcutToDelete.event].l18nParam}) }} (<span v-html="parseKeys(shortcutToDelete.keys)" />)</b>?
|
||||
{{ t('general.deleteConfirm') }} <b>{{ t(shortcutEvents[shortcutToDelete.event].i18n, {param: shortcutEvents[shortcutToDelete.event].i18nParam}) }} (<span v-html="parseKeys(shortcutToDelete.keys)" />)</b>?
|
||||
</div>
|
||||
</template>
|
||||
</ConfirmModal>
|
||||
@@ -233,7 +233,7 @@ const { shortcuts } = storeToRefs(settingsStore);
|
||||
const eventOptions = computed(() => {
|
||||
return Object.keys(shortcutEvents)
|
||||
.map(key => {
|
||||
return { value: key, label: t(shortcutEvents[key].l18n, { param: shortcutEvents[key].l18nParam }) };
|
||||
return { value: key, label: t(shortcutEvents[key].i18n, { param: shortcutEvents[key].i18nParam }) };
|
||||
})
|
||||
.sort((a, b) => {
|
||||
if (a.label < b.label) return -1;
|
||||
|
@@ -3,6 +3,7 @@
|
||||
<div
|
||||
:id="`editor-${id}`"
|
||||
class="editor"
|
||||
:class="editorClasses"
|
||||
:style="{height: `${height}px`}"
|
||||
/>
|
||||
</div>
|
||||
@@ -54,7 +55,8 @@ const props = defineProps({
|
||||
schema: { type: String, default: '' },
|
||||
autoFocus: { type: Boolean, default: false },
|
||||
readOnly: { type: Boolean, default: false },
|
||||
height: { type: Number, default: 200 }
|
||||
height: { type: Number, default: 200 },
|
||||
editorClasses: { type: String, default: '' }
|
||||
});
|
||||
|
||||
const emit = defineEmits(['update:modelValue']);
|
||||
@@ -341,7 +343,7 @@ onMounted(() => {
|
||||
lastTableFields.value = res.response.map((field: { name: string }) => field.name);
|
||||
editor.value.completers = [tableFieldsCompleter.value];
|
||||
editor.value.execCommand('startAutocomplete');
|
||||
}).catch(console.log);
|
||||
}).catch(console.error);
|
||||
}
|
||||
else
|
||||
editor.value.completers = customCompleter.value;
|
||||
@@ -405,18 +407,17 @@ defineExpose({ editor });
|
||||
|
||||
.ace_gutter-cell.ace_breakpoint {
|
||||
&::before {
|
||||
content: '\F0403';
|
||||
content: '';
|
||||
position: absolute;
|
||||
left: 3px;
|
||||
top: 2px;
|
||||
color: $primary-color;
|
||||
left: 0px;
|
||||
top: 8px;
|
||||
display: inline-block;
|
||||
font: normal normal normal 24px/1 "Material Design Icons", sans-serif;
|
||||
font-size: inherit;
|
||||
text-rendering: auto;
|
||||
line-height: inherit;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
width: 0;
|
||||
height: 0;
|
||||
border-left: 8px solid transparent;
|
||||
border-top: 8px solid transparent;
|
||||
border-right: 8px solid var(--primary-color);
|
||||
transform: rotate(-45deg);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
@@ -14,7 +14,7 @@
|
||||
<div class="tile-icon">
|
||||
<BaseIcon
|
||||
:icon-name="note.type === 'query'
|
||||
? 'mdiStarOutline'
|
||||
? 'mdiHeartOutline'
|
||||
: note.type === 'todo'
|
||||
? note.isArchived
|
||||
? 'mdiCheckboxMarkedOutline'
|
||||
@@ -32,7 +32,7 @@
|
||||
v-if="note.type === 'query'"
|
||||
ref="noteParagraph"
|
||||
class="tile-paragraph sql"
|
||||
v-html="highlight(highlightWord(note.note), {html: true})"
|
||||
v-html="highlight(note.note, {html: true})"
|
||||
/>
|
||||
<div
|
||||
v-else
|
||||
@@ -47,65 +47,50 @@
|
||||
<div class="tile-history-buttons">
|
||||
<button
|
||||
v-if="note.type === 'todo' && !note.isArchived"
|
||||
class="btn btn-link pl-1"
|
||||
class="btn btn-dark tooltip tooltip-left"
|
||||
:data-tooltip="t('general.archive')"
|
||||
@click.stop="$emit('archive-note', note.uid)"
|
||||
>
|
||||
<BaseIcon
|
||||
icon-name="mdiCheck"
|
||||
class="pr-1"
|
||||
:size="22"
|
||||
/> {{ t('general.archive') }}
|
||||
<BaseIcon icon-name="mdiCheck" :size="22" />
|
||||
</button>
|
||||
<button
|
||||
v-if="note.type === 'todo' && note.isArchived"
|
||||
class="btn btn-link pl-1"
|
||||
class="btn btn-dark tooltip tooltip-left"
|
||||
:data-tooltip="t('general.undo')"
|
||||
@click.stop="$emit('restore-note', note.uid)"
|
||||
>
|
||||
<BaseIcon
|
||||
icon-name="mdiRestore"
|
||||
class="pr-1"
|
||||
:size="22"
|
||||
/> {{ t('general.undo') }}
|
||||
<BaseIcon icon-name="mdiRestore" :size="22" />
|
||||
</button>
|
||||
<button
|
||||
v-if="note.type === 'query'"
|
||||
class="btn btn-link pl-1"
|
||||
class="btn btn-dark tooltip tooltip-left"
|
||||
:data-tooltip="t('general.select')"
|
||||
@click.stop="$emit('select-query', note.note)"
|
||||
>
|
||||
<BaseIcon
|
||||
icon-name="mdiOpenInApp"
|
||||
class="pr-1"
|
||||
:size="22"
|
||||
/> {{ t('general.select') }}
|
||||
<BaseIcon icon-name="mdiOpenInApp" :size="22" />
|
||||
</button>
|
||||
<button
|
||||
v-if="note.type === 'query'"
|
||||
class="btn btn-link pl-1"
|
||||
class="btn btn-dark tooltip tooltip-left"
|
||||
:data-tooltip="t('general.copy')"
|
||||
@click.stop="copyText(note.note)"
|
||||
>
|
||||
<BaseIcon
|
||||
icon-name="mdiContentCopy"
|
||||
class="pr-1"
|
||||
:size="22"
|
||||
/> {{ t('general.copy') }}
|
||||
<BaseIcon icon-name="mdiContentCopy" :size="18" />
|
||||
</button>
|
||||
<button
|
||||
v-if=" !note.isArchived"
|
||||
class="btn btn-link pl-1"
|
||||
class="btn btn-dark tooltip tooltip-left"
|
||||
:data-tooltip="t('general.edit')"
|
||||
@click.stop="$emit('edit-note')"
|
||||
>
|
||||
<BaseIcon
|
||||
icon-name="mdiPencil"
|
||||
class="pr-1"
|
||||
:size="22"
|
||||
/> {{ t('general.edit') }}
|
||||
<BaseIcon icon-name="mdiPencil" :size="22" />
|
||||
</button>
|
||||
<button class="btn btn-link pl-1" @click.stop="$emit('delete-note', note.uid)">
|
||||
<BaseIcon
|
||||
icon-name="mdiDeleteForever"
|
||||
class="pr-1"
|
||||
:size="22"
|
||||
/> {{ t('general.delete') }}
|
||||
<button
|
||||
class="btn btn-dark tooltip tooltip-left"
|
||||
:data-tooltip="t('general.delete')"
|
||||
@click.stop="$emit('delete-note', note.uid)"
|
||||
>
|
||||
<BaseIcon icon-name="mdiDeleteForever" :size="22" />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -256,9 +241,9 @@ const highlightWord = (string: string) => {
|
||||
|
||||
code, pre {
|
||||
max-width: 100%;
|
||||
width: 100%;
|
||||
display: inline-block;
|
||||
font-size: 100%;
|
||||
// color: $primary-color;
|
||||
opacity: 0.8;
|
||||
font-weight: 600;
|
||||
white-space: break-spaces;
|
||||
@@ -278,11 +263,14 @@ const highlightWord = (string: string) => {
|
||||
|
||||
button {
|
||||
font-size: 0.7rem;
|
||||
height: 1rem;
|
||||
line-height: 1rem;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
margin: 0 5px;
|
||||
padding: 0;
|
||||
height: 24px;
|
||||
width: 24px;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -342,6 +330,8 @@ const highlightWord = (string: string) => {
|
||||
<style lang="scss">
|
||||
.tile-paragraph {
|
||||
white-space: initial;
|
||||
word-break: break-word;
|
||||
user-select: text;
|
||||
|
||||
h1, h2, h3, h4, h5, h6, p, li {
|
||||
margin: 0;
|
||||
|
@@ -56,6 +56,7 @@
|
||||
>
|
||||
<BaseIcon
|
||||
:icon-name="camelize(element.icon)"
|
||||
:type="element.hasCustomIcon ? 'custom' : 'mdi'"
|
||||
:size="36"
|
||||
/>
|
||||
</div>
|
||||
@@ -93,6 +94,7 @@ import * as Draggable from 'vuedraggable';
|
||||
|
||||
import BaseIcon from '@/components/BaseIcon.vue';
|
||||
import SettingBarConnectionsFolder from '@/components/SettingBarConnectionsFolder.vue';
|
||||
import { camelize } from '@/libs/camelize';
|
||||
import { SidebarElement, useConnectionsStore } from '@/stores/connections';
|
||||
import { useWorkspacesStore } from '@/stores/workspaces';
|
||||
|
||||
@@ -165,16 +167,6 @@ const getStatusBadge = (uid: string) => {
|
||||
}
|
||||
};
|
||||
|
||||
const camelize = (text: string) => {
|
||||
const textArr = text.split('-');
|
||||
for (let i = 0; i < textArr.length; i++) {
|
||||
if (i === 0) continue;
|
||||
textArr[i] = textArr[i].charAt(0).toUpperCase() + textArr[i].slice(1);
|
||||
}
|
||||
|
||||
return textArr.join('');
|
||||
};
|
||||
|
||||
watch(() => dummyNested.value.length, () => {
|
||||
dummyNested.value = [];
|
||||
});
|
||||
|
@@ -70,6 +70,7 @@
|
||||
>
|
||||
<BaseIcon
|
||||
:icon-name="camelize(getConnectionOrderByUid(element).icon)"
|
||||
:type="getConnectionOrderByUid(element).hasCustomIcon ? 'custom' : 'mdi'"
|
||||
:size="36"
|
||||
/>
|
||||
</div>
|
||||
|
@@ -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 = {
|
||||
|
@@ -1,8 +1,8 @@
|
||||
<template>
|
||||
<div
|
||||
id="footer"
|
||||
:class="[lightColors.includes(footerColor) ? 'text-dark' : 'text-light']"
|
||||
:style="`background-color: ${footerColor};`"
|
||||
:class="[lightColors.includes(accentColor) ? 'text-dark' : 'text-light']"
|
||||
:style="`background-color: ${accentColor};`"
|
||||
>
|
||||
<div class="footer-left-elements">
|
||||
<ul class="footer-elements">
|
||||
@@ -43,11 +43,7 @@
|
||||
|
||||
<div class="footer-right-elements">
|
||||
<ul class="footer-elements">
|
||||
<li
|
||||
v-if="workspace?.connectionStatus === 'connected'"
|
||||
class="footer-element footer-link"
|
||||
@click="toggleConsole()"
|
||||
>
|
||||
<li class="footer-element footer-link" @click="toggleConsole()">
|
||||
<BaseIcon
|
||||
icon-name="mdiConsoleLine"
|
||||
class="mr-1"
|
||||
@@ -85,10 +81,11 @@
|
||||
<script setup lang="ts">
|
||||
import { shell } from 'electron';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { computed, ComputedRef } from 'vue';
|
||||
import { computed, ComputedRef, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
|
||||
import BaseIcon from '@/components/BaseIcon.vue';
|
||||
import { hexToRGBA } from '@/libs/hexToRgba';
|
||||
import { useApplicationStore } from '@/stores/application';
|
||||
import { useConnectionsStore } from '@/stores/connections';
|
||||
import { useConsoleStore } from '@/stores/console';
|
||||
@@ -117,7 +114,11 @@ const { getWorkspace } = workspacesStore;
|
||||
const { getConnectionFolder, getConnectionByUid } = connectionsStore;
|
||||
|
||||
const workspace = computed(() => getWorkspace(workspaceUid.value));
|
||||
const footerColor = computed(() => getConnectionFolder(workspaceUid.value)?.color || '#E36929');
|
||||
const accentColor = computed(() => {
|
||||
if (getConnectionFolder(workspaceUid.value)?.color)
|
||||
return getConnectionFolder(workspaceUid.value).color;
|
||||
return '#E36929';
|
||||
});
|
||||
const connectionInfos = computed(() => getConnectionByUid(workspaceUid.value));
|
||||
const version: ComputedRef<DatabaseInfos> = computed(() => {
|
||||
return getWorkspace(workspaceUid.value) ? workspace.value.version : null;
|
||||
@@ -129,7 +130,17 @@ const versionString = computed(() => {
|
||||
return '';
|
||||
});
|
||||
|
||||
watch(accentColor, () => {
|
||||
changeAccentColor();
|
||||
});
|
||||
|
||||
const openOutside = (link: string) => shell.openExternal(link);
|
||||
const changeAccentColor = () => {
|
||||
document.querySelector<HTMLBodyElement>(':root').style.setProperty('--primary-color', accentColor.value);
|
||||
document.querySelector<HTMLBodyElement>(':root').style.setProperty('--primary-color-shadow', hexToRGBA(accentColor.value, 0.2));
|
||||
};
|
||||
|
||||
changeAccentColor();
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
|
@@ -32,7 +32,7 @@ const { removeNotification } = notificationsStore;
|
||||
const { notifications } = storeToRefs(notificationsStore);
|
||||
const { notificationsTimeout } = storeToRefs(settingsStore);
|
||||
|
||||
const timeouts: Ref<{[key: string]: NodeJS.Timeout}> = ref({});
|
||||
const timeouts: Ref<Record<string, NodeJS.Timeout>> = ref({});
|
||||
|
||||
const latestNotifications = computed(() => notifications.value.slice(0, 10));
|
||||
|
||||
|
@@ -186,7 +186,7 @@ if (!connectionsArr.value.length)
|
||||
.settingbar-top-elements {
|
||||
overflow-x: hidden;
|
||||
overflow-y: overlay;
|
||||
// max-height: calc((100vh - 3.5rem) - #{$excluding-size});
|
||||
width: 100%;
|
||||
|
||||
&::-webkit-scrollbar {
|
||||
width: 3px;
|
||||
@@ -233,6 +233,7 @@ if (!connectionsArr.value.length)
|
||||
border-radius: 0;
|
||||
padding: 0;
|
||||
position: relative;
|
||||
border: none;
|
||||
|
||||
&:hover {
|
||||
opacity: 1;
|
||||
|
@@ -1,6 +1,5 @@
|
||||
<template>
|
||||
<div
|
||||
v-if="!isLinux"
|
||||
id="titlebar"
|
||||
@dblclick="toggleFullScreen"
|
||||
>
|
||||
@@ -21,16 +20,27 @@
|
||||
class="titlebar-element"
|
||||
@click="openDevTools"
|
||||
>
|
||||
<BaseIcon icon-name="mdiBugPlayOutline" :size="24" />
|
||||
<BaseIcon icon-name="mdiBugPlayOutline" :size="18" />
|
||||
</div>
|
||||
<div
|
||||
v-if="isDevelopment"
|
||||
class="titlebar-element"
|
||||
@click="reload"
|
||||
>
|
||||
<BaseIcon icon-name="mdiRefresh" :size="24" />
|
||||
<BaseIcon icon-name="mdiRefresh" :size="18" />
|
||||
</div>
|
||||
<div v-if="isWindows" :style="'width: 140px;'" />
|
||||
<div v-if="isLinux" class="d-flex">
|
||||
<div class="titlebar-element" @click="minimize">
|
||||
<BaseIcon icon-name="mdiWindowMinimize" :size="18" />
|
||||
</div>
|
||||
<div class="titlebar-element" @click="toggleFullScreen">
|
||||
<BaseIcon :icon-name="isMaximized ? 'mdiWindowRestore' : 'mdiWindowMaximize'" :size="18" />
|
||||
</div>
|
||||
<div class="titlebar-element" @click="closeApp">
|
||||
<BaseIcon icon-name="mdiClose" :size="18" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -74,6 +84,18 @@ const windowTitle = computed(() => {
|
||||
return [connectionName, ...breadcrumbs].join(' • ');
|
||||
});
|
||||
|
||||
const openDevTools = () => {
|
||||
w.value.webContents.openDevTools();
|
||||
};
|
||||
|
||||
const reload = () => {
|
||||
w.value.reload();
|
||||
};
|
||||
|
||||
const minimize = () => {
|
||||
w.value.minimize();
|
||||
};
|
||||
|
||||
const toggleFullScreen = () => {
|
||||
if (isMaximized.value)
|
||||
w.value.unmaximize();
|
||||
@@ -81,12 +103,8 @@ const toggleFullScreen = () => {
|
||||
w.value.maximize();
|
||||
};
|
||||
|
||||
const openDevTools = () => {
|
||||
w.value.webContents.openDevTools();
|
||||
};
|
||||
|
||||
const reload = () => {
|
||||
w.value.reload();
|
||||
const closeApp = () => {
|
||||
ipcRenderer.send('close-app');
|
||||
};
|
||||
|
||||
const onResize = () => {
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -1,432 +1,461 @@
|
||||
<template>
|
||||
<div class="connection-panel">
|
||||
<div class="panel">
|
||||
<div class="panel-nav">
|
||||
<ul class="tab tab-block">
|
||||
<li
|
||||
class="tab-item c-hand"
|
||||
:class="{'active': selectedTab === 'general'}"
|
||||
@click="selectTab('general')"
|
||||
>
|
||||
<a class="tab-link">{{ t('application.general') }}</a>
|
||||
</li>
|
||||
<li
|
||||
v-if="clientCustomizations.sslConnection"
|
||||
class="tab-item c-hand"
|
||||
:class="{'active': selectedTab === 'ssl'}"
|
||||
@click="selectTab('ssl')"
|
||||
>
|
||||
<a class="tab-link">{{ t('connection.ssl') }}</a>
|
||||
</li>
|
||||
<li
|
||||
v-if="clientCustomizations.sshConnection"
|
||||
class="tab-item c-hand"
|
||||
:class="{'active': selectedTab === 'ssh'}"
|
||||
@click="selectTab('ssh')"
|
||||
>
|
||||
<a class="tab-link">{{ t('connection.sshTunnel') }}</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div v-if="selectedTab === 'general'" class="panel-body py-0">
|
||||
<div>
|
||||
<form class="form-horizontal">
|
||||
<fieldset class="m-0" :disabled="isBusy">
|
||||
<div class="form-group columns">
|
||||
<div class="column col-5 col-sm-12">
|
||||
<label class="form-label cut-text">{{ t('connection.connectionName') }}</label>
|
||||
</div>
|
||||
<div class="column col-7 col-sm-12">
|
||||
<input
|
||||
ref="firstInput"
|
||||
v-model="connection.name"
|
||||
class="form-input"
|
||||
type="text"
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group columns">
|
||||
<div class="column col-5 col-sm-12">
|
||||
<label class="form-label cut-text">{{ t('connection.client') }}</label>
|
||||
</div>
|
||||
<div class="column col-7 col-sm-12">
|
||||
<BaseSelect
|
||||
v-model="connection.client"
|
||||
:options="clients"
|
||||
option-track-by="slug"
|
||||
option-label="name"
|
||||
class="form-select"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="connection.client === 'pg'" class="form-group columns">
|
||||
<div class="column col-5 col-sm-12">
|
||||
<label class="form-label cut-text">{{ t('connection.connectionString') }}</label>
|
||||
</div>
|
||||
<div class="column col-7 col-sm-12">
|
||||
<input
|
||||
ref="pgString"
|
||||
v-model="connection.pgConnString"
|
||||
class="form-input"
|
||||
type="text"
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="!clientCustomizations.fileConnection" class="form-group columns">
|
||||
<div class="column col-5 col-sm-12">
|
||||
<label class="form-label cut-text">{{ t('connection.hostName') }}/IP</label>
|
||||
</div>
|
||||
<div class="column col-7 col-sm-12">
|
||||
<input
|
||||
v-model="connection.host"
|
||||
class="form-input"
|
||||
type="text"
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="clientCustomizations.fileConnection" class="form-group columns">
|
||||
<div class="column col-5 col-sm-12">
|
||||
<label class="form-label cut-text">{{ t('database.database') }}</label>
|
||||
</div>
|
||||
<div class="column col-7 col-sm-12">
|
||||
<BaseUploadInput
|
||||
:model-value="connection.databasePath"
|
||||
:message="t('general.browse')"
|
||||
@clear="pathClear('databasePath')"
|
||||
@change="pathSelection($event, 'databasePath')"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="!clientCustomizations.fileConnection" class="form-group columns">
|
||||
<div class="column col-5 col-sm-12">
|
||||
<label class="form-label cut-text">{{ t('connection.port') }}</label>
|
||||
</div>
|
||||
<div class="column col-7 col-sm-12">
|
||||
<input
|
||||
v-model="connection.port"
|
||||
class="form-input"
|
||||
type="number"
|
||||
min="1"
|
||||
max="65535"
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="clientCustomizations.database" class="form-group columns">
|
||||
<div class="column col-5 col-sm-12">
|
||||
<label class="form-label cut-text">{{ t('database.database') }}</label>
|
||||
</div>
|
||||
<div class="column col-7 col-sm-12">
|
||||
<input
|
||||
v-model="connection.database"
|
||||
class="form-input"
|
||||
type="text"
|
||||
:placeholder="clientCustomizations.defaultDatabase"
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="!clientCustomizations.fileConnection" class="form-group columns">
|
||||
<div class="column col-5 col-sm-12">
|
||||
<label class="form-label cut-text">{{ t('connection.user') }}</label>
|
||||
</div>
|
||||
<div class="column col-7 col-sm-12">
|
||||
<input
|
||||
v-model="connection.user"
|
||||
class="form-input"
|
||||
type="text"
|
||||
:disabled="connection.ask"
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="!clientCustomizations.fileConnection" class="form-group columns">
|
||||
<div class="column col-5 col-sm-12">
|
||||
<label class="form-label cut-text">{{ t('connection.password') }}</label>
|
||||
</div>
|
||||
<div class="column col-7 col-sm-12">
|
||||
<input
|
||||
v-model="connection.password"
|
||||
class="form-input"
|
||||
type="password"
|
||||
:disabled="connection.ask"
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="clientCustomizations.connectionSchema" class="form-group columns">
|
||||
<div class="column col-5 col-sm-12">
|
||||
<label class="form-label cut-text">{{ t('database.schema') }}</label>
|
||||
</div>
|
||||
<div class="column col-7 col-sm-12">
|
||||
<input
|
||||
v-model="connection.schema"
|
||||
class="form-input"
|
||||
type="text"
|
||||
:placeholder="t('general.all')"
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="clientCustomizations.readOnlyMode" class="form-group columns">
|
||||
<div class="column col-5 col-sm-12" />
|
||||
<div class="column col-7 col-sm-12">
|
||||
<label class="form-checkbox form-inline">
|
||||
<input v-model="connection.readonly" type="checkbox"><i class="form-icon" /> {{ t('connection.readOnlyMode') }}
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="!clientCustomizations.fileConnection" class="form-group columns">
|
||||
<div class="column col-5 col-sm-12" />
|
||||
<div class="column col-7 col-sm-12">
|
||||
<label class="form-checkbox form-inline">
|
||||
<input v-model="connection.ask" type="checkbox"><i class="form-icon" /> {{ t('connection.askCredentials') }}
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
</form>
|
||||
<div class="connection-panel-wrapper p-relative">
|
||||
<div class="connection-panel">
|
||||
<div class="panel">
|
||||
<div class="panel-nav">
|
||||
<ul class="tab tab-block">
|
||||
<li
|
||||
class="tab-item c-hand"
|
||||
:class="{'active': selectedTab === 'general'}"
|
||||
@click="selectTab('general')"
|
||||
>
|
||||
<a class="tab-link">{{ t('application.general') }}</a>
|
||||
</li>
|
||||
<li
|
||||
v-if="clientCustomizations.sslConnection"
|
||||
class="tab-item c-hand"
|
||||
:class="{'active': selectedTab === 'ssl'}"
|
||||
@click="selectTab('ssl')"
|
||||
>
|
||||
<a class="tab-link">{{ t('connection.ssl') }}</a>
|
||||
</li>
|
||||
<li
|
||||
v-if="clientCustomizations.sshConnection"
|
||||
class="tab-item c-hand"
|
||||
:class="{'active': selectedTab === 'ssh'}"
|
||||
@click="selectTab('ssh')"
|
||||
>
|
||||
<a class="tab-link">{{ t('connection.sshTunnel') }}</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="selectedTab === 'ssl'" class="panel-body py-0">
|
||||
<div>
|
||||
<form class="form-horizontal">
|
||||
<div class="form-group columns">
|
||||
<div class="column col-5 col-sm-12">
|
||||
<label class="form-label cut-text">
|
||||
{{ t('connection.enableSsl') }}
|
||||
</label>
|
||||
</div>
|
||||
<div class="column col-7 col-sm-12">
|
||||
<label class="form-switch d-inline-block" @click.prevent="toggleSsl">
|
||||
<input type="checkbox" :checked="connection.ssl">
|
||||
<i class="form-icon" />
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<fieldset class="m-0" :disabled="isBusy || !connection.ssl">
|
||||
<div class="form-group columns">
|
||||
<div class="column col-5 col-sm-12">
|
||||
<label class="form-label cut-text">{{ t('connection.privateKey') }}</label>
|
||||
</div>
|
||||
<div class="column col-7 col-sm-12">
|
||||
<BaseUploadInput
|
||||
:model-value="connection.key"
|
||||
:message="t('general.browse')"
|
||||
@clear="pathClear('key')"
|
||||
@change="pathSelection($event, 'key')"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group columns">
|
||||
<div class="column col-5 col-sm-12">
|
||||
<label class="form-label cut-text">{{ t('connection.certificate') }}</label>
|
||||
</div>
|
||||
<div class="column col-7 col-sm-12">
|
||||
<BaseUploadInput
|
||||
:model-value="connection.cert"
|
||||
:message="t('general.browse')"
|
||||
@clear="pathClear('cert')"
|
||||
@change="pathSelection($event, 'cert')"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group columns">
|
||||
<div class="column col-5 col-sm-12">
|
||||
<label class="form-label cut-text">{{ t('connection.caCertificate') }}</label>
|
||||
</div>
|
||||
<div class="column col-7 col-sm-12">
|
||||
<BaseUploadInput
|
||||
:model-value="connection.ca"
|
||||
:message="t('general.browse')"
|
||||
@clear="pathClear('ca')"
|
||||
@change="pathSelection($event, 'ca')"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group columns">
|
||||
<div class="column col-5 col-sm-12">
|
||||
<label class="form-label cut-text">{{ t('connection.ciphers') }}</label>
|
||||
</div>
|
||||
<div class="column col-7 col-sm-12">
|
||||
<input
|
||||
ref="firstInput"
|
||||
v-model="connection.ciphers"
|
||||
class="form-input"
|
||||
type="text"
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group columns">
|
||||
<div class="column col-5 col-sm-12" />
|
||||
<div class="column col-7 col-sm-12">
|
||||
<label class="form-checkbox form-inline">
|
||||
<input v-model="connection.untrustedConnection" type="checkbox"><i class="form-icon" /> {{ t('connection.untrustedConnection') }}
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="selectedTab === 'ssh'" class="panel-body py-0">
|
||||
<div>
|
||||
<form class="form-horizontal">
|
||||
<div class="form-group columns">
|
||||
<div class="column col-5 col-sm-12">
|
||||
<label class="form-label cut-text">
|
||||
{{ t('connection.enableSsh') }}
|
||||
</label>
|
||||
</div>
|
||||
<div class="column col-7 col-sm-12">
|
||||
<label class="form-switch d-inline-block" @click.prevent="toggleSsh">
|
||||
<input type="checkbox" :checked="connection.ssh">
|
||||
<i class="form-icon" />
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<fieldset class="m-0" :disabled="isBusy || !connection.ssh">
|
||||
<div class="form-group columns">
|
||||
<div class="column col-5 col-sm-12">
|
||||
<label class="form-label cut-text">{{ t('connection.hostName') }}/IP</label>
|
||||
</div>
|
||||
<div class="column col-7 col-sm-12">
|
||||
<input
|
||||
v-model="connection.sshHost"
|
||||
class="form-input"
|
||||
type="text"
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group columns">
|
||||
<div class="column col-5 col-sm-12">
|
||||
<label class="form-label cut-text">{{ t('connection.user') }}</label>
|
||||
</div>
|
||||
<div class="column col-7 col-sm-12">
|
||||
<input
|
||||
v-model="connection.sshUser"
|
||||
class="form-input"
|
||||
type="text"
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group columns">
|
||||
<div class="column col-5 col-sm-12">
|
||||
<label class="form-label cut-text">{{ t('connection.password') }}</label>
|
||||
</div>
|
||||
<div class="column col-7 col-sm-12">
|
||||
<input
|
||||
v-model="connection.sshPass"
|
||||
class="form-input"
|
||||
type="password"
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group columns">
|
||||
<div class="column col-5 col-sm-12">
|
||||
<label class="form-label cut-text">{{ t('connection.port') }}</label>
|
||||
</div>
|
||||
<div class="column col-7 col-sm-12">
|
||||
<input
|
||||
v-model="connection.sshPort"
|
||||
class="form-input"
|
||||
type="number"
|
||||
min="1"
|
||||
max="65535"
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group columns">
|
||||
<div class="column col-5 col-sm-12">
|
||||
<label class="form-label cut-text">{{ t('connection.privateKey') }}</label>
|
||||
</div>
|
||||
<div class="column col-7 col-sm-12">
|
||||
<BaseUploadInput
|
||||
:model-value="connection.sshKey"
|
||||
:message="t('general.browse')"
|
||||
@clear="pathClear('sshKey')"
|
||||
@change="pathSelection($event, 'sshKey')"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group columns">
|
||||
<div class="column col-5 col-sm-12">
|
||||
<label class="form-label cut-text">{{ t('connection.passphrase') }}</label>
|
||||
</div>
|
||||
<div class="column col-7 col-sm-12">
|
||||
<input
|
||||
v-model="connection.sshPassphrase"
|
||||
class="form-input"
|
||||
type="password"
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group columns">
|
||||
<div class="column col-5 col-sm-12">
|
||||
<label class="form-label cut-text">{{ t('connection.keepAliveInterval') }}</label>
|
||||
</div>
|
||||
<div class="column col-7 col-sm-12">
|
||||
<div class="input-group">
|
||||
<div v-if="selectedTab === 'general'" class="panel-body py-0">
|
||||
<div>
|
||||
<form class="form-horizontal">
|
||||
<fieldset class="m-0" :disabled="isBusy">
|
||||
<div class="form-group columns">
|
||||
<div class="column col-5 col-sm-12">
|
||||
<label class="form-label cut-text">{{ t('connection.connectionName') }}</label>
|
||||
</div>
|
||||
<div class="column col-7 col-sm-12">
|
||||
<input
|
||||
v-model="connection.sshKeepAliveInterval"
|
||||
ref="firstInput"
|
||||
v-model="connection.name"
|
||||
class="form-input"
|
||||
type="text"
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group columns">
|
||||
<div class="column col-5 col-sm-12">
|
||||
<label class="form-label cut-text">{{ t('connection.client') }}</label>
|
||||
</div>
|
||||
<div class="column col-7 col-sm-12">
|
||||
<BaseSelect
|
||||
v-model="connection.client"
|
||||
:options="clients"
|
||||
option-track-by="slug"
|
||||
option-label="name"
|
||||
class="form-select"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="connection.client === 'pg'" class="form-group columns">
|
||||
<div class="column col-5 col-sm-12">
|
||||
<label class="form-label cut-text">{{ t('connection.connectionString') }}</label>
|
||||
</div>
|
||||
<div class="column col-7 col-sm-12">
|
||||
<input
|
||||
ref="pgString"
|
||||
v-model="connection.connString"
|
||||
class="form-input"
|
||||
type="text"
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="!clientCustomizations.fileConnection" class="form-group columns">
|
||||
<div class="column col-5 col-sm-12">
|
||||
<label class="form-label cut-text">{{ t('connection.hostName') }}/IP</label>
|
||||
</div>
|
||||
<div class="column col-7 col-sm-12">
|
||||
<input
|
||||
v-model="connection.host"
|
||||
class="form-input"
|
||||
type="text"
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="clientCustomizations.fileConnection" class="form-group columns">
|
||||
<div class="column col-5 col-sm-12">
|
||||
<label class="form-label cut-text">{{ t('database.database') }}</label>
|
||||
</div>
|
||||
<div class="column col-7 col-sm-12">
|
||||
<BaseUploadInput
|
||||
:model-value="connection.databasePath"
|
||||
:message="t('general.browse')"
|
||||
@clear="pathClear('databasePath')"
|
||||
@change="pathSelection($event, 'databasePath')"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="!clientCustomizations.fileConnection" class="form-group columns">
|
||||
<div class="column col-5 col-sm-12">
|
||||
<label class="form-label cut-text">{{ t('connection.port') }}</label>
|
||||
</div>
|
||||
<div class="column col-7 col-sm-12">
|
||||
<input
|
||||
v-model="connection.port"
|
||||
class="form-input"
|
||||
type="number"
|
||||
min="1"
|
||||
max="65535"
|
||||
>
|
||||
<span class="input-group-addon">{{ t('general.seconds') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="clientCustomizations.database" class="form-group columns">
|
||||
<div class="column col-5 col-sm-12">
|
||||
<label class="form-label cut-text">{{ t('database.database') }}</label>
|
||||
</div>
|
||||
<div class="column col-7 col-sm-12">
|
||||
<input
|
||||
v-model="connection.database"
|
||||
class="form-input"
|
||||
type="text"
|
||||
:placeholder="clientCustomizations.defaultDatabase"
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="!clientCustomizations.fileConnection" class="form-group columns">
|
||||
<div class="column col-5 col-sm-12">
|
||||
<label class="form-label cut-text">{{ t('connection.user') }}</label>
|
||||
</div>
|
||||
<div class="column col-7 col-sm-12">
|
||||
<input
|
||||
v-model="connection.user"
|
||||
class="form-input"
|
||||
type="text"
|
||||
:disabled="connection.ask"
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="!clientCustomizations.fileConnection" class="form-group columns">
|
||||
<div class="column col-5 col-sm-12">
|
||||
<label class="form-label cut-text">{{ t('connection.password') }}</label>
|
||||
</div>
|
||||
<div class="column col-7 col-sm-12">
|
||||
<input
|
||||
v-model="connection.password"
|
||||
class="form-input"
|
||||
type="password"
|
||||
:disabled="connection.ask"
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="clientCustomizations.connectionSchema" class="form-group columns">
|
||||
<div class="column col-5 col-sm-12">
|
||||
<label class="form-label cut-text">{{ t('database.schema') }}</label>
|
||||
</div>
|
||||
<div class="column col-7 col-sm-12">
|
||||
<input
|
||||
v-model="connection.schema"
|
||||
class="form-input"
|
||||
type="text"
|
||||
:placeholder="t('general.all')"
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="clientCustomizations.readOnlyMode" class="form-group columns mb-0">
|
||||
<div class="column col-5 col-sm-12" />
|
||||
<div class="column col-7 col-sm-12">
|
||||
<label class="form-checkbox form-inline my-0">
|
||||
<input v-model="connection.readonly" type="checkbox"><i class="form-icon" /> {{ t('connection.readOnlyMode') }}
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="!clientCustomizations.fileConnection" class="form-group columns mb-0">
|
||||
<div class="column col-5 col-sm-12" />
|
||||
<div class="column col-7 col-sm-12">
|
||||
<label class="form-checkbox form-inline my-0">
|
||||
<input v-model="connection.ask" type="checkbox"><i class="form-icon" /> {{ t('connection.askCredentials') }}
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="clientCustomizations.singleConnectionMode" class="form-group columns mb-0">
|
||||
<div class="column col-5 col-sm-12" />
|
||||
<div class="column col-7 col-sm-12">
|
||||
<label class="form-checkbox form-inline my-0">
|
||||
<input v-model="connection.singleConnectionMode" type="checkbox"><i class="form-icon" /> {{ t('connection.singleConnection') }}
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="selectedTab === 'ssl'" class="panel-body py-0">
|
||||
<div>
|
||||
<form class="form-horizontal">
|
||||
<div class="form-group columns">
|
||||
<div class="column col-5 col-sm-12">
|
||||
<label class="form-label cut-text">
|
||||
{{ t('connection.enableSsl') }}
|
||||
</label>
|
||||
</div>
|
||||
<div class="column col-7 col-sm-12">
|
||||
<label class="form-switch d-inline-block" @click.prevent="toggleSsl">
|
||||
<input type="checkbox" :checked="connection.ssl">
|
||||
<i class="form-icon" />
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
</form>
|
||||
<fieldset class="m-0" :disabled="isBusy || !connection.ssl">
|
||||
<div class="form-group columns">
|
||||
<div class="column col-5 col-sm-12">
|
||||
<label class="form-label cut-text">{{ t('connection.privateKey') }}</label>
|
||||
</div>
|
||||
<div class="column col-7 col-sm-12">
|
||||
<BaseUploadInput
|
||||
:model-value="connection.key"
|
||||
:message="t('general.browse')"
|
||||
@clear="pathClear('key')"
|
||||
@change="pathSelection($event, 'key')"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group columns">
|
||||
<div class="column col-5 col-sm-12">
|
||||
<label class="form-label cut-text">{{ t('connection.certificate') }}</label>
|
||||
</div>
|
||||
<div class="column col-7 col-sm-12">
|
||||
<BaseUploadInput
|
||||
:model-value="connection.cert"
|
||||
:message="t('general.browse')"
|
||||
@clear="pathClear('cert')"
|
||||
@change="pathSelection($event, 'cert')"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group columns">
|
||||
<div class="column col-5 col-sm-12">
|
||||
<label class="form-label cut-text">{{ t('connection.caCertificate') }}</label>
|
||||
</div>
|
||||
<div class="column col-7 col-sm-12">
|
||||
<BaseUploadInput
|
||||
:model-value="connection.ca"
|
||||
:message="t('general.browse')"
|
||||
@clear="pathClear('ca')"
|
||||
@change="pathSelection($event, 'ca')"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group columns">
|
||||
<div class="column col-5 col-sm-12">
|
||||
<label class="form-label cut-text">{{ t('connection.ciphers') }}</label>
|
||||
</div>
|
||||
<div class="column col-7 col-sm-12">
|
||||
<input
|
||||
ref="firstInput"
|
||||
v-model="connection.ciphers"
|
||||
class="form-input"
|
||||
type="text"
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group columns">
|
||||
<div class="column col-5 col-sm-12" />
|
||||
<div class="column col-7 col-sm-12">
|
||||
<label class="form-checkbox form-inline">
|
||||
<input v-model="connection.untrustedConnection" type="checkbox"><i class="form-icon" /> {{ t('connection.untrustedConnection') }}
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="selectedTab === 'ssh'" class="panel-body py-0">
|
||||
<div>
|
||||
<form class="form-horizontal">
|
||||
<div class="form-group columns">
|
||||
<div class="column col-5 col-sm-12">
|
||||
<label class="form-label cut-text">
|
||||
{{ t('connection.enableSsh') }}
|
||||
</label>
|
||||
</div>
|
||||
<div class="column col-7 col-sm-12">
|
||||
<label class="form-switch d-inline-block" @click.prevent="toggleSsh">
|
||||
<input type="checkbox" :checked="connection.ssh">
|
||||
<i class="form-icon" />
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<fieldset class="m-0" :disabled="isBusy || !connection.ssh">
|
||||
<div class="form-group columns">
|
||||
<div class="column col-5 col-sm-12">
|
||||
<label class="form-label cut-text">{{ t('connection.hostName') }}/IP</label>
|
||||
</div>
|
||||
<div class="column col-7 col-sm-12">
|
||||
<input
|
||||
v-model="connection.sshHost"
|
||||
class="form-input"
|
||||
type="text"
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group columns">
|
||||
<div class="column col-5 col-sm-12">
|
||||
<label class="form-label cut-text">{{ t('connection.user') }}</label>
|
||||
</div>
|
||||
<div class="column col-7 col-sm-12">
|
||||
<input
|
||||
v-model="connection.sshUser"
|
||||
class="form-input"
|
||||
type="text"
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group columns">
|
||||
<div class="column col-5 col-sm-12">
|
||||
<label class="form-label cut-text">{{ t('connection.password') }}</label>
|
||||
</div>
|
||||
<div class="column col-7 col-sm-12">
|
||||
<input
|
||||
v-model="connection.sshPass"
|
||||
class="form-input"
|
||||
type="password"
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group columns">
|
||||
<div class="column col-5 col-sm-12">
|
||||
<label class="form-label cut-text">{{ t('connection.port') }}</label>
|
||||
</div>
|
||||
<div class="column col-7 col-sm-12">
|
||||
<input
|
||||
v-model="connection.sshPort"
|
||||
class="form-input"
|
||||
type="number"
|
||||
min="1"
|
||||
max="65535"
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group columns">
|
||||
<div class="column col-5 col-sm-12">
|
||||
<label class="form-label cut-text">{{ t('connection.privateKey') }}</label>
|
||||
</div>
|
||||
<div class="column col-7 col-sm-12">
|
||||
<BaseUploadInput
|
||||
:model-value="connection.sshKey"
|
||||
:message="t('general.browse')"
|
||||
@clear="pathClear('sshKey')"
|
||||
@change="pathSelection($event, 'sshKey')"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group columns">
|
||||
<div class="column col-5 col-sm-12">
|
||||
<label class="form-label cut-text">{{ t('connection.passphrase') }}</label>
|
||||
</div>
|
||||
<div class="column col-7 col-sm-12">
|
||||
<input
|
||||
v-model="connection.sshPassphrase"
|
||||
class="form-input"
|
||||
type="password"
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group columns">
|
||||
<div class="column col-5 col-sm-12">
|
||||
<label class="form-label cut-text">{{ t('connection.keepAliveInterval') }}</label>
|
||||
</div>
|
||||
<div class="column col-7 col-sm-12">
|
||||
<div class="input-group">
|
||||
<input
|
||||
v-model="connection.sshKeepAliveInterval"
|
||||
class="form-input"
|
||||
type="number"
|
||||
min="1"
|
||||
>
|
||||
<span class="input-group-addon">{{ t('general.seconds') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div class="panel-footer">
|
||||
<div
|
||||
@mouseenter="setCancelTestButtonVisibility(true)"
|
||||
@mouseleave="setCancelTestButtonVisibility(false)"
|
||||
>
|
||||
<button
|
||||
v-if="showTestCancel && isTesting"
|
||||
class="btn btn-gray mr-2 cancellable"
|
||||
:title="t('general.cancel')"
|
||||
@click="abortConnection()"
|
||||
>
|
||||
<BaseIcon icon-name="mdiWindowClose" :size="24" />
|
||||
<span class="d-invisible pr-1">{{ t('connection.testConnection') }}</span>
|
||||
</button>
|
||||
<button
|
||||
v-else
|
||||
id="connection-test"
|
||||
class="btn btn-gray mr-2 d-flex"
|
||||
:class="{'loading': isTesting}"
|
||||
:disabled="isBusy"
|
||||
@click="startTest"
|
||||
>
|
||||
<BaseIcon
|
||||
icon-name="mdiLightningBolt"
|
||||
:size="24"
|
||||
class="mr-1"
|
||||
/>
|
||||
{{ t('connection.testConnection') }}
|
||||
</button>
|
||||
</div>
|
||||
<button
|
||||
id="connection-save"
|
||||
class="btn btn-primary mr-2 d-flex"
|
||||
:disabled="isBusy"
|
||||
@click="saveConnection"
|
||||
>
|
||||
<BaseIcon
|
||||
icon-name="mdiContentSave"
|
||||
:size="24"
|
||||
class="mr-1"
|
||||
/>
|
||||
{{ t('general.save') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="panel-footer">
|
||||
<button
|
||||
id="connection-test"
|
||||
class="btn btn-gray mr-2 d-flex"
|
||||
:class="{'loading': isTesting}"
|
||||
:disabled="isBusy"
|
||||
@click="startTest"
|
||||
>
|
||||
<BaseIcon
|
||||
icon-name="mdiLightningBolt"
|
||||
:size="24"
|
||||
class="mr-1"
|
||||
/>
|
||||
{{ t('connection.testConnection') }}
|
||||
</button>
|
||||
<button
|
||||
id="connection-save"
|
||||
class="btn btn-primary mr-2 d-flex"
|
||||
:disabled="isBusy"
|
||||
@click="saveConnection"
|
||||
>
|
||||
<BaseIcon
|
||||
icon-name="mdiContentSave"
|
||||
:size="24"
|
||||
class="mr-1"
|
||||
/>
|
||||
{{ t('general.save') }}
|
||||
</button>
|
||||
</div>
|
||||
<ModalAskCredentials
|
||||
v-if="isAsking"
|
||||
@close-asking="closeAsking"
|
||||
@credentials="continueTest"
|
||||
/>
|
||||
</div>
|
||||
<ModalAskCredentials
|
||||
v-if="isAsking"
|
||||
@close-asking="closeAsking"
|
||||
@credentials="continueTest"
|
||||
/>
|
||||
</div>
|
||||
<DebugConsole v-if="isConsoleOpen" />
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import customizations from 'common/customizations';
|
||||
import { ConnectionParams } from 'common/interfaces/antares';
|
||||
import { uidGen } from 'common/libs/uidGen';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { computed, Ref, ref, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
|
||||
import BaseIcon from '@/components/BaseIcon.vue';
|
||||
import BaseSelect from '@/components/BaseSelect.vue';
|
||||
import BaseUploadInput from '@/components/BaseUploadInput.vue';
|
||||
import DebugConsole from '@/components/DebugConsole.vue';
|
||||
import ModalAskCredentials from '@/components/ModalAskCredentials.vue';
|
||||
import Connection from '@/ipc-api/Connection';
|
||||
import { useConnectionsStore } from '@/stores/connections';
|
||||
import { useConsoleStore } from '@/stores/console';
|
||||
import { useNotificationsStore } from '@/stores/notifications';
|
||||
import { useWorkspacesStore } from '@/stores/workspaces';
|
||||
|
||||
@@ -435,6 +464,7 @@ const { t } = useI18n();
|
||||
const { addConnection } = useConnectionsStore();
|
||||
const { addNotification } = useNotificationsStore();
|
||||
const workspacesStore = useWorkspacesStore();
|
||||
const { isConsoleOpen } = storeToRefs(useConsoleStore());
|
||||
|
||||
const { connectWorkspace, selectWorkspace } = workspacesStore;
|
||||
|
||||
@@ -472,13 +502,15 @@ const connection = ref({
|
||||
sshKey: '',
|
||||
sshPort: 22,
|
||||
sshKeepAliveInterval: 1800,
|
||||
pgConnString: ''
|
||||
}) as Ref<ConnectionParams & { pgConnString: string }>;
|
||||
connString: ''
|
||||
}) as Ref<ConnectionParams & { connString: string }>;
|
||||
|
||||
const firstInput: Ref<HTMLInputElement> = ref(null);
|
||||
const isConnecting = ref(false);
|
||||
const isTesting = ref(false);
|
||||
const isAsking = ref(false);
|
||||
const showTestCancel = ref(false);
|
||||
const abortController: Ref<AbortController> = ref(new AbortController());
|
||||
const selectedTab = ref('general');
|
||||
|
||||
const clientCustomizations = computed(() => {
|
||||
@@ -501,6 +533,10 @@ const setDefaults = () => {
|
||||
connection.value.database = clientCustomizations.value.defaultDatabase;
|
||||
};
|
||||
|
||||
const setCancelTestButtonVisibility = (val: boolean) => {
|
||||
showTestCancel.value = val;
|
||||
};
|
||||
|
||||
const startTest = async () => {
|
||||
isTesting.value = true;
|
||||
|
||||
@@ -511,7 +547,7 @@ const startTest = async () => {
|
||||
const res = await Connection.makeTest(connection.value);
|
||||
if (res.status === 'error')
|
||||
addNotification({ status: 'error', message: res.response.message || res.response.toString() });
|
||||
else
|
||||
else if (res.status === 'success')
|
||||
addNotification({ status: 'success', message: t('connection.connectionSuccessfullyMade') });
|
||||
}
|
||||
catch (err) {
|
||||
@@ -522,13 +558,21 @@ const startTest = async () => {
|
||||
}
|
||||
};
|
||||
|
||||
const abortConnection = (): void => {
|
||||
abortController.value.abort();
|
||||
Connection.abortConnection(connection.value.uid);
|
||||
isTesting.value = false;
|
||||
isConnecting.value = false;
|
||||
abortController.value = new AbortController();
|
||||
};
|
||||
|
||||
const continueTest = async (credentials: { user: string; password: string }) => { // if "Ask for credentials" is true
|
||||
isAsking.value = false;
|
||||
const params = Object.assign({}, connection.value, credentials);
|
||||
|
||||
try {
|
||||
if (isConnecting.value) {
|
||||
await connectWorkspace(params);
|
||||
await connectWorkspace(params, { signal: abortController.value.signal }).catch(() => undefined);
|
||||
isConnecting.value = false;
|
||||
}
|
||||
else {
|
||||
@@ -572,11 +616,11 @@ const pathSelection = (event: Event & {target: {files: {path: string}[]}}, name:
|
||||
const { files } = event.target;
|
||||
if (!files.length) return;
|
||||
|
||||
(connection.value as unknown as {[key: string]: string})[name] = files[0].path as string;
|
||||
(connection.value as unknown as Record<string, string>)[name] = files[0].path as string;
|
||||
};
|
||||
|
||||
const pathClear = (name: keyof ConnectionParams) => {
|
||||
(connection.value as unknown as {[key: string]: string})[name] = '';
|
||||
(connection.value as unknown as Record<string, string>)[name] = '';
|
||||
};
|
||||
|
||||
setDefaults();
|
||||
|
@@ -68,7 +68,7 @@
|
||||
<div class="column col-7 col-sm-12">
|
||||
<input
|
||||
ref="pgString"
|
||||
v-model="localConnection.pgConnString"
|
||||
v-model="localConnection.connString"
|
||||
class="form-input"
|
||||
type="text"
|
||||
>
|
||||
@@ -165,22 +165,30 @@
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="clientCustomizations.readOnlyMode" class="form-group columns">
|
||||
<div v-if="clientCustomizations.readOnlyMode" class="form-group columns mb-0">
|
||||
<div class="column col-5 col-sm-12" />
|
||||
<div class="column col-7 col-sm-12">
|
||||
<label class="form-checkbox form-inline">
|
||||
<label class="form-checkbox form-inline my-0">
|
||||
<input v-model="localConnection.readonly" type="checkbox"><i class="form-icon" /> {{ t('connection.readOnlyMode') }}
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="!clientCustomizations.fileConnection" class="form-group columns">
|
||||
<div v-if="!clientCustomizations.fileConnection" class="form-group columns mb-0">
|
||||
<div class="column col-5 col-sm-12" />
|
||||
<div class="column col-7 col-sm-12">
|
||||
<label class="form-checkbox form-inline">
|
||||
<label class="form-checkbox form-inline my-0">
|
||||
<input v-model="localConnection.ask" type="checkbox"><i class="form-icon" /> {{ t('connection.askCredentials') }}
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="clientCustomizations.singleConnectionMode" class="form-group columns mb-0">
|
||||
<div class="column col-5 col-sm-12" />
|
||||
<div class="column col-7 col-sm-12">
|
||||
<label class="form-checkbox form-inline my-0">
|
||||
<input v-model="localConnection.singleConnectionMode" type="checkbox"><i class="form-icon" /> {{ t('connection.singleConnection') }}
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
</form>
|
||||
</div>
|
||||
@@ -379,20 +387,35 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="panel-footer">
|
||||
<button
|
||||
id="connection-test"
|
||||
class="btn btn-gray mr-2 d-flex"
|
||||
:class="{'loading': isTesting}"
|
||||
:disabled="isBusy"
|
||||
@click="startTest"
|
||||
<div
|
||||
@mouseenter="setCancelTestButtonVisibility(true)"
|
||||
@mouseleave="setCancelTestButtonVisibility(false)"
|
||||
>
|
||||
<BaseIcon
|
||||
icon-name="mdiLightningBolt"
|
||||
:size="24"
|
||||
class="mr-1"
|
||||
/>
|
||||
{{ t('connection.testConnection') }}
|
||||
</button>
|
||||
<button
|
||||
v-if="showTestCancel && isTesting"
|
||||
class="btn btn-gray mr-2 cancellable"
|
||||
:title="t('general.cancel')"
|
||||
@click="abortConnection()"
|
||||
>
|
||||
<BaseIcon icon-name="mdiWindowClose" :size="24" />
|
||||
<span class="d-invisible pr-1">{{ t('connection.testConnection') }}</span>
|
||||
</button>
|
||||
<button
|
||||
v-else
|
||||
id="connection-test"
|
||||
class="btn btn-gray mr-2 d-flex"
|
||||
:class="{'loading': isTesting}"
|
||||
:disabled="isBusy"
|
||||
@click="startTest"
|
||||
>
|
||||
<BaseIcon
|
||||
icon-name="mdiLightningBolt"
|
||||
:size="24"
|
||||
class="mr-1"
|
||||
/>
|
||||
{{ t('connection.testConnection') }}
|
||||
</button>
|
||||
</div>
|
||||
<button
|
||||
id="connection-save"
|
||||
class="btn btn-primary mr-2 d-flex"
|
||||
@@ -406,20 +429,35 @@
|
||||
/>
|
||||
{{ t('general.save') }}
|
||||
</button>
|
||||
<button
|
||||
id="connection-connect"
|
||||
class="btn btn-success d-flex"
|
||||
:class="{'loading': isConnecting}"
|
||||
:disabled="isBusy"
|
||||
@click="startConnection"
|
||||
<div
|
||||
@mouseenter="setCancelConnectButtonVisibility(true)"
|
||||
@mouseleave="setCancelConnectButtonVisibility(false)"
|
||||
>
|
||||
<BaseIcon
|
||||
icon-name="mdiConnection"
|
||||
:size="24"
|
||||
class="mr-1"
|
||||
/>
|
||||
{{ t('connection.connect') }}
|
||||
</button>
|
||||
<button
|
||||
v-if="showConnectCancel && isConnecting"
|
||||
class="btn btn-success cancellable"
|
||||
:title="t('general.cancel')"
|
||||
@click="abortConnection()"
|
||||
>
|
||||
<BaseIcon icon-name="mdiWindowClose" :size="24" />
|
||||
<span class="d-invisible pr-1">{{ t('connection.connect') }}</span>
|
||||
</button>
|
||||
<button
|
||||
v-else
|
||||
id="connection-connect"
|
||||
class="btn btn-success d-flex"
|
||||
:class="{'loading': isConnecting}"
|
||||
:disabled="isBusy"
|
||||
@click="startConnection"
|
||||
>
|
||||
<BaseIcon
|
||||
icon-name="mdiConnection"
|
||||
:size="24"
|
||||
class="mr-1"
|
||||
/>
|
||||
{{ t('connection.connect') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<ModalAskCredentials
|
||||
@@ -464,10 +502,13 @@ const clients = [
|
||||
];
|
||||
|
||||
const firstInput: Ref<HTMLInputElement> = ref(null);
|
||||
const localConnection: Ref<ConnectionParams & { pgConnString: string }> = ref(null);
|
||||
const localConnection: Ref<ConnectionParams & { connString: string }> = ref(null);
|
||||
const isConnecting = ref(false);
|
||||
const isTesting = ref(false);
|
||||
const isAsking = ref(false);
|
||||
const showTestCancel = ref(false);
|
||||
const showConnectCancel = ref(false);
|
||||
const abortController: Ref<AbortController> = ref(new AbortController());
|
||||
const selectedTab = ref('general');
|
||||
|
||||
const clientCustomizations = computed(() => {
|
||||
@@ -486,14 +527,14 @@ watch(() => props.connection, () => {
|
||||
localConnection.value = JSON.parse(JSON.stringify(props.connection));
|
||||
});
|
||||
|
||||
const startConnection = async () => {
|
||||
const startConnection = async (): Promise<void> => {
|
||||
await saveConnection();
|
||||
isConnecting.value = true;
|
||||
|
||||
if (localConnection.value.ask)
|
||||
isAsking.value = true;
|
||||
else {
|
||||
await connectWorkspace(localConnection.value);
|
||||
await connectWorkspace(localConnection.value, { signal: abortController.value.signal }).catch((): void => undefined);
|
||||
isConnecting.value = false;
|
||||
}
|
||||
};
|
||||
@@ -508,7 +549,7 @@ const startTest = async () => {
|
||||
const res = await Connection.makeTest(localConnection.value);
|
||||
if (res.status === 'error')
|
||||
addNotification({ status: 'error', message: res.response.message || res.response.toString() });
|
||||
else
|
||||
else if (res.status === 'success')
|
||||
addNotification({ status: 'success', message: t('connection.connectionSuccessfullyMade') });
|
||||
}
|
||||
catch (err) {
|
||||
@@ -519,20 +560,36 @@ const startTest = async () => {
|
||||
}
|
||||
};
|
||||
|
||||
const setCancelTestButtonVisibility = (val: boolean) => {
|
||||
showTestCancel.value = val;
|
||||
};
|
||||
|
||||
const setCancelConnectButtonVisibility = (val: boolean) => {
|
||||
showConnectCancel.value = val;
|
||||
};
|
||||
|
||||
const abortConnection = (): void => {
|
||||
abortController.value.abort();
|
||||
Connection.abortConnection(localConnection.value.uid);
|
||||
isTesting.value = false;
|
||||
isConnecting.value = false;
|
||||
abortController.value = new AbortController();
|
||||
};
|
||||
|
||||
const continueTest = async (credentials: {user: string; password: string }) => { // if "Ask for credentials" is true
|
||||
isAsking.value = false;
|
||||
const params = Object.assign({}, localConnection.value, credentials);
|
||||
try {
|
||||
if (isConnecting.value) {
|
||||
const params = Object.assign({}, props.connection, credentials);
|
||||
await connectWorkspace(params);
|
||||
await connectWorkspace(params, { signal: abortController.value.signal }).catch((): void => undefined);
|
||||
isConnecting.value = false;
|
||||
}
|
||||
else {
|
||||
const res = await Connection.makeTest(params);
|
||||
if (res.status === 'error')
|
||||
addNotification({ status: 'error', message: res.response.message || res.response.toString() });
|
||||
else
|
||||
else if (res.status === 'success')
|
||||
addNotification({ status: 'success', message: t('connection.connectionSuccessfullyMade') });
|
||||
}
|
||||
}
|
||||
@@ -569,11 +626,11 @@ const pathSelection = (event: Event & {target: {files: {path: string}[]}}, name:
|
||||
const { files } = event.target;
|
||||
if (!files.length) return;
|
||||
|
||||
(localConnection.value as unknown as {[key: string]: string})[name] = files[0].path;
|
||||
(localConnection.value as unknown as Record<string, string>)[name] = files[0].path;
|
||||
};
|
||||
|
||||
const pathClear = (name: keyof ConnectionParams) => {
|
||||
(localConnection.value as unknown as {[key: string]: string})[name] = '';
|
||||
(localConnection.value as unknown as Record<string, string>)[name] = '';
|
||||
};
|
||||
|
||||
localConnection.value = JSON.parse(JSON.stringify(props.connection));
|
||||
@@ -590,6 +647,22 @@ localConnection.value = JSON.parse(JSON.stringify(props.connection));
|
||||
min-width: 450px;
|
||||
border-radius: $border-radius;
|
||||
|
||||
.panel-nav {
|
||||
.tab-block {
|
||||
background: transparent;
|
||||
margin: 0.2rem 0 0.15rem 0;
|
||||
|
||||
.tab-item {
|
||||
background: transparent;
|
||||
flex: 1 0 0;
|
||||
|
||||
> a {
|
||||
padding: 8px 4px 6px 4px
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.panel-body {
|
||||
flex: initial;
|
||||
}
|
||||
|
@@ -19,6 +19,8 @@
|
||||
v-model="selectedDatabase"
|
||||
:options="databases"
|
||||
class="form-select select-sm text-bold my-0"
|
||||
@keypress.stop=""
|
||||
@keydown.stop=""
|
||||
/>
|
||||
</div>
|
||||
<span v-else class="workspace-explorebar-title">{{ connectionName }}</span>
|
||||
@@ -34,7 +36,6 @@
|
||||
</div>
|
||||
<div :title="t('general.refresh')">
|
||||
<BaseIcon
|
||||
v-if="customizations.schemas"
|
||||
icon-name="mdiRefresh"
|
||||
:size="18"
|
||||
class="c-hand mr-2"
|
||||
@@ -110,6 +111,7 @@
|
||||
@close-context="closeDatabaseContext"
|
||||
@open-create-table-tab="openCreateElementTab('table')"
|
||||
@open-create-view-tab="openCreateElementTab('view')"
|
||||
@open-create-materialized-view-tab="openCreateElementTab('materialized-view')"
|
||||
@open-create-trigger-tab="openCreateElementTab('trigger')"
|
||||
@open-create-routine-tab="openCreateElementTab('routine')"
|
||||
@open-create-function-tab="openCreateElementTab('function')"
|
||||
@@ -140,10 +142,12 @@
|
||||
:selected-misc="selectedMisc"
|
||||
:selected-schema="selectedSchema"
|
||||
:context-event="miscContextEvent"
|
||||
@open-create-view-tab="openCreateElementTab('view')"
|
||||
@open-create-materializedView-tab="openCreateElementTab('materialized-view')"
|
||||
@open-create-trigger-tab="openCreateElementTab('trigger')"
|
||||
@open-create-trigger-function-tab="openCreateElementTab('trigger-function')"
|
||||
@open-create-routine-tab="openCreateElementTab('routine')"
|
||||
@open-create-function-tab="openCreateElementTab('function')"
|
||||
@open-create-trigger-function-tab="openCreateElementTab('trigger-function')"
|
||||
@open-create-scheduler-tab="openCreateElementTab('scheduler')"
|
||||
@close-context="closeMiscFolderContext"
|
||||
@reload="refresh"
|
||||
@@ -502,7 +506,7 @@ const toggleSearchMethod = () => {
|
||||
transition: background 0.2s;
|
||||
|
||||
&:hover {
|
||||
background: rgba($primary-color, 50%);
|
||||
background: var(--primary-color-dark);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -16,7 +16,7 @@
|
||||
/> {{ t('general.run') }}</span>
|
||||
</div>
|
||||
<div
|
||||
v-if="selectedMisc.type === 'trigger' && customizations.triggerEnableDisable"
|
||||
v-if="selectedMisc.type === 'trigger' && customizations.triggerEnableDisable && !connection.readonly"
|
||||
class="context-element"
|
||||
@click="toggleTrigger"
|
||||
>
|
||||
@@ -36,7 +36,7 @@
|
||||
</span>
|
||||
</div>
|
||||
<div
|
||||
v-if="selectedMisc.type === 'scheduler'"
|
||||
v-if="selectedMisc.type === 'scheduler' && !connection.readonly"
|
||||
class="context-element"
|
||||
@click="toggleScheduler"
|
||||
>
|
||||
@@ -63,7 +63,11 @@
|
||||
:size="18"
|
||||
/> {{ t('general.copyName') }}</span>
|
||||
</div>
|
||||
<div class="context-element" @click="showDeleteModal">
|
||||
<div
|
||||
v-if="!connection.readonly"
|
||||
class="context-element"
|
||||
@click="showDeleteModal"
|
||||
>
|
||||
<span class="d-flex">
|
||||
<BaseIcon
|
||||
class="text-light mt-1 mr-1"
|
||||
@@ -117,6 +121,7 @@ import Routines from '@/ipc-api/Routines';
|
||||
import Schedulers from '@/ipc-api/Schedulers';
|
||||
import Triggers from '@/ipc-api/Triggers';
|
||||
import { copyText } from '@/libs/copyText';
|
||||
import { useConnectionsStore } from '@/stores/connections';
|
||||
import { useNotificationsStore } from '@/stores/notifications';
|
||||
import { useWorkspacesStore } from '@/stores/workspaces';
|
||||
|
||||
@@ -132,6 +137,7 @@ const emit = defineEmits(['close-context', 'reload']);
|
||||
|
||||
const { addNotification } = useNotificationsStore();
|
||||
const workspacesStore = useWorkspacesStore();
|
||||
const { getConnectionByUid } = useConnectionsStore();
|
||||
|
||||
const { getSelected: selectedWorkspace } = storeToRefs(workspacesStore);
|
||||
|
||||
@@ -154,6 +160,7 @@ const workspace = computed(() => {
|
||||
const customizations = computed(() => {
|
||||
return getWorkspace(selectedWorkspace.value).customizations;
|
||||
});
|
||||
const connection = computed(() => getConnectionByUid(selectedWorkspace.value));
|
||||
|
||||
const deleteMessage = computed(() => {
|
||||
switch (props.selectedMisc.type) {
|
||||
|
@@ -3,6 +3,30 @@
|
||||
:context-event="props.contextEvent"
|
||||
@close-context="closeContext"
|
||||
>
|
||||
<div
|
||||
v-if="props.selectedMisc === 'view'"
|
||||
class="context-element"
|
||||
@click="emit('open-create-view-tab')"
|
||||
>
|
||||
<span class="d-flex">
|
||||
<BaseIcon
|
||||
class="text-light mt-1 mr-1"
|
||||
icon-name="mdiTableCog"
|
||||
:size="18"
|
||||
/> {{ t('database.createNewView') }}</span>
|
||||
</div>
|
||||
<div
|
||||
v-if="props.selectedMisc === 'materializedView'"
|
||||
class="context-element"
|
||||
@click="emit('open-create-materializedView-tab')"
|
||||
>
|
||||
<span class="d-flex">
|
||||
<BaseIcon
|
||||
class="text-light mt-1 mr-1"
|
||||
icon-name="mdiTableCog"
|
||||
:size="18"
|
||||
/> {{ t('database.createNewMaterializedView') }}</span>
|
||||
</div>
|
||||
<div
|
||||
v-if="props.selectedMisc === 'trigger'"
|
||||
class="context-element"
|
||||
@@ -81,6 +105,8 @@ const props = defineProps({
|
||||
});
|
||||
|
||||
const emit = defineEmits([
|
||||
'open-create-view-tab',
|
||||
'open-create-materializedView-tab',
|
||||
'open-create-trigger-tab',
|
||||
'open-create-routine-tab',
|
||||
'open-create-function-tab',
|
||||
|
@@ -67,6 +67,104 @@
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div v-if="filteredViews.length" class="database-misc">
|
||||
<details class="accordion">
|
||||
<summary
|
||||
class="accordion-header misc-name"
|
||||
:class="{'text-bold': breadcrumbs.schema === database.name && breadcrumbs.trigger}"
|
||||
@contextmenu.prevent="showMiscFolderContext($event, 'view')"
|
||||
>
|
||||
<BaseIcon
|
||||
class="misc-icon mr-1"
|
||||
icon-name="mdiFolderEye"
|
||||
:size="18"
|
||||
/>
|
||||
<BaseIcon
|
||||
class="misc-icon open-folder mr-1"
|
||||
icon-name="mdiFolderOpen"
|
||||
:size="18"
|
||||
/>
|
||||
{{ t('database.view', 2) }}
|
||||
</summary>
|
||||
<div class="accordion-body">
|
||||
<div>
|
||||
<ul class="menu menu-nav pt-0">
|
||||
<li
|
||||
v-for="view of filteredViews"
|
||||
:key="view.name"
|
||||
class="menu-item"
|
||||
:class="{'selected': breadcrumbs.schema === database.name && breadcrumbs.view === view.name}"
|
||||
@mousedown.left="selectTable({schema: database.name, table: view})"
|
||||
@dblclick="openDataTab({schema: database.name, table: view})"
|
||||
@contextmenu.prevent="showTableContext($event, view)"
|
||||
>
|
||||
<a class="table-name">
|
||||
<div v-if="checkLoadingStatus(view.name, 'table')" class="icon loading mr-1" />
|
||||
<BaseIcon
|
||||
v-else
|
||||
class="table-icon mr-1"
|
||||
icon-name="mdiTableEye"
|
||||
:size="18"
|
||||
:style="`min-width: 18px`"
|
||||
/>
|
||||
<span v-html="highlightWord(view.name)" />
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</details>
|
||||
</div>
|
||||
|
||||
<div v-if="filteredMatViews.length && customizations.materializedViews" class="database-misc">
|
||||
<details class="accordion">
|
||||
<summary
|
||||
class="accordion-header misc-name"
|
||||
:class="{'text-bold': breadcrumbs.schema === database.name && breadcrumbs.trigger}"
|
||||
@contextmenu.prevent="showMiscFolderContext($event, 'materializedView')"
|
||||
>
|
||||
<BaseIcon
|
||||
class="misc-icon mr-1"
|
||||
icon-name="mdiFolderEye"
|
||||
:size="18"
|
||||
/>
|
||||
<BaseIcon
|
||||
class="misc-icon open-folder mr-1"
|
||||
icon-name="mdiFolderOpen"
|
||||
:size="18"
|
||||
/>
|
||||
{{ t('database.materializedView', 2) }}
|
||||
</summary>
|
||||
<div class="accordion-body">
|
||||
<div>
|
||||
<ul class="menu menu-nav pt-0">
|
||||
<li
|
||||
v-for="view of filteredMatViews"
|
||||
:key="view.name"
|
||||
class="menu-item"
|
||||
:class="{'selected': breadcrumbs.schema === database.name && breadcrumbs.view === view.name}"
|
||||
@mousedown.left="selectTable({schema: database.name, table: view})"
|
||||
@dblclick="openDataTab({schema: database.name, table: view})"
|
||||
@contextmenu.prevent="showTableContext($event, view)"
|
||||
>
|
||||
<a class="table-name">
|
||||
<div v-if="checkLoadingStatus(view.name, 'table')" class="icon loading mr-1" />
|
||||
<BaseIcon
|
||||
v-else
|
||||
class="table-icon mr-1"
|
||||
icon-name="mdiTableEye"
|
||||
:size="18"
|
||||
:style="`min-width: 18px`"
|
||||
/>
|
||||
<span v-html="highlightWord(view.name)" />
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</details>
|
||||
</div>
|
||||
|
||||
<div v-if="filteredTriggers.length && customizations.triggers" class="database-misc">
|
||||
<details class="accordion">
|
||||
<summary
|
||||
@@ -379,12 +477,30 @@ const searchTerm = computed(() => {
|
||||
});
|
||||
|
||||
const filteredTables = computed(() => {
|
||||
if (props.searchMethod === 'elements')
|
||||
return props.database.tables.filter(table => table.name.search(searchTerm.value) >= 0);
|
||||
if (props.searchMethod === 'elements') {
|
||||
const searchTermLower = searchTerm.value.toLowerCase();
|
||||
return props.database.tables.filter(table =>
|
||||
table.name.toLowerCase().includes(searchTermLower) && table.type === 'table'
|
||||
);
|
||||
}
|
||||
else
|
||||
return props.database.tables;
|
||||
});
|
||||
|
||||
const filteredViews = computed(() => {
|
||||
if (props.searchMethod === 'elements')
|
||||
return props.database.tables.filter(table => table.name.search(searchTerm.value) >= 0 && table.type === 'view');
|
||||
else
|
||||
return props.database.tables.filter(table => table.type === 'view');
|
||||
});
|
||||
|
||||
const filteredMatViews = computed(() => {
|
||||
if (props.searchMethod === 'elements')
|
||||
return props.database.tables.filter(table => table.name.search(searchTerm.value) >= 0 && table.type === 'materializedView');
|
||||
else
|
||||
return props.database.tables.filter(table => table.type === 'materializedView');
|
||||
});
|
||||
|
||||
const filteredTriggers = computed(() => {
|
||||
if (props.searchMethod === 'elements')
|
||||
return props.database.triggers.filter(trigger => trigger.name.search(searchTerm.value) >= 0);
|
||||
@@ -513,7 +629,13 @@ const selectMisc = ({ schema, misc, type }: { schema: string; misc: { name: stri
|
||||
};
|
||||
|
||||
const openDataTab = ({ schema, table }: { schema: string; table: TableInfos }) => {
|
||||
newTab({ uid: props.connection.uid, elementName: table.name, schema: props.database.name, type: 'data', elementType: table.type });
|
||||
newTab({
|
||||
uid: props.connection.uid,
|
||||
elementName: table.name,
|
||||
schema: props.database.name,
|
||||
type: 'data',
|
||||
elementType: table.type
|
||||
});
|
||||
setBreadcrumbs({ schema, [table.type]: table.name });
|
||||
};
|
||||
|
||||
|
@@ -3,7 +3,7 @@
|
||||
:context-event="contextEvent"
|
||||
@close-context="closeContext"
|
||||
>
|
||||
<div class="context-element">
|
||||
<div v-if="!connection.readonly" class="context-element">
|
||||
<span class="d-flex">
|
||||
<BaseIcon
|
||||
class="text-light mt-1 mr-1"
|
||||
@@ -40,6 +40,18 @@
|
||||
:size="18"
|
||||
/> {{ t('database.view') }}</span>
|
||||
</div>
|
||||
<div
|
||||
v-if="workspace.customizations.materializedViewAdd"
|
||||
class="context-element"
|
||||
@click="openCreateMaterializedViewTab"
|
||||
>
|
||||
<span class="d-flex">
|
||||
<BaseIcon
|
||||
class="text-light mt-1 mr-1"
|
||||
icon-name="mdiTableEye"
|
||||
:size="18"
|
||||
/> {{ t('database.materializedView') }}</span>
|
||||
</div>
|
||||
<div
|
||||
v-if="workspace.customizations.triggerAdd"
|
||||
class="context-element"
|
||||
@@ -123,7 +135,7 @@
|
||||
/> {{ t('database.export') }}</span>
|
||||
</div>
|
||||
<div
|
||||
v-if="workspace.customizations.schemaImport"
|
||||
v-if="workspace.customizations.schemaImport && !connection.readonly"
|
||||
class="context-element"
|
||||
@click="initImport"
|
||||
>
|
||||
@@ -135,7 +147,7 @@
|
||||
/> {{ t('database.import') }}</span>
|
||||
</div>
|
||||
<div
|
||||
v-if="workspace.customizations.schemaEdit"
|
||||
v-if="workspace.customizations.schemaEdit && !connection.readonly"
|
||||
class="context-element"
|
||||
@click="showEditModal"
|
||||
>
|
||||
@@ -147,7 +159,7 @@
|
||||
/> {{ t('database.editSchema') }}</span>
|
||||
</div>
|
||||
<div
|
||||
v-if="workspace.customizations.schemaDrop"
|
||||
v-if="workspace.customizations.schemaDrop && !connection.readonly"
|
||||
class="context-element"
|
||||
@click="showDeleteModal"
|
||||
>
|
||||
@@ -207,6 +219,7 @@ import ModalImportSchema from '@/components/ModalImportSchema.vue';
|
||||
import Application from '@/ipc-api/Application';
|
||||
import Schema from '@/ipc-api/Schema';
|
||||
import { copyText } from '@/libs/copyText';
|
||||
import { useConnectionsStore } from '@/stores/connections';
|
||||
import { useNotificationsStore } from '@/stores/notifications';
|
||||
import { useSchemaExportStore } from '@/stores/schemaExport';
|
||||
import { useWorkspacesStore } from '@/stores/workspaces';
|
||||
@@ -221,6 +234,7 @@ const props = defineProps({
|
||||
const emit = defineEmits([
|
||||
'open-create-table-tab',
|
||||
'open-create-view-tab',
|
||||
'open-create-materialized-view-tab',
|
||||
'open-create-trigger-tab',
|
||||
'open-create-routine-tab',
|
||||
'open-create-function-tab',
|
||||
@@ -235,7 +249,9 @@ const workspacesStore = useWorkspacesStore();
|
||||
const schemaExportStore = useSchemaExportStore();
|
||||
const { showExportModal } = schemaExportStore;
|
||||
|
||||
const connectionsStore = useConnectionsStore();
|
||||
const { getSelected: selectedWorkspace } = storeToRefs(workspacesStore);
|
||||
const { getConnectionByUid } = connectionsStore;
|
||||
|
||||
const {
|
||||
getWorkspace,
|
||||
@@ -248,6 +264,7 @@ const isEditModal = ref(false);
|
||||
const isImportSchemaModal = ref(false);
|
||||
|
||||
const workspace = computed(() => getWorkspace(selectedWorkspace.value));
|
||||
const connection = computed(() => getConnectionByUid(selectedWorkspace.value));
|
||||
|
||||
const openCreateTableTab = () => {
|
||||
emit('open-create-table-tab');
|
||||
@@ -257,6 +274,10 @@ const openCreateViewTab = () => {
|
||||
emit('open-create-view-tab');
|
||||
};
|
||||
|
||||
const openCreateMaterializedViewTab = () => {
|
||||
emit('open-create-materialized-view-tab');
|
||||
};
|
||||
|
||||
const openCreateTriggerTab = () => {
|
||||
emit('open-create-trigger-tab');
|
||||
};
|
||||
|
@@ -48,7 +48,19 @@
|
||||
/> {{ t('application.settings') }}</span>
|
||||
</div>
|
||||
<div
|
||||
v-if="selectedTable && selectedTable.type === 'table' && customizations.tableDuplicate"
|
||||
v-if="selectedTable && selectedTable.type === 'materializedView' && customizations.materializedViewSettings"
|
||||
class="context-element"
|
||||
@click="openMaterializedViewSettingTab"
|
||||
>
|
||||
<span class="d-flex">
|
||||
<BaseIcon
|
||||
class="text-light mt-1 mr-1"
|
||||
icon-name="mdiWrenchCog"
|
||||
:size="18"
|
||||
/> {{ t('application.settings') }}</span>
|
||||
</div>
|
||||
<div
|
||||
v-if="selectedTable && selectedTable.type === 'table' && customizations.tableDuplicate && !connection.readonly"
|
||||
class="context-element"
|
||||
@click="duplicateTable"
|
||||
>
|
||||
@@ -60,7 +72,7 @@
|
||||
/> {{ t('database.duplicateTable') }}</span>
|
||||
</div>
|
||||
<div
|
||||
v-if="selectedTable && selectedTable.type === 'table'"
|
||||
v-if="selectedTable && selectedTable.type === 'table' && !connection.readonly"
|
||||
class="context-element"
|
||||
@click="showEmptyModal"
|
||||
>
|
||||
@@ -71,7 +83,11 @@
|
||||
:size="18"
|
||||
/> {{ t('database.emptyTable') }}</span>
|
||||
</div>
|
||||
<div class="context-element" @click="showDeleteModal">
|
||||
<div
|
||||
v-if="!connection.readonly"
|
||||
class="context-element"
|
||||
@click="showDeleteModal"
|
||||
>
|
||||
<span class="d-flex">
|
||||
<BaseIcon
|
||||
class="text-light mt-1 mr-1"
|
||||
@@ -139,6 +155,7 @@ import BaseContextMenu from '@/components/BaseContextMenu.vue';
|
||||
import BaseIcon from '@/components/BaseIcon.vue';
|
||||
import Tables from '@/ipc-api/Tables';
|
||||
import { copyText } from '@/libs/copyText';
|
||||
import { useConnectionsStore } from '@/stores/connections';
|
||||
import { useNotificationsStore } from '@/stores/notifications';
|
||||
import { useSchemaExportStore } from '@/stores/schemaExport';
|
||||
import { useWorkspacesStore } from '@/stores/workspaces';
|
||||
@@ -156,6 +173,7 @@ const emit = defineEmits(['close-context', 'duplicate-table', 'reload', 'delete-
|
||||
const { addNotification } = useNotificationsStore();
|
||||
const workspacesStore = useWorkspacesStore();
|
||||
const { showExportModal } = useSchemaExportStore();
|
||||
const { getConnectionByUid } = useConnectionsStore();
|
||||
|
||||
const { getSelected: selectedWorkspace } = storeToRefs(workspacesStore);
|
||||
|
||||
@@ -173,6 +191,7 @@ const forceTruncate = ref(false);
|
||||
|
||||
const workspace = computed(() => getWorkspace(selectedWorkspace.value));
|
||||
const customizations = computed(() => workspace.value && workspace.value.customizations ? workspace.value.customizations : null);
|
||||
const connection = computed(() => getConnectionByUid(selectedWorkspace.value));
|
||||
|
||||
const showTableExportModal = () => {
|
||||
showExportModal(props.selectedSchema, props.selectedTable.name);
|
||||
@@ -238,6 +257,23 @@ const openViewSettingTab = () => {
|
||||
closeContext();
|
||||
};
|
||||
|
||||
const openMaterializedViewSettingTab = () => {
|
||||
newTab({
|
||||
uid: selectedWorkspace.value,
|
||||
elementType: 'table',
|
||||
elementName: props.selectedTable.name,
|
||||
schema: props.selectedSchema,
|
||||
type: 'materialized-view-props'
|
||||
});
|
||||
|
||||
changeBreadcrumbs({
|
||||
schema: props.selectedSchema,
|
||||
view: props.selectedTable.name
|
||||
});
|
||||
|
||||
closeContext();
|
||||
};
|
||||
|
||||
const duplicateTable = () => {
|
||||
emit('duplicate-table', { schema: props.selectedSchema, table: props.selectedTable });
|
||||
};
|
||||
|
@@ -1,189 +0,0 @@
|
||||
<template>
|
||||
<div
|
||||
ref="wrapper"
|
||||
class="query-console-wrapper"
|
||||
@mouseenter="isHover = true"
|
||||
@mouseleave="isHover = false"
|
||||
>
|
||||
<div ref="resizer" class="query-console-resizer" />
|
||||
<div
|
||||
id="query-console"
|
||||
ref="queryConsole"
|
||||
class="query-console column col-12"
|
||||
:style="{height: localHeight ? localHeight+'px' : ''}"
|
||||
>
|
||||
<div class="query-console-header">
|
||||
<div>{{ t('application.console') }}</div>
|
||||
<button class="btn btn-clear mr-1" @click="resizeConsole(0)" />
|
||||
</div>
|
||||
<div ref="queryConsoleBody" class="query-console-body">
|
||||
<div
|
||||
v-for="(wLog, i) in workspaceLogs"
|
||||
:key="i"
|
||||
class="query-console-log"
|
||||
tabindex="0"
|
||||
@contextmenu.prevent="contextMenu($event, wLog)"
|
||||
>
|
||||
<span class="type-datetime">{{ moment(wLog.date).format('HH:mm:ss') }}</span>: <code class="query-console-log-sql" v-html="highlight(wLog.sql, {html: true})" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<BaseContextMenu
|
||||
v-if="isContext"
|
||||
:context-event="contextEvent"
|
||||
@close-context="isContext = false"
|
||||
>
|
||||
<div class="context-element" @click="copyQuery">
|
||||
<span class="d-flex">
|
||||
<BaseIcon
|
||||
class="text-light mt-1 mr-1"
|
||||
icon-name="mdiContentCopy"
|
||||
:size="18"
|
||||
/> {{ t('general.copy') }}</span>
|
||||
</div>
|
||||
</BaseContextMenu>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import * as moment from 'moment';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { highlight } from 'sql-highlight';
|
||||
import { computed, nextTick, onMounted, Ref, ref, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
|
||||
import BaseContextMenu from '@/components/BaseContextMenu.vue';
|
||||
import BaseIcon from '@/components/BaseIcon.vue';
|
||||
import { copyText } from '@/libs/copyText';
|
||||
import { useConsoleStore } from '@/stores/console';
|
||||
|
||||
const { t } = useI18n();
|
||||
|
||||
const consoleStore = useConsoleStore();
|
||||
|
||||
const { resizeConsole, getLogsByWorkspace } = consoleStore;
|
||||
const { consoleHeight } = storeToRefs(consoleStore);
|
||||
|
||||
const props = defineProps({
|
||||
uid: String
|
||||
});
|
||||
|
||||
const wrapper: Ref<HTMLInputElement> = ref(null);
|
||||
const queryConsole: Ref<HTMLInputElement> = ref(null);
|
||||
const queryConsoleBody: Ref<HTMLInputElement> = ref(null);
|
||||
const resizer: Ref<HTMLInputElement> = ref(null);
|
||||
const localHeight = ref(250);
|
||||
const isHover = ref(false);
|
||||
const isContext = ref(false);
|
||||
const contextQuery: Ref<string> = ref(null);
|
||||
const contextEvent: Ref<MouseEvent> = ref(null);
|
||||
|
||||
const resize = (e: MouseEvent) => {
|
||||
const el = queryConsole.value;
|
||||
let consoleHeight = el.getBoundingClientRect().bottom - e.pageY;
|
||||
if (consoleHeight > 400) consoleHeight = 400;
|
||||
localHeight.value = consoleHeight;
|
||||
};
|
||||
|
||||
const workspaceLogs = computed(() => {
|
||||
return getLogsByWorkspace(props.uid);
|
||||
});
|
||||
|
||||
const stopResize = () => {
|
||||
if (localHeight.value < 0) localHeight.value = 0;
|
||||
resizeConsole(localHeight.value);
|
||||
window.removeEventListener('mousemove', resize);
|
||||
window.removeEventListener('mouseup', stopResize);
|
||||
};
|
||||
|
||||
const contextMenu = (event: MouseEvent, wLog: {date: Date; sql: string}) => {
|
||||
contextEvent.value = event;
|
||||
contextQuery.value = wLog.sql;
|
||||
isContext.value = true;
|
||||
};
|
||||
|
||||
const copyQuery = () => {
|
||||
copyText(contextQuery.value);
|
||||
isContext.value = false;
|
||||
};
|
||||
|
||||
watch(workspaceLogs, async () => {
|
||||
if (!isHover.value) {
|
||||
await nextTick();
|
||||
queryConsoleBody.value.scrollTop = queryConsoleBody.value.scrollHeight;
|
||||
}
|
||||
});
|
||||
|
||||
onMounted(() => {
|
||||
localHeight.value = consoleHeight.value;
|
||||
queryConsoleBody.value.scrollTop = queryConsoleBody.value.scrollHeight;
|
||||
});
|
||||
|
||||
onMounted(() => {
|
||||
resizer.value.addEventListener('mousedown', (e: MouseEvent) => {
|
||||
e.preventDefault();
|
||||
|
||||
window.addEventListener('mousemove', resize);
|
||||
window.addEventListener('mouseup', stopResize);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
.query-console-wrapper {
|
||||
width: 100%;
|
||||
z-index: 9;
|
||||
margin-top: auto;
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
|
||||
.query-console-resizer {
|
||||
height: 4px;
|
||||
top: -1px;
|
||||
width: 100%;
|
||||
cursor: ns-resize;
|
||||
position: absolute;
|
||||
z-index: 99;
|
||||
transition: background 0.2s;
|
||||
|
||||
&:hover {
|
||||
background: rgba($primary-color, 50%);
|
||||
}
|
||||
}
|
||||
|
||||
.query-console {
|
||||
padding: 0;
|
||||
padding-bottom: $footer-height;
|
||||
|
||||
.query-console-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 4px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.query-console-body {
|
||||
overflow: auto;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
max-height: 100%;
|
||||
padding: 0 6px 3px;
|
||||
|
||||
.query-console-log {
|
||||
padding: 1px 3px;
|
||||
margin: 1px 0;
|
||||
border-radius: $border-radius;
|
||||
|
||||
.query-console-log-sql {
|
||||
font-size: 95%;
|
||||
opacity: 0.8;
|
||||
font-weight: 700;
|
||||
|
||||
&:hover {
|
||||
user-select: text;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
293
src/renderer/components/WorkspaceTabNewMaterializedView.vue
Normal file
293
src/renderer/components/WorkspaceTabNewMaterializedView.vue
Normal file
@@ -0,0 +1,293 @@
|
||||
<template>
|
||||
<div v-show="isSelected" class="workspace-query-tab column col-12 columns col-gapless">
|
||||
<div class="workspace-query-runner column col-12">
|
||||
<div class="workspace-query-runner-footer">
|
||||
<div class="workspace-query-buttons">
|
||||
<button
|
||||
class="btn btn-primary btn-sm"
|
||||
:disabled="!isChanged"
|
||||
:class="{'loading':isSaving}"
|
||||
@click="saveChanges"
|
||||
>
|
||||
<BaseIcon
|
||||
class="mr-1"
|
||||
icon-name="mdiContentSave"
|
||||
:size="24"
|
||||
/>
|
||||
<span>{{ t('general.save') }}</span>
|
||||
</button>
|
||||
<button
|
||||
:disabled="!isChanged"
|
||||
class="btn btn-link btn-sm mr-0"
|
||||
:title="t('database.clearChanges')"
|
||||
@click="clearChanges"
|
||||
>
|
||||
<BaseIcon
|
||||
class="mr-1"
|
||||
icon-name="mdiDeleteSweep"
|
||||
:size="24"
|
||||
/>
|
||||
<span>{{ t('general.clear') }}</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="workspace-query-info">
|
||||
<div class="d-flex" :title="t('database.schema')">
|
||||
<BaseIcon
|
||||
class="mt-1 mr-1"
|
||||
icon-name="mdiDatabase"
|
||||
:size="18"
|
||||
/><b>{{ schema }}</b>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="container">
|
||||
<div class="columns">
|
||||
<div class="column col-auto">
|
||||
<div class="form-group">
|
||||
<label class="form-label">{{ t('general.name') }}</label>
|
||||
<input
|
||||
ref="firstInput"
|
||||
v-model="localView.name"
|
||||
class="form-input"
|
||||
type="text"
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
<div class="column col-auto">
|
||||
<div v-if="workspace.customizations.definer" class="form-group">
|
||||
<label class="form-label">{{ t('database.definer') }}</label>
|
||||
<BaseSelect
|
||||
v-model="localView.definer"
|
||||
:options="users"
|
||||
:option-label="(user: any) => user.value === '' ? t('database.currentUser') : `${user.name}@${user.host}`"
|
||||
:option-track-by="(user: any) => user.value === '' ? '' : `\`${user.name}\`@\`${user.host}\``"
|
||||
class="form-select"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="column col-auto mr-2">
|
||||
<div v-if="workspace.customizations.viewSqlSecurity" class="form-group">
|
||||
<label class="form-label">{{ t('database.sqlSecurity') }}</label>
|
||||
<BaseSelect
|
||||
v-model="localView.security"
|
||||
:options="['DEFINER', 'INVOKER']"
|
||||
class="form-select"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="column col-auto mr-2">
|
||||
<div v-if="workspace.customizations.viewAlgorithm" class="form-group">
|
||||
<label class="form-label">{{ t('database.algorithm') }}</label>
|
||||
<BaseSelect
|
||||
v-model="localView.algorithm"
|
||||
:options="['UNDEFINED', 'MERGE', 'TEMPTABLE']"
|
||||
class="form-select"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="workspace.customizations.viewUpdateOption" class="column col-auto mr-2">
|
||||
<div class="form-group">
|
||||
<label class="form-label">{{ t('database.updateOption') }}</label>
|
||||
<BaseSelect
|
||||
v-model="localView.updateOption"
|
||||
:option-track-by="(user: any) => user.value"
|
||||
:options="[{label: 'None', value: ''}, {label: 'CASCADED', value: 'CASCADED'}, {label: 'LOCAL', value: 'LOCAL'}]"
|
||||
class="form-select"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="workspace-query-results column col-12 mt-2 p-relative">
|
||||
<BaseLoader v-if="isLoading" />
|
||||
<label class="form-label ml-2">{{ t('database.selectStatement') }}</label>
|
||||
<QueryEditor
|
||||
v-show="isSelected"
|
||||
ref="queryEditor"
|
||||
v-model="localView.sql"
|
||||
:workspace="workspace"
|
||||
:schema="schema"
|
||||
:height="editorHeight"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { Ace } from 'ace-builds';
|
||||
import { ipcRenderer } from 'electron';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { Component, computed, onBeforeUnmount, onMounted, onUnmounted, Ref, ref, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
|
||||
import BaseIcon from '@/components/BaseIcon.vue';
|
||||
import BaseLoader from '@/components/BaseLoader.vue';
|
||||
import BaseSelect from '@/components/BaseSelect.vue';
|
||||
import QueryEditor from '@/components/QueryEditor.vue';
|
||||
import Views from '@/ipc-api/Views';
|
||||
import { useConsoleStore } from '@/stores/console';
|
||||
import { useNotificationsStore } from '@/stores/notifications';
|
||||
import { useWorkspacesStore } from '@/stores/workspaces';
|
||||
|
||||
const { t } = useI18n();
|
||||
|
||||
const props = defineProps({
|
||||
tabUid: String,
|
||||
connection: Object,
|
||||
tab: Object,
|
||||
isSelected: Boolean,
|
||||
schema: String
|
||||
});
|
||||
|
||||
const { addNotification } = useNotificationsStore();
|
||||
const workspacesStore = useWorkspacesStore();
|
||||
const { consoleHeight } = storeToRefs(useConsoleStore());
|
||||
|
||||
const {
|
||||
getWorkspace,
|
||||
refreshStructure,
|
||||
setUnsavedChanges,
|
||||
changeBreadcrumbs,
|
||||
newTab,
|
||||
removeTab
|
||||
} = workspacesStore;
|
||||
|
||||
const queryEditor: Ref<Component & {editor: Ace.Editor; $el: HTMLElement}> = ref(null);
|
||||
const firstInput: Ref<HTMLInputElement> = ref(null);
|
||||
const isLoading = ref(false);
|
||||
const isSaving = ref(false);
|
||||
const originalView = ref(null);
|
||||
const localView = ref(null);
|
||||
const editorHeight = ref(300);
|
||||
|
||||
const workspace = computed(() => getWorkspace(props.connection.uid));
|
||||
const isChanged = computed(() => JSON.stringify(originalView.value) !== JSON.stringify(localView.value));
|
||||
const isDefinerInUsers = computed(() => originalView.value ? workspace.value.users.some(user => originalView.value.definer === `\`${user.name}\`@\`${user.host}\``) : true);
|
||||
|
||||
const users = computed(() => {
|
||||
const users = [{ value: '' }, ...workspace.value.users];
|
||||
if (!isDefinerInUsers.value) {
|
||||
const [name, host] = originalView.value.definer.replaceAll('`', '').split('@');
|
||||
users.unshift({ name, host });
|
||||
}
|
||||
|
||||
return users;
|
||||
});
|
||||
|
||||
const saveChanges = async () => {
|
||||
if (isSaving.value) return;
|
||||
isSaving.value = true;
|
||||
|
||||
const params = {
|
||||
uid: props.connection.uid,
|
||||
schema: props.schema,
|
||||
...localView.value
|
||||
};
|
||||
|
||||
try {
|
||||
const { status, response } = await Views.createMaterializedView(params);
|
||||
|
||||
if (status === 'success') {
|
||||
await refreshStructure(props.connection.uid);
|
||||
|
||||
newTab({
|
||||
uid: props.connection.uid,
|
||||
schema: props.schema,
|
||||
elementName: localView.value.name,
|
||||
elementType: 'materializedView',
|
||||
type: 'materialized-view-props'
|
||||
});
|
||||
|
||||
removeTab({ uid: props.connection.uid, tab: props.tab.uid });
|
||||
changeBreadcrumbs({ schema: props.schema, view: localView.value.name });
|
||||
}
|
||||
else
|
||||
addNotification({ status: 'error', message: response });
|
||||
}
|
||||
catch (err) {
|
||||
addNotification({ status: 'error', message: err.stack });
|
||||
}
|
||||
|
||||
isSaving.value = false;
|
||||
};
|
||||
|
||||
const clearChanges = () => {
|
||||
localView.value = JSON.parse(JSON.stringify(originalView.value));
|
||||
queryEditor.value.editor.session.setValue(localView.value.sql);
|
||||
};
|
||||
|
||||
const resizeQueryEditor = () => {
|
||||
if (queryEditor.value) {
|
||||
let sizeToSubtract = 0;
|
||||
const footer = document.getElementById('footer');
|
||||
if (footer) sizeToSubtract += footer.offsetHeight;
|
||||
sizeToSubtract += consoleHeight.value;
|
||||
|
||||
const size = window.innerHeight - queryEditor.value.$el.getBoundingClientRect().top - sizeToSubtract;
|
||||
editorHeight.value = size;
|
||||
queryEditor.value.editor.resize();
|
||||
}
|
||||
};
|
||||
|
||||
const saveContentListener = () => {
|
||||
const hasModalOpen = !!document.querySelectorAll('.modal.active').length;
|
||||
if (props.isSelected && !hasModalOpen && isChanged.value)
|
||||
saveChanges();
|
||||
};
|
||||
|
||||
watch(() => props.isSelected, (val) => {
|
||||
if (val) {
|
||||
changeBreadcrumbs({ schema: props.schema, view: localView.value.name });
|
||||
|
||||
setTimeout(() => {
|
||||
resizeQueryEditor();
|
||||
}, 50);
|
||||
}
|
||||
});
|
||||
|
||||
watch(isChanged, (val) => {
|
||||
setUnsavedChanges({ uid: props.connection.uid, tUid: props.tabUid, isChanged: val });
|
||||
});
|
||||
|
||||
watch(consoleHeight, () => {
|
||||
resizeQueryEditor();
|
||||
});
|
||||
|
||||
originalView.value = {
|
||||
algorithm: 'UNDEFINED',
|
||||
definer: '',
|
||||
security: 'DEFINER',
|
||||
updateOption: '',
|
||||
sql: '',
|
||||
name: ''
|
||||
};
|
||||
|
||||
localView.value = JSON.parse(JSON.stringify(originalView.value));
|
||||
|
||||
setTimeout(() => {
|
||||
resizeQueryEditor();
|
||||
}, 50);
|
||||
|
||||
onMounted(() => {
|
||||
if (props.isSelected)
|
||||
changeBreadcrumbs({ schema: props.schema });
|
||||
|
||||
ipcRenderer.on('save-content', saveContentListener);
|
||||
|
||||
setTimeout(() => {
|
||||
firstInput.value.focus();
|
||||
}, 100);
|
||||
|
||||
window.addEventListener('resize', resizeQueryEditor);
|
||||
});
|
||||
|
||||
onUnmounted(() => {
|
||||
window.removeEventListener('resize', resizeQueryEditor);
|
||||
});
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
ipcRenderer.removeListener('save-content', saveContentListener);
|
||||
});
|
||||
|
||||
</script>
|
@@ -72,6 +72,20 @@
|
||||
/>
|
||||
<span>{{ t('database.foreignKeys') }}</span>
|
||||
</button>
|
||||
<button
|
||||
v-if="workspace.customizations.tableCheck"
|
||||
class="btn btn-dark btn-sm ml-2 mr-0"
|
||||
:disabled="isSaving || !localFields.length"
|
||||
:title="t('database.manageTableChecks')"
|
||||
@click="showTableChecksModal"
|
||||
>
|
||||
<BaseIcon
|
||||
class="mr-1"
|
||||
icon-name="mdiTableCheck"
|
||||
:size="24"
|
||||
/>
|
||||
<span>{{ t('database.tableChecks') }}</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="workspace-query-info">
|
||||
<div class="d-flex" :title="t('database.schema')">
|
||||
@@ -183,11 +197,19 @@
|
||||
@hide="hideForeignModal"
|
||||
@foreigns-update="foreignsUpdate"
|
||||
/>
|
||||
<WorkspaceTabPropsTableChecksModal
|
||||
v-if="isTableChecksModal"
|
||||
:local-checks="localTableChecks"
|
||||
table="new"
|
||||
:workspace="workspace"
|
||||
@hide="hideTableChecksModal"
|
||||
@checks-update="checksUpdate"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ConnectionParams, TableField, TableForeign, TableIndex, TableOptions } from 'common/interfaces/antares';
|
||||
import { ConnectionParams, TableCheck, TableField, TableForeign, TableIndex, TableOptions } from 'common/interfaces/antares';
|
||||
import { uidGen } from 'common/libs/uidGen';
|
||||
import { ipcRenderer } from 'electron';
|
||||
import { storeToRefs } from 'pinia';
|
||||
@@ -198,6 +220,7 @@ import BaseIcon from '@/components/BaseIcon.vue';
|
||||
import BaseLoader from '@/components/BaseLoader.vue';
|
||||
import BaseSelect from '@/components/BaseSelect.vue';
|
||||
import WorkspaceTabNewTableEmptyState from '@/components/WorkspaceTabNewTableEmptyState.vue';
|
||||
import WorkspaceTabPropsTableChecksModal from '@/components/WorkspaceTabPropsTableChecksModal.vue';
|
||||
import WorkspaceTabPropsTableFields from '@/components/WorkspaceTabPropsTableFields.vue';
|
||||
import WorkspaceTabPropsTableForeignModal from '@/components/WorkspaceTabPropsTableForeignModal.vue';
|
||||
import WorkspaceTabPropsTableIndexesModal from '@/components/WorkspaceTabPropsTableIndexesModal.vue';
|
||||
@@ -236,12 +259,16 @@ const isLoading = ref(false);
|
||||
const isSaving = ref(false);
|
||||
const isIndexesModal = ref(false);
|
||||
const isForeignModal = ref(false);
|
||||
const isTableChecksModal = ref(false);
|
||||
|
||||
const originalFields: Ref<TableField[]> = ref([]);
|
||||
const localFields: Ref<TableField[]> = ref([]);
|
||||
const originalKeyUsage: Ref<TableForeign[]> = ref([]);
|
||||
const localKeyUsage: Ref<TableForeign[]> = ref([]);
|
||||
const originalIndexes: Ref<TableIndex[]> = ref([]);
|
||||
const localIndexes: Ref<TableIndex[]> = ref([]);
|
||||
const originalTableChecks: Ref<TableCheck[]> = ref([]);
|
||||
const localTableChecks: Ref<TableCheck[]> = ref([]);
|
||||
const tableOptions: Ref<TableOptions> = ref(null);
|
||||
const localOptions: Ref<TableOptions> = ref(null);
|
||||
const newFieldsCounter = ref(0);
|
||||
@@ -274,6 +301,7 @@ const isChanged = computed(() => {
|
||||
return JSON.stringify(originalFields.value) !== JSON.stringify(localFields.value) ||
|
||||
JSON.stringify(originalKeyUsage.value) !== JSON.stringify(localKeyUsage.value) ||
|
||||
JSON.stringify(originalIndexes.value) !== JSON.stringify(localIndexes.value) ||
|
||||
JSON.stringify(originalTableChecks.value) !== JSON.stringify(localTableChecks.value) ||
|
||||
JSON.stringify(tableOptions.value) !== JSON.stringify(localOptions.value);
|
||||
});
|
||||
|
||||
@@ -291,6 +319,7 @@ const saveChanges = async () => {
|
||||
fields: localFields.value,
|
||||
foreigns: localKeyUsage.value,
|
||||
indexes: localIndexes.value,
|
||||
checks: localTableChecks.value,
|
||||
options: localOptions.value
|
||||
};
|
||||
|
||||
@@ -326,6 +355,7 @@ const clearChanges = () => {
|
||||
localFields.value = JSON.parse(JSON.stringify(originalFields.value));
|
||||
localIndexes.value = JSON.parse(JSON.stringify(originalIndexes.value));
|
||||
localKeyUsage.value = JSON.parse(JSON.stringify(originalKeyUsage.value));
|
||||
localTableChecks.value = JSON.parse(JSON.stringify(originalTableChecks.value));
|
||||
|
||||
tableOptions.value = {
|
||||
name: '',
|
||||
@@ -446,10 +476,22 @@ const hideForeignModal = () => {
|
||||
isForeignModal.value = false;
|
||||
};
|
||||
|
||||
const showTableChecksModal = () => {
|
||||
isTableChecksModal.value = true;
|
||||
};
|
||||
|
||||
const hideTableChecksModal = () => {
|
||||
isTableChecksModal.value = false;
|
||||
};
|
||||
|
||||
const foreignsUpdate = (foreigns: TableForeign[]) => {
|
||||
localKeyUsage.value = foreigns;
|
||||
};
|
||||
|
||||
const checksUpdate = (checks: TableCheck[]) => {
|
||||
localTableChecks.value = checks;
|
||||
};
|
||||
|
||||
const saveContentListener = () => {
|
||||
const hasModalOpen = !!document.querySelectorAll('.modal.active').length;
|
||||
if (props.isSelected && !hasModalOpen && isChanged.value)
|
||||
|
316
src/renderer/components/WorkspaceTabPropsMaterializedView.vue
Normal file
316
src/renderer/components/WorkspaceTabPropsMaterializedView.vue
Normal file
@@ -0,0 +1,316 @@
|
||||
<template>
|
||||
<div v-show="isSelected" class="workspace-query-tab column col-12 columns col-gapless">
|
||||
<div class="workspace-query-runner column col-12">
|
||||
<div class="workspace-query-runner-footer">
|
||||
<div class="workspace-query-buttons">
|
||||
<button
|
||||
class="btn btn-primary btn-sm"
|
||||
:disabled="!isChanged"
|
||||
:class="{'loading':isSaving}"
|
||||
@click="saveChanges"
|
||||
>
|
||||
<BaseIcon
|
||||
class="mr-1"
|
||||
icon-name="mdiContentSave"
|
||||
:size="24"
|
||||
/>
|
||||
<span>{{ t('general.save') }}</span>
|
||||
</button>
|
||||
<button
|
||||
:disabled="!isChanged"
|
||||
class="btn btn-link btn-sm mr-0"
|
||||
:title="t('database.clearChanges')"
|
||||
@click="clearChanges"
|
||||
>
|
||||
<BaseIcon
|
||||
class="mr-1"
|
||||
icon-name="mdiDeleteSweep"
|
||||
:size="24"
|
||||
/>
|
||||
<span>{{ t('general.clear') }}</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="workspace-query-info">
|
||||
<div class="d-flex" :title="t('database.schema')">
|
||||
<BaseIcon
|
||||
class="mt-1 mr-1"
|
||||
icon-name="mdiDatabase"
|
||||
:size="18"
|
||||
/><b>{{ schema }}</b>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="container">
|
||||
<div class="columns">
|
||||
<div class="column col-auto">
|
||||
<div class="form-group">
|
||||
<label class="form-label">{{ t('general.name') }}</label>
|
||||
<input
|
||||
v-model="localView.name"
|
||||
class="form-input"
|
||||
type="text"
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
<div class="column col-auto">
|
||||
<div v-if="workspace.customizations.definer" class="form-group">
|
||||
<label class="form-label">{{ t('database.definer') }}</label>
|
||||
<BaseSelect
|
||||
v-model="localView.definer"
|
||||
:options="users"
|
||||
:option-label="(user: any) => user.value === '' ? t('database.currentUser') : `${user.name}@${user.host}`"
|
||||
:option-track-by="(user: any) => user.value === '' ? '' : `\`${user.name}\`@\`${user.host}\``"
|
||||
class="form-select"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="column col-auto mr-2">
|
||||
<div v-if="workspace.customizations.viewSqlSecurity" class="form-group">
|
||||
<label class="form-label">{{ t('database.sqlSecurity') }}</label>
|
||||
<BaseSelect
|
||||
v-model="localView.security"
|
||||
:options="['DEFINER', 'INVOKER']"
|
||||
class="form-select"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="column col-auto mr-2">
|
||||
<div v-if="workspace.customizations.viewAlgorithm" class="form-group">
|
||||
<label class="form-label">{{ t('database.algorithm') }}</label>
|
||||
<BaseSelect
|
||||
v-model="localView.algorithm"
|
||||
:options="['UNDEFINED', 'MERGE', 'TEMPTABLE']"
|
||||
class="form-select"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="workspace.customizations.viewUpdateOption" class="column col-auto mr-2">
|
||||
<div class="form-group">
|
||||
<label class="form-label">{{ t('database.updateOption') }}</label>
|
||||
<BaseSelect
|
||||
v-model="localView.updateOption"
|
||||
:option-track-by="(user: any) => user.value"
|
||||
:options="[{label: 'None', value: ''}, {label: 'CASCADED', value: 'CASCADED'}, {label: 'LOCAL', value: 'LOCAL'}]"
|
||||
class="form-select"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="workspace-query-results column col-12 mt-2 p-relative">
|
||||
<BaseLoader v-if="isLoading" />
|
||||
<label class="form-label ml-2">{{ t('database.selectStatement') }}</label>
|
||||
<QueryEditor
|
||||
v-show="isSelected"
|
||||
ref="queryEditor"
|
||||
v-model="localView.sql"
|
||||
:workspace="workspace"
|
||||
:schema="schema"
|
||||
:height="editorHeight"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { Ace } from 'ace-builds';
|
||||
import { ipcRenderer } from 'electron';
|
||||
import { Component, computed, onBeforeUnmount, onMounted, onUnmounted, Ref, ref, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
|
||||
import BaseIcon from '@/components/BaseIcon.vue';
|
||||
import BaseLoader from '@/components/BaseLoader.vue';
|
||||
import BaseSelect from '@/components/BaseSelect.vue';
|
||||
import QueryEditor from '@/components/QueryEditor.vue';
|
||||
import Views from '@/ipc-api/Views';
|
||||
import { useNotificationsStore } from '@/stores/notifications';
|
||||
import { useWorkspacesStore } from '@/stores/workspaces';
|
||||
|
||||
const { t } = useI18n();
|
||||
|
||||
const props = defineProps({
|
||||
tabUid: String,
|
||||
connection: Object,
|
||||
isSelected: Boolean,
|
||||
schema: String,
|
||||
view: String
|
||||
});
|
||||
|
||||
const { addNotification } = useNotificationsStore();
|
||||
const workspacesStore = useWorkspacesStore();
|
||||
|
||||
const {
|
||||
getWorkspace,
|
||||
refreshStructure,
|
||||
renameTabs,
|
||||
changeBreadcrumbs,
|
||||
setUnsavedChanges
|
||||
} = workspacesStore;
|
||||
|
||||
const queryEditor: Ref<Component & {editor: Ace.Editor; $el: HTMLElement}> = ref(null);
|
||||
const isLoading = ref(false);
|
||||
const isSaving = ref(false);
|
||||
const originalView = ref(null);
|
||||
const localView = ref(null);
|
||||
const editorHeight = ref(300);
|
||||
const lastView = ref(null);
|
||||
const sqlProxy = ref('');
|
||||
|
||||
const workspace = computed(() => getWorkspace(props.connection.uid));
|
||||
const isChanged = computed(() => JSON.stringify(originalView.value) !== JSON.stringify(localView.value));
|
||||
const isDefinerInUsers = computed(() => originalView.value ? workspace.value.users.some(user => originalView.value.definer === `\`${user.name}\`@\`${user.host}\``) : true);
|
||||
|
||||
const users = computed(() => {
|
||||
const users = [{ value: '' }, ...workspace.value.users];
|
||||
if (!isDefinerInUsers.value) {
|
||||
const [name, host] = originalView.value.definer.replaceAll('`', '').split('@');
|
||||
users.unshift({ name, host });
|
||||
}
|
||||
|
||||
return users;
|
||||
});
|
||||
|
||||
const getViewData = async () => {
|
||||
if (!props.view) return;
|
||||
isLoading.value = true;
|
||||
localView.value = { sql: '' };
|
||||
lastView.value = props.view;
|
||||
|
||||
const params = {
|
||||
uid: props.connection.uid,
|
||||
schema: props.schema,
|
||||
view: props.view
|
||||
};
|
||||
|
||||
try {
|
||||
const { status, response } = await Views.getMaterializedViewInformations(params);
|
||||
if (status === 'success') {
|
||||
originalView.value = response;
|
||||
localView.value = JSON.parse(JSON.stringify(originalView.value));
|
||||
sqlProxy.value = localView.value.sql;
|
||||
}
|
||||
else
|
||||
addNotification({ status: 'error', message: response });
|
||||
}
|
||||
catch (err) {
|
||||
addNotification({ status: 'error', message: err.stack });
|
||||
}
|
||||
|
||||
resizeQueryEditor();
|
||||
isLoading.value = false;
|
||||
};
|
||||
|
||||
const saveChanges = async () => {
|
||||
if (isSaving.value) return;
|
||||
isSaving.value = true;
|
||||
const params = {
|
||||
uid: props.connection.uid,
|
||||
view: {
|
||||
...localView.value,
|
||||
schema: props.schema,
|
||||
oldName: originalView.value.name
|
||||
}
|
||||
};
|
||||
|
||||
try {
|
||||
const { status, response } = await Views.alterMaterializedView(params);
|
||||
|
||||
if (status === 'success') {
|
||||
const oldName = originalView.value.name;
|
||||
|
||||
await refreshStructure(props.connection.uid);
|
||||
|
||||
if (oldName !== localView.value.name) {
|
||||
renameTabs({
|
||||
uid: props.connection.uid,
|
||||
schema: props.schema,
|
||||
elementName: oldName,
|
||||
elementNewName: localView.value.name,
|
||||
elementType: 'materializedView'
|
||||
});
|
||||
|
||||
changeBreadcrumbs({ schema: props.schema, view: localView.value.name });
|
||||
}
|
||||
else
|
||||
getViewData();
|
||||
}
|
||||
else
|
||||
addNotification({ status: 'error', message: response });
|
||||
}
|
||||
catch (err) {
|
||||
addNotification({ status: 'error', message: err.stack });
|
||||
}
|
||||
|
||||
isSaving.value = false;
|
||||
};
|
||||
|
||||
const clearChanges = () => {
|
||||
localView.value = JSON.parse(JSON.stringify(originalView.value));
|
||||
queryEditor.value.editor.session.setValue(localView.value.sql);
|
||||
};
|
||||
|
||||
const resizeQueryEditor = () => {
|
||||
if (queryEditor.value) {
|
||||
const footer = document.getElementById('footer');
|
||||
const size = window.innerHeight - queryEditor.value.$el.getBoundingClientRect().top - footer.offsetHeight;
|
||||
editorHeight.value = size;
|
||||
queryEditor.value.editor.resize();
|
||||
}
|
||||
};
|
||||
|
||||
const saveContentListener = () => {
|
||||
const hasModalOpen = !!document.querySelectorAll('.modal.active').length;
|
||||
if (props.isSelected && !hasModalOpen && isChanged.value)
|
||||
saveChanges();
|
||||
};
|
||||
|
||||
watch(() => props.schema, async () => {
|
||||
if (props.isSelected) {
|
||||
await getViewData();
|
||||
queryEditor.value.editor.session.setValue(localView.value.sql);
|
||||
lastView.value = props.view;
|
||||
}
|
||||
});
|
||||
|
||||
watch(() => props.view, async () => {
|
||||
if (props.isSelected) {
|
||||
await getViewData();
|
||||
queryEditor.value.editor.session.setValue(localView.value.sql);
|
||||
lastView.value = props.view;
|
||||
}
|
||||
});
|
||||
|
||||
watch(() => props.isSelected, (val) => {
|
||||
if (val) {
|
||||
changeBreadcrumbs({ schema: props.schema, view: localView.value.name });
|
||||
|
||||
setTimeout(() => {
|
||||
resizeQueryEditor();
|
||||
}, 50);
|
||||
}
|
||||
});
|
||||
|
||||
watch(isChanged, (val) => {
|
||||
setUnsavedChanges({ uid: props.connection.uid, tUid: props.tabUid, isChanged: val });
|
||||
});
|
||||
|
||||
(async () => {
|
||||
await getViewData();
|
||||
queryEditor.value.editor.session.setValue(localView.value.sql);
|
||||
})();
|
||||
|
||||
onMounted(() => {
|
||||
window.addEventListener('resize', resizeQueryEditor);
|
||||
|
||||
ipcRenderer.on('save-content', saveContentListener);
|
||||
});
|
||||
|
||||
onUnmounted(() => {
|
||||
window.removeEventListener('resize', resizeQueryEditor);
|
||||
});
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
ipcRenderer.removeListener('save-content', saveContentListener);
|
||||
});
|
||||
</script>
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user