@mongoosejs/studio 0.0.45 → 0.0.47
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/frontend/public/app.js +704 -423
- package/frontend/public/index.html +2 -1
- package/frontend/public/tw.css +4 -0
- package/frontend/src/dashboard/dashboard.html +12 -0
- package/frontend/src/dashboard/dashboard.js +11 -3
- package/frontend/src/dashboard/edit-dashboard/edit-dashboard.js +2 -2
- package/frontend/src/dashboard-result/dashboard-result.js +3 -0
- package/frontend/src/dashboard-result/dashboard-text/dashboard-text.html +8 -0
- package/frontend/src/dashboard-result/dashboard-text/dashboard-text.js +8 -0
- package/frontend/src/document/confirm-delete/confirm-delete.html +18 -0
- package/frontend/src/document/confirm-delete/confirm-delete.js +24 -0
- package/frontend/src/document/document.html +7 -1
- package/frontend/src/document/document.js +2 -1
- package/frontend/src/edit-array/edit-array.js +6 -4
- package/frontend/src/index.js +3 -1
- package/package.json +2 -2
- package/frontend/dist/app.js +0 -160
- package/frontend/dist/tw.css +0 -595
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
<link rel="stylesheet" href="tw.css">
|
|
12
12
|
<link rel="stylesheet" href="vanillatoasts/vanillatoasts.css">
|
|
13
13
|
<link rel="stylesheet" href="https://unpkg.com/codemirror@5.65.16/lib/codemirror.css">
|
|
14
|
+
<link rel="icon" href="images/logo.svg" type="image/svg+xml">
|
|
14
15
|
<script src="https://unpkg.com/vue@3.x"></script>
|
|
15
16
|
<script src="https://unpkg.com/vue-router@4.0.10"></script>
|
|
16
17
|
<script src="https://unpkg.com/chart.js@4.2.0/dist/chart.umd.js"></script>
|
|
@@ -25,4 +26,4 @@
|
|
|
25
26
|
<script src="https://unpkg.com/chart.js@4.2.0/dist/chart.umd.js"></script>
|
|
26
27
|
<script src="app.js"></script>
|
|
27
28
|
</body>
|
|
28
|
-
</html>
|
|
29
|
+
</html>
|
package/frontend/public/tw.css
CHANGED
|
@@ -27,6 +27,18 @@
|
|
|
27
27
|
@close="showEditor=false;"
|
|
28
28
|
@update="updateCode"></edit-dashboard>
|
|
29
29
|
</div>
|
|
30
|
+
<div v-if="errorMessage" class="rounded-md bg-red-50 p-4 mt-4">
|
|
31
|
+
<div class="flex">
|
|
32
|
+
<div class="flex-shrink-0">
|
|
33
|
+
<svg class="h-5 w-5 text-red-400" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true" data-slot="icon">
|
|
34
|
+
<path fill-rule="evenodd" d="M10 18a8 8 0 1 0 0-16 8 8 0 0 0 0 16ZM8.28 7.22a.75.75 0 0 0-1.06 1.06L8.94 10l-1.72 1.72a.75.75 0 1 0 1.06 1.06L10 11.06l1.72 1.72a.75.75 0 1 0 1.06-1.06L11.06 10l1.72-1.72a.75.75 0 0 0-1.06-1.06L10 8.94 8.28 7.22Z" clip-rule="evenodd" />
|
|
35
|
+
</svg>
|
|
36
|
+
</div>
|
|
37
|
+
<div class="ml-3">
|
|
38
|
+
<h3 class="text-sm font-medium text-red-800">{{errorMessage}}</h3>
|
|
39
|
+
</div>
|
|
40
|
+
</div>
|
|
41
|
+
</div>
|
|
30
42
|
|
|
31
43
|
</div>
|
|
32
44
|
<div v-if="!dashboard && status === 'loaded'">
|
|
@@ -14,7 +14,8 @@ module.exports = app => app.component('dashboard', {
|
|
|
14
14
|
description: '',
|
|
15
15
|
showEditor: false,
|
|
16
16
|
dashboard: null,
|
|
17
|
-
result: null
|
|
17
|
+
result: null,
|
|
18
|
+
errorMessage: null
|
|
18
19
|
}
|
|
19
20
|
},
|
|
20
21
|
methods: {
|
|
@@ -25,15 +26,22 @@ module.exports = app => app.component('dashboard', {
|
|
|
25
26
|
this.code = update.doc.code;
|
|
26
27
|
this.title = update.doc.title;
|
|
27
28
|
this.description = update.doc.description;
|
|
28
|
-
|
|
29
|
+
if (update.result) {
|
|
30
|
+
this.result = update.result;
|
|
31
|
+
} else {
|
|
32
|
+
this.errorMessage = update.error.message;
|
|
33
|
+
}
|
|
29
34
|
}
|
|
30
35
|
},
|
|
31
36
|
mounted: async function() {
|
|
32
|
-
const { dashboard, result } = await api.Dashboard.getDashboard({ dashboardId: this.dashboardId, evaluate: true });
|
|
37
|
+
const { dashboard, result, error } = await api.Dashboard.getDashboard({ dashboardId: this.dashboardId, evaluate: true });
|
|
33
38
|
if (!dashboard) {
|
|
34
39
|
return;
|
|
35
40
|
}
|
|
36
41
|
this.dashboard = dashboard;
|
|
42
|
+
if (error) {
|
|
43
|
+
this.errorMessage = error.message;
|
|
44
|
+
}
|
|
37
45
|
this.code = this.dashboard.code;
|
|
38
46
|
this.title = this.dashboard.title;
|
|
39
47
|
this.description = this.dashboard.description ?? '';
|
|
@@ -20,13 +20,13 @@ module.exports = app => app.component('edit-dashboard', {
|
|
|
20
20
|
},
|
|
21
21
|
async updateCode() {
|
|
22
22
|
console.log('this.title', this.title, 'this.description', this.description)
|
|
23
|
-
const { doc, result } = await api.Dashboard.updateDashboard({
|
|
23
|
+
const { doc, result, error } = await api.Dashboard.updateDashboard({
|
|
24
24
|
dashboardId: this.dashboardId,
|
|
25
25
|
code: this.editor.getValue(),
|
|
26
26
|
title: this.title,
|
|
27
27
|
description: this.description
|
|
28
28
|
});
|
|
29
|
-
this.$emit('update', { doc, result });
|
|
29
|
+
this.$emit('update', { doc, result, error });
|
|
30
30
|
this.editor.setValue(doc.code);
|
|
31
31
|
this.closeEditor();
|
|
32
32
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<div>
|
|
2
|
+
<h2>
|
|
3
|
+
Are you sure you want to delete the following document?
|
|
4
|
+
</h2>
|
|
5
|
+
<pre class="max-h-[50vh] overflow-auto"><code ref="code" class="language-javascript" v-text="displayValue"></code></pre>
|
|
6
|
+
<div class="flex gap-2 mt-2">
|
|
7
|
+
<async-button
|
|
8
|
+
class="rounded-md bg-green-600 px-2.5 py-1.5 text-sm font-semibold text-white shadow-sm hover:bg-green-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-green-600"
|
|
9
|
+
@click="startDelete">
|
|
10
|
+
Confirm
|
|
11
|
+
</async-button>
|
|
12
|
+
<button
|
|
13
|
+
class="rounded-md bg-gray-200 px-2.5 py-1.5 text-sm font-semibold text-black shadow-sm hover:bg-gray-300 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-gray-300"
|
|
14
|
+
@click="closeDelete">
|
|
15
|
+
Cancel
|
|
16
|
+
</button>
|
|
17
|
+
</div>
|
|
18
|
+
</div>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const template = require('./confirm-delete.html');
|
|
4
|
+
|
|
5
|
+
module.exports = app => app.component('confirm-delete', {
|
|
6
|
+
template: template,
|
|
7
|
+
props: ['value'],
|
|
8
|
+
computed: {
|
|
9
|
+
displayValue() {
|
|
10
|
+
return JSON.stringify(this.value, null, ' ').trim();
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
methods: {
|
|
14
|
+
closeDelete() {
|
|
15
|
+
this.$emit('close')
|
|
16
|
+
},
|
|
17
|
+
startDelete() {
|
|
18
|
+
this.$emit('remove');
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
mounted() {
|
|
22
|
+
Prism.highlightElement(this.$refs.code);
|
|
23
|
+
}
|
|
24
|
+
});
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
<img src="images/save.svg" class="inline" /> Save
|
|
30
30
|
</button>
|
|
31
31
|
<button
|
|
32
|
-
@click="
|
|
32
|
+
@click="shouldShowDeleteModal=true;"
|
|
33
33
|
type="button"
|
|
34
34
|
class="rounded-md bg-red-600 px-2.5 py-1.5 text-sm font-semibold text-white shadow-sm hover:bg-red-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-red-600">
|
|
35
35
|
<img src="images/delete.svg" class="inline" /> Delete
|
|
@@ -49,5 +49,11 @@
|
|
|
49
49
|
<confirm-changes @close="shouldShowConfirmModal = false;" @save="save" :value="changes"></confirm-changes>
|
|
50
50
|
</template>
|
|
51
51
|
</modal>
|
|
52
|
+
<modal v-if="shouldShowDeleteModal">
|
|
53
|
+
<template v-slot:body>
|
|
54
|
+
<div class="modal-exit" @click="shouldShowConfirmModal = false;">×</div>
|
|
55
|
+
<confirm-delete @close="shouldShowConfirmModal = false;" @remove="remove" :value="document"></confirm-delete>
|
|
56
|
+
</template>
|
|
57
|
+
</modal>
|
|
52
58
|
</div>
|
|
53
59
|
</div>
|
|
@@ -20,7 +20,8 @@ module.exports = app => app.component('document', {
|
|
|
20
20
|
invalid: {},
|
|
21
21
|
editting: false,
|
|
22
22
|
virtuals: [],
|
|
23
|
-
shouldShowConfirmModal: false
|
|
23
|
+
shouldShowConfirmModal: false,
|
|
24
|
+
shouldShowDeleteModal: false
|
|
24
25
|
}),
|
|
25
26
|
async mounted() {
|
|
26
27
|
window.pageState = this;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
const template = require('./edit-array.html');
|
|
4
4
|
|
|
5
|
-
const { BSON
|
|
5
|
+
const { BSON } = require('bson');
|
|
6
6
|
|
|
7
7
|
const ObjectId = new Proxy(BSON.ObjectId, {
|
|
8
8
|
apply (target, thisArg, argumentsList) {
|
|
@@ -29,15 +29,17 @@ module.exports = app => app.component('edit-array', {
|
|
|
29
29
|
this.editor.on('change', ev => {
|
|
30
30
|
this.currentValue = this.editor.getValue();
|
|
31
31
|
});
|
|
32
|
-
this.status = 'loaded';
|
|
33
32
|
},
|
|
34
33
|
watch: {
|
|
35
|
-
currentValue() {
|
|
34
|
+
currentValue(newValue, oldValue) {
|
|
35
|
+
// Hacky way of skipping initial trigger because `immediate: false` doesn't work in Vue 3
|
|
36
36
|
if (this.status === 'init') {
|
|
37
37
|
return;
|
|
38
38
|
}
|
|
39
|
+
this.status = 'loaded';
|
|
39
40
|
try {
|
|
40
|
-
|
|
41
|
+
const array = eval(`(${this.currentValue})`);
|
|
42
|
+
this.$emit('input', array);
|
|
41
43
|
} catch (err) {
|
|
42
44
|
this.$emit('error', err);
|
|
43
45
|
}
|
package/frontend/src/index.js
CHANGED
|
@@ -19,11 +19,13 @@ require('./dashboard-result/dashboard-result')(app);
|
|
|
19
19
|
require('./dashboard-result/dashboard-chart/dashboard-chart')(app);
|
|
20
20
|
require('./dashboard-result/dashboard-document/dashboard-document')(app);
|
|
21
21
|
require('./dashboard-result/dashboard-primitive/dashboard-primitive')(app);
|
|
22
|
+
require('./dashboard-result/dashboard-text/dashboard-text')(app);
|
|
22
23
|
require('./dashboard/edit-dashboard/edit-dashboard')(app)
|
|
23
24
|
require('./detail-array/detail-array')(app);
|
|
24
25
|
require('./detail-default/detail-default')(app);
|
|
25
26
|
require('./document/document')(app);
|
|
26
27
|
require('./document/confirm-changes/confirm-changes')(app);
|
|
28
|
+
require('./document/confirm-delete/confirm-delete')(app);
|
|
27
29
|
require('./document-details/document-details')(app);
|
|
28
30
|
require('./document-details/document-property/document-property')(app);
|
|
29
31
|
require('./edit-array/edit-array')(app);
|
|
@@ -73,4 +75,4 @@ const router = VueRouter.createRouter({
|
|
|
73
75
|
|
|
74
76
|
app.use(router);
|
|
75
77
|
|
|
76
|
-
app.mount('#content');
|
|
78
|
+
app.mount('#content');
|