Compare commits
59 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5ed3266942 | ||
|
|
debaa21b96 | ||
|
|
1996c1d853 | ||
|
|
79c3eb7dd2 | ||
|
|
bd3e3399b3 | ||
|
|
42d817f261 | ||
|
|
37d3f33926 | ||
|
|
595199a3c2 | ||
|
|
bf62fcf0b9 | ||
|
|
e1969bf553 | ||
|
|
3d059ecf0c | ||
|
|
e72510f236 | ||
|
|
d586e43d6e | ||
|
|
20c1e3f1cc | ||
|
|
c991691fcb | ||
|
|
39151732cf | ||
|
|
92e6150ea5 | ||
|
|
d4c233e1ef | ||
|
|
05243ec991 | ||
|
|
ec2b2b21d0 | ||
|
|
1ae68a0043 | ||
|
|
19f3e8b74a | ||
|
|
f65953a2e1 | ||
|
|
c5fa3e903a | ||
|
|
3f0a7597a2 | ||
|
|
9912ed24cf | ||
|
|
4c685b6d7c | ||
|
|
a37edc501b | ||
|
|
46a9d1613b | ||
|
|
b08265fab9 | ||
|
|
f1b5f5e3c7 | ||
|
|
e08fdbecbc | ||
|
|
a5ba1cb821 | ||
|
|
7da1cb36fa | ||
|
|
57c8fe5bc8 | ||
|
|
e7d3da8869 | ||
|
|
5dc80751c4 | ||
|
|
3e52dcac2c | ||
|
|
1037185a6a | ||
|
|
fec8fb5ac0 | ||
|
|
621a41844e | ||
|
|
0a3a94444e | ||
|
|
37aa2d35d5 | ||
|
|
5f91180a8c | ||
|
|
b8c5a2bfd7 | ||
|
|
880c15762b | ||
|
|
df54c9086b | ||
|
|
fdd50b2f86 | ||
|
|
b39a6bdb86 | ||
|
|
5a8b2584ff | ||
|
|
aae47eff86 | ||
|
|
65db2556c0 | ||
|
|
d132127143 | ||
|
|
3e5e4b29c1 | ||
|
|
71c70e0232 | ||
|
|
8f49c0509f | ||
|
|
5e29a051b2 | ||
|
|
8b76258260 | ||
|
|
518270e1f5 |
17
.github/workflows/main.yml
vendored
@@ -1,4 +1,4 @@
|
|||||||
name: Deploy to GitHub Pages
|
name: Deploy to GitHub Pages and create release
|
||||||
on:
|
on:
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
push:
|
push:
|
||||||
@@ -7,10 +7,10 @@ on:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
deploy:
|
deploy:
|
||||||
name: Deploy to GitHub Pages
|
name: Deploy to GitHub Pages and create release
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@master
|
- uses: actions/checkout@v2
|
||||||
- name: Use Node.js
|
- name: Use Node.js
|
||||||
uses: actions/setup-node@v1
|
uses: actions/setup-node@v1
|
||||||
with:
|
with:
|
||||||
@@ -20,6 +20,17 @@ jobs:
|
|||||||
npm install
|
npm install
|
||||||
npm run build
|
npm run build
|
||||||
|
|
||||||
|
- name: Create archive
|
||||||
|
run: |
|
||||||
|
cd dist
|
||||||
|
zip -9 -r dist.zip . -x "js/*.map"
|
||||||
|
|
||||||
|
- name: Create release
|
||||||
|
uses: ncipollo/release-action@v1
|
||||||
|
with:
|
||||||
|
artifacts: "dist/dist.zip"
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
- name: Deploy 🚀
|
- name: Deploy 🚀
|
||||||
uses: JamesIves/github-pages-deploy-action@3.6.2
|
uses: JamesIves/github-pages-deploy-action@3.6.2
|
||||||
with:
|
with:
|
||||||
|
|||||||
201
LICENSE
Normal file
@@ -0,0 +1,201 @@
|
|||||||
|
Apache License
|
||||||
|
Version 2.0, January 2004
|
||||||
|
http://www.apache.org/licenses/
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||||
|
|
||||||
|
1. Definitions.
|
||||||
|
|
||||||
|
"License" shall mean the terms and conditions for use, reproduction,
|
||||||
|
and distribution as defined by Sections 1 through 9 of this document.
|
||||||
|
|
||||||
|
"Licensor" shall mean the copyright owner or entity authorized by
|
||||||
|
the copyright owner that is granting the License.
|
||||||
|
|
||||||
|
"Legal Entity" shall mean the union of the acting entity and all
|
||||||
|
other entities that control, are controlled by, or are under common
|
||||||
|
control with that entity. For the purposes of this definition,
|
||||||
|
"control" means (i) the power, direct or indirect, to cause the
|
||||||
|
direction or management of such entity, whether by contract or
|
||||||
|
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||||
|
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||||
|
|
||||||
|
"You" (or "Your") shall mean an individual or Legal Entity
|
||||||
|
exercising permissions granted by this License.
|
||||||
|
|
||||||
|
"Source" form shall mean the preferred form for making modifications,
|
||||||
|
including but not limited to software source code, documentation
|
||||||
|
source, and configuration files.
|
||||||
|
|
||||||
|
"Object" form shall mean any form resulting from mechanical
|
||||||
|
transformation or translation of a Source form, including but
|
||||||
|
not limited to compiled object code, generated documentation,
|
||||||
|
and conversions to other media types.
|
||||||
|
|
||||||
|
"Work" shall mean the work of authorship, whether in Source or
|
||||||
|
Object form, made available under the License, as indicated by a
|
||||||
|
copyright notice that is included in or attached to the work
|
||||||
|
(an example is provided in the Appendix below).
|
||||||
|
|
||||||
|
"Derivative Works" shall mean any work, whether in Source or Object
|
||||||
|
form, that is based on (or derived from) the Work and for which the
|
||||||
|
editorial revisions, annotations, elaborations, or other modifications
|
||||||
|
represent, as a whole, an original work of authorship. For the purposes
|
||||||
|
of this License, Derivative Works shall not include works that remain
|
||||||
|
separable from, or merely link (or bind by name) to the interfaces of,
|
||||||
|
the Work and Derivative Works thereof.
|
||||||
|
|
||||||
|
"Contribution" shall mean any work of authorship, including
|
||||||
|
the original version of the Work and any modifications or additions
|
||||||
|
to that Work or Derivative Works thereof, that is intentionally
|
||||||
|
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||||
|
or by an individual or Legal Entity authorized to submit on behalf of
|
||||||
|
the copyright owner. For the purposes of this definition, "submitted"
|
||||||
|
means any form of electronic, verbal, or written communication sent
|
||||||
|
to the Licensor or its representatives, including but not limited to
|
||||||
|
communication on electronic mailing lists, source code control systems,
|
||||||
|
and issue tracking systems that are managed by, or on behalf of, the
|
||||||
|
Licensor for the purpose of discussing and improving the Work, but
|
||||||
|
excluding communication that is conspicuously marked or otherwise
|
||||||
|
designated in writing by the copyright owner as "Not a Contribution."
|
||||||
|
|
||||||
|
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||||
|
on behalf of whom a Contribution has been received by Licensor and
|
||||||
|
subsequently incorporated within the Work.
|
||||||
|
|
||||||
|
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
copyright license to reproduce, prepare Derivative Works of,
|
||||||
|
publicly display, publicly perform, sublicense, and distribute the
|
||||||
|
Work and such Derivative Works in Source or Object form.
|
||||||
|
|
||||||
|
3. Grant of Patent License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
(except as stated in this section) patent license to make, have made,
|
||||||
|
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||||
|
where such license applies only to those patent claims licensable
|
||||||
|
by such Contributor that are necessarily infringed by their
|
||||||
|
Contribution(s) alone or by combination of their Contribution(s)
|
||||||
|
with the Work to which such Contribution(s) was submitted. If You
|
||||||
|
institute patent litigation against any entity (including a
|
||||||
|
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||||
|
or a Contribution incorporated within the Work constitutes direct
|
||||||
|
or contributory patent infringement, then any patent licenses
|
||||||
|
granted to You under this License for that Work shall terminate
|
||||||
|
as of the date such litigation is filed.
|
||||||
|
|
||||||
|
4. Redistribution. You may reproduce and distribute copies of the
|
||||||
|
Work or Derivative Works thereof in any medium, with or without
|
||||||
|
modifications, and in Source or Object form, provided that You
|
||||||
|
meet the following conditions:
|
||||||
|
|
||||||
|
(a) You must give any other recipients of the Work or
|
||||||
|
Derivative Works a copy of this License; and
|
||||||
|
|
||||||
|
(b) You must cause any modified files to carry prominent notices
|
||||||
|
stating that You changed the files; and
|
||||||
|
|
||||||
|
(c) You must retain, in the Source form of any Derivative Works
|
||||||
|
that You distribute, all copyright, patent, trademark, and
|
||||||
|
attribution notices from the Source form of the Work,
|
||||||
|
excluding those notices that do not pertain to any part of
|
||||||
|
the Derivative Works; and
|
||||||
|
|
||||||
|
(d) If the Work includes a "NOTICE" text file as part of its
|
||||||
|
distribution, then any Derivative Works that You distribute must
|
||||||
|
include a readable copy of the attribution notices contained
|
||||||
|
within such NOTICE file, excluding those notices that do not
|
||||||
|
pertain to any part of the Derivative Works, in at least one
|
||||||
|
of the following places: within a NOTICE text file distributed
|
||||||
|
as part of the Derivative Works; within the Source form or
|
||||||
|
documentation, if provided along with the Derivative Works; or,
|
||||||
|
within a display generated by the Derivative Works, if and
|
||||||
|
wherever such third-party notices normally appear. The contents
|
||||||
|
of the NOTICE file are for informational purposes only and
|
||||||
|
do not modify the License. You may add Your own attribution
|
||||||
|
notices within Derivative Works that You distribute, alongside
|
||||||
|
or as an addendum to the NOTICE text from the Work, provided
|
||||||
|
that such additional attribution notices cannot be construed
|
||||||
|
as modifying the License.
|
||||||
|
|
||||||
|
You may add Your own copyright statement to Your modifications and
|
||||||
|
may provide additional or different license terms and conditions
|
||||||
|
for use, reproduction, or distribution of Your modifications, or
|
||||||
|
for any such Derivative Works as a whole, provided Your use,
|
||||||
|
reproduction, and distribution of the Work otherwise complies with
|
||||||
|
the conditions stated in this License.
|
||||||
|
|
||||||
|
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||||
|
any Contribution intentionally submitted for inclusion in the Work
|
||||||
|
by You to the Licensor shall be under the terms and conditions of
|
||||||
|
this License, without any additional terms or conditions.
|
||||||
|
Notwithstanding the above, nothing herein shall supersede or modify
|
||||||
|
the terms of any separate license agreement you may have executed
|
||||||
|
with Licensor regarding such Contributions.
|
||||||
|
|
||||||
|
6. Trademarks. This License does not grant permission to use the trade
|
||||||
|
names, trademarks, service marks, or product names of the Licensor,
|
||||||
|
except as required for reasonable and customary use in describing the
|
||||||
|
origin of the Work and reproducing the content of the NOTICE file.
|
||||||
|
|
||||||
|
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||||
|
agreed to in writing, Licensor provides the Work (and each
|
||||||
|
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||||
|
implied, including, without limitation, any warranties or conditions
|
||||||
|
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||||
|
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||||
|
appropriateness of using or redistributing the Work and assume any
|
||||||
|
risks associated with Your exercise of permissions under this License.
|
||||||
|
|
||||||
|
8. Limitation of Liability. In no event and under no legal theory,
|
||||||
|
whether in tort (including negligence), contract, or otherwise,
|
||||||
|
unless required by applicable law (such as deliberate and grossly
|
||||||
|
negligent acts) or agreed to in writing, shall any Contributor be
|
||||||
|
liable to You for damages, including any direct, indirect, special,
|
||||||
|
incidental, or consequential damages of any character arising as a
|
||||||
|
result of this License or out of the use or inability to use the
|
||||||
|
Work (including but not limited to damages for loss of goodwill,
|
||||||
|
work stoppage, computer failure or malfunction, or any and all
|
||||||
|
other commercial damages or losses), even if such Contributor
|
||||||
|
has been advised of the possibility of such damages.
|
||||||
|
|
||||||
|
9. Accepting Warranty or Additional Liability. While redistributing
|
||||||
|
the Work or Derivative Works thereof, You may choose to offer,
|
||||||
|
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||||
|
or other liability obligations and/or rights consistent with this
|
||||||
|
License. However, in accepting such obligations, You may act only
|
||||||
|
on Your own behalf and on Your sole responsibility, not on behalf
|
||||||
|
of any other Contributor, and only if You agree to indemnify,
|
||||||
|
defend, and hold each Contributor harmless for any liability
|
||||||
|
incurred by, or claims asserted against, such Contributor by reason
|
||||||
|
of your accepting any such warranty or additional liability.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
APPENDIX: How to apply the Apache License to your work.
|
||||||
|
|
||||||
|
To apply the Apache License to your work, attach the following
|
||||||
|
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||||
|
replaced with your own identifying information. (Don't include
|
||||||
|
the brackets!) The text should be enclosed in the appropriate
|
||||||
|
comment syntax for the file format. We also recommend that a
|
||||||
|
file or class name and description of purpose be included on the
|
||||||
|
same "printed page" as the copyright notice for easier
|
||||||
|
identification within third-party archives.
|
||||||
|
|
||||||
|
Copyright [yyyy] [name of copyright owner]
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
@@ -1,3 +1,7 @@
|
|||||||
|
<p align="center">
|
||||||
|
<img src="src/assets/images/Logo.svg"/>
|
||||||
|
</p>
|
||||||
|
|
||||||
# sqliteviz
|
# sqliteviz
|
||||||
|
|
||||||
**Note: This is a work-in-progress project.**
|
**Note: This is a work-in-progress project.**
|
||||||
@@ -18,4 +22,4 @@ It is built on top of [react-chart-editor][3] and [sql.js][4] in [Vue.js][5].
|
|||||||
[2]: https://github.com/getredash/redash
|
[2]: https://github.com/getredash/redash
|
||||||
[3]: https://github.com/plotly/react-chart-editor
|
[3]: https://github.com/plotly/react-chart-editor
|
||||||
[4]: https://github.com/sql-js/sql.js
|
[4]: https://github.com/sql-js/sql.js
|
||||||
[5]: https://github.com/vuejs/vue
|
[5]: https://github.com/vuejs/vue
|
||||||
|
|||||||
1209
package-lock.json
generated
10
package.json
@@ -1,20 +1,22 @@
|
|||||||
{
|
{
|
||||||
"name": "sqliteviz",
|
"name": "sqliteviz",
|
||||||
"version": "0.0.1",
|
"version": "0.6.0",
|
||||||
|
"license" : "Apache-2.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"serve": "vue-cli-service serve",
|
"serve": "vue-cli-service serve",
|
||||||
"build": "vue-cli-service build",
|
"build": "NODE_OPTIONS=--max_old_space_size=4096 vue-cli-service build",
|
||||||
"test:unit": "vue-cli-service test:unit",
|
"test:unit": "vue-cli-service test:unit",
|
||||||
"lint": "vue-cli-service lint"
|
"lint": "vue-cli-service lint"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"codemirror": "^5.57.0",
|
"codemirror": "^5.57.0",
|
||||||
"core-js": "^3.6.5",
|
"core-js": "^3.6.5",
|
||||||
|
"debounce": "^1.2.0",
|
||||||
"nanoid": "^3.1.12",
|
"nanoid": "^3.1.12",
|
||||||
"plotly.js": "^1.54.6",
|
"plotly.js": "^1.57.1",
|
||||||
"react": "^16.13.1",
|
"react": "^16.13.1",
|
||||||
"react-chart-editor": "^0.41.7",
|
"react-chart-editor": "^0.42.0",
|
||||||
"react-dom": "^16.13.1",
|
"react-dom": "^16.13.1",
|
||||||
"sql.js": "^1.3.0",
|
"sql.js": "^1.3.0",
|
||||||
"sqlite-parser": "^1.0.1",
|
"sqlite-parser": "^1.0.1",
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 4.2 KiB |
BIN
public/favicon.png
Normal file
|
After Width: | Height: | Size: 798 B |
@@ -4,7 +4,7 @@
|
|||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
<meta name="viewport" content="width=device-width,initial-scale=1.0">
|
<meta name="viewport" content="width=device-width,initial-scale=1.0">
|
||||||
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
|
<link rel="icon" href="<%= BASE_URL %>favicon.png">
|
||||||
<title><%= htmlWebpackPlugin.options.title %></title>
|
<title><%= htmlWebpackPlugin.options.title %></title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|||||||
47
public/queries.json
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
{
|
||||||
|
"query": "select * from invoices",
|
||||||
|
"chart": {
|
||||||
|
"data": [
|
||||||
|
{
|
||||||
|
"type": "scatter",
|
||||||
|
"mode": "lines",
|
||||||
|
"x": null,
|
||||||
|
"xsrc": "InvoiceId",
|
||||||
|
"meta": {
|
||||||
|
"columnNames": {
|
||||||
|
"x": "InvoiceId",
|
||||||
|
"y": "Total"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"y": null,
|
||||||
|
"ysrc": "Total"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"layout": {
|
||||||
|
"xaxis": {
|
||||||
|
"range": [
|
||||||
|
1,
|
||||||
|
412
|
||||||
|
],
|
||||||
|
"autorange": true,
|
||||||
|
"type": "linear"
|
||||||
|
},
|
||||||
|
"yaxis": {
|
||||||
|
"range": [
|
||||||
|
-0.39166666666666683,
|
||||||
|
27.241666666666667
|
||||||
|
],
|
||||||
|
"autorange": true,
|
||||||
|
"type": "linear"
|
||||||
|
},
|
||||||
|
"autosize": true,
|
||||||
|
"mapbox": {
|
||||||
|
"style": "open-street-map"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"frames": []
|
||||||
|
},
|
||||||
|
"name": "Invoices",
|
||||||
|
"id": "ieZfcITwDUTADwOmQlYyL",
|
||||||
|
"createdAt": "2020-11-03T14:17:49.524Z"
|
||||||
|
}
|
||||||
13
src/assets/images/Logo.svg
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
<svg width="300" height="184" viewBox="0 0 300 184" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<rect width="300" height="183.736" fill="white"/>
|
||||||
|
<path d="M177.068 83.9497C175.39 82.9187 173.801 81.7464 172.32 80.4454V58.969H181.674V86.5318C180.125 85.7257 178.59 84.865 177.068 83.9497ZM195.084 73.109H185.73V88.2532C188.783 89.6738 191.905 90.9391 195.084 92.0443V73.109ZM172.32 84.7489L171.708 84.2571C170.771 83.4784 169.894 82.6791 169.059 81.8799L146.865 79.2978L150.941 87.208L179.473 89.5442C176.97 88.1329 174.578 86.5297 172.32 84.7489ZM194.595 96.2454C191.411 95.1997 188.288 93.975 185.241 92.5771L184.099 92.0033L165.289 90.7533L168.468 97.4134L201.28 98.1717C199.038 97.6389 196.776 96.9831 194.595 96.2454ZM155.547 58.969C159.138 65.2824 163.409 71.1789 168.284 76.5518V55.1573L147.721 44.9724L145.887 68.8465L167.062 79.7692C161.51 73.9456 157.544 66.782 155.547 58.969Z" fill="#119DFF"/>
|
||||||
|
<path d="M69.483 123.693C72.0574 125.13 74.6443 125.849 77.2437 125.849C79.4057 125.849 80.6742 125.08 81.0491 123.543C81.1741 123.018 81.2366 122.381 81.2366 121.631C81.2366 120.868 81.1491 120.281 80.9741 119.869C80.7992 119.444 80.5055 119.131 80.0931 118.931C79.6807 118.719 79.1308 118.563 78.4434 118.463C77.7686 118.363 76.9063 118.225 75.8565 118.05C74.8068 117.863 73.8445 117.657 72.9697 117.432C72.0949 117.207 71.3513 116.882 70.739 116.457C69.4393 115.545 68.8144 114.007 68.8644 111.845V111.377C68.8644 109.102 69.6142 107.484 71.1139 106.522C72.5635 105.572 74.9567 105.247 78.2935 105.547C80.568 105.759 82.38 106.153 83.7297 106.728L82.8487 109.559C81.349 108.921 79.5494 108.459 77.4499 108.171C76.8001 108.084 76.1877 108.04 75.6128 108.04C75.0505 108.04 74.5381 108.084 74.0757 108.171C73.6133 108.259 73.2259 108.421 72.9135 108.659C72.3136 109.146 72.0012 110.052 71.9762 111.377C71.9387 112.939 72.3761 113.933 73.2884 114.357C74.1632 114.77 75.2004 115.057 76.4002 115.22C77.5999 115.37 78.5809 115.507 79.3432 115.632C80.1056 115.745 80.7992 115.901 81.424 116.101C82.0489 116.301 82.5862 116.619 83.0361 117.057C83.9734 117.944 84.4296 119.487 84.4046 121.687C84.3421 125.524 82.7425 127.711 79.6057 128.248C78.6559 128.41 77.7061 128.492 76.7563 128.492C75.8065 128.492 74.9317 128.429 74.1319 128.304C73.3446 128.192 72.5885 128.029 71.8637 127.817C70.489 127.429 69.2455 126.917 68.1333 126.28L69.483 123.693Z" fill="#2A3F5F"/>
|
||||||
|
<path d="M106.093 125.98C103.706 127.654 101.182 128.492 98.5201 128.492C95.4083 128.492 93.3338 127.386 92.2965 125.174C91.6967 123.924 91.3467 122.343 91.2468 120.431C91.2093 119.556 91.1905 118.594 91.1905 117.544C91.1905 116.482 91.1968 115.413 91.2093 114.339C91.2343 113.264 91.3155 112.27 91.453 111.358C91.5904 110.446 91.8029 109.627 92.0903 108.902C92.3903 108.165 92.8152 107.54 93.365 107.028C94.5023 105.966 96.2519 105.434 98.6138 105.434C100.988 105.434 103.513 106.072 106.187 107.347L106.487 105.809H109.186L109.205 136.646H106.093V125.98ZM106.093 109.933C103.844 108.809 101.669 108.246 99.5699 108.246C98.0452 108.246 97.0392 108.371 96.5518 108.621C96.0644 108.871 95.6895 109.196 95.4271 109.596C95.1771 109.996 94.9709 110.546 94.8085 111.246C94.521 112.558 94.3773 114.72 94.3773 117.732V118.144C94.3773 120.918 94.721 122.862 95.4083 123.974C96.0957 125.111 97.3516 125.68 99.1762 125.68H99.4574C101.182 125.68 102.944 125.205 104.744 124.255C105.256 123.993 105.706 123.724 106.093 123.449V109.933Z" fill="#2A3F5F"/>
|
||||||
|
<path d="M118.072 96.249L121.165 95.9866V128.117H118.109L118.072 96.249Z" fill="#2A3F5F"/>
|
||||||
|
<path d="M132.45 100.467C131.613 100.467 131.075 100.348 130.838 100.111C130.463 99.7232 130.275 99.1921 130.275 98.5173C130.275 97.8299 130.313 97.3425 130.388 97.0551C130.475 96.7552 130.6 96.524 130.763 96.3615C131.063 96.0616 131.519 95.9116 132.131 95.9116C132.756 95.9116 133.2 95.9429 133.462 96.0053C133.737 96.0678 133.962 96.1866 134.137 96.3615C134.437 96.6614 134.587 97.1551 134.587 97.8424C134.587 98.5173 134.549 99.0047 134.474 99.3046C134.412 99.592 134.299 99.8232 134.137 99.9982C133.825 100.311 133.262 100.467 132.45 100.467ZM130.931 105.809H134.006V128.117H130.969L130.931 105.809Z" fill="#2A3F5F"/>
|
||||||
|
<path d="M154.026 127.048C151.989 128.011 150.108 128.492 148.384 128.492C145.259 128.492 143.485 127.154 143.06 124.48C142.96 123.843 142.91 122.918 142.91 121.706V108.415H140.211V106.109L142.91 105.809L143.397 100.711H146.003V105.809H152.508V108.415H146.003V121.649C146.003 123.187 146.115 124.168 146.34 124.593C146.753 125.367 147.578 125.755 148.815 125.755C150.052 125.755 151.433 125.374 152.958 124.611L154.026 127.048Z" fill="#2A3F5F"/>
|
||||||
|
<path d="M176.521 126.936C173.934 127.973 171.079 128.492 167.954 128.492C166.142 128.492 164.605 128.304 163.343 127.929C161.331 127.354 159.994 126.167 159.331 124.368C158.719 122.681 158.413 120.181 158.413 116.869V115.913C158.413 111.952 159.237 109.171 160.887 107.571C162.374 106.147 164.855 105.434 168.329 105.434C171.716 105.434 174.028 106.272 175.265 107.946C175.865 108.759 176.259 109.746 176.446 110.908C176.646 112.058 176.746 113.158 176.746 114.207C176.746 115.845 176.708 117.113 176.633 118.013C174.871 118.088 173.291 118.125 171.891 118.125C171.891 118.125 170.885 118.125 168.873 118.125C165.723 118.125 163.299 117.988 161.599 117.713C161.599 120.587 161.962 122.593 162.687 123.73C163.574 125.117 165.342 125.811 167.992 125.811C170.641 125.811 173.178 125.292 175.602 124.255L176.521 126.936ZM173.578 115.52V113.72C173.578 111.758 173.197 110.358 172.434 109.521C171.585 108.584 170.116 108.115 168.029 108.115C165.53 108.115 163.824 108.659 162.912 109.746C162.037 110.783 161.599 112.708 161.599 115.52H173.578Z" fill="#2A3F5F"/>
|
||||||
|
<path d="M181.976 105.809H185.332L191.18 124.011L191.743 125.867L192.267 124.011L197.854 105.809H201.247L193.711 128.117H189.624L181.976 105.809Z" fill="#2A3F5F"/>
|
||||||
|
<path d="M209.232 100.467C208.395 100.467 207.858 100.348 207.62 100.111C207.245 99.7232 207.058 99.1921 207.058 98.5173C207.058 97.8299 207.095 97.3425 207.17 97.0551C207.258 96.7552 207.383 96.524 207.545 96.3615C207.845 96.0616 208.301 95.9116 208.914 95.9116C209.538 95.9116 209.982 95.9429 210.245 96.0053C210.52 96.0678 210.744 96.1866 210.919 96.3615C211.219 96.6614 211.369 97.1551 211.369 97.8424C211.369 98.5173 211.332 99.0047 211.257 99.3046C211.194 99.592 211.082 99.8232 210.919 99.9982C210.607 100.311 210.045 100.467 209.232 100.467ZM207.714 105.809H210.788V128.117H207.751L207.714 105.809Z" fill="#2A3F5F"/>
|
||||||
|
<path d="M217.63 125.998L229.047 108.396H217.387V105.809H232.833V107.928L221.454 125.511H233.302V128.117H217.63V125.998Z" fill="#2A3F5F"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 6.4 KiB |
17
src/assets/images/checkbox_checked.svg
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
<svg width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<rect x="0.5" y="0.5" width="17" height="17" rx="2.5" fill="#119DFF" stroke="#0D76BF"/>
|
||||||
|
<g filter="url(#filter0_d)">
|
||||||
|
<path d="M15.75 5.25L6.75 14.25L2.625 10.125L3.6825 9.0675L6.75 12.1275L14.6925 4.1925L15.75 5.25Z" fill="white"/>
|
||||||
|
</g>
|
||||||
|
<defs>
|
||||||
|
<filter id="filter0_d" x="0.625" y="3.1925" width="17.125" height="14.0575" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
|
||||||
|
<feFlood flood-opacity="0" result="BackgroundImageFix"/>
|
||||||
|
<feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0"/>
|
||||||
|
<feOffset dy="1"/>
|
||||||
|
<feGaussianBlur stdDeviation="1"/>
|
||||||
|
<feColorMatrix type="matrix" values="0 0 0 0 0.164706 0 0 0 0 0.247059 0 0 0 0 0.372549 0 0 0 0.7 0"/>
|
||||||
|
<feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow"/>
|
||||||
|
<feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow" result="shape"/>
|
||||||
|
</filter>
|
||||||
|
</defs>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 981 B |
17
src/assets/images/checkbox_checked_light.svg
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
<svg width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<rect x="0.5" y="0.5" width="17" height="17" rx="2.5" fill="#F3F6FA" stroke="#C8D4E3"/>
|
||||||
|
<g filter="url(#filter0_d)">
|
||||||
|
<path d="M15.75 5.24988L6.75 14.2499L2.625 10.1249L3.6825 9.06738L6.75 12.1274L14.6925 4.19238L15.75 5.24988Z" fill="#119DFF"/>
|
||||||
|
</g>
|
||||||
|
<defs>
|
||||||
|
<filter id="filter0_d" x="0.625" y="3.19238" width="17.125" height="14.0575" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
|
||||||
|
<feFlood flood-opacity="0" result="BackgroundImageFix"/>
|
||||||
|
<feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0"/>
|
||||||
|
<feOffset dy="1"/>
|
||||||
|
<feGaussianBlur stdDeviation="1"/>
|
||||||
|
<feColorMatrix type="matrix" values="0 0 0 0 0.164706 0 0 0 0 0.247059 0 0 0 0 0.372549 0 0 0 0.45 0"/>
|
||||||
|
<feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow"/>
|
||||||
|
<feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow" result="shape"/>
|
||||||
|
</filter>
|
||||||
|
</defs>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 996 B |
@@ -1,3 +1,3 @@
|
|||||||
<svg width="8" height="12" viewBox="0 0 8 12" fill="none" xmlns="http://www.w3.org/2000/svg">
|
<svg width="4" height="9" viewBox="0 0 4 9" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||||
<path d="M0.721924 9.93097L4.85292 5.79997L0.721924 1.66897L1.99992 0.399973L7.39992 5.79997L1.99992 11.2L0.721924 9.93097Z" fill="#506784"/>
|
<path d="M4 0.98056V4.5L4.00004 7.71428L4 9L1.10694e-07 4.5L4 0V0.98056Z" fill="#506784"/>
|
||||||
</svg>
|
</svg>
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 243 B After Width: | Height: | Size: 190 B |
3
src/assets/images/info.svg
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<path d="M11 9H13V7H11V9ZM12 20C7.59 20 4 16.41 4 12C4 7.59 7.59 4 12 4C16.41 4 20 7.59 20 12C20 16.41 16.41 20 12 20ZM12 2C10.6868 2 9.38642 2.25866 8.17317 2.7612C6.95991 3.26375 5.85752 4.00035 4.92893 4.92893C3.05357 6.8043 2 9.34784 2 12C2 14.6522 3.05357 17.1957 4.92893 19.0711C5.85752 19.9997 6.95991 20.7362 8.17317 21.2388C9.38642 21.7413 10.6868 22 12 22C14.6522 22 17.1957 20.9464 19.0711 19.0711C20.9464 17.1957 22 14.6522 22 12C22 10.6868 21.7413 9.38642 21.2388 8.17317C20.7362 6.95991 19.9997 5.85752 19.0711 4.92893C18.1425 4.00035 17.0401 3.26375 15.8268 2.7612C14.6136 2.25866 13.3132 2 12 2V2ZM11 17H13V11H11V17Z" fill="#A2B1C6"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 754 B |
|
Before Width: | Height: | Size: 6.7 KiB |
6
src/assets/styles/messages.css
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
.warning {
|
||||||
|
background-color: var(--color-bg-warning);
|
||||||
|
color: var(--color-text-base);
|
||||||
|
font-size: 13px;
|
||||||
|
padding: 0 24px;
|
||||||
|
}
|
||||||
@@ -9,7 +9,7 @@
|
|||||||
.header-container {
|
.header-container {
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: -1px;;
|
top: -1px;
|
||||||
left: -1px;
|
left: -1px;
|
||||||
width: calc(100% + 2px);
|
width: calc(100% + 2px);
|
||||||
padding-left: 7px;
|
padding-left: 7px;
|
||||||
@@ -18,10 +18,17 @@
|
|||||||
border-radius: 5px 5px 0 0;
|
border-radius: 5px 5px 0 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@supports (-moz-appearance:none) {
|
||||||
|
.header-container {
|
||||||
|
top: 0;
|
||||||
|
padding-left: 6px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.header-container > div {
|
.header-container > div {
|
||||||
display: flex;
|
display: flex;
|
||||||
width: fit-content;
|
width: fit-content;
|
||||||
padding-right: 10px;
|
padding-right: 30px;
|
||||||
}
|
}
|
||||||
.table-container {
|
.table-container {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|||||||
15
src/assets/styles/tooltips.css
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
.icon-tooltip {
|
||||||
|
visibility: hidden;
|
||||||
|
background-color: rgba(80, 103, 132, 0.85);
|
||||||
|
color: #fff;
|
||||||
|
text-align: center;
|
||||||
|
font-size: 11px;
|
||||||
|
padding: 0 6px;
|
||||||
|
line-height: 19px;;
|
||||||
|
position: fixed;
|
||||||
|
z-index: 5;
|
||||||
|
height: 19px;
|
||||||
|
border-radius: var(--border-radius-medium);
|
||||||
|
white-space: nowrap;
|
||||||
|
z-index: 999;
|
||||||
|
}
|
||||||
@@ -11,6 +11,7 @@
|
|||||||
--color-blue-dark: #0D76BF;
|
--color-blue-dark: #0D76BF;
|
||||||
--color-blue-dark-2: #2A3F5F;
|
--color-blue-dark-2: #2A3F5F;
|
||||||
--color-red: #EF553B;
|
--color-red: #EF553B;
|
||||||
|
--color-yellow: #FBEFCB;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -18,6 +19,7 @@
|
|||||||
--color-bg-light-2: var(--color-gray-light-2);
|
--color-bg-light-2: var(--color-gray-light-2);
|
||||||
--color-bg-light-3: var(--color-gray-light-5);
|
--color-bg-light-3: var(--color-gray-light-5);
|
||||||
--color-bg-dark: var(--color-gray-dark);
|
--color-bg-dark: var(--color-gray-dark);
|
||||||
|
--color-bg-warning: var(--color-yellow);
|
||||||
--color-accent: var(--color-blue-medium);
|
--color-accent: var(--color-blue-medium);
|
||||||
--color-accent-shade: var(--color-blue-dark);
|
--color-accent-shade: var(--color-blue-dark);
|
||||||
--color-border-light: var(--color-gray-light-2);
|
--color-border-light: var(--color-gray-light-2);
|
||||||
@@ -29,6 +31,7 @@
|
|||||||
--color-text-error: var(--color-red);
|
--color-text-error: var(--color-red);
|
||||||
|
|
||||||
--shadow: 0 1px 2px rgba(42, 63, 95, 0.7);
|
--shadow: 0 1px 2px rgba(42, 63, 95, 0.7);
|
||||||
|
--shadow-1: 0 2px 9px rgba(80, 103, 132, 0.2);
|
||||||
|
|
||||||
--border-radius-big: 5px;
|
--border-radius-big: 5px;
|
||||||
--border-radius-medium: 3px;
|
--border-radius-medium: 3px;
|
||||||
|
|||||||
113
src/components/Chart.vue
Normal file
@@ -0,0 +1,113 @@
|
|||||||
|
<template>
|
||||||
|
<div v-show="visible" class="chart-container">
|
||||||
|
<div class="warning chart-warning" v-show="!sqlResult && visible">
|
||||||
|
There is no data to build a chart. Run your sql query and make sure the result is not empty.
|
||||||
|
</div>
|
||||||
|
<PlotlyEditor
|
||||||
|
:data="state.data"
|
||||||
|
:layout="state.layout"
|
||||||
|
:frames="state.frames"
|
||||||
|
:config="{ editable: true, displaylogo: false }"
|
||||||
|
:dataSources="dataSources"
|
||||||
|
:dataSourceOptions="dataSourceOptions"
|
||||||
|
:plotly="plotly"
|
||||||
|
@onUpdate="update"
|
||||||
|
:useResizeHandler="true"
|
||||||
|
:debug="true"
|
||||||
|
:advancedTraceTypeSelector="true"
|
||||||
|
class="chart"
|
||||||
|
:style="{ height: !sqlResult ? 'calc(100% - 40px)' : '100%' }"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import plotly from 'plotly.js/dist/plotly'
|
||||||
|
import 'react-chart-editor/lib/react-chart-editor.min.css'
|
||||||
|
|
||||||
|
import PlotlyEditor from 'react-chart-editor'
|
||||||
|
import dereference from 'react-chart-editor/lib/lib/dereference'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'Chart',
|
||||||
|
props: ['sqlResult', 'initChart', 'visible'],
|
||||||
|
components: {
|
||||||
|
PlotlyEditor
|
||||||
|
},
|
||||||
|
data () {
|
||||||
|
return {
|
||||||
|
plotly: plotly,
|
||||||
|
state: this.initChart || {
|
||||||
|
data: [],
|
||||||
|
layout: {},
|
||||||
|
frames: []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
dataSources () {
|
||||||
|
if (!this.sqlResult) {
|
||||||
|
return {}
|
||||||
|
}
|
||||||
|
const dataSorces = {}
|
||||||
|
const matrix = this.sqlResult.values
|
||||||
|
const [row] = matrix
|
||||||
|
const transposedMatrix = row.map((value, column) => matrix.map(row => row[column]))
|
||||||
|
this.sqlResult.columns.forEach((column, index) => {
|
||||||
|
dataSorces[column] = transposedMatrix[index]
|
||||||
|
})
|
||||||
|
return dataSorces
|
||||||
|
},
|
||||||
|
dataSourceOptions () {
|
||||||
|
return Object.keys(this.dataSources).map(name => ({
|
||||||
|
value: name,
|
||||||
|
label: name
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
dataSources () {
|
||||||
|
// we need to update state.data in order to update the graph
|
||||||
|
// https://github.com/plotly/react-chart-editor/issues/948
|
||||||
|
dereference(this.state.data, this.dataSources)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
update (data, layout, frames) {
|
||||||
|
this.state = { data, layout, frames }
|
||||||
|
this.$emit('update')
|
||||||
|
},
|
||||||
|
getChartSatateForSave () {
|
||||||
|
// we don't need to save the data, only settings
|
||||||
|
// so we modify state.data using dereference
|
||||||
|
const stateCopy = JSON.parse(JSON.stringify(this.state))
|
||||||
|
const emptySources = {}
|
||||||
|
for (const key in this.dataSources) {
|
||||||
|
emptySources[key] = []
|
||||||
|
}
|
||||||
|
dereference(stateCopy.data, emptySources)
|
||||||
|
return stateCopy
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.chart-container {
|
||||||
|
height: calc(100% - 89px);
|
||||||
|
}
|
||||||
|
|
||||||
|
.chart-warning {
|
||||||
|
height: 40px;
|
||||||
|
line-height: 40px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chart {
|
||||||
|
border-top: 1px solid var(--color-border);
|
||||||
|
min-height: 242px;
|
||||||
|
}
|
||||||
|
|
||||||
|
>>> .editor_controls .sidebar__item:before {
|
||||||
|
width: 0;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
67
src/components/CheckBox.vue
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
<template>
|
||||||
|
<div class="checkbox-container" @click.stop="onClick">
|
||||||
|
<div v-show="!checked" class="unchecked" />
|
||||||
|
<img
|
||||||
|
v-show="checked && theme === 'accent'"
|
||||||
|
:src="require('@/assets/images/checkbox_checked.svg')"
|
||||||
|
/>
|
||||||
|
<img
|
||||||
|
v-show="checked && theme === 'light'"
|
||||||
|
:src="require('@/assets/images/checkbox_checked_light.svg')"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
name: 'checkBox',
|
||||||
|
props: {
|
||||||
|
theme: {
|
||||||
|
type: String,
|
||||||
|
required: false,
|
||||||
|
default: 'accent',
|
||||||
|
validator: (value) => {
|
||||||
|
return ['accent', 'light'].includes(value)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
init: {
|
||||||
|
type: Boolean,
|
||||||
|
required: false,
|
||||||
|
default: false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
data () {
|
||||||
|
return {
|
||||||
|
checked: this.init
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
onClick () {
|
||||||
|
this.checked = !this.checked
|
||||||
|
this.$emit('click', this.checked)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.checkbox-container {
|
||||||
|
display: inline-block;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
.unchecked {
|
||||||
|
width: 18px;
|
||||||
|
height: 18px;
|
||||||
|
background-color: white;
|
||||||
|
border: 1px solid var(--color-border);
|
||||||
|
border-radius: var(--border-radius-medium);
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
.unchecked:hover {
|
||||||
|
background-color: var(--color-bg-light);
|
||||||
|
}
|
||||||
|
|
||||||
|
img {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -1,16 +1,15 @@
|
|||||||
<template>
|
<template>
|
||||||
<div id="dbloader-container">
|
<div class="db-upload-container">
|
||||||
<h1>Sqliteviz</h1>
|
|
||||||
<label for="assetsFieldHandle">
|
<label for="assetsFieldHandle">
|
||||||
<div id="drop-area" @dragover="dragover" @dragleave="dragleave" @drop="drop">
|
<div class="drop-area" @dragover="dragover" @dragleave="dragleave" @drop="drop">
|
||||||
<input
|
<input
|
||||||
type="file"
|
type="file"
|
||||||
id="assetsFieldHandle"
|
id="assetsFieldHandle"
|
||||||
@change="loadDb"
|
@change="loadDb"
|
||||||
ref="file"
|
ref="file"
|
||||||
accept=".db"
|
accept=".db,.sqlite,.sqlite3"
|
||||||
/>
|
/>
|
||||||
<div>
|
<div class="text">
|
||||||
Drop the database file to upload here or click to choose a file from your computer.
|
Drop the database file to upload here or click to choose a file from your computer.
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -22,41 +21,13 @@
|
|||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
name: 'DbUpload',
|
name: 'DbUpload',
|
||||||
data () {
|
|
||||||
return {
|
|
||||||
worker: this.$store.state.worker
|
|
||||||
}
|
|
||||||
},
|
|
||||||
methods: {
|
methods: {
|
||||||
loadDb () {
|
loadDb () {
|
||||||
const dbName = this.$refs.file.value.substr(this.$refs.file.value.lastIndexOf('\\') + 1)
|
this.$db.loadDb(this.$refs.file.files[0])
|
||||||
this.$store.commit('saveDbName', dbName)
|
|
||||||
const f = this.$refs.file.files[0]
|
|
||||||
const r = new FileReader()
|
|
||||||
r.onload = () => {
|
|
||||||
this.worker.onmessage = () => {
|
|
||||||
const getSchemaSql = `
|
|
||||||
SELECT name, sql
|
|
||||||
FROM sqlite_master
|
|
||||||
WHERE type='table' AND name NOT LIKE 'sqlite_%';`
|
|
||||||
this.worker.onmessage = event => {
|
|
||||||
this.$store.commit('saveSchema', event.data.results[0].values)
|
|
||||||
this.$router.push('/editor')
|
|
||||||
}
|
|
||||||
this.worker.postMessage({ action: 'exec', sql: getSchemaSql })
|
|
||||||
}
|
|
||||||
this.$store.commit('saveDbFile', r.result)
|
|
||||||
try {
|
|
||||||
this.worker.postMessage({ action: 'open', buffer: r.result }, [r.result])
|
|
||||||
} catch (exception) {
|
|
||||||
this.worker.postMessage({ action: 'open', buffer: r.result })
|
|
||||||
}
|
|
||||||
}
|
|
||||||
r.readAsArrayBuffer(f)
|
|
||||||
},
|
},
|
||||||
dragover (event) {
|
dragover (event) {
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
// TODO: Add some visual fluff to show the user can drop its files
|
// TODO: Add some visual stuff to show the user can drop its files
|
||||||
if (!event.currentTarget.classList.contains('bg-green-300')) {
|
if (!event.currentTarget.classList.contains('bg-green-300')) {
|
||||||
event.currentTarget.classList.remove('bg-gray-100')
|
event.currentTarget.classList.remove('bg-gray-100')
|
||||||
event.currentTarget.classList.add('bg-green-300')
|
event.currentTarget.classList.add('bg-green-300')
|
||||||
@@ -80,34 +51,29 @@ export default {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
#dbloader-container {
|
|
||||||
width: 100vw;
|
|
||||||
height: 100vh;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
}
|
|
||||||
h1 {
|
|
||||||
color: var(--color-accent);
|
|
||||||
}
|
|
||||||
label {
|
label {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
border: 1px dashed var(--color-border);
|
border: 1px dashed var(--color-border);
|
||||||
padding: 8px;
|
padding: 8px;
|
||||||
border-radius: var(--border-radius-big);
|
border-radius: var(--border-radius-big);
|
||||||
|
height: 100%;
|
||||||
|
width: 100%;
|
||||||
|
box-sizing: border-box;
|
||||||
}
|
}
|
||||||
#drop-area {
|
|
||||||
width: 231px;
|
.drop-area {
|
||||||
height: 153px;
|
|
||||||
background-color: var(--color-bg-light-3);
|
background-color: var(--color-bg-light-3);
|
||||||
border-radius: var(--border-radius-big);
|
border-radius: var(--border-radius-big);
|
||||||
color: var(--color-text-base);
|
color: var(--color-text-base);
|
||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
padding: 44px 15px;
|
|
||||||
text-align: center;
|
text-align: center;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
height: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
input {
|
input {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
@@ -6,23 +6,83 @@
|
|||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<button
|
<button
|
||||||
v-if="$store.state.tabs.length > 0"
|
v-if="currentQuery"
|
||||||
class="primary"
|
class="primary"
|
||||||
:disabled="!$store.state.currentTab.isUnsaved"
|
:disabled="currentQuery && (!$store.state.schema || !currentQuery.query)"
|
||||||
@click="saveQuery"
|
@click="currentQuery.execute"
|
||||||
|
>
|
||||||
|
Run
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
v-if="currentQuery"
|
||||||
|
class="primary"
|
||||||
|
:disabled="currentQuery && !currentQuery.isUnsaved"
|
||||||
|
@click="checkQueryBeforeSave"
|
||||||
>
|
>
|
||||||
Save
|
Save
|
||||||
</button>
|
</button>
|
||||||
<button class="primary" @click="createNewQuery">Create</button>
|
<button class="primary" @click="createNewQuery">Create</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!--Save Query dialog -->
|
||||||
|
<modal name="save" classes="dialog" height="auto">
|
||||||
|
<div class="dialog-header">
|
||||||
|
Save query
|
||||||
|
<close-icon @click="$modal.hide('save')"/>
|
||||||
|
</div>
|
||||||
|
<div class="dialog-body">
|
||||||
|
<div v-show="isPredefined" id="save-note">
|
||||||
|
<img :src="require('@/assets/images/info.svg')">
|
||||||
|
Note: Predefined queries can't be edited.
|
||||||
|
That's why your modifications will be saved as a new query. Enter the name for it.
|
||||||
|
</div>
|
||||||
|
<text-field
|
||||||
|
label="Query name"
|
||||||
|
:error-msg="errorMsg"
|
||||||
|
v-model="name"
|
||||||
|
width="100%"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div class="dialog-buttons-container">
|
||||||
|
<button class="secondary" @click="$modal.hide('save')">Cancel</button>
|
||||||
|
<button class="primary" @click="saveQuery">Save</button>
|
||||||
|
</div>
|
||||||
|
</modal>
|
||||||
</nav>
|
</nav>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { nanoid } from 'nanoid'
|
import { nanoid } from 'nanoid'
|
||||||
|
import TextField from '@/components/TextField'
|
||||||
|
import CloseIcon from '@/components/svg/close'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'MainMenu',
|
name: 'MainMenu',
|
||||||
|
components: {
|
||||||
|
TextField,
|
||||||
|
CloseIcon
|
||||||
|
},
|
||||||
|
data () {
|
||||||
|
return {
|
||||||
|
name: '',
|
||||||
|
errorMsg: null
|
||||||
|
}
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
currentQuery () {
|
||||||
|
return this.$store.state.currentTab
|
||||||
|
},
|
||||||
|
isPredefined () {
|
||||||
|
if (this.currentQuery) {
|
||||||
|
return this.currentQuery.isPredefined
|
||||||
|
} else {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
created () {
|
||||||
|
this.$root.$on('createNewQuery', this.createNewQuery)
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
createNewQuery () {
|
createNewQuery () {
|
||||||
const tab = {
|
const tab = {
|
||||||
@@ -35,38 +95,69 @@ export default {
|
|||||||
}
|
}
|
||||||
this.$store.commit('addTab', tab)
|
this.$store.commit('addTab', tab)
|
||||||
this.$store.commit('setCurrentTabId', tab.id)
|
this.$store.commit('setCurrentTabId', tab.id)
|
||||||
this.$store.commit('updateUntitledLastIndex')
|
},
|
||||||
|
checkQueryBeforeSave () {
|
||||||
|
this.errorMsg = null
|
||||||
|
const isFromScratch = !this.currentQuery.initName
|
||||||
|
|
||||||
|
if (isFromScratch || this.isPredefined) {
|
||||||
|
this.$modal.show('save')
|
||||||
|
} else {
|
||||||
|
this.saveQuery()
|
||||||
|
}
|
||||||
},
|
},
|
||||||
saveQuery () {
|
saveQuery () {
|
||||||
const currentQuery = this.$store.state.currentTab
|
const isFromScratch = !this.currentQuery.initName
|
||||||
const isFromScratch = !this.$store.state.currentTab.initName
|
if ((isFromScratch || this.isPredefined) && !this.name) {
|
||||||
|
this.errorMsg = 'Query name can\'t be empty'
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const dataSet = this.currentQuery.result
|
||||||
|
const tabView = this.currentQuery.view
|
||||||
|
// Prepare query
|
||||||
const value = {
|
const value = {
|
||||||
id: currentQuery.id,
|
id: this.isPredefined ? nanoid() : this.currentQuery.id,
|
||||||
query: currentQuery.query
|
query: this.currentQuery.query,
|
||||||
// TODO: save plotly settings
|
chart: this.currentQuery.getChartSatateForSave(),
|
||||||
}
|
name: (!this.isPredefined && this.currentQuery.initName) || this.name,
|
||||||
|
createdAt: new Date()
|
||||||
if (isFromScratch) {
|
|
||||||
value.name = prompt('query name')
|
|
||||||
// TODO: create dialog
|
|
||||||
this.$store.commit('updateTabName', { index: currentQuery.tabIndex, newName: value.name })
|
|
||||||
value.createdAt = new Date()
|
|
||||||
} else {
|
|
||||||
value.name = currentQuery.initName
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Save query
|
||||||
let myQueries = JSON.parse(localStorage.getItem('myQueries'))
|
let myQueries = JSON.parse(localStorage.getItem('myQueries'))
|
||||||
if (!myQueries) {
|
if (!myQueries) {
|
||||||
myQueries = [value]
|
myQueries = [value]
|
||||||
} else if (isFromScratch) {
|
} else if (isFromScratch || this.isPredefined) {
|
||||||
myQueries.push(value)
|
myQueries.push(value)
|
||||||
} else {
|
} else {
|
||||||
const queryIndex = myQueries.findIndex(query => query.id === currentQuery.id)
|
const queryIndex = myQueries.findIndex(query => query.id === this.currentQuery.id)
|
||||||
value.createdAt = myQueries[queryIndex].createdAt
|
value.createdAt = myQueries[queryIndex].createdAt
|
||||||
myQueries[queryIndex] = value
|
myQueries[queryIndex] = value
|
||||||
}
|
}
|
||||||
localStorage.setItem('myQueries', JSON.stringify(myQueries))
|
localStorage.setItem('myQueries', JSON.stringify(myQueries))
|
||||||
currentQuery.isUnsaved = false
|
|
||||||
|
// Update tab
|
||||||
|
this.$store.commit('updateTab', {
|
||||||
|
index: this.currentQuery.tabIndex,
|
||||||
|
name: value.name,
|
||||||
|
id: value.id,
|
||||||
|
query: value.query,
|
||||||
|
chart: value.chart,
|
||||||
|
isUnsaved: false
|
||||||
|
})
|
||||||
|
|
||||||
|
// Restore data:
|
||||||
|
// e.g. if we save predefined query the tab will be created again
|
||||||
|
// (because of new id) and
|
||||||
|
// it will be without sql result and has default view - table.
|
||||||
|
// That's why we need to restore data and view
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.currentQuery.result = dataSet
|
||||||
|
this.currentQuery.view = tabView
|
||||||
|
})
|
||||||
|
|
||||||
|
// Hide dialog
|
||||||
|
this.$modal.hide('save')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -80,12 +171,14 @@ nav {
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
background-color: var(--color-bg-light);
|
background-color: var(--color-bg-light);
|
||||||
border-bottom: 1px solid var(--color-border-light);
|
border-bottom: 1px solid var(--color-border-light);
|
||||||
|
box-shadow: var(--shadow-1);
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
position: fixed;
|
position: fixed;
|
||||||
top: 0;
|
top: 0;
|
||||||
left: 0;
|
left: 0;
|
||||||
width: 100vw;
|
width: 100vw;
|
||||||
padding: 0 52px;
|
padding: 0 52px;
|
||||||
|
z-index: 999;
|
||||||
}
|
}
|
||||||
a {
|
a {
|
||||||
font-size: 18px;
|
font-size: 18px;
|
||||||
@@ -100,4 +193,13 @@ a.router-link-active {
|
|||||||
button {
|
button {
|
||||||
margin-left: 16px;
|
margin-left: 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#save-note {
|
||||||
|
margin-bottom: 24px;
|
||||||
|
display: flex;
|
||||||
|
align-items: flex-start;
|
||||||
|
}
|
||||||
|
#save-note img {
|
||||||
|
margin: -3px 6px 0 0;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div id="schema-container">
|
||||||
<text-field placeholder="Search table" width="100%"/>
|
<div id="schema-filter">
|
||||||
|
<text-field placeholder="Search table" width="100%" v-model="filter"/>
|
||||||
|
</div>
|
||||||
<div id="db">
|
<div id="db">
|
||||||
<div @click="schemaVisible = !schemaVisible" class="db-name">
|
<div @click="schemaVisible = !schemaVisible" class="db-name">
|
||||||
<svg
|
<svg
|
||||||
:style="{transform: schemaVisible ? 'rotate(90deg)' : 'rotate(0)'}"
|
:style="{ transform: schemaVisible ? 'rotate(90deg)' : 'rotate(0)' }"
|
||||||
class="chevron-icon"
|
class="chevron-icon"
|
||||||
width="9"
|
width="9"
|
||||||
height="9"
|
height="9"
|
||||||
@@ -22,27 +24,16 @@
|
|||||||
<div class="db-edit">
|
<div class="db-edit">
|
||||||
<input type="file" id="actual-btn" ref="dbfile" hidden @change="changeDb"/>
|
<input type="file" id="actual-btn" ref="dbfile" hidden @change="changeDb"/>
|
||||||
<label for="actual-btn">
|
<label for="actual-btn">
|
||||||
<svg
|
<change-db-icon />
|
||||||
class="db-edit-icon"
|
|
||||||
width="18"
|
|
||||||
height="18"
|
|
||||||
viewBox="0 0 18 18"
|
|
||||||
fill="none"
|
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
|
||||||
>
|
|
||||||
<path d="M3 10.5V12.75C3 14.25 5.2875 15.54 8.25 15.75V13.5825L8.3475 13.5C5.34 13.32 3 12.045 3 10.5ZM9 9.75C5.685 9.75 3 8.4075 3 6.75V9C3 10.6575 5.685 12 9 12C9.2925 12 9.5775 12 9.87 12L12.75 9.09C11.55 9.54 10.2825 9.75 9 9.75ZM9 2.25C5.685 2.25 3 3.5925 3 5.25C3 6.9075 5.685 8.25 9 8.25C12.315 8.25 15 6.9075 15 5.25C15 3.5925 12.315 2.25 9 2.25ZM15.75 8.3475C15.6375 8.3475 15.5325 8.3925 15.4575 8.475L14.7075 9.225L16.245 10.725L16.995 9.975C17.1525 9.825 17.16 9.57 16.995 9.3975L16.065 8.475C15.99 8.3925 15.885 8.3475 15.78 8.3475H15.75ZM14.28 9.66L9.75 14.205V15.75H11.295L15.84 11.1975L14.28 9.66Z"
|
|
||||||
fill="#A2B1C6"/>
|
|
||||||
</svg>
|
|
||||||
</label>
|
</label>
|
||||||
<span class="db-edit-tooltip">Change database</span>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div v-show="schemaVisible" class="schema">
|
<div v-if="schemaVisible" class="schema">
|
||||||
<table-description
|
<table-description
|
||||||
v-for="(table, index) in schema"
|
v-for="table in schema"
|
||||||
:key="index"
|
:key="table.name"
|
||||||
:name="table[0]"
|
:name="table.name"
|
||||||
:sql="table[1]"
|
:columns="table.columns"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -51,19 +42,32 @@
|
|||||||
<script>
|
<script>
|
||||||
import TableDescription from '@/components/TableDescription'
|
import TableDescription from '@/components/TableDescription'
|
||||||
import TextField from '@/components/TextField'
|
import TextField from '@/components/TextField'
|
||||||
|
import ChangeDbIcon from '@/components/svg/changeDb'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'Schema',
|
name: 'Schema',
|
||||||
components: { TableDescription, TextField },
|
components: {
|
||||||
|
TableDescription,
|
||||||
|
TextField,
|
||||||
|
ChangeDbIcon
|
||||||
|
},
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
schemaVisible: true,
|
schemaVisible: true,
|
||||||
worker: this.$store.state.worker
|
filter: null
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
schema () {
|
schema () {
|
||||||
return this.$store.state.schema
|
if (!this.$store.state.schema) {
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
|
||||||
|
return !this.filter
|
||||||
|
? this.$store.state.schema
|
||||||
|
: this.$store.state.schema.filter(
|
||||||
|
table => table[0].toUpperCase().indexOf(this.filter.toUpperCase()) !== -1
|
||||||
|
)
|
||||||
},
|
},
|
||||||
dbName () {
|
dbName () {
|
||||||
return this.$store.state.dbName
|
return this.$store.state.dbName
|
||||||
@@ -71,37 +75,32 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
changeDb () {
|
changeDb () {
|
||||||
const dbName = this.$refs.dbfile.value.substr(this.$refs.dbfile.value.lastIndexOf('\\') + 1)
|
this.$db.loadDb(this.$refs.dbfile.files[0])
|
||||||
this.$store.commit('saveDbName', dbName)
|
|
||||||
const f = this.$refs.dbfile.files[0]
|
|
||||||
const r = new FileReader()
|
|
||||||
r.onload = () => {
|
|
||||||
this.worker.onmessage = () => {
|
|
||||||
const getSchemaSql = `
|
|
||||||
SELECT name, sql
|
|
||||||
FROM sqlite_master
|
|
||||||
WHERE type='table' AND name NOT LIKE 'sqlite_%';`
|
|
||||||
this.worker.onmessage = event => {
|
|
||||||
this.$store.commit('saveSchema', event.data.results[0].values)
|
|
||||||
}
|
|
||||||
this.worker.postMessage({ action: 'exec', sql: getSchemaSql })
|
|
||||||
}
|
|
||||||
this.$store.commit('saveDbFile', r.result)
|
|
||||||
try {
|
|
||||||
this.worker.postMessage({ action: 'open', buffer: r.result }, [r.result])
|
|
||||||
} catch (exception) {
|
|
||||||
this.worker.postMessage({ action: 'open', buffer: r.result })
|
|
||||||
}
|
|
||||||
}
|
|
||||||
r.readAsArrayBuffer(f)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
#schema-container {
|
||||||
|
position: relative;
|
||||||
|
padding-bottom: 24px;
|
||||||
|
}
|
||||||
|
|
||||||
.schema {
|
.schema {
|
||||||
margin-left: 12px;
|
margin-left: 12px;
|
||||||
|
padding: 0 12px;
|
||||||
|
}
|
||||||
|
#schema-filter {
|
||||||
|
padding: 32px 12px;
|
||||||
|
position: sticky;
|
||||||
|
position: -webkit-sticky;
|
||||||
|
top: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: 100px;
|
||||||
|
box-sizing: border-box;
|
||||||
|
background-image: linear-gradient(white 73%, transparent);;
|
||||||
|
z-index: 2;
|
||||||
}
|
}
|
||||||
.schema, .db-name {
|
.schema, .db-name {
|
||||||
color: var(--color-text-base);
|
color: var(--color-text-base);
|
||||||
@@ -111,6 +110,8 @@ export default {
|
|||||||
#db {
|
#db {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
margin-top: -5px;
|
||||||
|
padding: 0 12px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.db-name {
|
.db-name {
|
||||||
@@ -124,36 +125,4 @@ export default {
|
|||||||
>>> .table-name:hover .chevron-icon path {
|
>>> .table-name:hover .chevron-icon path {
|
||||||
fill: #506784;
|
fill: #506784;
|
||||||
}
|
}
|
||||||
|
|
||||||
.db-edit {
|
|
||||||
position: relative;
|
|
||||||
}
|
|
||||||
.db-edit-icon {
|
|
||||||
display: block;
|
|
||||||
}
|
|
||||||
.db-edit-icon:hover path{
|
|
||||||
fill: var(--color-accent);
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
|
|
||||||
.db-edit-tooltip {
|
|
||||||
visibility: hidden;
|
|
||||||
background-color: rgba(80, 103, 132, 0.75);
|
|
||||||
color: #fff;
|
|
||||||
text-align: center;
|
|
||||||
font-size: 11px;
|
|
||||||
padding: 0 6px;
|
|
||||||
line-height: 19px;;
|
|
||||||
position: absolute;
|
|
||||||
z-index: 5;
|
|
||||||
height: 19px;
|
|
||||||
left: 24px;
|
|
||||||
top: -12px;
|
|
||||||
border-radius: var(--border-radius-medium);
|
|
||||||
white-space: nowrap;
|
|
||||||
}
|
|
||||||
|
|
||||||
.db-edit:hover .db-edit-tooltip {
|
|
||||||
visibility: visible;
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
385
src/components/Splitpanes.vue
Normal file
@@ -0,0 +1,385 @@
|
|||||||
|
<template>
|
||||||
|
<div
|
||||||
|
ref="container"
|
||||||
|
:class="[
|
||||||
|
'splitpanes',
|
||||||
|
`splitpanes--${horizontal ? 'horizontal' : 'vertical'}`,
|
||||||
|
{ 'splitpanes--dragging': touch.dragging }
|
||||||
|
]"
|
||||||
|
>
|
||||||
|
<div class="movable-splitter" ref="movableSplitter" :style="movableSplitterStyle" />
|
||||||
|
<div
|
||||||
|
class="splitpanes__pane"
|
||||||
|
ref="left"
|
||||||
|
:size="paneBefore.size"
|
||||||
|
max-size="30"
|
||||||
|
:style="styles.before"
|
||||||
|
>
|
||||||
|
<slot name="left-pane" />
|
||||||
|
</div>
|
||||||
|
<!-- Splitter start-->
|
||||||
|
<div
|
||||||
|
class="splitpanes__splitter"
|
||||||
|
@mousedown="onMouseDown"
|
||||||
|
@touchstart="onMouseDown"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
:class="[
|
||||||
|
'toggle-btns',
|
||||||
|
{'both': after.max === 100 && before.max === 100 && after.size > 0 && before.size > 0}
|
||||||
|
]"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
v-if="after.max === 100 && after.size > 0"
|
||||||
|
class="toggle-btn"
|
||||||
|
@click="togglePane('before')"
|
||||||
|
>
|
||||||
|
<img
|
||||||
|
class="direction-icon"
|
||||||
|
:src="require('@/assets/images/chevron.svg')"
|
||||||
|
:style="directionBeforeIconStyle"
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
v-if="before.max === 100 && before.size > 0"
|
||||||
|
class="toggle-btn"
|
||||||
|
@click="togglePane('after')"
|
||||||
|
>
|
||||||
|
<img
|
||||||
|
class="direction-icon"
|
||||||
|
:src="require('@/assets/images/chevron.svg')"
|
||||||
|
:style="directionAfterIconStyle"
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!-- splitter end -->
|
||||||
|
<div
|
||||||
|
class="splitpanes__pane"
|
||||||
|
ref="right"
|
||||||
|
:style="styles.after"
|
||||||
|
>
|
||||||
|
<slot name="right-pane" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'Splitpanes',
|
||||||
|
props: {
|
||||||
|
horizontal: { type: Boolean, default: false },
|
||||||
|
before: { type: Object },
|
||||||
|
after: { type: Object }
|
||||||
|
},
|
||||||
|
data () {
|
||||||
|
return {
|
||||||
|
container: null,
|
||||||
|
paneBefore: this.before,
|
||||||
|
paneAfter: this.after,
|
||||||
|
beforeMinimising: {
|
||||||
|
before: this.before.size,
|
||||||
|
after: this.after.size
|
||||||
|
},
|
||||||
|
touch: {
|
||||||
|
mouseDown: false,
|
||||||
|
dragging: false
|
||||||
|
},
|
||||||
|
movableSplitter: {
|
||||||
|
top: 0,
|
||||||
|
left: 0,
|
||||||
|
visibility: 'hidden'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
styles () {
|
||||||
|
return {
|
||||||
|
before: { [this.horizontal ? 'height' : 'width']: `${this.paneBefore.size}%` },
|
||||||
|
after: { [this.horizontal ? 'height' : 'width']: `${this.paneAfter.size}%` }
|
||||||
|
}
|
||||||
|
},
|
||||||
|
movableSplitterStyle () {
|
||||||
|
const style = { ...this.movableSplitter }
|
||||||
|
style.top += '%'
|
||||||
|
style.left += '%'
|
||||||
|
return style
|
||||||
|
},
|
||||||
|
directionBeforeIconStyle () {
|
||||||
|
const expanded = this.paneBefore.size !== 0
|
||||||
|
const translation = 'translate(-50%, -50%)'
|
||||||
|
if (this.horizontal) {
|
||||||
|
return {
|
||||||
|
transform: `${translation} ${expanded ? 'rotate(90deg)' : 'rotate(-90deg)'}`
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return {
|
||||||
|
transform: `${translation} ${expanded ? 'rotate(0deg)' : 'rotate(180deg)'}`
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
directionAfterIconStyle () {
|
||||||
|
const expanded = this.paneAfter.size !== 0
|
||||||
|
const translation = 'translate(-50%, -50%)'
|
||||||
|
if (this.horizontal) {
|
||||||
|
return {
|
||||||
|
transform: `${translation} ${expanded ? 'rotate(-90deg)' : 'rotate(90deg)'}`
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return {
|
||||||
|
transform: `${translation} ${expanded ? 'rotate(180deg)' : 'rotate(0deg)'}`
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
methods: {
|
||||||
|
bindEvents () {
|
||||||
|
document.addEventListener('mousemove', this.onMouseMove, { passive: false })
|
||||||
|
document.addEventListener('mouseup', this.onMouseUp)
|
||||||
|
|
||||||
|
// Passive: false to prevent scrolling while touch dragging.
|
||||||
|
if ('ontouchstart' in window) {
|
||||||
|
document.addEventListener('touchmove', this.onMouseMove, { passive: false })
|
||||||
|
document.addEventListener('touchend', this.onMouseUp)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
unbindEvents () {
|
||||||
|
document.removeEventListener('mousemove', this.onMouseMove, { passive: false })
|
||||||
|
document.removeEventListener('mouseup', this.onMouseUp)
|
||||||
|
|
||||||
|
if ('ontouchstart' in window) {
|
||||||
|
document.removeEventListener('touchmove', this.onMouseMove, { passive: false })
|
||||||
|
document.removeEventListener('touchend', this.onMouseUp)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
onMouseDown () {
|
||||||
|
this.bindEvents()
|
||||||
|
this.touch.mouseDown = true
|
||||||
|
},
|
||||||
|
|
||||||
|
onMouseMove (event) {
|
||||||
|
if (this.touch.mouseDown) {
|
||||||
|
// Prevent scrolling while touch dragging (only works with an active event, eg. passive: false).
|
||||||
|
event.preventDefault()
|
||||||
|
this.touch.dragging = true
|
||||||
|
this.$set(this.movableSplitter, 'visibility', 'visible')
|
||||||
|
this.moveSplitter(event)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
onMouseUp () {
|
||||||
|
this.touch.mouseDown = false
|
||||||
|
if (this.touch.dragging) {
|
||||||
|
const dragPercentage = this.horizontal
|
||||||
|
? this.movableSplitter.top
|
||||||
|
: this.movableSplitter.left
|
||||||
|
|
||||||
|
this.paneBefore.size = dragPercentage
|
||||||
|
this.paneAfter.size = 100 - dragPercentage
|
||||||
|
|
||||||
|
this.movableSplitter = {
|
||||||
|
top: 0,
|
||||||
|
left: 0,
|
||||||
|
visibility: 'hidden'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Keep dragging flag until click event is finished (click happens immediately after mouseup)
|
||||||
|
// in order to prevent emitting `splitter-click` event if splitter was dragged.
|
||||||
|
setTimeout(() => {
|
||||||
|
this.touch.dragging = false
|
||||||
|
this.unbindEvents()
|
||||||
|
}, 100)
|
||||||
|
},
|
||||||
|
|
||||||
|
// Get the cursor position relative to the splitpane container.
|
||||||
|
getCurrentMouseDrag (event) {
|
||||||
|
const rect = this.container.getBoundingClientRect()
|
||||||
|
const { clientX, clientY } = ('ontouchstart' in window && event.touches)
|
||||||
|
? event.touches[0]
|
||||||
|
: event
|
||||||
|
return {
|
||||||
|
x: clientX - rect.left,
|
||||||
|
y: clientY - rect.top
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
// Returns the drag percentage of the splitter relative to the 2 panes it's inbetween.
|
||||||
|
// if the sum of size of the 2 cells is 60%, the dragPercentage range will be 0 to 100% of this 60%.
|
||||||
|
getCurrentDragPercentage (drag) {
|
||||||
|
drag = drag[this.horizontal ? 'y' : 'x']
|
||||||
|
// In the code bellow 'size' refers to 'width' for vertical and 'height' for horizontal layout.
|
||||||
|
const containerSize = this.container[this.horizontal ? 'clientHeight' : 'clientWidth']
|
||||||
|
return drag * 100 / containerSize
|
||||||
|
},
|
||||||
|
|
||||||
|
moveSplitter (event) {
|
||||||
|
const dragPercentage = this.getCurrentDragPercentage(this.getCurrentMouseDrag(event))
|
||||||
|
const paneBefore = this.paneBefore
|
||||||
|
const paneAfter = this.paneAfter
|
||||||
|
|
||||||
|
const paneBeforeMaxReached = paneBefore.max < 100 && (dragPercentage >= paneBefore.max)
|
||||||
|
const paneAfterMaxReached = paneAfter.max < 100 && (dragPercentage <= 100 - paneAfter.max)
|
||||||
|
|
||||||
|
const dir = this.horizontal ? 'top' : 'left'
|
||||||
|
|
||||||
|
// Prevent dragging beyond pane max.
|
||||||
|
if (paneBeforeMaxReached || paneAfterMaxReached) {
|
||||||
|
if (paneBeforeMaxReached) {
|
||||||
|
this.$set(this.movableSplitter, dir, paneBefore.max)
|
||||||
|
} else {
|
||||||
|
this.$set(this.movableSplitter, dir, Math.max(100 - paneAfter.max, 0))
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.$set(this.movableSplitter, dir, Math.min(Math.max(dragPercentage, 0), paneBefore.max))
|
||||||
|
}
|
||||||
|
},
|
||||||
|
togglePane (toggledPane) {
|
||||||
|
const pane = toggledPane === 'before' ? this.paneBefore : this.paneAfter
|
||||||
|
if (pane.size > 0) {
|
||||||
|
this.beforeMinimising.before = this.paneBefore.size
|
||||||
|
this.beforeMinimising.after = this.paneAfter.size
|
||||||
|
pane.size = 0
|
||||||
|
const otherPane = toggledPane === 'before' ? this.paneAfter : this.paneBefore
|
||||||
|
otherPane.size = 100 - pane.size
|
||||||
|
} else {
|
||||||
|
this.paneBefore.size = this.beforeMinimising.before
|
||||||
|
this.paneAfter.size = this.beforeMinimising.after
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
mounted () {
|
||||||
|
this.container = this.$refs.container
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.splitpanes {
|
||||||
|
display: flex;
|
||||||
|
height: 100%;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.splitpanes--vertical {flex-direction: row;}
|
||||||
|
.splitpanes--horizontal {flex-direction: column;}
|
||||||
|
.splitpanes--dragging * {user-select: none;}
|
||||||
|
|
||||||
|
.splitpanes__pane {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
overflow: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Splitter */
|
||||||
|
|
||||||
|
.splitpanes--vertical > .splitpanes__splitter,
|
||||||
|
.splitpanes--vertical.splitpanes--dragging {
|
||||||
|
cursor: col-resize;
|
||||||
|
}
|
||||||
|
.splitpanes--horizontal > .splitpanes__splitter,
|
||||||
|
.splitpanes--horizontal.splitpanes--dragging {
|
||||||
|
cursor: row-resize;
|
||||||
|
}
|
||||||
|
|
||||||
|
.splitpanes__splitter {
|
||||||
|
touch-action: none;
|
||||||
|
background-color: var(--color-bg-light);
|
||||||
|
box-sizing: border-box;
|
||||||
|
position: relative;
|
||||||
|
flex-shrink: 0;
|
||||||
|
z-index: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.splitpanes--horizontal > .splitpanes__splitter {
|
||||||
|
border-top: 1px solid var(--color-border-light);
|
||||||
|
border-bottom: 1px solid var(--color-border-light);
|
||||||
|
}
|
||||||
|
|
||||||
|
.splitpanes--vertical > .splitpanes__splitter {
|
||||||
|
border-left: 1px solid var(--color-border-light);
|
||||||
|
border-right: 1px solid var(--color-border-light);
|
||||||
|
}
|
||||||
|
|
||||||
|
.movable-splitter {
|
||||||
|
position: absolute;
|
||||||
|
background-color:rgba(162, 177, 198, 0.5);
|
||||||
|
}
|
||||||
|
|
||||||
|
.splitpanes--vertical > .splitpanes__splitter,
|
||||||
|
.splitpanes--vertical > .movable-splitter {
|
||||||
|
width: 8px;
|
||||||
|
z-index: 5;
|
||||||
|
height: 100%
|
||||||
|
}
|
||||||
|
|
||||||
|
.splitpanes--horizontal > .splitpanes__splitter,
|
||||||
|
.splitpanes--horizontal > .movable-splitter {
|
||||||
|
height: 8px;
|
||||||
|
width: 100%;
|
||||||
|
z-index: 5;
|
||||||
|
}
|
||||||
|
/* Toggle buttons */
|
||||||
|
.toggle-btns {
|
||||||
|
position: absolute;
|
||||||
|
top: 50%;
|
||||||
|
left: 50%;
|
||||||
|
transform: translate(-50%, -50%);
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
|
|
||||||
|
.splitpanes--vertical > .splitpanes__splitter .toggle-btns {
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
|
||||||
|
.splitpanes--horizontal > .splitpanes__splitter .toggle-btns {
|
||||||
|
flex-direction: row;
|
||||||
|
}
|
||||||
|
|
||||||
|
.toggle-btn {
|
||||||
|
background-color: var(--color-border-light);
|
||||||
|
border-radius: var(--border-radius-small);
|
||||||
|
border: 1px solid var(--color-border);
|
||||||
|
box-sizing: border-box;
|
||||||
|
position: relative;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.splitpanes--vertical > .splitpanes__splitter .toggle-btn {
|
||||||
|
height: 49px;
|
||||||
|
width: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.splitpanes--horizontal > .splitpanes__splitter .toggle-btn {
|
||||||
|
width: 49px;
|
||||||
|
height: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.toggle-btn .direction-icon {
|
||||||
|
position: absolute;
|
||||||
|
top: 50%;
|
||||||
|
left: 50%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.splitpanes--horizontal > .splitpanes__splitter .toggle-btns.both .toggle-btn:first-child {
|
||||||
|
border-radius: var(--border-radius-small) 0 0 var(--border-radius-small);
|
||||||
|
}
|
||||||
|
|
||||||
|
.splitpanes--horizontal > .splitpanes__splitter .toggle-btns.both .toggle-btn:last-child {
|
||||||
|
border-radius: 0 var(--border-radius-small) var(--border-radius-small) 0;
|
||||||
|
margin-left: -1px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.splitpanes--vertical > .splitpanes__splitter .toggle-btns.both .toggle-btn:first-child {
|
||||||
|
border-radius: var(--border-radius-small) var(--border-radius-small) 0 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.splitpanes--vertical > .splitpanes__splitter .toggle-btns.both .toggle-btn:last-child {
|
||||||
|
border-radius: 0 0 var(--border-radius-small) var(--border-radius-small);
|
||||||
|
margin-top: -1px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
101
src/components/SqlEditor.vue
Normal file
@@ -0,0 +1,101 @@
|
|||||||
|
<template>
|
||||||
|
<div class="codemirror-container">
|
||||||
|
<codemirror v-model="query" :options="cmOptions" @changes="onCmChange" />
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import CM from 'codemirror'
|
||||||
|
import { codemirror } from 'vue-codemirror'
|
||||||
|
import 'codemirror/lib/codemirror.css'
|
||||||
|
import 'codemirror/mode/sql/sql.js'
|
||||||
|
import 'codemirror/theme/neo.css'
|
||||||
|
import 'codemirror/addon/hint/show-hint.js'
|
||||||
|
import 'codemirror/addon/hint/show-hint.css'
|
||||||
|
import 'codemirror/addon/hint/sql-hint.js'
|
||||||
|
import { debounce } from 'debounce'
|
||||||
|
|
||||||
|
const sqlHint = CM.hint.sql
|
||||||
|
CM.hint.sql = (cm, options) => {
|
||||||
|
const token = cm.getTokenAt(cm.getCursor()).string.toUpperCase()
|
||||||
|
const result = sqlHint(cm, options)
|
||||||
|
// Don't show the hint if there is only one option
|
||||||
|
// and the token is already completed with this option
|
||||||
|
if (result.list.length === 1 && result.list[0].text.toUpperCase() === token) {
|
||||||
|
result.list = []
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'SqlEditor',
|
||||||
|
props: ['value'],
|
||||||
|
components: {
|
||||||
|
codemirror
|
||||||
|
},
|
||||||
|
data () {
|
||||||
|
return {
|
||||||
|
query: this.value,
|
||||||
|
cmOptions: {
|
||||||
|
// codemirror options
|
||||||
|
tabSize: 4,
|
||||||
|
mode: 'text/x-mysql',
|
||||||
|
theme: 'neo',
|
||||||
|
lineNumbers: true,
|
||||||
|
line: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
tables () {
|
||||||
|
const tables = {}
|
||||||
|
if (this.$store.state.schema) {
|
||||||
|
this.$store.state.schema.forEach(table => {
|
||||||
|
tables[table.name] = table.columns.map(column => column.name)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return tables
|
||||||
|
}
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
query () {
|
||||||
|
this.$emit('input', this.query)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
onCmChange: debounce(function (editor) {
|
||||||
|
// Don't show autocomplete after a space or semicolon or in string literals
|
||||||
|
const ch = editor.getTokenAt(editor.getCursor()).string.slice(-1)
|
||||||
|
const tokenType = editor.getTokenAt(editor.getCursor()).type
|
||||||
|
if (tokenType === 'string' || !ch || ch === ' ' || ch === ';') {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const hintOptions = {
|
||||||
|
tables: this.tables,
|
||||||
|
completeSingle: false,
|
||||||
|
completeOnSingleClick: true,
|
||||||
|
alignWithWord: false
|
||||||
|
}
|
||||||
|
|
||||||
|
CM.showHint(editor, CM.hint.sql, hintOptions)
|
||||||
|
}, 400)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.codemirror-container {
|
||||||
|
flex-grow: 1;
|
||||||
|
min-height: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
>>> .vue-codemirror {
|
||||||
|
height: 100%;
|
||||||
|
max-height: 100%;
|
||||||
|
}
|
||||||
|
>>> .CodeMirror {
|
||||||
|
height: 100%;
|
||||||
|
max-height: 100%;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -17,12 +17,12 @@
|
|||||||
class="table-container"
|
class="table-container"
|
||||||
ref="table-container"
|
ref="table-container"
|
||||||
@scroll="onScrollTable"
|
@scroll="onScrollTable"
|
||||||
:style="{height: `${height}px`}"
|
:style="{maxHeight: `${height}px`}"
|
||||||
>
|
>
|
||||||
<table ref="table">
|
<table ref="table">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th v-for="(th,index) in data.columns" :key="index" ref="th">
|
<th v-for="(th,index) in dataSet.columns" :key="index" ref="th">
|
||||||
<div class="cell-data" :style="cellStyle">{{ th }}</div>
|
<div class="cell-data" :style="cellStyle">{{ th }}</div>
|
||||||
</th>
|
</th>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -39,7 +39,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="table-footer">
|
<div class="table-footer">
|
||||||
<div class="table-footer-count">
|
<div class="table-footer-count">
|
||||||
{{ data.values.length}} {{data.values.length === 1 ? 'row' : 'rows'}} retrieved
|
{{ dataSet.values.length}} {{dataSet.values.length === 1 ? 'row' : 'rows'}} retrieved
|
||||||
</div>
|
</div>
|
||||||
<pager v-show="pageCount > 1" :page-count="pageCount" v-model="currentPage" />
|
<pager v-show="pageCount > 1" :page-count="pageCount" v-model="currentPage" />
|
||||||
</div>
|
</div>
|
||||||
@@ -52,17 +52,18 @@ import Pager from '@/components/Pager'
|
|||||||
export default {
|
export default {
|
||||||
name: 'SqlTable',
|
name: 'SqlTable',
|
||||||
components: { Pager },
|
components: { Pager },
|
||||||
props: ['data', 'height'],
|
props: ['dataSet', 'height'],
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
header: null,
|
header: null,
|
||||||
tableWidth: null,
|
tableWidth: null,
|
||||||
currentPage: 1
|
currentPage: 1,
|
||||||
|
resizeObserver: null
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
cellStyle () {
|
cellStyle () {
|
||||||
const eq = this.tableWidth / this.data.columns.length
|
const eq = this.tableWidth / this.dataSet.columns.length
|
||||||
|
|
||||||
return { maxWidth: `${Math.max(eq, 100)}px` }
|
return { maxWidth: `${Math.max(eq, 100)}px` }
|
||||||
},
|
},
|
||||||
@@ -70,11 +71,11 @@ export default {
|
|||||||
return Math.max(Math.floor(this.height / 40), 20)
|
return Math.max(Math.floor(this.height / 40), 20)
|
||||||
},
|
},
|
||||||
pageCount () {
|
pageCount () {
|
||||||
return Math.ceil(this.data.values.length / this.pageSize)
|
return Math.ceil(this.dataSet.values.length / this.pageSize)
|
||||||
},
|
},
|
||||||
currentPageData () {
|
currentPageData () {
|
||||||
const start = (this.currentPage - 1) * this.pageSize
|
const start = (this.currentPage - 1) * this.pageSize
|
||||||
return this.data.values.slice(start, start + this.pageSize)
|
return this.dataSet.values.slice(start, start + this.pageSize)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
@@ -82,7 +83,7 @@ export default {
|
|||||||
this.tableWidth = this.$refs['table-container'].offsetWidth
|
this.tableWidth = this.$refs['table-container'].offsetWidth
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
this.header = this.$refs.th.map(th => {
|
this.header = this.$refs.th.map(th => {
|
||||||
return { name: th.innerText, width: th.offsetWidth }
|
return { name: th.innerText, width: th.getBoundingClientRect().width }
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
@@ -94,12 +95,16 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted () {
|
mounted () {
|
||||||
new ResizeObserver(this.calculateHeadersWidth).observe(this.$refs.table)
|
this.resizeObserver = new ResizeObserver(this.calculateHeadersWidth)
|
||||||
|
this.resizeObserver.observe(this.$refs.table)
|
||||||
this.calculateHeadersWidth()
|
this.calculateHeadersWidth()
|
||||||
},
|
},
|
||||||
|
beforeDestroy () {
|
||||||
|
this.resizeObserver.unobserve(this.$refs.table)
|
||||||
|
},
|
||||||
watch: {
|
watch: {
|
||||||
currentPageData: 'calculateHeadersWidth',
|
currentPageData: 'calculateHeadersWidth',
|
||||||
data () {
|
dataSet () {
|
||||||
this.currentPage = 1
|
this.currentPage = 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
196
src/components/Tab.vue
Normal file
@@ -0,0 +1,196 @@
|
|||||||
|
<template>
|
||||||
|
<div class="tab-content-container" v-show="isActive">
|
||||||
|
<splitpanes
|
||||||
|
class="query-results-splitter"
|
||||||
|
horizontal
|
||||||
|
:before="{ size: 50, max: 100 }"
|
||||||
|
:after="{ size: 50, max: 100 }"
|
||||||
|
>
|
||||||
|
<template #left-pane>
|
||||||
|
<div class="query-editor">
|
||||||
|
<sql-editor v-model="query" />
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<template #right-pane>
|
||||||
|
<div id="bottomPane" ref="bottomPane">
|
||||||
|
<view-switcher :view.sync="view" />
|
||||||
|
<div v-show="view === 'table'" class="table-view">
|
||||||
|
<div v-show="result === null && !isGettingResults && !error" class="table-preview">
|
||||||
|
Run your query and get results here
|
||||||
|
</div>
|
||||||
|
<div v-show="isGettingResults" class="table-preview">
|
||||||
|
Fetching results...
|
||||||
|
</div>
|
||||||
|
<div v-show="result === undefined && !isGettingResults && !error" class="table-preview">
|
||||||
|
No rows retrieved according to your query
|
||||||
|
</div>
|
||||||
|
<div v-show="error" class="table-preview error">
|
||||||
|
{{ error }}
|
||||||
|
</div>
|
||||||
|
<sql-table v-if="result" :data-set="result" :height="tableViewHeight" />
|
||||||
|
</div>
|
||||||
|
<chart
|
||||||
|
:visible="view === 'chart'"
|
||||||
|
:sql-result="result"
|
||||||
|
:init-chart="initChart"
|
||||||
|
ref="chart"
|
||||||
|
@update="isUnsaved = true"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</splitpanes>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import SqlTable from '@/components/SqlTable'
|
||||||
|
import SqlEditor from '@/components/SqlEditor'
|
||||||
|
import Splitpanes from '@/components/Splitpanes'
|
||||||
|
import ViewSwitcher from '@/components/ViewSwitcher'
|
||||||
|
import Chart from '@/components/Chart'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'Tab',
|
||||||
|
props: ['id', 'initName', 'initQuery', 'initChart', 'tabIndex', 'isPredefined'],
|
||||||
|
components: {
|
||||||
|
SqlEditor,
|
||||||
|
SqlTable,
|
||||||
|
Splitpanes,
|
||||||
|
ViewSwitcher,
|
||||||
|
Chart
|
||||||
|
},
|
||||||
|
data () {
|
||||||
|
return {
|
||||||
|
query: this.initQuery,
|
||||||
|
result: null,
|
||||||
|
view: 'table',
|
||||||
|
tableViewHeight: 0,
|
||||||
|
isUnsaved: !this.initName,
|
||||||
|
isGettingResults: false,
|
||||||
|
error: null,
|
||||||
|
resizeObserver: null
|
||||||
|
}
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
isActive () {
|
||||||
|
return this.id === this.$store.state.currentTabId
|
||||||
|
}
|
||||||
|
},
|
||||||
|
created () {
|
||||||
|
this.$store.commit('setCurrentTab', this)
|
||||||
|
},
|
||||||
|
mounted () {
|
||||||
|
this.resizeObserver = new ResizeObserver(this.handleResize)
|
||||||
|
this.resizeObserver.observe(this.$refs.bottomPane)
|
||||||
|
this.calculateTableHeight()
|
||||||
|
},
|
||||||
|
beforeDestroy () {
|
||||||
|
this.resizeObserver.unobserve(this.$refs.bottomPane)
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
isActive () {
|
||||||
|
if (this.isActive) {
|
||||||
|
this.$store.commit('setCurrentTab', this)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
query () {
|
||||||
|
this.isUnsaved = true
|
||||||
|
},
|
||||||
|
isUnsaved () {
|
||||||
|
this.$store.commit('updateTabState', { index: this.tabIndex, newValue: this.isUnsaved })
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
// Run a command in the database
|
||||||
|
execute () {
|
||||||
|
// this.$refs.output.textContent = 'Fetching results...' */
|
||||||
|
this.isGettingResults = true
|
||||||
|
this.result = null
|
||||||
|
this.error = null
|
||||||
|
this.$db.execute(this.query + ';')
|
||||||
|
.then(result => {
|
||||||
|
this.result = result
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
this.error = err
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
this.isGettingResults = false
|
||||||
|
})
|
||||||
|
},
|
||||||
|
handleResize () {
|
||||||
|
if (this.view === 'chart') {
|
||||||
|
// hack react-chart editor: hidden and show in order to make the graph resize
|
||||||
|
this.view = 'not chart'
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.view = 'chart'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
this.calculateTableHeight()
|
||||||
|
},
|
||||||
|
calculateTableHeight () {
|
||||||
|
const bottomPane = this.$refs.bottomPane
|
||||||
|
// 88 - view swittcher height
|
||||||
|
// 42 - table footer width
|
||||||
|
// 30 - desirable space after the table
|
||||||
|
// 5 - padding-bottom of rounded table container
|
||||||
|
// 40 - height of table header
|
||||||
|
const freeSpace = bottomPane.offsetHeight - 88 - 42 - 30 - 5 - 40
|
||||||
|
this.tableViewHeight = freeSpace - (freeSpace % 40)
|
||||||
|
},
|
||||||
|
getChartSatateForSave () {
|
||||||
|
return this.$refs.chart.getChartSatateForSave()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.tab-content-container {
|
||||||
|
background-color: var(--color-white);
|
||||||
|
border-top: 1px solid var(--color-border-light);
|
||||||
|
margin-top: -1px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#bottomPane {
|
||||||
|
height: 100%;
|
||||||
|
background-color: var(--color-bg-light);
|
||||||
|
}
|
||||||
|
|
||||||
|
.query-results-splitter {
|
||||||
|
height: calc(100vh - 104px);
|
||||||
|
background-color: var(--color-bg-light);
|
||||||
|
}
|
||||||
|
|
||||||
|
.query-editor {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
height: 100%;
|
||||||
|
max-height: 100%;
|
||||||
|
box-sizing: border-box;
|
||||||
|
min-height: 190px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.table-view {
|
||||||
|
margin: 0 52px;
|
||||||
|
height: calc(100% - 88px);
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.table-preview {
|
||||||
|
position: absolute;
|
||||||
|
top: 40%;
|
||||||
|
left: 50%;
|
||||||
|
transform: translate(-50%, -50%);
|
||||||
|
color: var(--color-text-base);
|
||||||
|
font-size: 13px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.table-preview.error {
|
||||||
|
color: var(--color-text-error);
|
||||||
|
}
|
||||||
|
|
||||||
|
.table-preview.error::first-letter {
|
||||||
|
text-transform: capitalize;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -1,250 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div class="tab-content-container" v-show="isActive">
|
|
||||||
<splitpanes
|
|
||||||
class="query-results-splitter"
|
|
||||||
horizontal
|
|
||||||
:before="{ size: 50, max: 50 }"
|
|
||||||
:after="{ size: 50, max: 100 }"
|
|
||||||
>
|
|
||||||
<div slot="left-pane" class="query-editor">
|
|
||||||
<div class="codemirror-container">
|
|
||||||
<codemirror v-model="query" :options="cmOptions" @changes="onCmChange" ref="codemirror" />
|
|
||||||
</div>
|
|
||||||
<div class="run-btn-container">
|
|
||||||
<button class="primary run-btn" @click="execEditorContents">Run</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div slot="right-pane" id="bottomPane" ref="bottomPane">
|
|
||||||
<view-switcher :view.sync="view" />
|
|
||||||
<div v-show="view === 'table'" class="table-view">
|
|
||||||
<!-- <div id="error" class="error"></div>
|
|
||||||
<pre ref="output" id="output">Results will be displayed here</pre> -->
|
|
||||||
<sql-table v-if="result" :data="result" :height="tableViewHeight" />
|
|
||||||
</div>
|
|
||||||
<PlotlyEditor
|
|
||||||
v-show="view === 'chart'"
|
|
||||||
:data="state.data"
|
|
||||||
:layout="state.layout"
|
|
||||||
:frames="state.frames"
|
|
||||||
:config="{ editable: true }"
|
|
||||||
:dataSources="dataSources"
|
|
||||||
:dataSourceOptions="dataSourceOptions"
|
|
||||||
:plotly="plotly"
|
|
||||||
@onUpdate="update"
|
|
||||||
:useResizeHandler="true"
|
|
||||||
:debug="true"
|
|
||||||
:advancedTraceTypeSelector="true"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</splitpanes>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
import SqlTable from '@/components/SqlTable'
|
|
||||||
import Splitpanes from '@/components/splitpanes'
|
|
||||||
import ViewSwitcher from '@/components/ViewSwitcher'
|
|
||||||
|
|
||||||
import plotly from 'plotly.js/dist/plotly'
|
|
||||||
import 'react-chart-editor/lib/react-chart-editor.min.css'
|
|
||||||
|
|
||||||
import CM from 'codemirror'
|
|
||||||
import { codemirror } from 'vue-codemirror'
|
|
||||||
import 'codemirror/lib/codemirror.css'
|
|
||||||
import 'codemirror/mode/sql/sql.js'
|
|
||||||
import 'codemirror/theme/neo.css'
|
|
||||||
import 'codemirror/addon/hint/show-hint.js'
|
|
||||||
import 'codemirror/addon/hint/show-hint.css'
|
|
||||||
import 'codemirror/addon/hint/sql-hint.js'
|
|
||||||
|
|
||||||
import PlotlyEditor from 'react-chart-editor'
|
|
||||||
|
|
||||||
export default {
|
|
||||||
name: 'TabContent',
|
|
||||||
props: ['id', 'initName', 'initQuery', 'initPlotly', 'tabIndex'],
|
|
||||||
components: {
|
|
||||||
codemirror,
|
|
||||||
SqlTable,
|
|
||||||
Splitpanes,
|
|
||||||
ViewSwitcher,
|
|
||||||
PlotlyEditor
|
|
||||||
},
|
|
||||||
data () {
|
|
||||||
return {
|
|
||||||
plotly: plotly,
|
|
||||||
state: {
|
|
||||||
data: [],
|
|
||||||
layout: {},
|
|
||||||
frames: []
|
|
||||||
},
|
|
||||||
query: 'select * from albums',
|
|
||||||
cmOptions: {
|
|
||||||
// codemirror options
|
|
||||||
tabSize: 4,
|
|
||||||
mode: 'text/x-mysql',
|
|
||||||
theme: 'neo',
|
|
||||||
lineNumbers: true,
|
|
||||||
line: true
|
|
||||||
},
|
|
||||||
result: null,
|
|
||||||
view: 'table',
|
|
||||||
tableViewHeight: 0,
|
|
||||||
worker: this.$store.state.worker,
|
|
||||||
isUnsaved: !this.name
|
|
||||||
}
|
|
||||||
},
|
|
||||||
computed: {
|
|
||||||
isActive () {
|
|
||||||
return this.id === this.$store.state.currentTabId
|
|
||||||
},
|
|
||||||
dataSources () {
|
|
||||||
if (!this.result) {
|
|
||||||
return {}
|
|
||||||
}
|
|
||||||
const dataSorces = {}
|
|
||||||
const matrix = this.result.values
|
|
||||||
const [row] = matrix
|
|
||||||
const transposedMatrix = row.map((value, column) => matrix.map(row => row[column]))
|
|
||||||
this.result.columns.forEach((column, index) => {
|
|
||||||
dataSorces[column] = transposedMatrix[index]
|
|
||||||
})
|
|
||||||
return dataSorces
|
|
||||||
},
|
|
||||||
dataSourceOptions () {
|
|
||||||
return Object.keys(this.dataSources).map(name => ({
|
|
||||||
value: name,
|
|
||||||
label: name
|
|
||||||
}))
|
|
||||||
}
|
|
||||||
},
|
|
||||||
created () {
|
|
||||||
this.$store.commit('setCurrentTab', this)
|
|
||||||
},
|
|
||||||
mounted () {
|
|
||||||
new ResizeObserver(this.calculateTableHeight).observe(this.$refs.bottomPane)
|
|
||||||
this.calculateTableHeight()
|
|
||||||
},
|
|
||||||
watch: {
|
|
||||||
isActive () {
|
|
||||||
if (this.isActive) {
|
|
||||||
this.$store.commit('setCurrentTab', this)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
query () {
|
|
||||||
this.isUnsaved = true
|
|
||||||
},
|
|
||||||
isUnsaved () {
|
|
||||||
this.$store.commit('updateTabState', { index: this.tabIndex, newValue: this.isUnsaved })
|
|
||||||
}
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
update (data, layout, frames) {
|
|
||||||
this.state = { data, layout, frames }
|
|
||||||
this.isUnsaved = true
|
|
||||||
console.log(this.state)
|
|
||||||
},
|
|
||||||
onCmChange (editor) {
|
|
||||||
// Don't show autocomplete after a space or semicolon
|
|
||||||
const ch = editor.getTokenAt(editor.getCursor()).string.slice(-1)
|
|
||||||
if (!ch || ch === ' ' || ch === ';') {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
const hintOptions = {
|
|
||||||
// tables: this.state.tables,
|
|
||||||
completeSingle: false,
|
|
||||||
completeOnSingleClick: true
|
|
||||||
}
|
|
||||||
|
|
||||||
// editor.hint.sql is defined when importing codemirror/addon/hint/sql-hint
|
|
||||||
// (this is mentioned in codemirror addon documentation)
|
|
||||||
// Reference the hint function imported here when including other hint addons
|
|
||||||
// or supply your own
|
|
||||||
CM.showHint(editor, CM.hint.sql, hintOptions)
|
|
||||||
},
|
|
||||||
// Run a command in the database
|
|
||||||
execute (commands) {
|
|
||||||
this.worker.onmessage = (event) => {
|
|
||||||
// if it was more than one select - take only the first one
|
|
||||||
this.result = event.data.results[0]
|
|
||||||
if (!this.result) {
|
|
||||||
console.log(event.data.error)
|
|
||||||
// return
|
|
||||||
}
|
|
||||||
|
|
||||||
// this.$refs.output.innerHTML = ''
|
|
||||||
}
|
|
||||||
this.worker.postMessage({ action: 'exec', sql: commands })
|
|
||||||
// this.$refs.output.textContent = 'Fetching results...'
|
|
||||||
},
|
|
||||||
execEditorContents () {
|
|
||||||
this.execute(this.query + ';')
|
|
||||||
},
|
|
||||||
calculateTableHeight () {
|
|
||||||
const bottomPane = this.$refs.bottomPane
|
|
||||||
// 88 - view swittcher height
|
|
||||||
// 42 - table footer width
|
|
||||||
// 30 - desirable space after the table
|
|
||||||
// 5 - padding-bottom of rounded table container
|
|
||||||
// 40 - height of table header
|
|
||||||
const freeSpace = bottomPane.offsetHeight - 88 - 42 - 30 - 5 - 40
|
|
||||||
this.tableViewHeight = freeSpace - (freeSpace % 40)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
.tab-content-container {
|
|
||||||
padding-top: 6px;
|
|
||||||
background-color: var(--color-bg-light);
|
|
||||||
border-top: 1px solid var(--color-border-light);
|
|
||||||
margin-top: -1px;
|
|
||||||
}
|
|
||||||
|
|
||||||
#bottomPane {
|
|
||||||
height: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.query-results-splitter {
|
|
||||||
height: calc(100vh - 110px);
|
|
||||||
background-color: var(--color-bg-light);
|
|
||||||
}
|
|
||||||
|
|
||||||
.run-btn {
|
|
||||||
margin-top: 24px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.query-editor {
|
|
||||||
padding: 52px 52px 24px;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
height: 100%;
|
|
||||||
max-height: 100%;
|
|
||||||
box-sizing: border-box;
|
|
||||||
min-height: 150px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.codemirror-container {
|
|
||||||
flex-grow: 1;
|
|
||||||
min-height: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.run-btn-container {
|
|
||||||
text-align: right;
|
|
||||||
}
|
|
||||||
|
|
||||||
>>> .vue-codemirror {
|
|
||||||
height: 100%;
|
|
||||||
max-height: 100%;
|
|
||||||
}
|
|
||||||
>>> .CodeMirror {
|
|
||||||
border: 1px solid var(--color-border);
|
|
||||||
border-radius: var(--border-radius-big);
|
|
||||||
height: 100%;
|
|
||||||
max-height: 100%;
|
|
||||||
}
|
|
||||||
.table-view {
|
|
||||||
margin: 0 52px;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -27,40 +27,18 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import sqliteParser from 'sqlite-parser'
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'TableDescription',
|
name: 'TableDescription',
|
||||||
props: ['name', 'sql'],
|
props: ['name', 'columns'],
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
colVisible: false
|
colVisible: false
|
||||||
}
|
}
|
||||||
},
|
|
||||||
computed: {
|
|
||||||
ast () {
|
|
||||||
return sqliteParser(this.sql)
|
|
||||||
},
|
|
||||||
columns () {
|
|
||||||
const columns = []
|
|
||||||
this.ast.statement[0].definition.forEach(item => {
|
|
||||||
if (item.variant === 'column') {
|
|
||||||
let type = item.datatype.variant
|
|
||||||
if (item.datatype.args) {
|
|
||||||
type = type + '(' + item.datatype.args.expression[0].value
|
|
||||||
if (item.datatype.args.expression.length === 2) {
|
|
||||||
type = type + ', ' + item.datatype.args.expression[1].value
|
|
||||||
}
|
|
||||||
type = type + ')'
|
|
||||||
}
|
|
||||||
columns.push({ name: item.name, type: type })
|
|
||||||
}
|
|
||||||
})
|
|
||||||
return columns
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.table-name, .column {
|
.table-name, .column {
|
||||||
margin-top: 11px;
|
margin-top: 11px;
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div id="tabs-container">
|
||||||
<div id="tabs__header">
|
<div id="tabs__header" v-if="tabs.length > 0">
|
||||||
<div
|
<div
|
||||||
v-for="(tab, index) in tabs"
|
v-for="(tab, index) in tabs"
|
||||||
:key="tab.id"
|
:key="index"
|
||||||
@click="selectTab(tab.id)"
|
@click="selectTab(tab.id)"
|
||||||
:class="[{'tab__selected': (tab.id === selectedIndex)}, 'tab']"
|
:class="[{'tab__selected': (tab.id === selectedIndex)}, 'tab']"
|
||||||
>
|
>
|
||||||
@@ -29,22 +29,30 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<tab-content
|
<tab
|
||||||
v-for="(tab, index) in tabs"
|
v-for="(tab, index) in tabs"
|
||||||
:key="tab.id"
|
:key="tab.id"
|
||||||
:id="tab.id"
|
:id="tab.id"
|
||||||
:init-name="tab.name"
|
:init-name="tab.name"
|
||||||
|
:init-query="tab.query"
|
||||||
|
:init-chart="tab.chart"
|
||||||
|
:is-predefined="tab.isPredefined"
|
||||||
:tab-index="index"
|
:tab-index="index"
|
||||||
/>
|
/>
|
||||||
|
<div v-if="tabs.length === 0" id="start-guide">
|
||||||
|
<span class="link" @click="$root.$emit('createNewQuery')">Create</span>
|
||||||
|
a new query from scratch or open the one from
|
||||||
|
<router-link class="link" to="/my-queries">My queries</router-link>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import TabContent from '@/components/TabContent'
|
import Tab from '@/components/Tab'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
TabContent
|
Tab
|
||||||
},
|
},
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
@@ -70,6 +78,11 @@ export default {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
#tabs-container {
|
||||||
|
position: relative;
|
||||||
|
height: 100%;
|
||||||
|
background-color: var(--color-bg-light);
|
||||||
|
}
|
||||||
#tabs__header {
|
#tabs__header {
|
||||||
display: flex;
|
display: flex;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
@@ -107,19 +120,11 @@ export default {
|
|||||||
color: var(--color-text-active);
|
color: var(--color-text-active);
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
border-bottom: none;
|
border-bottom: none;
|
||||||
|
background-color: var(--color-white);
|
||||||
}
|
}
|
||||||
#tabs__header .tab__selected:hover {
|
#tabs__header .tab__selected:hover {
|
||||||
cursor: default;
|
cursor: default;
|
||||||
}
|
}
|
||||||
#tabs__header .tab__selected:before {
|
|
||||||
content: '';
|
|
||||||
position: absolute;
|
|
||||||
width: 100%;
|
|
||||||
height: 5px;
|
|
||||||
background-color: var(--color-accent);
|
|
||||||
top: 0;
|
|
||||||
left: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.close-icon {
|
.close-icon {
|
||||||
margin-left: 5px;
|
margin-left: 5px;
|
||||||
@@ -129,4 +134,19 @@ export default {
|
|||||||
fill: var(--color-text-base);
|
fill: var(--color-text-base);
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
#start-guide {
|
||||||
|
position: absolute;
|
||||||
|
top: 50%;
|
||||||
|
left: 50%;
|
||||||
|
transform: translate(-50%, -50%);
|
||||||
|
color: var(--color-text-base);
|
||||||
|
font-size: 14px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
.link {
|
||||||
|
color: var(--color-accent);
|
||||||
|
text-decoration: none;
|
||||||
|
cursor: pointer;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -1,186 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div
|
|
||||||
ref="container"
|
|
||||||
:class="['splitpanes', `splitpanes--${horizontal ? 'horizontal' : 'vertical'}`, { 'splitpanes--dragging': touch.dragging }]"
|
|
||||||
>
|
|
||||||
<div
|
|
||||||
class="splitpanes__pane"
|
|
||||||
ref="left"
|
|
||||||
:size="paneBefore.size"
|
|
||||||
max-size="30"
|
|
||||||
:style="styles[0]"
|
|
||||||
>
|
|
||||||
<slot name="left-pane" />
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<splitter
|
|
||||||
@mousedown="onMouseDown"
|
|
||||||
@toggle="toggleFirstPane"
|
|
||||||
:expanded="paneBefore.size !== 0"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<div
|
|
||||||
class="splitpanes__pane"
|
|
||||||
ref="right"
|
|
||||||
:style="styles[1]"
|
|
||||||
>
|
|
||||||
<slot name="right-pane" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
import Splitter from '@/components/splitter'
|
|
||||||
|
|
||||||
export default {
|
|
||||||
name: 'splitpanes',
|
|
||||||
components: { Splitter },
|
|
||||||
props: {
|
|
||||||
horizontal: { type: Boolean, default: false },
|
|
||||||
before: { type: Object },
|
|
||||||
after: { type: Object }
|
|
||||||
},
|
|
||||||
data: () => ({
|
|
||||||
container: null,
|
|
||||||
paneBefore: null,
|
|
||||||
paneAfter: null,
|
|
||||||
beforeMinimising: 20,
|
|
||||||
touch: {
|
|
||||||
mouseDown: false,
|
|
||||||
dragging: false
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
|
|
||||||
computed: {
|
|
||||||
styles () {
|
|
||||||
return [
|
|
||||||
{ [this.horizontal ? 'height' : 'width']: `${this.paneBefore.size}%` },
|
|
||||||
{ [this.horizontal ? 'height' : 'width']: `${this.paneAfter.size}%` }
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
methods: {
|
|
||||||
bindEvents () {
|
|
||||||
document.addEventListener('mousemove', this.onMouseMove, { passive: false })
|
|
||||||
document.addEventListener('mouseup', this.onMouseUp)
|
|
||||||
|
|
||||||
// Passive: false to prevent scrolling while touch dragging.
|
|
||||||
if ('ontouchstart' in window) {
|
|
||||||
document.addEventListener('touchmove', this.onMouseMove, { passive: false })
|
|
||||||
document.addEventListener('touchend', this.onMouseUp)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
unbindEvents () {
|
|
||||||
document.removeEventListener('mousemove', this.onMouseMove, { passive: false })
|
|
||||||
document.removeEventListener('mouseup', this.onMouseUp)
|
|
||||||
|
|
||||||
if ('ontouchstart' in window) {
|
|
||||||
document.removeEventListener('touchmove', this.onMouseMove, { passive: false })
|
|
||||||
document.removeEventListener('touchend', this.onMouseUp)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
onMouseDown () {
|
|
||||||
this.bindEvents()
|
|
||||||
this.touch.mouseDown = true
|
|
||||||
},
|
|
||||||
|
|
||||||
onMouseMove (event) {
|
|
||||||
if (this.touch.mouseDown) {
|
|
||||||
// Prevent scrolling while touch dragging (only works with an active event, eg. passive: false).
|
|
||||||
event.preventDefault()
|
|
||||||
this.touch.dragging = true
|
|
||||||
this.calculatePanesSize(this.getCurrentMouseDrag(event))
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
onMouseUp () {
|
|
||||||
this.touch.mouseDown = false
|
|
||||||
// Keep dragging flag until click event is finished (click happens immediately after mouseup)
|
|
||||||
// in order to prevent emitting `splitter-click` event if splitter was dragged.
|
|
||||||
setTimeout(() => {
|
|
||||||
this.touch.dragging = false
|
|
||||||
this.unbindEvents()
|
|
||||||
}, 100)
|
|
||||||
},
|
|
||||||
|
|
||||||
// Get the cursor position relative to the splitpane container.
|
|
||||||
getCurrentMouseDrag (event) {
|
|
||||||
const rect = this.container.getBoundingClientRect()
|
|
||||||
const { clientX, clientY } = ('ontouchstart' in window && event.touches) ? event.touches[0] : event
|
|
||||||
|
|
||||||
return {
|
|
||||||
x: clientX - rect.left,
|
|
||||||
y: clientY - rect.top
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
// Returns the drag percentage of the splitter relative to the 2 panes it's inbetween.
|
|
||||||
// if the sum of size of the 2 cells is 60%, the dragPercentage range will be 0 to 100% of this 60%.
|
|
||||||
getCurrentDragPercentage (drag) {
|
|
||||||
drag = drag[this.horizontal ? 'y' : 'x']
|
|
||||||
// In the code bellow 'size' refers to 'width' for vertical and 'height' for horizontal layout.
|
|
||||||
const containerSize = this.container[this.horizontal ? 'clientHeight' : 'clientWidth']
|
|
||||||
return drag * 100 / containerSize
|
|
||||||
},
|
|
||||||
|
|
||||||
calculatePanesSize (drag) {
|
|
||||||
const dragPercentage = this.getCurrentDragPercentage(drag)
|
|
||||||
// If not pushing other panes, panes to resize are right before and right after splitter.
|
|
||||||
const paneBefore = this.paneBefore
|
|
||||||
const paneAfter = this.paneAfter
|
|
||||||
|
|
||||||
const paneBeforeMaxReached = paneBefore.max < 100 && (dragPercentage >= paneBefore.max)
|
|
||||||
const paneAfterMaxReached = paneAfter.max < 100 && (dragPercentage <= 100 - paneAfter.max)
|
|
||||||
// Prevent dragging beyond pane max.
|
|
||||||
if (paneBeforeMaxReached || paneAfterMaxReached) {
|
|
||||||
if (paneBeforeMaxReached) {
|
|
||||||
paneBefore.size = paneBefore.max
|
|
||||||
paneAfter.size = Math.max(100 - paneBefore.max, 0)
|
|
||||||
} else {
|
|
||||||
paneBefore.size = Math.max(100 - paneAfter.max, 0)
|
|
||||||
paneAfter.size = paneAfter.max
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
paneBefore.size = Math.min(Math.max(dragPercentage, 0), paneBefore.max)
|
|
||||||
paneAfter.size = Math.min(Math.max(100 - dragPercentage, 0), paneAfter.max)
|
|
||||||
},
|
|
||||||
toggleFirstPane () {
|
|
||||||
if (this.paneBefore.size > 0) {
|
|
||||||
this.beforeMinimising = this.paneBefore.size
|
|
||||||
this.paneBefore.size = 0
|
|
||||||
} else {
|
|
||||||
this.paneBefore.size = this.beforeMinimising
|
|
||||||
}
|
|
||||||
this.paneAfter.size = 100 - this.paneBefore.size
|
|
||||||
}
|
|
||||||
},
|
|
||||||
mounted () {
|
|
||||||
this.container = this.$refs.container
|
|
||||||
},
|
|
||||||
created () {
|
|
||||||
this.paneBefore = this.before
|
|
||||||
this.paneAfter = this.after
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style>
|
|
||||||
.splitpanes {
|
|
||||||
display: flex;
|
|
||||||
height: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.splitpanes--vertical {flex-direction: row;}
|
|
||||||
.splitpanes--horizontal {flex-direction: column;}
|
|
||||||
.splitpanes--dragging * {user-select: none;}
|
|
||||||
|
|
||||||
.splitpanes__pane {
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
overflow: auto;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -1,85 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div
|
|
||||||
class="splitpanes__splitter"
|
|
||||||
@mousedown="$emit('mousedown')"
|
|
||||||
@touchstart="$emit('mousedown')"
|
|
||||||
>
|
|
||||||
<div class="toggle-btn" @click="$emit('toggle')">
|
|
||||||
<img
|
|
||||||
class="direction-icon"
|
|
||||||
:src="require('@/assets/images/chevron.svg')"
|
|
||||||
:style="directionIconStyle"
|
|
||||||
>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
export default {
|
|
||||||
name: 'splitter',
|
|
||||||
props: ['expanded'],
|
|
||||||
computed: {
|
|
||||||
directionIconStyle () {
|
|
||||||
const translation = 'translate(-50%, -50%)'
|
|
||||||
if (this.$parent.horizontal) {
|
|
||||||
return {
|
|
||||||
transform: `${translation} ${this.expanded ? 'rotate(-90deg)' : 'rotate(90deg)'}`
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return {
|
|
||||||
transform: `${translation} ${this.expanded ? 'rotate(180deg)' : ''}`
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style>
|
|
||||||
.splitpanes--vertical > .splitpanes__splitter {min-width: 1px;cursor: col-resize;}
|
|
||||||
.splitpanes--horizontal > .splitpanes__splitter {min-height: 1px; cursor: row-resize;}
|
|
||||||
.splitpanes__splitter {
|
|
||||||
touch-action: none;
|
|
||||||
background-color: var(--color-bg-light-2);
|
|
||||||
box-sizing: border-box;
|
|
||||||
position: relative;
|
|
||||||
flex-shrink: 0;
|
|
||||||
z-index: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
.splitpanes--vertical > .splitpanes__splitter {
|
|
||||||
width: 3px;
|
|
||||||
z-index: 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
.splitpanes--horizontal > .splitpanes__splitter {
|
|
||||||
height: 3px;
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
.splitpanes__splitter .toggle-btn {
|
|
||||||
background-color: var(--color-bg-light-2);
|
|
||||||
border-radius: var(--border-radius-small);
|
|
||||||
position: absolute;
|
|
||||||
top: 50%;
|
|
||||||
left: 50%;
|
|
||||||
transform: translate(-50%, -50%);
|
|
||||||
}
|
|
||||||
|
|
||||||
.splitpanes__splitter .toggle-btn:hover {
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
|
|
||||||
.splitpanes--vertical .toggle-btn {
|
|
||||||
height: 68px;
|
|
||||||
width: 15px;
|
|
||||||
}
|
|
||||||
.splitpanes--horizontal .toggle-btn {
|
|
||||||
width: 68px;
|
|
||||||
height: 15px;
|
|
||||||
}
|
|
||||||
.splitpanes__splitter .toggle-btn .direction-icon {
|
|
||||||
position: absolute;
|
|
||||||
top: 50%;
|
|
||||||
left: 50%;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
41
src/components/svg/changeDb.vue
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<svg
|
||||||
|
class="db-edit-icon"
|
||||||
|
width="18"
|
||||||
|
height="18"
|
||||||
|
viewBox="0 0 18 18"
|
||||||
|
fill="none"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
@mouseover="showTooltip"
|
||||||
|
@mouseout="$set(tooltipStyle, 'visibility', 'hidden')"
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
d="M3 10.5V12.75C3 14.25 5.2875 15.54 8.25 15.75V13.5825L8.3475 13.5C5.34 13.32 3 12.045 3 10.5ZM9 9.75C5.685 9.75 3 8.4075 3 6.75V9C3 10.6575 5.685 12 9 12C9.2925 12 9.5775 12 9.87 12L12.75 9.09C11.55 9.54 10.2825 9.75 9 9.75ZM9 2.25C5.685 2.25 3 3.5925 3 5.25C3 6.9075 5.685 8.25 9 8.25C12.315 8.25 15 6.9075 15 5.25C15 3.5925 12.315 2.25 9 2.25ZM15.75 8.3475C15.6375 8.3475 15.5325 8.3925 15.4575 8.475L14.7075 9.225L16.245 10.725L16.995 9.975C17.1525 9.825 17.16 9.57 16.995 9.3975L16.065 8.475C15.99 8.3925 15.885 8.3475 15.78 8.3475H15.75ZM14.28 9.66L9.75 14.205V15.75H11.295L15.84 11.1975L14.28 9.66Z"
|
||||||
|
fill="#A2B1C6"
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
<span class="icon-tooltip" :style="tooltipStyle">
|
||||||
|
Change database
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import tooltipMixin from '@/mixins/tooltips'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'changeDbIcon',
|
||||||
|
mixins: [tooltipMixin]
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.db-edit-icon {
|
||||||
|
display: block;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
.db-edit-icon:hover path {
|
||||||
|
fill: var(--color-accent);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -1,12 +1,33 @@
|
|||||||
<template>
|
<template>
|
||||||
<svg @click.stop="$emit('click')" class="icon" width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg">
|
<span>
|
||||||
<path d="M14.25 15.75H6V5.25H14.25V15.75ZM14.25 3.75H6C5.60218 3.75 5.22064 3.90804 4.93934 4.18934C4.65804 4.47064 4.5 4.85218 4.5 5.25V15.75C4.5 16.1478 4.65804 16.5294 4.93934 16.8107C5.22064 17.092 5.60218 17.25 6 17.25H14.25C14.6478 17.25 15.0294 17.092 15.3107 16.8107C15.592 16.5294 15.75 16.1478 15.75 15.75V5.25C15.75 4.85218 15.592 4.47064 15.3107 4.18934C15.0294 3.90804 14.6478 3.75 14.25 3.75ZM12 0.75H3C2.60218 0.75 2.22064 0.908035 1.93934 1.18934C1.65804 1.47064 1.5 1.85218 1.5 2.25V12.75H3V2.25H12V0.75Z" fill="#A2B1C6"/>
|
<svg
|
||||||
</svg>
|
class="icon"
|
||||||
|
width="18"
|
||||||
|
height="18"
|
||||||
|
viewBox="0 0 18 18"
|
||||||
|
fill="none"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
@click.stop="$emit('click')"
|
||||||
|
@mouseover="showTooltip"
|
||||||
|
@mouseout="$set(tooltipStyle, 'visibility', 'hidden')"
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
d="M14.25 15.75H6V5.25H14.25V15.75ZM14.25 3.75H6C5.60218 3.75 5.22064 3.90804 4.93934 4.18934C4.65804 4.47064 4.5 4.85218 4.5 5.25V15.75C4.5 16.1478 4.65804 16.5294 4.93934 16.8107C5.22064 17.092 5.60218 17.25 6 17.25H14.25C14.6478 17.25 15.0294 17.092 15.3107 16.8107C15.592 16.5294 15.75 16.1478 15.75 15.75V5.25C15.75 4.85218 15.592 4.47064 15.3107 4.18934C15.0294 3.90804 14.6478 3.75 14.25 3.75ZM12 0.75H3C2.60218 0.75 2.22064 0.908035 1.93934 1.18934C1.65804 1.47064 1.5 1.85218 1.5 2.25V12.75H3V2.25H12V0.75Z"
|
||||||
|
fill="#A2B1C6"
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
<span class="icon-tooltip" :style="tooltipStyle">
|
||||||
|
Duplicate query
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import tooltipMixin from '@/mixins/tooltips'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'CopyIcon'
|
name: 'CopyIcon',
|
||||||
|
mixins: [tooltipMixin]
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -1,19 +1,40 @@
|
|||||||
<template>
|
<template>
|
||||||
<svg @click.stop="$emit('click')" class="icon" width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg">
|
<span>
|
||||||
<path d="M6.75 2.25V3H3V4.5H3.75V14.25C3.75 14.6478 3.90804 15.0294 4.18934 15.3107C4.47064 15.592 4.85218 15.75 5.25 15.75H12.75C13.1478 15.75 13.5294 15.592 13.8107 15.3107C14.092 15.0294 14.25 14.6478 14.25 14.25V4.5H15V3H11.25V2.25H6.75ZM5.25 4.5H12.75V14.25H5.25V4.5ZM6.75 6V12.75H8.25V6H6.75ZM9.75 6V12.75H11.25V6H9.75Z" fill="#A2B1C6"/>
|
<svg
|
||||||
</svg>
|
class="icon"
|
||||||
|
width="18"
|
||||||
|
height="18"
|
||||||
|
viewBox="0 0 18 18"
|
||||||
|
fill="none"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
@click.stop="$emit('click')"
|
||||||
|
@mouseover="showTooltip"
|
||||||
|
@mouseout="$set(tooltipStyle, 'visibility', 'hidden')"
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
d="M6.75 2.25V3H3V4.5H3.75V14.25C3.75 14.6478 3.90804 15.0294 4.18934 15.3107C4.47064 15.592 4.85218 15.75 5.25 15.75H12.75C13.1478 15.75 13.5294 15.592 13.8107 15.3107C14.092 15.0294 14.25 14.6478 14.25 14.25V4.5H15V3H11.25V2.25H6.75ZM5.25 4.5H12.75V14.25H5.25V4.5ZM6.75 6V12.75H8.25V6H6.75ZM9.75 6V12.75H11.25V6H9.75Z"
|
||||||
|
fill="#A2B1C6"
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
<span class="icon-tooltip" :style="tooltipStyle">
|
||||||
|
Delete query
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import tooltipMixin from '@/mixins/tooltips'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'DeleteIcon'
|
name: 'DeleteIcon',
|
||||||
|
mixins: [tooltipMixin]
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.icon {
|
.icon {
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
margin: 0 0 0 12px;
|
margin: 0 12px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.icon:hover path {
|
.icon:hover path {
|
||||||
|
|||||||
@@ -1,12 +1,33 @@
|
|||||||
<template>
|
<template>
|
||||||
<svg @click.stop="$emit('click')" class="icon" width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg">
|
<span>
|
||||||
<path d="M10.5 1.5H4.5C3.675 1.5 3 2.175 3 3V15C3 15.825 3.675 16.5 4.5 16.5H13.5C14.325 16.5 15 15.825 15 15V6L10.5 1.5ZM13.5 15H4.5V3H9.75V6.75H13.5V15ZM12 8.25V13.575L10.425 12L8.325 14.1L6.225 12L8.325 9.9L6.675 8.25H12Z" fill="#A2B1C6"/>
|
<svg
|
||||||
</svg>
|
class="icon"
|
||||||
|
width="18"
|
||||||
|
height="18"
|
||||||
|
viewBox="0 0 18 18"
|
||||||
|
fill="none"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
@click.stop="$emit('click')"
|
||||||
|
@mouseover="showTooltip"
|
||||||
|
@mouseout="$set(tooltipStyle, 'visibility', 'hidden')"
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
d="M10.5 1.5H4.5C3.675 1.5 3 2.175 3 3V15C3 15.825 3.675 16.5 4.5 16.5H13.5C14.325 16.5 15 15.825 15 15V6L10.5 1.5ZM13.5 15H4.5V3H9.75V6.75H13.5V15ZM12 8.25V13.575L10.425 12L8.325 14.1L6.225 12L8.325 9.9L6.675 8.25H12Z"
|
||||||
|
fill="#A2B1C6"
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
<span class="icon-tooltip" :style="tooltipStyle">
|
||||||
|
Export query to file
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import tooltipMixin from '@/mixins/tooltips'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'ExportIcon'
|
name: 'ExportIcon',
|
||||||
|
mixins: [tooltipMixin]
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -1,19 +1,40 @@
|
|||||||
<template>
|
<template>
|
||||||
<svg @click.stop="$emit('click')" class="icon" width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg">
|
<span>
|
||||||
<path d="M10.545 6.75L11.25 7.455L4.44 14.25H3.75V13.56L10.545 6.75ZM13.245 2.25C13.0575 2.25 12.8625 2.325 12.72 2.4675L11.3475 3.84L14.16 6.6525L15.5325 5.28C15.825 4.9875 15.825 4.5 15.5325 4.2225L13.7775 2.4675C13.6275 2.3175 13.44 2.25 13.245 2.25ZM10.545 4.6425L2.25 12.9375V15.75H5.0625L13.3575 7.455L10.545 4.6425Z" fill="#A2B1C6"/>
|
<svg
|
||||||
</svg>
|
class="icon"
|
||||||
|
width="18"
|
||||||
|
height="18"
|
||||||
|
viewBox="0 0 18 18"
|
||||||
|
fill="none"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
@click.stop="$emit('click')"
|
||||||
|
@mouseover="showTooltip"
|
||||||
|
@mouseout="$set(tooltipStyle, 'visibility', 'hidden')"
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
d="M10.545 6.75L11.25 7.455L4.44 14.25H3.75V13.56L10.545 6.75ZM13.245 2.25C13.0575 2.25 12.8625 2.325 12.72 2.4675L11.3475 3.84L14.16 6.6525L15.5325 5.28C15.825 4.9875 15.825 4.5 15.5325 4.2225L13.7775 2.4675C13.6275 2.3175 13.44 2.25 13.245 2.25ZM10.545 4.6425L2.25 12.9375V15.75H5.0625L13.3575 7.455L10.545 4.6425Z"
|
||||||
|
fill="#A2B1C6"
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
<span class="icon-tooltip" :style="tooltipStyle">
|
||||||
|
Rename query
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import tooltipMixin from '@/mixins/tooltips'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'RenameIcon'
|
name: 'RenameIcon',
|
||||||
|
mixins: [tooltipMixin]
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.icon {
|
.icon {
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
margin: 0 12px 0 6px;
|
margin: 0 12px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.icon:hover path {
|
.icon:hover path {
|
||||||
|
|||||||
46
src/dataBase.js
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
import store from '@/store'
|
||||||
|
import router from '@/router'
|
||||||
|
const worker = new Worker('js/worker.sql-wasm.js')
|
||||||
|
|
||||||
|
export default {
|
||||||
|
loadDb (file) {
|
||||||
|
const dbName = file.name
|
||||||
|
store.commit('saveDbName', dbName)
|
||||||
|
const f = file
|
||||||
|
const r = new FileReader()
|
||||||
|
r.onload = () => {
|
||||||
|
worker.onmessage = () => {
|
||||||
|
const getSchemaSql = `
|
||||||
|
SELECT name, sql
|
||||||
|
FROM sqlite_master
|
||||||
|
WHERE type='table' AND name NOT LIKE 'sqlite_%';`
|
||||||
|
worker.onmessage = event => {
|
||||||
|
store.commit('saveSchema', event.data.results[0].values)
|
||||||
|
if (router.currentRoute.path !== '/editor') {
|
||||||
|
router.push('/editor')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
worker.postMessage({ action: 'exec', sql: getSchemaSql })
|
||||||
|
}
|
||||||
|
store.commit('saveDbFile', r.result)
|
||||||
|
try {
|
||||||
|
worker.postMessage({ action: 'open', buffer: r.result }, [r.result])
|
||||||
|
} catch (exception) {
|
||||||
|
worker.postMessage({ action: 'open', buffer: r.result })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
r.readAsArrayBuffer(f)
|
||||||
|
},
|
||||||
|
execute (commands) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
worker.onmessage = (event) => {
|
||||||
|
if (event.data.error) {
|
||||||
|
reject(event.data.error)
|
||||||
|
}
|
||||||
|
// if it was more than one select - take only the first one
|
||||||
|
resolve(event.data.results[0])
|
||||||
|
}
|
||||||
|
worker.postMessage({ action: 'exec', sql: commands })
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,16 +4,20 @@ import router from './router'
|
|||||||
import store from './store'
|
import store from './store'
|
||||||
import { VuePlugin } from 'vuera'
|
import { VuePlugin } from 'vuera'
|
||||||
import VModal from 'vue-js-modal'
|
import VModal from 'vue-js-modal'
|
||||||
|
import db from '@/dataBase'
|
||||||
|
|
||||||
import '@/assets/styles/variables.css'
|
import '@/assets/styles/variables.css'
|
||||||
import '@/assets/styles/buttons.css'
|
import '@/assets/styles/buttons.css'
|
||||||
import '@/assets/styles/tables.css'
|
import '@/assets/styles/tables.css'
|
||||||
import '@/assets/styles/dialogs.css'
|
import '@/assets/styles/dialogs.css'
|
||||||
|
import '@/assets/styles/tooltips.css'
|
||||||
|
import '@/assets/styles/messages.css'
|
||||||
|
|
||||||
Vue.use(VuePlugin)
|
Vue.use(VuePlugin)
|
||||||
Vue.use(VModal)
|
Vue.use(VModal)
|
||||||
|
|
||||||
Vue.config.productionTip = false
|
Vue.config.productionTip = false
|
||||||
|
Vue.prototype.$db = db
|
||||||
|
|
||||||
new Vue({
|
new Vue({
|
||||||
router,
|
router,
|
||||||
|
|||||||
17
src/mixins/tooltips.js
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
export default {
|
||||||
|
data () {
|
||||||
|
return {
|
||||||
|
tooltipStyle: {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
showTooltip (e) {
|
||||||
|
this.tooltipStyle = {
|
||||||
|
visibility: 'visible',
|
||||||
|
position: 'fixed',
|
||||||
|
top: e.clientY - 12 + 'px',
|
||||||
|
left: e.clientX + 12 + 'px'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,7 +2,7 @@ import Vue from 'vue'
|
|||||||
import VueRouter from 'vue-router'
|
import VueRouter from 'vue-router'
|
||||||
import Editor from '../views/Editor'
|
import Editor from '../views/Editor'
|
||||||
import MyQueries from '../views/MyQueries'
|
import MyQueries from '../views/MyQueries'
|
||||||
import DbUpload from '../views/DbUpload'
|
import Home from '../views/Home'
|
||||||
import MainView from '../views/MainView'
|
import MainView from '../views/MainView'
|
||||||
|
|
||||||
Vue.use(VueRouter)
|
Vue.use(VueRouter)
|
||||||
@@ -11,7 +11,7 @@ const routes = [
|
|||||||
{
|
{
|
||||||
path: '/',
|
path: '/',
|
||||||
name: 'Welcome',
|
name: 'Welcome',
|
||||||
component: DbUpload
|
component: Home
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/',
|
path: '/',
|
||||||
|
|||||||
@@ -1,22 +1,67 @@
|
|||||||
import Vue from 'vue'
|
import Vue from 'vue'
|
||||||
import Vuex from 'vuex'
|
import Vuex from 'vuex'
|
||||||
|
import sqliteParser from 'sqlite-parser'
|
||||||
|
|
||||||
Vue.use(Vuex)
|
Vue.use(Vuex)
|
||||||
|
|
||||||
|
function getAst (sql) {
|
||||||
|
// There is a bug is sqlite-parser
|
||||||
|
// It throws an error if tokenizer has an arguments:
|
||||||
|
// https://github.com/codeschool/sqlite-parser/issues/59
|
||||||
|
const fixedSql = sql
|
||||||
|
.replace(/(?<=tokenize=.+)"tokenchars=.+"/, '')
|
||||||
|
.replace(/(?<=tokenize=.+)"remove_diacritics=.+"/, '')
|
||||||
|
.replace(/(?<=tokenize=.+)"separators=.+"/, '')
|
||||||
|
.replace(/tokenize=.+(?=(,|\)))/, 'tokenize=unicode61')
|
||||||
|
|
||||||
|
return sqliteParser(fixedSql)
|
||||||
|
}
|
||||||
|
|
||||||
|
function getColumns (sql) {
|
||||||
|
const columns = []
|
||||||
|
const ast = getAst(sql)
|
||||||
|
|
||||||
|
const columnDefinition = ast.statement[0].format === 'table'
|
||||||
|
? ast.statement[0].definition
|
||||||
|
: ast.statement[0].result.args.expression // virtual table
|
||||||
|
|
||||||
|
columnDefinition.forEach(item => {
|
||||||
|
if (item.variant === 'column' && ['identifier', 'definition'].includes(item.type)) {
|
||||||
|
let type = item.datatype ? item.datatype.variant : 'N/A'
|
||||||
|
if (item.datatype && item.datatype.args) {
|
||||||
|
type = type + '(' + item.datatype.args.expression[0].value
|
||||||
|
if (item.datatype.args.expression.length === 2) {
|
||||||
|
type = type + ', ' + item.datatype.args.expression[1].value
|
||||||
|
}
|
||||||
|
type = type + ')'
|
||||||
|
}
|
||||||
|
columns.push({ name: item.name, type: type })
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return columns
|
||||||
|
}
|
||||||
|
|
||||||
export default new Vuex.Store({
|
export default new Vuex.Store({
|
||||||
state: {
|
state: {
|
||||||
schema: null,
|
schema: null,
|
||||||
dbFile: null,
|
dbFile: null,
|
||||||
dbName: null,
|
dbName: null,
|
||||||
worker: new Worker('js/worker.sql-wasm.js'),
|
|
||||||
tabs: [],
|
tabs: [],
|
||||||
currentTab: null,
|
currentTab: null,
|
||||||
currentTabId: null,
|
currentTabId: null,
|
||||||
untitledLastIndex: 0
|
untitledLastIndex: 0,
|
||||||
|
predefinedQueries: []
|
||||||
},
|
},
|
||||||
mutations: {
|
mutations: {
|
||||||
saveSchema (state, schema) {
|
saveSchema (state, schema) {
|
||||||
state.schema = schema
|
const parsedSchema = []
|
||||||
|
schema.forEach(item => {
|
||||||
|
parsedSchema.push({
|
||||||
|
name: item[0],
|
||||||
|
columns: getColumns(item[1])
|
||||||
|
})
|
||||||
|
})
|
||||||
|
state.schema = parsedSchema
|
||||||
},
|
},
|
||||||
saveDbFile (state, file) {
|
saveDbFile (state, file) {
|
||||||
state.dbFile = file
|
state.dbFile = file
|
||||||
@@ -26,14 +71,29 @@ export default new Vuex.Store({
|
|||||||
},
|
},
|
||||||
addTab (state, tab) {
|
addTab (state, tab) {
|
||||||
state.tabs.push(tab)
|
state.tabs.push(tab)
|
||||||
|
|
||||||
|
if (!tab.name) {
|
||||||
|
state.untitledLastIndex += 1
|
||||||
|
}
|
||||||
},
|
},
|
||||||
updateTabName (state, { index, newName }) {
|
updateTab (state, { index, name, id, query, chart, isUnsaved }) {
|
||||||
const tab = state.tabs[index]
|
const tab = state.tabs[index]
|
||||||
tab.name = newName
|
const oldId = tab.id
|
||||||
|
|
||||||
|
if (state.currentTabId === oldId) {
|
||||||
|
state.currentTabId = id
|
||||||
|
}
|
||||||
|
|
||||||
|
tab.id = id
|
||||||
|
if (name) { tab.name = name }
|
||||||
|
if (query) { tab.query = query }
|
||||||
|
if (chart) { tab.chart = chart }
|
||||||
|
if (isUnsaved !== undefined) { tab.isUnsaved = isUnsaved }
|
||||||
|
delete tab.isPredefined
|
||||||
|
|
||||||
Vue.set(state.tabs, index, tab)
|
Vue.set(state.tabs, index, tab)
|
||||||
},
|
},
|
||||||
updateTabState (state, { index, newValue }) {
|
updateTabState (state, { index, newValue }) {
|
||||||
console.log(index, newValue)
|
|
||||||
const tab = state.tabs[index]
|
const tab = state.tabs[index]
|
||||||
tab.isUnsaved = newValue
|
tab.isUnsaved = newValue
|
||||||
Vue.set(state.tabs, index, tab)
|
Vue.set(state.tabs, index, tab)
|
||||||
@@ -46,6 +106,7 @@ export default new Vuex.Store({
|
|||||||
state.currentTabId = state.tabs[index - 1].id
|
state.currentTabId = state.tabs[index - 1].id
|
||||||
} else {
|
} else {
|
||||||
state.currentTabId = null
|
state.currentTabId = null
|
||||||
|
state.currentTab = null
|
||||||
state.untitledLastIndex = 0
|
state.untitledLastIndex = 0
|
||||||
}
|
}
|
||||||
state.tabs.splice(index, 1)
|
state.tabs.splice(index, 1)
|
||||||
@@ -56,12 +117,14 @@ export default new Vuex.Store({
|
|||||||
setCurrentTab (state, tab) {
|
setCurrentTab (state, tab) {
|
||||||
state.currentTab = tab
|
state.currentTab = tab
|
||||||
},
|
},
|
||||||
updateUntitledLastIndex (state) {
|
updatePredefinedQueries (state, queries) {
|
||||||
state.untitledLastIndex += 1
|
if (Array.isArray(queries)) {
|
||||||
|
state.predefinedQueries = queries
|
||||||
|
} else {
|
||||||
|
state.predefinedQueries = [queries]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
},
|
|
||||||
modules: {
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -5,34 +5,74 @@
|
|||||||
:before="{ size: 20, max: 30 }"
|
:before="{ size: 20, max: 30 }"
|
||||||
:after="{ size: 80, max: 100 }"
|
:after="{ size: 80, max: 100 }"
|
||||||
>
|
>
|
||||||
<div slot="left-pane">
|
<template #left-pane>
|
||||||
<schema />
|
<schema v-if="$store.state.schema"/>
|
||||||
</div>
|
<div v-else id="empty-schema-container">
|
||||||
<div slot="right-pane">
|
<div class="warning">
|
||||||
|
Database is not uploaded. Queries can’t be run without database.
|
||||||
|
</div>
|
||||||
|
<db-upload id="db-uploader"/>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<template #right-pane>
|
||||||
<tabs />
|
<tabs />
|
||||||
</div>
|
</template>
|
||||||
</splitpanes>
|
</splitpanes>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import Splitpanes from '@/components/splitpanes'
|
import Splitpanes from '@/components/Splitpanes'
|
||||||
import Schema from '@/components/Schema'
|
import Schema from '@/components/Schema'
|
||||||
import Tabs from '@/components/Tabs'
|
import Tabs from '@/components/Tabs'
|
||||||
|
import dbUpload from '@/components/DbUpload'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'Editor',
|
name: 'Editor',
|
||||||
components: {
|
components: {
|
||||||
Schema,
|
Schema,
|
||||||
Splitpanes,
|
Splitpanes,
|
||||||
Tabs
|
Tabs,
|
||||||
|
dbUpload
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style scoped>
|
||||||
.schema-tabs-splitter {
|
.schema-tabs-splitter {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
margin-left: 6px;
|
background-color: var(--color-white);
|
||||||
|
}
|
||||||
|
#empty-schema-container {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
min-width: 200px;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
#db-uploader {
|
||||||
|
flex-grow: 1;
|
||||||
|
padding: 24px;
|
||||||
|
width: 100%;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
.warning {
|
||||||
|
padding: 12px 24px;
|
||||||
|
width: 100%;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
>>> .db-upload-container {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
>>>.drop-area {
|
||||||
|
padding: 0 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
>>>.drop-area .text {
|
||||||
|
max-width: 200px;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
70
src/views/Home.vue
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
<template>
|
||||||
|
<div id="dbloader-container">
|
||||||
|
<h1>Sqliteviz</h1>
|
||||||
|
<db-upload />
|
||||||
|
<button id ="skip" class="secondary" @click="$router.push('/editor')">
|
||||||
|
Skip database connection for now
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import dbUpload from '@/components/DbUpload'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'Home',
|
||||||
|
components: { dbUpload },
|
||||||
|
methods: {
|
||||||
|
loadDb () {
|
||||||
|
this.$db.loadDb(this.$refs.file.files[0])
|
||||||
|
},
|
||||||
|
dragover (event) {
|
||||||
|
event.preventDefault()
|
||||||
|
// TODO: Add some visual stuff to show the user can drop its files
|
||||||
|
if (!event.currentTarget.classList.contains('bg-green-300')) {
|
||||||
|
event.currentTarget.classList.remove('bg-gray-100')
|
||||||
|
event.currentTarget.classList.add('bg-green-300')
|
||||||
|
}
|
||||||
|
},
|
||||||
|
dragleave (event) {
|
||||||
|
// Clean up
|
||||||
|
event.currentTarget.classList.add('bg-gray-100')
|
||||||
|
event.currentTarget.classList.remove('bg-green-300')
|
||||||
|
},
|
||||||
|
drop (event) {
|
||||||
|
event.preventDefault()
|
||||||
|
this.$refs.file.files = event.dataTransfer.files
|
||||||
|
this.loadDb()
|
||||||
|
// Clean up
|
||||||
|
event.currentTarget.classList.add('bg-gray-100')
|
||||||
|
event.currentTarget.classList.remove('bg-green-300')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
#dbloader-container {
|
||||||
|
width: 100vw;
|
||||||
|
height: 100vh;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1 {
|
||||||
|
color: var(--color-accent);
|
||||||
|
}
|
||||||
|
|
||||||
|
#skip {
|
||||||
|
position: absolute;
|
||||||
|
bottom: 50px;
|
||||||
|
}
|
||||||
|
|
||||||
|
>>>.drop-area {
|
||||||
|
width: 628px;
|
||||||
|
height: 490px;
|
||||||
|
padding: 0 150px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -13,7 +13,35 @@ import '@/assets/styles/scrollbars.css'
|
|||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'MainView',
|
name: 'MainView',
|
||||||
components: { MainMenu }
|
components: { MainMenu },
|
||||||
|
created () {
|
||||||
|
this.readPredefinedQueries()
|
||||||
|
.then(queries => {
|
||||||
|
this.$store.commit('updatePredefinedQueries', queries)
|
||||||
|
})
|
||||||
|
.catch(console.error)
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
readPredefinedQueries () {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
const xhr = new XMLHttpRequest()
|
||||||
|
xhr.open('GET', './queries.json')
|
||||||
|
xhr.onload = () => {
|
||||||
|
if (xhr.readyState === 4) {
|
||||||
|
if (xhr.status === 200) {
|
||||||
|
resolve(JSON.parse(xhr.responseText))
|
||||||
|
} else {
|
||||||
|
reject(xhr.statusText)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
xhr.onerror = () => {
|
||||||
|
reject(xhr.statusText)
|
||||||
|
}
|
||||||
|
xhr.send()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
|||||||
@@ -1,6 +1,12 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<div id="my-queries-content">
|
<div id="start-guide" v-if="showedQueries.length === 0">
|
||||||
|
You don't have saved queries so far.
|
||||||
|
<span class="link" @click="create">Create</span>
|
||||||
|
the one from scratch or
|
||||||
|
<label for="import-file" class="link">import</label> from a file.
|
||||||
|
</div>
|
||||||
|
<div id="my-queries-content" ref="my-queries-content" v-show="showedQueries.length > 0">
|
||||||
<div id="my-queries-toolbar">
|
<div id="my-queries-toolbar">
|
||||||
<div id="toolbar-buttons">
|
<div id="toolbar-buttons">
|
||||||
<input
|
<input
|
||||||
@@ -10,23 +16,36 @@
|
|||||||
id="import-file"
|
id="import-file"
|
||||||
@change="importQueries"
|
@change="importQueries"
|
||||||
/>
|
/>
|
||||||
<button class="toolbar">
|
<button class="toolbar">
|
||||||
<label for="import-file">
|
<label for="import-file">
|
||||||
Import
|
Import
|
||||||
</label>
|
</label>
|
||||||
</button>
|
</button>
|
||||||
<button class="toolbar" v-show="selectedQueries.length > 0">Export</button>
|
<button
|
||||||
<button class="toolbar" v-show="selectedQueries.length > 0">Delete</button>
|
class="toolbar"
|
||||||
|
v-show="selectedQueriesCount > 0"
|
||||||
|
@click="exportQuery(selectedQueriesIds)"
|
||||||
|
>
|
||||||
|
Export
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
class="toolbar"
|
||||||
|
v-show="selectedNotPredefinedCount > 0"
|
||||||
|
@click="showDeleteDialog(selectedQueriesIds)"
|
||||||
|
>
|
||||||
|
Delete
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div id="toolbar-search">
|
<div id="toolbar-search">
|
||||||
<text-field placeholder="Search query by name" width="300px"/>
|
<text-field placeholder="Search query by name" width="300px" v-model="filter"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="rounded-bg">
|
<div class="rounded-bg">
|
||||||
<div class="header-container">
|
<div class="header-container">
|
||||||
<div>
|
<div>
|
||||||
<div class="fixed-header" ref="name-th">
|
<div class="fixed-header" ref="name-th">
|
||||||
Name
|
<check-box ref="mainCheckBox" theme="light" @click="toggleSelectAll"/>
|
||||||
|
<div class="name-th">Name</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="fixed-header">
|
<div class="fixed-header">
|
||||||
Created at
|
Created at
|
||||||
@@ -34,23 +53,45 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
class="table-container"
|
class="table-container" :style="{ 'max-height': `${maxTableHeight}px` }"
|
||||||
ref="table-container"
|
|
||||||
>
|
>
|
||||||
<table ref="table">
|
<table ref="table">
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr v-for="(query, index) in queries" :key="query.id" @click="openQuery(index)">
|
<tr
|
||||||
|
v-for="(query, index) in showedQueries"
|
||||||
|
:key="query.id"
|
||||||
|
:class="{ 'predefined': query.isPredefined }"
|
||||||
|
@click="openQuery(index)"
|
||||||
|
>
|
||||||
<td ref="name-td">
|
<td ref="name-td">
|
||||||
{{ query.name }}
|
<div class="cell-data">
|
||||||
|
<check-box
|
||||||
|
ref="rowCheckBox"
|
||||||
|
:init="selectAll || selectedQueriesIds.has(query.id)"
|
||||||
|
@click="toggleRow($event, query.id)"
|
||||||
|
/>
|
||||||
|
<div class="name">{{ query.name }}</div>
|
||||||
|
<div
|
||||||
|
class="badge"
|
||||||
|
@mouseover="showTooltip"
|
||||||
|
@mouseout="$set(tooltipStyle, 'visibility', 'hidden')"
|
||||||
|
>
|
||||||
|
Predefined
|
||||||
|
<span class="icon-tooltip" :style="tooltipStyle">
|
||||||
|
Predefined queries come from the server.
|
||||||
|
These queries can’t be deleted or renamed.
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<div class="second-column">
|
<div class="second-column">
|
||||||
<div class="date-container">{{ query.createdAt | date }}</div>
|
<div class="date-container">{{ query.createdAt | date }}</div>
|
||||||
<div class="icons-container">
|
<div class="icons-container">
|
||||||
<rename-icon @click="showRenameDialog(index)" />
|
<rename-icon v-if="!query.isPredefined" @click="showRenameDialog(query.id)" />
|
||||||
<copy-icon @click="duplicateQuery(index)"/>
|
<copy-icon @click="duplicateQuery(index)"/>
|
||||||
<export-icon @click="exportQuery(index)"/>
|
<export-icon @click="exportQuery(index)"/>
|
||||||
<delete-icon @click="showDeleteDialog(index)"/>
|
<delete-icon v-if="!query.isPredefined" @click="showDeleteDialog(query.id)"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
@@ -84,19 +125,28 @@
|
|||||||
<!--Delete Query dialog -->
|
<!--Delete Query dialog -->
|
||||||
<modal name="delete" classes="dialog" height="auto">
|
<modal name="delete" classes="dialog" height="auto">
|
||||||
<div class="dialog-header">
|
<div class="dialog-header">
|
||||||
Delete query
|
Delete {{ deleteGroup ? 'queries' : 'query' }}
|
||||||
<close-icon @click="$modal.hide('delete')"/>
|
<close-icon @click="$modal.hide('delete')"/>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
v-if="
|
v-if="
|
||||||
currentQueryIndex !== null
|
deleteGroup || (
|
||||||
&& currentQueryIndex >= 0
|
currentQueryIndex !== null
|
||||||
&& currentQueryIndex < queries.length
|
&& currentQueryIndex >= 0
|
||||||
|
&& currentQueryIndex < queries.length
|
||||||
|
)
|
||||||
"
|
"
|
||||||
class="dialog-body"
|
class="dialog-body"
|
||||||
>
|
>
|
||||||
Are you sure you want to delete
|
Are you sure you want to delete
|
||||||
"{{ queries[currentQueryIndex].name }}"?
|
{{ deleteGroup
|
||||||
|
? `${selectedNotPredefinedCount} ${selectedNotPredefinedCount > 1 ? 'queries' : 'query'}`
|
||||||
|
: `"${queries[currentQueryIndex].name}"`
|
||||||
|
}}?
|
||||||
|
<div v-show="selectedQueriesCount > selectedNotPredefinedCount" id="note">
|
||||||
|
<img :src="require('@/assets/images/info.svg')">
|
||||||
|
Note: Predefined queries you've selected won't be deleted
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="dialog-buttons-container">
|
<div class="dialog-buttons-container">
|
||||||
<button class="secondary" @click="$modal.hide('delete')">Cancel</button>
|
<button class="secondary" @click="$modal.hide('delete')">Cancel</button>
|
||||||
@@ -114,6 +164,8 @@ import ExportIcon from '@/components/svg/export'
|
|||||||
import DeleteIcon from '@/components/svg/delete'
|
import DeleteIcon from '@/components/svg/delete'
|
||||||
import CloseIcon from '@/components/svg/close'
|
import CloseIcon from '@/components/svg/close'
|
||||||
import TextField from '@/components/TextField'
|
import TextField from '@/components/TextField'
|
||||||
|
import CheckBox from '@/components/CheckBox'
|
||||||
|
import tooltipMixin from '@/mixins/tooltips'
|
||||||
import { nanoid } from 'nanoid'
|
import { nanoid } from 'nanoid'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@@ -124,23 +176,67 @@ export default {
|
|||||||
ExportIcon,
|
ExportIcon,
|
||||||
DeleteIcon,
|
DeleteIcon,
|
||||||
CloseIcon,
|
CloseIcon,
|
||||||
TextField
|
TextField,
|
||||||
|
CheckBox
|
||||||
},
|
},
|
||||||
|
mixins: [tooltipMixin],
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
queries: [],
|
queries: [],
|
||||||
|
filter: null,
|
||||||
newName: null,
|
newName: null,
|
||||||
currentQueryIndex: null,
|
currentQueryId: null,
|
||||||
errorMsg: null,
|
errorMsg: null,
|
||||||
selectedQueries: []
|
selectedQueriesIds: new Set(),
|
||||||
|
selectedQueriesCount: 0,
|
||||||
|
selectedNotPredefinedCount: 0,
|
||||||
|
selectAll: false,
|
||||||
|
deleteGroup: false,
|
||||||
|
resizeObserver: null,
|
||||||
|
maxTableHeight: 0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
predefinedQueries () {
|
||||||
|
return this.$store.state.predefinedQueries.map(query => {
|
||||||
|
query.isPredefined = true
|
||||||
|
return query
|
||||||
|
})
|
||||||
|
},
|
||||||
|
predefinedQueriesIds () {
|
||||||
|
return new Set(this.predefinedQueries.map(query => query.id))
|
||||||
|
},
|
||||||
|
showedQueries () {
|
||||||
|
let showedQueries = this.allQueries
|
||||||
|
if (this.filter) {
|
||||||
|
showedQueries = showedQueries.filter(
|
||||||
|
query => query.name.toUpperCase().indexOf(this.filter.toUpperCase()) >= 0
|
||||||
|
)
|
||||||
|
}
|
||||||
|
return showedQueries
|
||||||
|
},
|
||||||
|
allQueries () {
|
||||||
|
return this.predefinedQueries.concat(this.queries)
|
||||||
|
},
|
||||||
|
currentQueryIndex () {
|
||||||
|
return this.queries.findIndex(query => query.id === this.currentQueryId)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created () {
|
created () {
|
||||||
this.queries = JSON.parse(localStorage.getItem('myQueries'))
|
this.queries = JSON.parse(localStorage.getItem('myQueries')) || []
|
||||||
},
|
},
|
||||||
mounted () {
|
mounted () {
|
||||||
new ResizeObserver(this.calcNameWidth).observe(this.$refs.table)
|
this.resizeObserver = new ResizeObserver(this.calcMaxTableHeight)
|
||||||
|
this.resizeObserver.observe(this.$refs['my-queries-content'])
|
||||||
|
|
||||||
|
this.tableResizeObserver = new ResizeObserver(this.calcNameWidth)
|
||||||
|
this.tableResizeObserver.observe(this.$refs.table)
|
||||||
this.calcNameWidth()
|
this.calcNameWidth()
|
||||||
|
this.calcMaxTableHeight()
|
||||||
|
},
|
||||||
|
beforeDestroy () {
|
||||||
|
this.resizeObserver.unobserve(this.$refs['my-queries-content'])
|
||||||
|
this.tableResizeObserver.unobserve(this.$refs.table)
|
||||||
},
|
},
|
||||||
filters: {
|
filters: {
|
||||||
date (value) {
|
date (value) {
|
||||||
@@ -159,18 +255,29 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
calcNameWidth () {
|
calcNameWidth () {
|
||||||
this.$refs['name-th'].style = `width: ${this.$refs['name-td'][0].offsetWidth}px`
|
const nameWidth = this.$refs['name-td']
|
||||||
|
? this.$refs['name-td'][0].getBoundingClientRect().width
|
||||||
|
: 0
|
||||||
|
this.$refs['name-th'].style = `width: ${nameWidth}px`
|
||||||
|
},
|
||||||
|
calcMaxTableHeight () {
|
||||||
|
const freeSpace = this.$refs['my-queries-content'].offsetHeight - 200
|
||||||
|
this.maxTableHeight = freeSpace - (freeSpace % 40) + 1
|
||||||
|
},
|
||||||
|
create () {
|
||||||
|
this.$root.$emit('createNewQuery')
|
||||||
|
this.$router.push('/editor')
|
||||||
},
|
},
|
||||||
openQuery (index) {
|
openQuery (index) {
|
||||||
const tab = this.queries[index]
|
const tab = JSON.parse(JSON.stringify(this.showedQueries[index]))
|
||||||
tab.isUnsaved = false
|
tab.isUnsaved = false
|
||||||
this.$store.commit('addTab', tab)
|
this.$store.commit('addTab', tab)
|
||||||
this.$store.commit('setCurrentTabId', tab.id)
|
this.$store.commit('setCurrentTabId', tab.id)
|
||||||
this.$router.push('/editor')
|
this.$router.push('/editor')
|
||||||
},
|
},
|
||||||
showRenameDialog (index) {
|
showRenameDialog (id) {
|
||||||
this.errorMsg = null
|
this.errorMsg = null
|
||||||
this.currentQueryIndex = index
|
this.currentQueryId = id
|
||||||
this.newName = this.queries[this.currentQueryIndex].name
|
this.newName = this.queries[this.currentQueryIndex].name
|
||||||
this.$modal.show('rename')
|
this.$modal.show('rename')
|
||||||
},
|
},
|
||||||
@@ -182,67 +289,123 @@ export default {
|
|||||||
const currentQuery = this.queries[this.currentQueryIndex]
|
const currentQuery = this.queries[this.currentQueryIndex]
|
||||||
currentQuery.name = this.newName
|
currentQuery.name = this.newName
|
||||||
this.$set(this.queries, this.currentQueryIndex, currentQuery)
|
this.$set(this.queries, this.currentQueryIndex, currentQuery)
|
||||||
this.$modal.hide('rename')
|
|
||||||
|
// update queries in local storage
|
||||||
this.saveQueriesInLocalStorage()
|
this.saveQueriesInLocalStorage()
|
||||||
|
|
||||||
|
// update tab, if renamed query is opened
|
||||||
const tabIndex = this.findTabIndex(currentQuery.id)
|
const tabIndex = this.findTabIndex(currentQuery.id)
|
||||||
if (tabIndex >= 0) {
|
if (tabIndex >= 0) {
|
||||||
this.$store.commit('updateTabName', { index: tabIndex, newName: this.newName })
|
this.$store.commit('updateTab', {
|
||||||
|
index: tabIndex,
|
||||||
|
name: this.newName,
|
||||||
|
id: currentQuery.id
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
// hide dialog
|
||||||
|
this.$modal.hide('rename')
|
||||||
},
|
},
|
||||||
duplicateQuery (index) {
|
duplicateQuery (index) {
|
||||||
const newQuery = JSON.parse(JSON.stringify(this.queries[index]))
|
const newQuery = JSON.parse(JSON.stringify(this.showedQueries[index]))
|
||||||
newQuery.name = newQuery.name + ' Copy'
|
newQuery.name = newQuery.name + ' Copy'
|
||||||
newQuery.id = nanoid()
|
newQuery.id = nanoid()
|
||||||
newQuery.createdAt = new Date()
|
newQuery.createdAt = new Date()
|
||||||
|
delete newQuery.isPredefined
|
||||||
|
if (this.selectAll) {
|
||||||
|
this.selectedQueriesIds.add(newQuery.id)
|
||||||
|
this.selectedQueriesCount = this.selectedQueriesIds.size
|
||||||
|
}
|
||||||
this.queries.push(newQuery)
|
this.queries.push(newQuery)
|
||||||
this.saveQueriesInLocalStorage()
|
this.saveQueriesInLocalStorage()
|
||||||
},
|
},
|
||||||
showDeleteDialog (index) {
|
showDeleteDialog (id) {
|
||||||
this.currentQueryIndex = index
|
this.deleteGroup = typeof id !== 'string'
|
||||||
|
if (!this.deleteGroup) {
|
||||||
|
this.currentQueryId = id
|
||||||
|
}
|
||||||
this.$modal.show('delete')
|
this.$modal.show('delete')
|
||||||
},
|
},
|
||||||
deleteQuery () {
|
deleteQuery () {
|
||||||
this.$modal.hide('delete')
|
this.$modal.hide('delete')
|
||||||
const id = this.queries[this.currentQueryIndex].id
|
if (!this.deleteGroup) {
|
||||||
this.queries.splice(this.currentQueryIndex, 1)
|
this.queries.splice(this.currentQueryIndex, 1)
|
||||||
this.saveQueriesInLocalStorage()
|
const tabIndex = this.findTabIndex(this.currentQueryId)
|
||||||
const tabIndex = this.findTabIndex(id)
|
if (tabIndex >= 0) {
|
||||||
if (tabIndex >= 0) {
|
this.$store.commit('deleteTab', tabIndex)
|
||||||
this.$store.commit('deleteTab', tabIndex)
|
}
|
||||||
|
if (this.selectedQueriesIds.has(this.currentQueryId)) {
|
||||||
|
this.selectedQueriesIds.delete(this.currentQueryId)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.queries = this.selectAll
|
||||||
|
? []
|
||||||
|
: this.queries.filter(query => !this.selectedQueriesIds.has(query.id))
|
||||||
|
const tabs = this.$store.state.tabs
|
||||||
|
for (let i = tabs.length - 1; i >= 0; i--) {
|
||||||
|
if (this.selectedQueriesIds.has(tabs[i].id)) {
|
||||||
|
this.$store.commit('deleteTab', i)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.selectedQueriesIds.clear()
|
||||||
}
|
}
|
||||||
|
this.selectedQueriesCount = this.selectedQueriesIds.size
|
||||||
|
this.saveQueriesInLocalStorage()
|
||||||
},
|
},
|
||||||
findTabIndex (id) {
|
findTabIndex (id) {
|
||||||
return this.$store.state.tabs.findIndex(tab => tab.id === id)
|
return this.$store.state.tabs.findIndex(tab => tab.id === id)
|
||||||
},
|
},
|
||||||
exportQuery (index) {
|
exportQuery (index) {
|
||||||
this.currentQueryIndex = index
|
let data
|
||||||
|
let name
|
||||||
|
|
||||||
|
// single operation
|
||||||
|
if (typeof index === 'number') {
|
||||||
|
data = JSON.parse(JSON.stringify(this.showedQueries[index]))
|
||||||
|
name = data.name
|
||||||
|
delete data.isPredefined
|
||||||
|
} else {
|
||||||
|
// group operation
|
||||||
|
data = this.selectAll
|
||||||
|
? JSON.parse(JSON.stringify(this.allQueries))
|
||||||
|
: this.allQueries.filter(query => this.selectedQueriesIds.has(query.id))
|
||||||
|
name = 'My sqliteviz queries'
|
||||||
|
data.forEach(query => delete query.isPredefined)
|
||||||
|
}
|
||||||
|
|
||||||
|
// export data to file
|
||||||
const downloader = this.$refs.downloader
|
const downloader = this.$refs.downloader
|
||||||
const currentQuery = JSON.parse(JSON.stringify(this.queries[this.currentQueryIndex]))
|
const json = JSON.stringify(data, null, 4)
|
||||||
delete currentQuery.id
|
|
||||||
delete currentQuery.createdAt
|
|
||||||
const json = JSON.stringify(currentQuery)
|
|
||||||
const blob = new Blob([json], { type: 'octet/stream' })
|
const blob = new Blob([json], { type: 'octet/stream' })
|
||||||
const url = window.URL.createObjectURL(blob)
|
const url = window.URL.createObjectURL(blob)
|
||||||
downloader.href = url
|
downloader.href = url
|
||||||
downloader.download = `${currentQuery.name}.json`
|
downloader.download = `${name}.json`
|
||||||
downloader.click()
|
downloader.click()
|
||||||
window.URL.revokeObjectURL(url)
|
window.URL.revokeObjectURL(url)
|
||||||
},
|
},
|
||||||
importQueries () {
|
importQueries () {
|
||||||
const file = this.$refs.importFile.files[0]
|
const file = this.$refs.importFile.files[0]
|
||||||
const reader = new FileReader()
|
const reader = new FileReader()
|
||||||
reader.onload = () => {
|
reader.onload = (e) => {
|
||||||
let importedQueries = JSON.parse(event.target.result)
|
let importedQueries = JSON.parse(e.target.result)
|
||||||
|
|
||||||
if (!Array.isArray(importedQueries)) {
|
if (!Array.isArray(importedQueries)) {
|
||||||
importedQueries = [importedQueries]
|
importedQueries = [importedQueries]
|
||||||
}
|
}
|
||||||
|
|
||||||
importedQueries.forEach(query => {
|
importedQueries.forEach(query => {
|
||||||
query.id = nanoid()
|
const allQueriesIds = this.allQueries.map(query => query.id)
|
||||||
query.createdAt = new Date()
|
if (new Set(allQueriesIds).has(query.id)) {
|
||||||
|
query.id = nanoid()
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if (this.selectAll) {
|
||||||
|
importedQueries.forEach(query => {
|
||||||
|
this.selectedQueriesIds.add(query.id)
|
||||||
|
})
|
||||||
|
this.selectedQueriesCount = this.selectedQueriesIds.size
|
||||||
|
}
|
||||||
|
|
||||||
this.queries = this.queries.concat(importedQueries)
|
this.queries = this.queries.concat(importedQueries)
|
||||||
this.saveQueriesInLocalStorage()
|
this.saveQueriesInLocalStorage()
|
||||||
this.$refs.importFile.value = null
|
this.$refs.importFile.value = null
|
||||||
@@ -251,14 +414,56 @@ export default {
|
|||||||
},
|
},
|
||||||
saveQueriesInLocalStorage () {
|
saveQueriesInLocalStorage () {
|
||||||
localStorage.setItem('myQueries', JSON.stringify(this.queries))
|
localStorage.setItem('myQueries', JSON.stringify(this.queries))
|
||||||
|
},
|
||||||
|
toggleSelectAll (checked) {
|
||||||
|
this.selectAll = checked
|
||||||
|
this.$refs.rowCheckBox.forEach(item => { item.checked = checked })
|
||||||
|
|
||||||
|
this.selectedQueriesIds = checked
|
||||||
|
? new Set(this.allQueries.map(query => query.id))
|
||||||
|
: new Set()
|
||||||
|
|
||||||
|
this.selectedQueriesCount = this.selectedQueriesIds.size
|
||||||
|
this.selectedNotPredefinedCount = checked ? this.queries.length : 0
|
||||||
|
},
|
||||||
|
toggleRow (checked, id) {
|
||||||
|
const isPredefined = this.predefinedQueriesIds.has(id)
|
||||||
|
if (checked) {
|
||||||
|
this.selectedQueriesIds.add(id)
|
||||||
|
if (!isPredefined) {
|
||||||
|
this.selectedNotPredefinedCount += 1
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (this.selectedQueriesIds.size === this.allQueries.length) {
|
||||||
|
this.$refs.mainCheckBox.checked = false
|
||||||
|
this.selectAll = false
|
||||||
|
}
|
||||||
|
this.selectedQueriesIds.delete(id)
|
||||||
|
if (!isPredefined) {
|
||||||
|
this.selectedNotPredefinedCount -= 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.selectedQueriesCount = this.selectedQueriesIds.size
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
#start-guide {
|
||||||
|
position: absolute;
|
||||||
|
top: 50%;
|
||||||
|
left: 50%;
|
||||||
|
transform: translate(-50%, -50%);
|
||||||
|
color: var(--color-text-base);
|
||||||
|
font-size: 14px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
#my-queries-content {
|
#my-queries-content {
|
||||||
padding: 52px;
|
padding: 52px;
|
||||||
|
height: 100%;
|
||||||
|
box-sizing: border-box;
|
||||||
}
|
}
|
||||||
|
|
||||||
#my-queries-toolbar {
|
#my-queries-toolbar {
|
||||||
@@ -275,24 +480,48 @@ export default {
|
|||||||
max-width: 1500px;
|
max-width: 1500px;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
.fixed-header {
|
||||||
|
padding: 11px 24px;
|
||||||
|
}
|
||||||
|
.fixed-header:first-child {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
padding-left: 12px;
|
||||||
|
}
|
||||||
|
.fixed-header:first-child .name-th {
|
||||||
|
margin-left: 24px;
|
||||||
|
}
|
||||||
|
|
||||||
table {
|
table {
|
||||||
margin-top: 0;
|
margin-top: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
tbody tr td {
|
tbody tr td {
|
||||||
overflow: hidden;
|
|
||||||
min-width: 0;
|
min-width: 0;
|
||||||
text-overflow: ellipsis;
|
height: 40px;
|
||||||
padding: 0 24px;
|
|
||||||
line-height: 40px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tbody tr td:first-child {
|
tbody tr td:first-child {
|
||||||
width: 70%;
|
width: 70%;
|
||||||
max-width: 0;
|
max-width: 0;
|
||||||
|
padding: 0 12px;
|
||||||
}
|
}
|
||||||
tbody tr td:last-child {
|
tbody tr td:last-child {
|
||||||
width: 30%;
|
width: 30%;
|
||||||
max-width: 0;
|
max-width: 0;
|
||||||
|
padding: 0 24px;
|
||||||
|
}
|
||||||
|
|
||||||
|
tbody .cell-data {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
max-width: 100%;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
tbody .cell-data div.name {
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
margin-left: 24px;
|
||||||
}
|
}
|
||||||
|
|
||||||
tbody tr:hover td {
|
tbody tr:hover td {
|
||||||
@@ -313,6 +542,7 @@ tbody tr:hover td {
|
|||||||
|
|
||||||
.icons-container {
|
.icons-container {
|
||||||
display: none;
|
display: none;
|
||||||
|
margin-right: -12px;
|
||||||
}
|
}
|
||||||
.date-container {
|
.date-container {
|
||||||
flex-shrink: 1;
|
flex-shrink: 1;
|
||||||
@@ -332,11 +562,42 @@ a, #import-file {
|
|||||||
button.toolbar {
|
button.toolbar {
|
||||||
margin-right: 16px;
|
margin-right: 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
button label {
|
button label {
|
||||||
display: block;
|
display: block;
|
||||||
line-height: 36px;
|
line-height: 36px;
|
||||||
}
|
}
|
||||||
|
|
||||||
button label:hover {
|
button label:hover {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.badge {
|
||||||
|
display: none;
|
||||||
|
background-color: var(--color-gray-light-4);
|
||||||
|
border: 1px solid var(--color-border);
|
||||||
|
border-radius: var(--border-radius-small);
|
||||||
|
padding: 2px 6px;
|
||||||
|
font-size: 11px;
|
||||||
|
line-height: normal;
|
||||||
|
margin-left: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
tbody tr.predefined:hover .badge {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
#note {
|
||||||
|
margin-top: 24px;
|
||||||
|
}
|
||||||
|
#note img {
|
||||||
|
vertical-align: middle;
|
||||||
|
}
|
||||||
|
.icon-tooltip {
|
||||||
|
display: block;
|
||||||
|
width: 149px;
|
||||||
|
white-space: normal;
|
||||||
|
height: auto;
|
||||||
|
line-height: normal;
|
||||||
|
padding: 6px;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||