@muze-nl/simplystore 0.4.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/commands.mjs +2 -2
- package/src/share.mjs +22 -39
- package/.eslintrc.cjs +0 -15
- package/package.json~ +0 -33
- package/test/produce.mjs +0 -79
- package/test/share.mjs +0 -18
- package/test/test.jsontag +0 -20
- package/www/assets/css/style.css +0 -2296
- package/www/assets/feather-sprite.svg +0 -1
- package/www/assets/img/simplystore-narrow-white.svg +0 -138
- package/www/assets/img/simplystore-narrow.svg +0 -138
- package/www/assets/img/simplystore-white.svg +0 -153
- package/www/assets/img/simplystore.svg +0 -153
- package/www/codemirror/AUTHORS +0 -979
- package/www/codemirror/CHANGELOG.md +0 -2208
- package/www/codemirror/CONTRIBUTING.md +0 -92
- package/www/codemirror/LICENSE +0 -21
- package/www/codemirror/README.md +0 -47
- package/www/codemirror/addon/lint/javascript-lint.js +0 -65
- package/www/codemirror/addon/lint/lint.css +0 -79
- package/www/codemirror/addon/lint/lint.js +0 -291
- package/www/codemirror/lib/codemirror.css +0 -344
- package/www/codemirror/lib/codemirror.js +0 -9874
- package/www/codemirror/mode/javascript/javascript.js +0 -960
- package/www/codemirror/package.json +0 -52
- package/www/codemirror/theme/material-ocean.css +0 -141
- package/www/index.html +0 -359
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "codemirror",
|
|
3
|
-
"version": "5.65.11",
|
|
4
|
-
"main": "lib/codemirror.js",
|
|
5
|
-
"style": "lib/codemirror.css",
|
|
6
|
-
"author": {
|
|
7
|
-
"name": "Marijn Haverbeke",
|
|
8
|
-
"email": "marijnh@gmail.com",
|
|
9
|
-
"url": "http://marijnhaverbeke.nl"
|
|
10
|
-
},
|
|
11
|
-
"description": "Full-featured in-browser code editor",
|
|
12
|
-
"license": "MIT",
|
|
13
|
-
"directories": {
|
|
14
|
-
"lib": "./lib"
|
|
15
|
-
},
|
|
16
|
-
"scripts": {
|
|
17
|
-
"build": "rollup -c",
|
|
18
|
-
"watch": "rollup -w -c",
|
|
19
|
-
"prepare": "npm run-script build",
|
|
20
|
-
"test": "node ./test/run.js",
|
|
21
|
-
"lint": "bin/lint"
|
|
22
|
-
},
|
|
23
|
-
"devDependencies": {
|
|
24
|
-
"@rollup/plugin-buble": "^0.21.3",
|
|
25
|
-
"blint": "^1.1.2",
|
|
26
|
-
"cm5-vim": "^0.0.5",
|
|
27
|
-
"node-static": "0.7.11",
|
|
28
|
-
"puppeteer": "^1.20.0",
|
|
29
|
-
"rollup": "^1.26.3",
|
|
30
|
-
"rollup-plugin-copy": "^3.4.0"
|
|
31
|
-
},
|
|
32
|
-
"bugs": "http://github.com/codemirror/CodeMirror/issues",
|
|
33
|
-
"keywords": [
|
|
34
|
-
"JavaScript",
|
|
35
|
-
"CodeMirror",
|
|
36
|
-
"Editor"
|
|
37
|
-
],
|
|
38
|
-
"homepage": "https://codemirror.net/5/",
|
|
39
|
-
"repository": {
|
|
40
|
-
"type": "git",
|
|
41
|
-
"url": "https://github.com/codemirror/CodeMirror.git"
|
|
42
|
-
},
|
|
43
|
-
"jspm": {
|
|
44
|
-
"directories": {},
|
|
45
|
-
"dependencies": {},
|
|
46
|
-
"devDependencies": {}
|
|
47
|
-
},
|
|
48
|
-
"dependencies": {},
|
|
49
|
-
"publishConfig": {
|
|
50
|
-
"tag": "version5"
|
|
51
|
-
}
|
|
52
|
-
}
|
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Name: material
|
|
3
|
-
Author: Mattia Astorino (http://github.com/equinusocio)
|
|
4
|
-
Website: https://material-theme.site/
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
.cm-s-material-ocean.CodeMirror {
|
|
8
|
-
background-color: #0F111A;
|
|
9
|
-
color: #8F93A2;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
.cm-s-material-ocean .CodeMirror-gutters {
|
|
13
|
-
background: #0F111A;
|
|
14
|
-
color: #464B5D;
|
|
15
|
-
border: none;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
.cm-s-material-ocean .CodeMirror-guttermarker,
|
|
19
|
-
.cm-s-material-ocean .CodeMirror-guttermarker-subtle,
|
|
20
|
-
.cm-s-material-ocean .CodeMirror-linenumber {
|
|
21
|
-
color: #464B5D;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
.cm-s-material-ocean .CodeMirror-cursor {
|
|
25
|
-
border-left: 1px solid #FFCC00;
|
|
26
|
-
}
|
|
27
|
-
.cm-s-material-ocean.cm-fat-cursor .CodeMirror-cursor {
|
|
28
|
-
background-color: #a2a8a175 !important;
|
|
29
|
-
}
|
|
30
|
-
.cm-s-material-ocean .cm-animate-fat-cursor {
|
|
31
|
-
background-color: #a2a8a175 !important;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
.cm-s-material-ocean div.CodeMirror-selected {
|
|
35
|
-
background: rgba(113, 124, 180, 0.2);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
.cm-s-material-ocean.CodeMirror-focused div.CodeMirror-selected {
|
|
39
|
-
background: rgba(113, 124, 180, 0.2);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
.cm-s-material-ocean .CodeMirror-line::selection,
|
|
43
|
-
.cm-s-material-ocean .CodeMirror-line>span::selection,
|
|
44
|
-
.cm-s-material-ocean .CodeMirror-line>span>span::selection {
|
|
45
|
-
background: rgba(128, 203, 196, 0.2);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
.cm-s-material-ocean .CodeMirror-line::-moz-selection,
|
|
49
|
-
.cm-s-material-ocean .CodeMirror-line>span::-moz-selection,
|
|
50
|
-
.cm-s-material-ocean .CodeMirror-line>span>span::-moz-selection {
|
|
51
|
-
background: rgba(128, 203, 196, 0.2);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
.cm-s-material-ocean .CodeMirror-activeline-background {
|
|
55
|
-
background: rgba(0, 0, 0, 0.5);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
.cm-s-material-ocean .cm-keyword {
|
|
59
|
-
color: #C792EA;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
.cm-s-material-ocean .cm-operator {
|
|
63
|
-
color: #89DDFF;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
.cm-s-material-ocean .cm-variable-2 {
|
|
67
|
-
color: #EEFFFF;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
.cm-s-material-ocean .cm-variable-3,
|
|
71
|
-
.cm-s-material-ocean .cm-type {
|
|
72
|
-
color: #f07178;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
.cm-s-material-ocean .cm-builtin {
|
|
76
|
-
color: #FFCB6B;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
.cm-s-material-ocean .cm-atom {
|
|
80
|
-
color: #F78C6C;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
.cm-s-material-ocean .cm-number {
|
|
84
|
-
color: #FF5370;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
.cm-s-material-ocean .cm-def {
|
|
88
|
-
color: #82AAFF;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
.cm-s-material-ocean .cm-string {
|
|
92
|
-
color: #C3E88D;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
.cm-s-material-ocean .cm-string-2 {
|
|
96
|
-
color: #f07178;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
.cm-s-material-ocean .cm-comment {
|
|
100
|
-
color: #464B5D;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
.cm-s-material-ocean .cm-variable {
|
|
104
|
-
color: #f07178;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
.cm-s-material-ocean .cm-tag {
|
|
108
|
-
color: #FF5370;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
.cm-s-material-ocean .cm-meta {
|
|
112
|
-
color: #FFCB6B;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
.cm-s-material-ocean .cm-attribute {
|
|
116
|
-
color: #C792EA;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
.cm-s-material-ocean .cm-property {
|
|
120
|
-
color: #C792EA;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
.cm-s-material-ocean .cm-qualifier {
|
|
124
|
-
color: #DECB6B;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
.cm-s-material-ocean .cm-variable-3,
|
|
128
|
-
.cm-s-material-ocean .cm-type {
|
|
129
|
-
color: #DECB6B;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
.cm-s-material-ocean .cm-error {
|
|
134
|
-
color: rgba(255, 255, 255, 1.0);
|
|
135
|
-
background-color: #FF5370;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
.cm-s-material-ocean .CodeMirror-matchingbracket {
|
|
139
|
-
text-decoration: underline;
|
|
140
|
-
color: white !important;
|
|
141
|
-
}
|
package/www/index.html
DELETED
|
@@ -1,359 +0,0 @@
|
|
|
1
|
-
<!doctype html>
|
|
2
|
-
<meta charset="utf-8">
|
|
3
|
-
<link rel="stylesheet" href="/assets/css/style.css">
|
|
4
|
-
<style>
|
|
5
|
-
:root {
|
|
6
|
-
--ds-primary: var(--ds-simplystore);
|
|
7
|
-
--ds-primary-contrast: var(--ds-simplystore-contrast);
|
|
8
|
-
--ds-primary-gradient: var(--ds-simplystore-gradient);
|
|
9
|
-
--ds-primary-gradient-bump: var(--ds-simplystore-gradient-bump);
|
|
10
|
-
}
|
|
11
|
-
body {
|
|
12
|
-
position: fixed;
|
|
13
|
-
width: 100%;
|
|
14
|
-
display: grid;
|
|
15
|
-
grid-template:
|
|
16
|
-
"header header" 65px
|
|
17
|
-
"code data" auto / 1fr 1fr;
|
|
18
|
-
height: 100%;
|
|
19
|
-
column-gap: 5px;
|
|
20
|
-
}
|
|
21
|
-
header {
|
|
22
|
-
grid-area: header;
|
|
23
|
-
}
|
|
24
|
-
form.Query {
|
|
25
|
-
grid-area: code;
|
|
26
|
-
overflow: auto;
|
|
27
|
-
}
|
|
28
|
-
.dataBrowser {
|
|
29
|
-
position: relative;
|
|
30
|
-
grid-area: data;
|
|
31
|
-
overflow: auto;
|
|
32
|
-
}
|
|
33
|
-
.CodeMirror {
|
|
34
|
-
height: 100% !important;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
.ds-visible {
|
|
38
|
-
display: block;
|
|
39
|
-
}
|
|
40
|
-
.help {
|
|
41
|
-
position: absolute;
|
|
42
|
-
top: 0;
|
|
43
|
-
left: 0;
|
|
44
|
-
width: 100%;
|
|
45
|
-
height: 100%;
|
|
46
|
-
background: var(--ds-black);
|
|
47
|
-
color: var(--ds-white);
|
|
48
|
-
margin:0;
|
|
49
|
-
padding:0;
|
|
50
|
-
overflow: hidden;
|
|
51
|
-
}
|
|
52
|
-
iframe.full {
|
|
53
|
-
border: 0;
|
|
54
|
-
height: calc(100% + 1px);
|
|
55
|
-
width: calc(100% + 1px);
|
|
56
|
-
border: 0;
|
|
57
|
-
}
|
|
58
|
-
.ds-close {
|
|
59
|
-
position: absolute;
|
|
60
|
-
z-index: 1000;
|
|
61
|
-
top: 0;
|
|
62
|
-
right: 0;
|
|
63
|
-
}
|
|
64
|
-
dialog {
|
|
65
|
-
border: 0;
|
|
66
|
-
margin: 0;
|
|
67
|
-
}
|
|
68
|
-
</style>
|
|
69
|
-
<body class="ds-nightmode">
|
|
70
|
-
<header>
|
|
71
|
-
<nav class="ds-toolbar">
|
|
72
|
-
<div class="simply-title">
|
|
73
|
-
<img src="/assets/img/simplystore-narrow.svg" alt="SimplyStore">
|
|
74
|
-
</div>
|
|
75
|
-
<button data-simply-command="run-query" class="ds-button ds-button-icon">
|
|
76
|
-
<svg class="ds-icon ds-icon-feather">
|
|
77
|
-
<use xlink:href="/assets/feather-sprite.svg#search">
|
|
78
|
-
</use></svg>
|
|
79
|
-
Run
|
|
80
|
-
</button>
|
|
81
|
-
<button data-simply-command="load-query-dropdown" class="ds-button ds-button-icon">
|
|
82
|
-
<svg class="ds-icon ds-icon-feather">
|
|
83
|
-
<use xlink:href="/assets/feather-sprite.svg#download">
|
|
84
|
-
</use></svg>
|
|
85
|
-
Load
|
|
86
|
-
<nav class="ds-dropdown-nav">
|
|
87
|
-
<ul class="ds-dropdown-list" data-simply-list="queries">
|
|
88
|
-
<template>
|
|
89
|
-
<li class="ds-dropdown-item" data-simply-command="load-query"><span data-simply-field="name">Query</span></li>
|
|
90
|
-
</template>
|
|
91
|
-
</ul>
|
|
92
|
-
</nav>
|
|
93
|
-
</button>
|
|
94
|
-
<button data-simply-command="save-query" class="ds-button ds-button-icon">
|
|
95
|
-
<svg class="ds-icon ds-icon-feather">
|
|
96
|
-
<use xlink:href="/assets/feather-sprite.svg#bookmark">
|
|
97
|
-
</use></svg>
|
|
98
|
-
Save
|
|
99
|
-
</button>
|
|
100
|
-
<button data-simply-command="delete-query" class="ds-button ds-button-icon" disabled>
|
|
101
|
-
<svg class="ds-icon ds-icon-feather">
|
|
102
|
-
<use xlink:href="/assets/feather-sprite.svg#trash-2">
|
|
103
|
-
</use></svg>
|
|
104
|
-
Delete
|
|
105
|
-
</button>
|
|
106
|
-
<button data-simply-command="load-fixtures" class="ds-button ds-button-icon">
|
|
107
|
-
<svg class="ds-icon ds-icon-feather">
|
|
108
|
-
<use xlink:href="/assets/feather-sprite.svg#briefcase">
|
|
109
|
-
</use></svg>
|
|
110
|
-
Fixtures
|
|
111
|
-
</button>
|
|
112
|
-
<span class="ds-push-right"></span>
|
|
113
|
-
<button data-simply-command="download" class="ds-button ds-button-icon">
|
|
114
|
-
<svg class="ds-icon ds-icon-feather">
|
|
115
|
-
<use xlink:href="/assets/feather-sprite.svg#download">
|
|
116
|
-
</use></svg>
|
|
117
|
-
Download
|
|
118
|
-
</button>
|
|
119
|
-
<button data-simply-command="help" class="ds-button ds-button-icon">
|
|
120
|
-
<svg class="ds-icon ds-icon-feather">
|
|
121
|
-
<use xlink:href="/assets/feather-sprite.svg#help-circle">
|
|
122
|
-
</use></svg>
|
|
123
|
-
Help
|
|
124
|
-
</button>
|
|
125
|
-
</nav>
|
|
126
|
-
</header>
|
|
127
|
-
|
|
128
|
-
<form data-simply-command="query" class="Query" data-simply-keyboard="query">
|
|
129
|
-
<textarea name="query" id="codeEditor" class="CodeMirror"></textarea>
|
|
130
|
-
</form>
|
|
131
|
-
|
|
132
|
-
<div class="dataBrowser">
|
|
133
|
-
<textarea id="databrowser" class="CodeMirror" data-simply-field="data"></textarea>
|
|
134
|
-
<dialog class="help">
|
|
135
|
-
<button data-simply-command="close" class="ds-button ds-button-naked ds-close" data-simply-value="button[data-simply-command=help]">
|
|
136
|
-
<svg class="ds-icon ds-icon-feather">
|
|
137
|
-
<use xlink:href="/assets/feather-sprite.svg#x">
|
|
138
|
-
</use></svg>
|
|
139
|
-
</button>
|
|
140
|
-
<iframe class="full" src="/help/"></iframe>
|
|
141
|
-
<dialog>
|
|
142
|
-
</div>
|
|
143
|
-
|
|
144
|
-
<script src="/codemirror/lib/codemirror.js"></script>
|
|
145
|
-
<link rel="stylesheet" href="/codemirror/lib/codemirror.css">
|
|
146
|
-
<link rel="stylesheet" href="/codemirror/addon/lint/lint.css">
|
|
147
|
-
<script src="/codemirror/mode/javascript/javascript.js"></script>
|
|
148
|
-
<link rel="stylesheet" href="/codemirror/theme/material-ocean.css">
|
|
149
|
-
<script src="https://unpkg.com/jshint@2.13.6/dist/jshint.js"></script>
|
|
150
|
-
<script src="/codemirror/addon/lint/lint.js"></script>
|
|
151
|
-
<script src="/codemirror/addon/lint/javascript-lint.js"></script>
|
|
152
|
-
<script src="https://unpkg.com/@muze-nl/jsontag@0.8.3/dist/browser.js"></script>
|
|
153
|
-
<script src="https://cdn.simplyedit.io/1/simply-edit.js"></script>
|
|
154
|
-
<script src="https://unpkg.com/simplyview@2.0.3/dist/simply.everything.js"></script>
|
|
155
|
-
<script>
|
|
156
|
-
var codeEditor = CodeMirror.fromTextArea(document.getElementById('codeEditor'), {
|
|
157
|
-
lineNumbers: true,
|
|
158
|
-
styleActiveLine: true,
|
|
159
|
-
matchBrackets: true,
|
|
160
|
-
theme: 'material-ocean',
|
|
161
|
-
mode: 'javascript'
|
|
162
|
-
})
|
|
163
|
-
codeEditor.focus()
|
|
164
|
-
var browser = CodeMirror.fromTextArea(document.getElementById('databrowser'), {
|
|
165
|
-
theme: 'material-ocean',
|
|
166
|
-
readOnly: true
|
|
167
|
-
})
|
|
168
|
-
</script>
|
|
169
|
-
<script>
|
|
170
|
-
const databrowser = simply.app({
|
|
171
|
-
routes: {
|
|
172
|
-
'/:*': async (params) => {
|
|
173
|
-
await databrowser.actions.query(window.location.pathname)
|
|
174
|
-
browser.setValue(databrowser.view.data)
|
|
175
|
-
}
|
|
176
|
-
},
|
|
177
|
-
commands: {
|
|
178
|
-
'run-query': async function(button, value) {
|
|
179
|
-
await this.app.actions.query(window.location.pathname, codeEditor.getValue())
|
|
180
|
-
browser.setValue(databrowser.view.data)
|
|
181
|
-
},
|
|
182
|
-
query: async function(form, values) {
|
|
183
|
-
await this.app.actions.query(window.location.pathname, values.query)
|
|
184
|
-
browser.setValue(databrowser.view.data)
|
|
185
|
-
},
|
|
186
|
-
'load-query-dropdown': async function(button) {
|
|
187
|
-
button.querySelector('nav.ds-dropdown-nav').classList.toggle('ds-visible')
|
|
188
|
-
},
|
|
189
|
-
'load-query': async function(el, value) {
|
|
190
|
-
let query = await this.app.actions.loadQuery(el.innerText)
|
|
191
|
-
codeEditor.setValue(query)
|
|
192
|
-
let button = el.closest('.ds-button')
|
|
193
|
-
button.querySelector('nav.ds-dropdown-nav').classList.remove('ds-visible')
|
|
194
|
-
this.app.actions.toggleDelete('on')
|
|
195
|
-
codeEditor.focus()
|
|
196
|
-
},
|
|
197
|
-
'save-query': async function() {
|
|
198
|
-
let name = prompt('Enter the query name:',this.app.view.queryName || 'query')
|
|
199
|
-
if (name) {
|
|
200
|
-
this.app.actions.saveQuery(name, codeEditor.getValue())
|
|
201
|
-
this.app.actions.toggleDelete('on')
|
|
202
|
-
}
|
|
203
|
-
},
|
|
204
|
-
'delete-query': async function() {
|
|
205
|
-
if (confirm('Delete this query: '+this.app.view.queryName+'?')) {
|
|
206
|
-
this.app.actions.deleteQuery(this.app.view.queryName)
|
|
207
|
-
this.app.view.queryName = ''
|
|
208
|
-
this.app.actions.toggleDelete('off')
|
|
209
|
-
}
|
|
210
|
-
},
|
|
211
|
-
'load-fixtures': async function() {
|
|
212
|
-
let fixtures = await this.app.actions.loadFixtures()
|
|
213
|
-
codeEditor.setValue(fixtures)
|
|
214
|
-
codeEditor.focus()
|
|
215
|
-
},
|
|
216
|
-
'help': async function(el) {
|
|
217
|
-
let help = document.querySelector('.help');
|
|
218
|
-
if (help.open) {
|
|
219
|
-
help.removeAttribute('open')
|
|
220
|
-
el.classList.remove('ds-selected')
|
|
221
|
-
} else {
|
|
222
|
-
help.setAttribute('open','open')
|
|
223
|
-
el.classList.add('ds-selected')
|
|
224
|
-
}
|
|
225
|
-
},
|
|
226
|
-
'close': async function(el, value) {
|
|
227
|
-
el.closest('dialog').removeAttribute('open')
|
|
228
|
-
document.querySelector(value).classList.remove('ds-selected')
|
|
229
|
-
}
|
|
230
|
-
},
|
|
231
|
-
actions: {
|
|
232
|
-
start: async function() {
|
|
233
|
-
this.app.view.queries = JSON.parse(localStorage.getItem('queries') || '[]')
|
|
234
|
-
},
|
|
235
|
-
loadQuery: async function(name) {
|
|
236
|
-
this.app.view.queryName = name
|
|
237
|
-
return this.app.actions.getQuery(name)
|
|
238
|
-
},
|
|
239
|
-
saveQuery: async function(name, query) {
|
|
240
|
-
this.app.view.queryName = name
|
|
241
|
-
this.app.view.queries = this.app.view.queries.filter(q => q.name!=name)
|
|
242
|
-
this.app.view.queries.push({
|
|
243
|
-
name: name,
|
|
244
|
-
query: codeEditor.getValue()
|
|
245
|
-
})
|
|
246
|
-
localStorage.setItem('queries',JSON.stringify(this.app.view.queries))
|
|
247
|
-
},
|
|
248
|
-
deleteQuery: async function(name) {
|
|
249
|
-
this.app.view.queries = this.app.view.queries.filter(q => q.name!=name)
|
|
250
|
-
localStorage.setItem('queries',JSON.stringify(this.app.view.queris))
|
|
251
|
-
},
|
|
252
|
-
toggleDelete: async function(state) {
|
|
253
|
-
let deleteButtons = document.querySelectorAll('.ds-button[data-simply-command="delete-query"]')
|
|
254
|
-
if (deleteButtons) {
|
|
255
|
-
if (state==='on') {
|
|
256
|
-
deleteButtons.forEach(b => b.removeAttribute('disabled'))
|
|
257
|
-
} else if (state==='off') {
|
|
258
|
-
deleteButtons.forEach(b => b.setAttribute('disabled','disabled'))
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
},
|
|
262
|
-
loadFixtures: async function() {
|
|
263
|
-
return this.app.actions.loadQuery('Fixtures')
|
|
264
|
-
},
|
|
265
|
-
getQuery: async function(name) {
|
|
266
|
-
let query = this.app.view.queries.filter(q => q.name===name)
|
|
267
|
-
if (query && query[0]) {
|
|
268
|
-
return query[0].query
|
|
269
|
-
}
|
|
270
|
-
return ''
|
|
271
|
-
},
|
|
272
|
-
query: async function(path, query) {
|
|
273
|
-
try {
|
|
274
|
-
let data;
|
|
275
|
-
if (query) {
|
|
276
|
-
query = await this.app.actions.getQuery('Fixtures')+';'+query
|
|
277
|
-
data = await api.post(path, query)
|
|
278
|
-
} else {
|
|
279
|
-
data = await api.get(path)
|
|
280
|
-
}
|
|
281
|
-
databrowser.view.data = JSONTag.stringify(data, null, 4)
|
|
282
|
-
return data
|
|
283
|
-
} catch(err) {
|
|
284
|
-
databrowser.view.data = JSONTag.stringify(err, null, 4)
|
|
285
|
-
return err
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
},
|
|
289
|
-
keyboard: {
|
|
290
|
-
query: {
|
|
291
|
-
'Control+Enter': async function() {
|
|
292
|
-
await databrowser.actions.query(window.location.pathname, codeEditor.getValue())
|
|
293
|
-
browser.setValue(databrowser.view.data)
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
},
|
|
297
|
-
view: {
|
|
298
|
-
queries: [
|
|
299
|
-
{
|
|
300
|
-
name: 'Test Query',
|
|
301
|
-
query: 'from(data.persons).select({name:_})'
|
|
302
|
-
}
|
|
303
|
-
]
|
|
304
|
-
}
|
|
305
|
-
})
|
|
306
|
-
|
|
307
|
-
const apiBase = window.location.protocol+'//'+window.location.host;
|
|
308
|
-
const api = {
|
|
309
|
-
get: function(path, params) {
|
|
310
|
-
let url = apiBase+path;
|
|
311
|
-
if (!params && window.location.search) {
|
|
312
|
-
url += window.location.search
|
|
313
|
-
}
|
|
314
|
-
if (params) {
|
|
315
|
-
var args = Object.keys(params).map(param => encodeURIComponent(param)+'='+encodeURIComponent(params[param])).join('&')
|
|
316
|
-
url += '?' + args
|
|
317
|
-
}
|
|
318
|
-
return fetch(url, {
|
|
319
|
-
headers: {
|
|
320
|
-
'Accept': 'application/jsontag'
|
|
321
|
-
}
|
|
322
|
-
})
|
|
323
|
-
.then(response => {
|
|
324
|
-
let jsontag = response.text().then(JSONTag.parse)
|
|
325
|
-
if (response.ok) {
|
|
326
|
-
return jsontag
|
|
327
|
-
}
|
|
328
|
-
return jsontag.then(Promise.reject.bind(Promise))
|
|
329
|
-
})
|
|
330
|
-
},
|
|
331
|
-
post: function(path, query, params) {
|
|
332
|
-
let url = apiBase+path;
|
|
333
|
-
if (!params && window.location.search) {
|
|
334
|
-
url += window.location.search
|
|
335
|
-
}
|
|
336
|
-
if (params) {
|
|
337
|
-
var args = Object.keys(params).map(param => encodeURIComponent(param)+'='+encodeURIComponent(params[param])).join('&')
|
|
338
|
-
url += '?' + args
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
return fetch(url, {
|
|
342
|
-
method: 'POST',
|
|
343
|
-
headers: {
|
|
344
|
-
'Accept': 'application/jsontag'
|
|
345
|
-
},
|
|
346
|
-
body: query
|
|
347
|
-
})
|
|
348
|
-
.then(response => {
|
|
349
|
-
let jsontag = response.text().then(JSONTag.parse)
|
|
350
|
-
if (response.ok) {
|
|
351
|
-
return jsontag
|
|
352
|
-
}
|
|
353
|
-
return jsontag.then(Promise.reject.bind(Promise))
|
|
354
|
-
})
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
databrowser.actions.start()
|
|
359
|
-
</script>
|