@mongoosejs/studio 0.0.46 → 0.0.48

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.
@@ -425,11 +425,33 @@ module.exports = app => app.component('dashboard-result', {
425
425
  if (value.$document) {
426
426
  return 'dashboard-document';
427
427
  }
428
+ if (value.$text) {
429
+ return 'dashboard-text';
430
+ }
428
431
  }
429
432
  }
430
433
  });
431
434
 
432
435
 
436
+ /***/ }),
437
+
438
+ /***/ "./frontend/src/dashboard-result/dashboard-text/dashboard-text.js":
439
+ /*!************************************************************************!*\
440
+ !*** ./frontend/src/dashboard-result/dashboard-text/dashboard-text.js ***!
441
+ \************************************************************************/
442
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
443
+
444
+ "use strict";
445
+
446
+
447
+ const template = __webpack_require__(/*! ./dashboard-text.html */ "./frontend/src/dashboard-result/dashboard-text/dashboard-text.html");
448
+
449
+ module.exports = app => app.component('dashboard-text', {
450
+ template: template,
451
+ props: ['value']
452
+ });
453
+
454
+
433
455
  /***/ }),
434
456
 
435
457
  /***/ "./frontend/src/dashboard/dashboard.js":
@@ -455,7 +477,8 @@ module.exports = app => app.component('dashboard', {
455
477
  description: '',
456
478
  showEditor: false,
457
479
  dashboard: null,
458
- result: null
480
+ result: null,
481
+ errorMessage: null
459
482
  }
460
483
  },
