@muze-nl/simplystore 0.2.0 → 0.2.2
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/README.md +1 -1
- package/package.json +2 -2
- package/www/index.html +67 -7
package/README.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@muze-nl/simplystore",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"main": "src/server.mjs",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"homepage": "https://github.com/simplyedit/simplystore#readme",
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"@muze-nl/jsontag": "^0.8.4",
|
|
19
|
-
"array-where-select": "^0.2.
|
|
19
|
+
"array-where-select": "^0.2.1",
|
|
20
20
|
"codemirror": "^6.0.1",
|
|
21
21
|
"express": "^4.18.1",
|
|
22
22
|
"json-pointer": "^0.6.2",
|
package/www/index.html
CHANGED
|
@@ -33,6 +33,9 @@
|
|
|
33
33
|
position: fixed;
|
|
34
34
|
width: 100%;
|
|
35
35
|
}
|
|
36
|
+
.ds-visible {
|
|
37
|
+
display: block;
|
|
38
|
+
}
|
|
36
39
|
</style>
|
|
37
40
|
<body class="ds-nightmode">
|
|
38
41
|
<header>
|
|
@@ -44,17 +47,17 @@
|
|
|
44
47
|
<svg class="ds-icon ds-icon-feather">
|
|
45
48
|
<use xlink:href="/assets/feather-sprite.svg#search">
|
|
46
49
|
</use></svg>
|
|
47
|
-
Run
|
|
50
|
+
Run
|
|
48
51
|
</button>
|
|
49
52
|
<button data-simply-command="load-query-dropdown" class="ds-button ds-button-icon">
|
|
50
53
|
<svg class="ds-icon ds-icon-feather">
|
|
51
54
|
<use xlink:href="/assets/feather-sprite.svg#download">
|
|
52
55
|
</use></svg>
|
|
53
|
-
Load
|
|
56
|
+
Load
|
|
54
57
|
<nav class="ds-dropdown-nav">
|
|
55
58
|
<ul class="ds-dropdown-list" data-simply-list="queries">
|
|
56
59
|
<template>
|
|
57
|
-
<li class="ds-dropdown-item" data-simply-command="load-query"><span data-simply-field="
|
|
60
|
+
<li class="ds-dropdown-item" data-simply-command="load-query"><span data-simply-field="name">Query</span></li>
|
|
58
61
|
</template>
|
|
59
62
|
</ul>
|
|
60
63
|
</nav>
|
|
@@ -63,9 +66,21 @@
|
|
|
63
66
|
<svg class="ds-icon ds-icon-feather">
|
|
64
67
|
<use xlink:href="/assets/feather-sprite.svg#bookmark">
|
|
65
68
|
</use></svg>
|
|
66
|
-
Save
|
|
69
|
+
Save
|
|
70
|
+
</button>
|
|
71
|
+
<button data-simply-command="load-fixtures" class="ds-button ds-button-icon">
|
|
72
|
+
<svg class="ds-icon ds-icon-feather">
|
|
73
|
+
<use xlink:href="/assets/feather-sprite.svg#briefcase">
|
|
74
|
+
</use></svg>
|
|
75
|
+
Fixtures
|
|
67
76
|
</button>
|
|
68
77
|
<span class="ds-push-right"></span>
|
|
78
|
+
<button class="ds-button ds-button-icon">
|
|
79
|
+
<svg class="ds-icon ds-icon-feather">
|
|
80
|
+
<use xlink:href="/assets/feather-sprite.svg#download">
|
|
81
|
+
</use></svg>
|
|
82
|
+
Download
|
|
83
|
+
</button>
|
|
69
84
|
<button class="ds-button ds-button-icon">
|
|
70
85
|
<svg class="ds-icon ds-icon-feather">
|
|
71
86
|
<use xlink:href="/assets/feather-sprite.svg#help-circle">
|
|
@@ -126,11 +141,53 @@
|
|
|
126
141
|
browser.setValue(databrowser.view.data)
|
|
127
142
|
},
|
|
128
143
|
'load-query-dropdown': async function(button) {
|
|
129
|
-
button.querySelector('nav.ds-dropdown-nav').
|
|
144
|
+
button.querySelector('nav.ds-dropdown-nav').classList.toggle('ds-visible')
|
|
145
|
+
},
|
|
146
|
+
'load-query': async function(el, value) {
|
|
147
|
+
let query = await this.app.actions.loadQuery(el.innerText)
|
|
148
|
+
codeEditor.setValue(query)
|
|
149
|
+
let button = el.closest('.ds-button')
|
|
150
|
+
button.querySelector('nav.ds-dropdown-nav').classList.remove('ds-visible')
|
|
151
|
+
codeEditor.focus()
|
|
152
|
+
},
|
|
153
|
+
'save-query': async function() {
|
|
154
|
+
let name = prompt('Enter the query name:',this.app.view.queryName || 'query')
|
|
155
|
+
this.app.actions.saveQuery(name, codeEditor.getValue())
|
|
156
|
+
},
|
|
157
|
+
'load-fixtures': async function() {
|
|
158
|
+
let fixtures = await this.app.actions.loadFixtures()
|
|
159
|
+
codeEditor.setValue(fixtures)
|
|
160
|
+
codeEditor.focus()
|
|
130
161
|
}
|
|
131
162
|
},
|
|
132
163
|
actions: {
|
|
133
|
-
|
|
164
|
+
start: async function() {
|
|
165
|
+
this.app.view.queries = JSON.parse(localStorage.getItem('queries') || '[]')
|
|
166
|
+
},
|
|
167
|
+
loadQuery: async function(name) {
|
|
168
|
+
this.app.view.queryName = name
|
|
169
|
+
return this.app.actions.getQuery(name)
|
|
170
|
+
},
|
|
171
|
+
saveQuery: async function(name, query) {
|
|
172
|
+
this.app.view.queries = this.app.view.queries.filter(q => q.name!=name)
|
|
173
|
+
this.app.view.queries.push({
|
|
174
|
+
name: name,
|
|
175
|
+
query: codeEditor.getValue()
|
|
176
|
+
})
|
|
177
|
+
localStorage.setItem('queries',JSON.stringify(this.app.view.queries))
|
|
178
|
+
},
|
|
179
|
+
loadFixtures: async function() {
|
|
180
|
+
return this.app.actions.loadQuery('Fixtures')
|
|
181
|
+
},
|
|
182
|
+
getQuery: async function(name) {
|
|
183
|
+
let query = this.app.view.queries.filter(q => q.name===name)
|
|
184
|
+
if (query && query[0]) {
|
|
185
|
+
return query[0].query
|
|
186
|
+
}
|
|
187
|
+
return ''
|
|
188
|
+
},
|
|
189
|
+
query: async function(path, query) {
|
|
190
|
+
query = await this.app.actions.getQuery('Fixtures')+';'+query
|
|
134
191
|
try {
|
|
135
192
|
let data;
|
|
136
193
|
if (query) {
|
|
@@ -157,7 +214,8 @@
|
|
|
157
214
|
view: {
|
|
158
215
|
queries: [
|
|
159
216
|
{
|
|
160
|
-
|
|
217
|
+
name: 'Test Query',
|
|
218
|
+
query: 'from(data.persons).select({name:_})'
|
|
161
219
|
}
|
|
162
220
|
]
|
|
163
221
|
}
|
|
@@ -213,4 +271,6 @@
|
|
|
213
271
|
})
|
|
214
272
|
}
|
|
215
273
|
}
|
|
274
|
+
|
|
275
|
+
databrowser.actions.start()
|
|
216
276
|
</script>
|