461
484
  methods: {
@@ -466,15 +489,22 @@ module.exports = app => app.component('dashboard', {
466
489
  this.code = update.doc.code;
467
490
  this.title = update.doc.title;
468
491
  this.description = update.doc.description;
469
- this.result = update.result;
492
+ if (update.result) {
493
+ this.result = update.result;
494
+ } else {
495
+ this.errorMessage = update.error.message;
496
+ }
470
497
  }
471
498
  },
472
499
  mounted: async function() {
473
- const { dashboard, result } = await api.Dashboard.getDashboard({ dashboardId: this.dashboardId, evaluate: true });
500
+ const { dashboard, result, error } = await api.Dashboard.getDashboard({ dashboardId: this.dashboardId, evaluate: true });
474
501
  if (!dashboard) {
475
502
  return;
476
503
  }
477
504
  this.dashboard = dashboard;
505
+ if (error) {
506
+ this.errorMessage = error.message;
507
+ }
478
508
  this.code = this.dashboard.code;
479
509
  this.title = this.dashboard.title;
480
510
  this.description = this.dashboard.description ?? '';
@@ -515,13 +545,13 @@ module.exports = app => app.component('edit-dashboard', {
515
545
  },
516
546
  async updateCode() {
517
547
  console.log('this.title', this.title, 'this.description', this.description)
518
- const { doc, result } = await api.Dashboard.updateDashboard({
548
+ const { doc, result, error } = await api.Dashboard.updateDashboard({
519
549
  dashboardId: this.dashboardId,
520
550
  code: this.editor.getValue(),
521
551
  title: this.title,
522
552
  description: this.description
523
553
  });
524
- this.$emit('update', { doc, result });
554
+ this.$emit('update', { doc, result, error });
525
555
  this.editor.setValue(doc.code);
526
556
  this.closeEditor();
527
557
  }
@@ -801,6 +831,40 @@ module.exports = app => app.component('confirm-changes', {
801
831
 
802
832
  /***/ }),
803
833
 
834
+ /***/ "./frontend/src/document/confirm-delete/confirm-delete.js":
835
+ /*!****************************************************************!*\
836
+ !*** ./frontend/src/document/confirm-delete/confirm-delete.js ***!
837
+ \****************************************************************/
838
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
839
+
840
+ "use strict";
841
+
842
+
843
+ const template = __webpack_require__(/*! ./confirm-delete.html */ "./frontend/src/document/confirm-delete/confirm-delete.html");
844
+
845
+ module.exports = app => app.component('confirm-delete', {
846
+ template: template,
847
+ props: ['value'],
848
+ computed: {
849
+ displayValue() {
850
+ return JSON.stringify(this.value, null, ' ').trim();
851
+ }
852
+ },
853
+ methods: {
854
+ closeDelete() {
855
+ this.$emit('close')
856
+ },
857
+ startDelete() {
858
+ this.$emit('remove');
859
+ }
860
+ },
861
+ mounted() {
862
+ Prism.highlightElement(this.$refs.code);
863
+ }
864
+ });
865
+
866
+ /***/ }),
867
+
804
868
  /***/ "./frontend/src/document/document.js":
805
869
  /*!*******************************************!*\
806
870
  !*** ./frontend/src/document/document.js ***!
@@ -830,14 +894,15 @@ module.exports = app => app.component('document', {
830
894
  invalid: {},
831
895
  editting: false,
832
896
  virtuals: [],
833
- shouldShowConfirmModal: false
897
+ shouldShowConfirmModal: false,
898
+ shouldShowDeleteModal: false
834
899
  }),
835
900
  async mounted() {
836
901
  window.pageState = this;
837
902
  const { doc, schemaPaths } = await api.Model.getDocument({ model: this.model, documentId: this.documentId });
838
903
  window.doc = doc;
839
904
  this.document = doc;
840
- this.schemaPaths = await Object.keys(schemaPaths).sort((k1, k2) => {
905
+ this.schemaPaths = Object.keys(schemaPaths).sort((k1, k2) => {
841
906
  if (k1 === '_id' && k2 !== '_id') {
842
907
  return -1;
843
908
  }
@@ -887,6 +952,7 @@ module.exports = app => app.component('document', {
887
952
  }
888
953
  });
889
954
 
955
+
890
956
  /***/ }),
891
957
 
892
958
  /***/ "./frontend/src/edit-array/edit-array.js":
@@ -900,7 +966,7 @@ module.exports = app => app.component('document', {
900
966
 
901
967
  const template = __webpack_require__(/*! ./edit-array.html */ "./frontend/src/edit-array/edit-array.html");
902
968
 
903
- const { BSON, EJSON } = __webpack_require__(/*! bson */ "./node_modules/bson/lib/bson.cjs");
969
+ const { BSON } = __webpack_require__(/*! bson */ "./node_modules/bson/lib/bson.cjs");
904
970
 
905
971
  const ObjectId = new Proxy(BSON.ObjectId, {
906
972
  apply (target, thisArg, argumentsList) {
@@ -914,7 +980,7 @@ appendCSS(__webpack_require__(/*! ./edit-array.css */ "./frontend/src/edit-array
914
980
  module.exports = app => app.component('edit-array', {
915
981
  template: template,
916
982
  props: ['value'],
917
- data: () => ({ currentValue: null, status: 'init' }),
983
+ data: () => ({ currentValue: -1, status: 'init' }),
918
984
  mounted() {
919
985
  this.currentValue = this.value == null
920
986
  ? '' + this.value
@@ -927,15 +993,19 @@ module.exports = app => app.component('edit-array', {
927
993
  this.editor.on('change', ev => {
928
994
  this.currentValue = this.editor.getValue();
929
995
  });
930
- this.status = 'loaded';
996
+ this.$nextTick(() => {
997
+ this.status = 'init';
998
+ })
931
999
  },
932
1000
  watch: {
933
- currentValue() {
934
- if (this.status === 'init') {
1001
+ currentValue(newValue, oldValue) {
1002
+ // Hacky way of skipping initial trigger because `immediate: false` doesn't work in Vue 3
1003
+ if (oldValue === -1) {
935
1004
  return;
936
1005
  }
937
1006
  try {
938
- this.$emit('input', eval(`(${this.currentValue})`));
1007
+ const array = eval(`(${this.currentValue})`);
1008
+ this.$emit('input', array);
939
1009
  } catch (err) {
940
1010
  this.$emit('error', err);
941
1011
  }
@@ -2537,6 +2607,17 @@ module.exports = "<div>\n <div v-if=\"Array.isArray(result)\">\n <div v-for=
2537
2607
 
2538
2608
  /***/ }),
2539
2609
 
2610
+ /***/ "./frontend/src/dashboard-result/dashboard-text/dashboard-text.html":
2611
+ /*!**************************************************************************!*\
2612
+ !*** ./frontend/src/dashboard-result/dashboard-text/dashboard-text.html ***!
2613
+ \**************************************************************************/
2614
+ /***/ ((module) => {
2615
+
2616
+ "use strict";
2617
+ module.exports = "<div class=\"py-2\">\n <div v-if=\"header\" class=\"border-b border-gray-100 px-2 pb-2 text-xl font-bold\">\n {{header}}\n </div>\n <div class=\"text-xl p-2\">\n <pre v-text=\"value.$text\"></pre>\n </div>\n</div>\n";
2618
+
2619
+ /***/ }),
2620
+
2540
2621
  /***/ "./frontend/src/dashboard/dashboard.html":
2541
2622
  /*!***********************************************!*\
2542
2623
  !*** ./frontend/src/dashboard/dashboard.html ***!
@@ -2544,7 +2625,7 @@ module.exports = "<div>\n <div v-if=\"Array.isArray(result)\">\n <div v-for=
2544
2625
  /***/ ((module) => {
2545
2626
 
2546
2627
  "use strict";
2547
- module.exports = "<div class=\"dashboard px-1\">\n <div v-if=\"status === 'loading'\" class=\"max-w-5xl mx-auto text-center\">\n <img src=\"images/loader.gif\" class=\"inline mt-10\">\n </div>\n <div v-if=\"dashboard && status === 'loaded'\" class=\"max-w-5xl mx-auto\">\n <div class=\"flex items-center w-full\">\n <h2 class=\"mt-4 mb-4 text-gray-900 font-semibold text-xl grow shrink\">{{title}}</h2>\n <div>\n <button\n v-if=\"!showEditor\"\n @click=\"showEditor = true\"\n type=\"button\"\n class=\"rounded-md bg-teal-600 px-2.5 py-1.5 text-sm font-semibold text-white shadow-sm hover:bg-teal-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-teal-600\">\n <img src=\"images/edit.svg\" class=\"inline h-[1em]\" /> Edit\n </button>\n </div>\n </div>\n <div v-if=\"!showEditor\" class=\"mt-4 mb-4\">\n <dashboard-result :result=\"result\"></dashboard-result>\n </div>\n <div v-if=\"showEditor\">\n <edit-dashboard\n :dashboardId=\"dashboard._id\"\n :code=\"code\"\n :currentDescription=\"description\"\n :currentTitle=\"title\"\n @close=\"showEditor=false;\"\n @update=\"updateCode\"></edit-dashboard>\n </div>\n \n </div>\n <div v-if=\"!dashboard && status === 'loaded'\">\n No dashboard with the given id could be found.\n </div>\n</div>\n";
2628
+ module.exports = "<div class=\"dashboard px-1\">\n <div v-if=\"status === 'loading'\" class=\"max-w-5xl mx-auto text-center\">\n <img src=\"images/loader.gif\" class=\"inline mt-10\">\n </div>\n <div v-if=\"dashboard && status === 'loaded'\" class=\"max-w-5xl mx-auto\">\n <div class=\"flex items-center w-full\">\n <h2 class=\"mt-4 mb-4 text-gray-900 font-semibold text-xl grow shrink\">{{title}}</h2>\n <div>\n <button\n v-if=\"!showEditor\"\n @click=\"showEditor = true\"\n type=\"button\"\n class=\"rounded-md bg-teal-600 px-2.5 py-1.5 text-sm font-semibold text-white shadow-sm hover:bg-teal-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-teal-600\">\n <img src=\"images/edit.svg\" class=\"inline h-[1em]\" /> Edit\n </button>\n </div>\n </div>\n <div v-if=\"!showEditor\" class=\"mt-4 mb-4\">\n <dashboard-result :result=\"result\"></dashboard-result>\n </div>\n <div v-if=\"showEditor\">\n <edit-dashboard\n :dashboardId=\"dashboard._id\"\n :code=\"code\"\n :currentDescription=\"description\"\n :currentTitle=\"title\"\n @close=\"showEditor=false;\"\n @update=\"updateCode\"></edit-dashboard>\n </div>\n <div v-if=\"errorMessage\" class=\"rounded-md bg-red-50 p-4 mt-4\">\n <div class=\"flex\">\n <div class=\"flex-shrink-0\">\n <svg class=\"h-5 w-5 text-red-400\" viewBox=\"0 0 20 20\" fill=\"currentColor\" aria-hidden=\"true\" data-slot=\"icon\">\n <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\" />\n </svg>\n </div>\n <div class=\"ml-3\">\n <h3 class=\"text-sm font-medium text-red-800\">{{errorMessage}}</h3>\n </div>\n </div>\n </div>\n \n </div>\n <div v-if=\"!dashboard && status === 'loaded'\">\n No dashboard with the given id could be found.\n </div>\n</div>\n";
2548
2629
 
2549
2630
  /***/ }),
2550
2631
 
@@ -2647,6 +2728,17 @@ module.exports = "<div>\n <h2>\n Are you sure you want to save the fol
2647
2728
 
2648
2729
  /***/ }),
2649
2730
 
2731
+ /***/ "./frontend/src/document/confirm-delete/confirm-delete.html":
2732
+ /*!******************************************************************!*\
2733
+ !*** ./frontend/src/document/confirm-delete/confirm-delete.html ***!
2734
+ \******************************************************************/
2735
+ /***/ ((module) => {
2736
+
2737
+ "use strict";
2738
+ module.exports = "<div>\n <h2>\n Are you sure you want to delete the following document?\n </h2>\n <pre class=\"max-h-[50vh] overflow-auto\"><code ref=\"code\" class=\"language-javascript\" v-text=\"displayValue\"></code></pre>\n <div class=\"flex gap-2 mt-2\">\n <async-button\n 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\"\n @click=\"startDelete\">\n Confirm\n </async-button>\n <button \n 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\"\n @click=\"closeDelete\">\n Cancel\n </button>\n </div>\n</div>";
2739
+
2740
+ /***/ }),
2741
+
2650
2742
  /***/ "./frontend/src/document/document.css":
2651
2743
  /*!********************************************!*\
2652
2744
  !*** ./frontend/src/document/document.css ***!
@@ -2665,7 +2757,7 @@ module.exports = ".document {\n max-width: 1200px;\n margin-left: auto;\n mar
2665
2757
  /***/ ((module) => {
2666
2758
 
2667
2759
  "use strict";
2668
- module.exports = "<div class=\"document\">\n <div class=\"document-menu\">\n <div class=\"left\">\n <button @click=\"$router.push('/model/' + this.model)\">\n &lsaquo; Back\n </button>\n </div>\n\n <div class=\"right\">\n <button\n v-if=\"!editting\"\n @click=\"editting = true\"\n type=\"button\"\n class=\"rounded-md bg-teal-600 px-2.5 py-1.5 text-sm font-semibold text-white shadow-sm hover:bg-teal-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-teal-600\">\n <img src=\"images/edit.svg\" class=\"inline\" /> Edit\n </button>\n <button\n v-if=\"editting\"\n @click=\"editting = false\"\n type=\"button\"\n class=\"rounded-md bg-slate-600 px-2.5 py-1.5 text-sm font-semibold text-white shadow-sm hover:bg-slate-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-slate-600\">\n &times; Cancel\n </button>\n <button\n v-if=\"editting\"\n @click=\"shouldShowConfirmModal=true;\"\n type=\"button\"\n 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\">\n <img src=\"images/save.svg\" class=\"inline\" /> Save\n </button>\n <button\n @click=\"remove\"\n type=\"button\"\n 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\">\n <img src=\"images/delete.svg\" class=\"inline\" /> Delete\n </button>\n </div>\n </div>\n <div v-if=\"status === 'loaded'\">\n <document-details\n :document=\"document\"\n :schemaPaths=\"schemaPaths\"\n :editting=\"editting\"\n :changes=\"changes\"\n :invalid=\"invalid\"></document-details>\n <modal v-if=\"shouldShowConfirmModal\">\n <template v-slot:body>\n <div class=\"modal-exit\" @click=\"shouldShowConfirmModal = false;\">&times;</div>\n <confirm-changes @close=\"shouldShowConfirmModal = false;\" @save=\"save\" :value=\"changes\"></confirm-changes>\n </template>\n </modal>\n </div>\n</div>\n";
2760
+ module.exports = "<div class=\"document\">\n <div class=\"document-menu\">\n <div class=\"left\">\n <button @click=\"$router.push('/model/' + this.model)\">\n &lsaquo; Back\n </button>\n </div>\n\n <div class=\"right\">\n <button\n v-if=\"!editting\"\n @click=\"editting = true\"\n type=\"button\"\n class=\"rounded-md bg-teal-600 px-2.5 py-1.5 text-sm font-semibold text-white shadow-sm hover:bg-teal-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-teal-600\">\n <img src=\"images/edit.svg\" class=\"inline\" /> Edit\n </button>\n <button\n v-if=\"editting\"\n @click=\"editting = false\"\n type=\"button\"\n class=\"rounded-md bg-slate-600 px-2.5 py-1.5 text-sm font-semibold text-white shadow-sm hover:bg-slate-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-slate-600\">\n &times; Cancel\n </button>\n <button\n v-if=\"editting\"\n @click=\"shouldShowConfirmModal=true;\"\n type=\"button\"\n 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\">\n <img src=\"images/save.svg\" class=\"inline\" /> Save\n </button>\n <button\n @click=\"shouldShowDeleteModal=true;\"\n type=\"button\"\n 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\">\n <img src=\"images/delete.svg\" class=\"inline\" /> Delete\n </button>\n </div>\n </div>\n <div v-if=\"status === 'loaded'\">\n <document-details\n :document=\"document\"\n :schemaPaths=\"schemaPaths\"\n :editting=\"editting\"\n :changes=\"changes\"\n :invalid=\"invalid\"></document-details>\n <modal v-if=\"shouldShowConfirmModal\">\n <template v-slot:body>\n <div class=\"modal-exit\" @click=\"shouldShowConfirmModal = false;\">&times;</div>\n <confirm-changes @close=\"shouldShowConfirmModal = false;\" @save=\"save\" :value=\"changes\"></confirm-changes>\n </template>\n </modal>\n <modal v-if=\"shouldShowDeleteModal\">\n <template v-slot:body>\n <div class=\"modal-exit\" @click=\"shouldShowConfirmModal = false;\">&times;</div>\n <confirm-delete @close=\"shouldShowConfirmModal = false;\" @remove=\"remove\" :value=\"document\"></confirm-delete>\n </template>\n </modal>\n </div>\n</div>\n";
2669
2761
 
2670
2762
  /***/ }),
2671
2763
 
@@ -10787,11 +10879,13 @@ __webpack_require__(/*! ./dashboard-result/dashboard-result */ "./frontend/src/d
10787
10879
  __webpack_require__(/*! ./dashboard-result/dashboard-chart/dashboard-chart */ "./frontend/src/dashboard-result/dashboard-chart/dashboard-chart.js")(app);
10788
10880
  __webpack_require__(/*! ./dashboard-result/dashboard-document/dashboard-document */ "./frontend/src/dashboard-result/dashboard-document/dashboard-document.js")(app);
10789
10881
  __webpack_require__(/*! ./dashboard-result/dashboard-primitive/dashboard-primitive */ "./frontend/src/dashboard-result/dashboard-primitive/dashboard-primitive.js")(app);
10882
+ __webpack_require__(/*! ./dashboard-result/dashboard-text/dashboard-text */ "./frontend/src/dashboard-result/dashboard-text/dashboard-text.js")(app);
10790
10883
  __webpack_require__(/*! ./dashboard/edit-dashboard/edit-dashboard */ "./frontend/src/dashboard/edit-dashboard/edit-dashboard.js")(app)
10791
10884
  __webpack_require__(/*! ./detail-array/detail-array */ "./frontend/src/detail-array/detail-array.js")(app);
10792
10885
  __webpack_require__(/*! ./detail-default/detail-default */ "./frontend/src/detail-default/detail-default.js")(app);
10793
10886
  __webpack_require__(/*! ./document/document */ "./frontend/src/document/document.js")(app);
10794
10887
  __webpack_require__(/*! ./document/confirm-changes/confirm-changes */ "./frontend/src/document/confirm-changes/confirm-changes.js")(app);
10888
+ __webpack_require__(/*! ./document/confirm-delete/confirm-delete */ "./frontend/src/document/confirm-delete/confirm-delete.js")(app);
10795
10889
  __webpack_require__(/*! ./document-details/document-details */ "./frontend/src/document-details/document-details.js")(app);
10796
10890
  __webpack_require__(/*! ./document-details/document-property/document-property */ "./frontend/src/document-details/document-property/document-property.js")(app);
10797
10891
  __webpack_require__(/*! ./edit-array/edit-array */ "./frontend/src/edit-array/edit-array.js")(app);
@@ -10842,6 +10936,7 @@ const router = VueRouter.createRouter({
10842
10936
  app.use(router);
10843
10937
 
10844
10938
  app.mount('#content');
10939
+
10845
10940
  })();
10846
10941
 
10847
10942
  /******/ })()
@@ -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>
@@ -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
- this.result = update.result;
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
  }
@@ -24,6 +24,9 @@ module.exports = app => app.component('dashboard-result', {
24
24
  if (value.$document) {
25
25
  return 'dashboard-document';
26
26
  }
27
+ if (value.$text) {
28
+ return 'dashboard-text';
29
+ }
27
30
  }
28
31
  }
29
32
  });
@@ -0,0 +1,8 @@
1
+ <div class="py-2">
2
+ <div v-if="header" class="border-b border-gray-100 px-2 pb-2 text-xl font-bold">
3
+ {{header}}
4
+ </div>
5
+ <div class="text-xl p-2">
6
+ <pre v-text="value.$text"></pre>
7
+ </div>
8
+ </div>
@@ -0,0 +1,8 @@
1
+ 'use strict';
2
+
3
+ const template = require('./dashboard-text.html');
4
+
5
+ module.exports = app => app.component('dashboard-text', {
6
+ template: template,
7
+ props: ['value']
8
+ });
@@ -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="remove"
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;">&times;</div>
55
+ <confirm-delete @close="shouldShowConfirmModal = false;" @remove="remove" :value="document"></confirm-delete>
56
+ </template>
57
+ </modal>
52
58
  </div>
53
59
  </div>
@@ -20,14 +20,15 @@ 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;
27
28
  const { doc, schemaPaths } = await api.Model.getDocument({ model: this.model, documentId: this.documentId });
28
29
  window.doc = doc;
29
30
  this.document = doc;
30
- this.schemaPaths = await Object.keys(schemaPaths).sort((k1, k2) => {
31
+ this.schemaPaths = Object.keys(schemaPaths).sort((k1, k2) => {
31
32
  if (k1 === '_id' && k2 !== '_id') {
32
33
  return -1;
33
34
  }
@@ -75,4 +76,4 @@ module.exports = app => app.component('document', {
75
76
  }
76
77
  }
77
78
  }
78
- });
79
+ });
@@ -2,7 +2,7 @@
2
2
 
3
3
  const template = require('./edit-array.html');
4
4
 
5
- const { BSON, EJSON } = require('bson');
5
+ const { BSON } = require('bson');
6
6
 
7
7
  const ObjectId = new Proxy(BSON.ObjectId, {
8
8
  apply (target, thisArg, argumentsList) {
@@ -16,7 +16,7 @@ appendCSS(require('./edit-array.css'));
16
16
  module.exports = app => app.component('edit-array', {
17
17
  template: template,
18
18
  props: ['value'],
19
- data: () => ({ currentValue: null, status: 'init' }),
19
+ data: () => ({ currentValue: -1 }),
20
20
  mounted() {
21
21
  this.currentValue = this.value == null
22
22
  ? '' + this.value
@@ -29,15 +29,16 @@ 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() {
36
- if (this.status === 'init') {
34
+ currentValue(newValue, oldValue) {
35
+ // Hacky way of skipping initial trigger because `immediate: false` doesn't work in Vue 3
36
+ if (oldValue === -1) {
37
37
  return;
38
38
  }
39
39
  try {
40
- this.$emit('input', eval(`(${this.currentValue})`));
40
+ const array = eval(`(${this.currentValue})`);
41
+ this.$emit('input', array);
41
42
  } catch (err) {
42
43
  this.$emit('error', err);
43
44
  }
@@ -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');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mongoosejs/studio",
3
- "version": "0.0.46",
3
+ "version": "0.0.48",
4
4
  "dependencies": {
5
5
  "archetype": "0.13.1",
6
6
  "csv-stringify": "6.3.0",