@mongoosejs/studio 0.0.31 → 0.0.32

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.
@@ -34,10 +34,10 @@ if (false) {} else {
34
34
  return client.post('/Dashboard/createDashboard', params).then(res => res.data);
35
35
  },
36
36
  getDashboard: function getDashboard(params) {
37
- return client.get('/Dashboard/getDashboard', params).then(res => res.data);
37
+ return client.put('/Dashboard/getDashboard', params).then(res => res.data);
38
38
  },
39
39
  getDashboards: function getDashboards(params) {
40
- return client.get('/Dashboard/getDashboards', params).then(res => res.data);
40
+ return client.put('/Dashboard/getDashboards', params).then(res => res.data);
41
41
  },
42
42
  updateDashboard: function updateDashboard(params) {
43
43
  return client.post('/Dashboard/updateDashboard', params).then(res => res.data);
@@ -429,7 +429,6 @@ module.exports = app => app.component('dashboard-result', {
429
429
  },
430
430
  methods: {
431
431
  getComponentForValue(value) {
432
- console.log('X', value);
433
432
  if (typeof value !== 'object' || value == null) {
434
433
  return 'dashboard-primitive';
435
434
  }
@@ -482,7 +481,7 @@ module.exports = app => app.component('dashboard', {
482
481
  },
483
482
  mounted: async function() {
484
483
  const dashboardId = this.$route.query.dashboardId;
485
- const { dashboard, result } = await api.Dashboard.getDashboard({ params: { dashboardId: dashboardId, evaluate: true } });
484
+ const { dashboard, result } = await api.Dashboard.getDashboard({ dashboardId: dashboardId, evaluate: true });
486
485
  if (!dashboard) {
487
486
  return;
488
487
  }
@@ -662,7 +661,7 @@ appendCSS(__webpack_require__(/*! ./document-details.css */ "./frontend/src/docu
662
661
 
663
662
  module.exports = app => app.component('document-details', {
664
663
  template,
665
- props: ['document', 'schemaPaths', 'editting', 'changes'],
664
+ props: ['document', 'schemaPaths', 'editting', 'changes', 'invalid'],
666
665
  methods: {
667
666
  getComponentForPath(schemaPath) {
668
667
  if (schemaPath.instance === 'Array') {
@@ -680,6 +679,9 @@ module.exports = app => app.component('document-details', {
680
679
  if (path.instance === 'Array') {
681
680
  return 'edit-array';
682
681
  }
682
+ if (path.instance === 'Embedded') {
683
+ return 'edit-subdocument';
684
+ }
683
685
  return 'edit-default';
684
686
  },
685
687
  getValueForPath(path) {
@@ -860,19 +862,28 @@ appendCSS(__webpack_require__(/*! ./edit-array.css */ "./frontend/src/edit-array
860
862
  module.exports = app => app.component('edit-array', {
861
863
  template: template,
862
864
  props: ['value'],
863
- data: () => ({ currentValue: null }),
865
+ data: () => ({ currentValue: null, status: 'init' }),
864
866
  mounted() {
865
- this.currentValue = JSON.stringify(this.value, null, ' ').trim();
867
+ this.currentValue = this.value == null
868
+ ? '' + this.value
869
+ : JSON.stringify(this.value, null, ' ').trim();
866
870
  this.$refs.arrayEditor.value = this.currentValue;
867
871
  this.editor = CodeMirror.fromTextArea(this.$refs.arrayEditor, {
868
872
  mode: 'javascript',
869
873
  lineNumbers: true
870
874
  });
875
+ this.editor.on('change', ev => {
876
+ this.currentValue = this.editor.getValue();
877
+ });
878
+ this.status = 'loaded';
871
879
  },
872
880
  watch: {
873
881
  currentValue() {
882
+ if (this.status === 'init') {
883
+ return;
884
+ }
874
885
  try {
875
- this.$emit('input', eval(this.currentValue));
886
+ this.$emit('input', eval(`(${this.currentValue})`));
876
887
  } catch (err) {
877
888
  this.$emit('error', err);
878
889
  }
@@ -998,6 +1009,67 @@ module.exports = app => app.component('edit-number', {
998
1009
  }
999
1010
  });
1000
1011
 
1012
+ /***/ }),
1013
+
1014
+ /***/ "./frontend/src/edit-subdocument/edit-subdocument.js":
1015
+ /*!***********************************************************!*\
1016
+ !*** ./frontend/src/edit-subdocument/edit-subdocument.js ***!
1017
+ \***********************************************************/
1018
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
1019
+
1020
+ "use strict";
1021
+
1022
+
1023
+ const template = __webpack_require__(/*! ./edit-subdocument.html */ "./frontend/src/edit-subdocument/edit-subdocument.html");
1024
+
1025
+ const { BSON, EJSON } = __webpack_require__(/*! bson */ "./node_modules/bson/lib/bson.cjs");
1026
+
1027
+ const ObjectId = new Proxy(BSON.ObjectId, {
1028
+ apply (target, thisArg, argumentsList) {
1029
+ return new target(...argumentsList);
1030
+ }
1031
+ });
1032
+
1033
+ module.exports = app => app.component('edit-subdocument', {
1034
+ template: template,
1035
+ props: ['value'],
1036
+ data: () => ({ currentValue: null, status: 'init' }),
1037
+ mounted() {
1038
+ this.currentValue = this.value == null
1039
+ ? '' + this.value
1040
+ : JSON.stringify(this.value, null, ' ').trim();
1041
+ this.$refs.editor.value = this.currentValue;
1042
+ this.editor = CodeMirror.fromTextArea(this.$refs.editor, {
1043
+ mode: 'javascript',
1044
+ lineNumbers: true
1045
+ });
1046
+ this.editor.on('change', ev => {
1047
+ this.currentValue = this.editor.getValue();
1048
+ });
1049
+ this.status = 'loaded';
1050
+ },
1051
+ watch: {
1052
+ currentValue() {
1053
+ if (this.status === 'init') {
1054
+ return;
1055
+ }
1056
+ try {
1057
+ this.$emit('input', eval(`(${this.currentValue})`));
1058
+ } catch (err) {
1059
+ console.log('Error', err);
1060
+ this.$emit('error', err);
1061
+ }
1062
+ }
1063
+ },
1064
+ beforeDestroy() {
1065
+ if (this.editor) {
1066
+ this.editor.toTextArea();
1067
+ }
1068
+ },
1069
+ emits: ['input', 'error']
1070
+ });
1071
+
1072
+
1001
1073
  /***/ }),
1002
1074
 
1003
1075
  /***/ "./frontend/src/export-query-results/export-query-results.js":
@@ -2527,7 +2599,7 @@ module.exports = ".document {\n max-width: 1200px;\n margin-left: auto;\n mar
2527
2599
  /***/ ((module) => {
2528
2600
 
2529
2601
  "use strict";
2530
- 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\"></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";
2602
+ 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";
2531
2603
 
2532
2604
  /***/ }),
2533
2605
 
@@ -2549,7 +2621,7 @@ module.exports = ".edit-array button {\n margin-top: 0.5em;\n}";
2549
2621
  /***/ ((module) => {
2550
2622
 
2551
2623
  "use strict";
2552
- module.exports = "<div class=\"edit-array\">\n <textarea ref=\"arrayEditor\" v-model=\"currentValue\" class=\"w-full border border-gray-300 p-1 h-[300px]\"></textarea>\n</div>";
2624
+ module.exports = "<div class=\"edit-array\">\n <textarea\n ref=\"arrayEditor\"\n class=\"w-full border border-gray-300 p-1 h-[300px]\"></textarea>\n</div>";
2553
2625
 
2554
2626
  /***/ }),
2555
2627
 
@@ -2586,6 +2658,17 @@ module.exports = "<div>\n <input type=\"number\" :value=\"value\" @input=\"$emi
2586
2658
 
2587
2659
  /***/ }),
2588
2660
 
2661
+ /***/ "./frontend/src/edit-subdocument/edit-subdocument.html":
2662
+ /*!*************************************************************!*\
2663
+ !*** ./frontend/src/edit-subdocument/edit-subdocument.html ***!
2664
+ \*************************************************************/
2665
+ /***/ ((module) => {
2666
+
2667
+ "use strict";
2668
+ module.exports = "<div class=\"edit-subdocument\">\n <textarea\n ref=\"editor\"\n v-model=\"currentValue\"\n class=\"w-full border border-gray-300 p-1 h-[300px]\"></textarea>\n</div>";
2669
+
2670
+ /***/ }),
2671
+
2589
2672
  /***/ "./frontend/src/export-query-results/export-query-results.css":
2590
2673
  /*!********************************************************************!*\
2591
2674
  !*** ./frontend/src/export-query-results/export-query-results.css ***!
@@ -10478,6 +10561,7 @@ __webpack_require__(/*! ./edit-array/edit-array */ "./frontend/src/edit-array/ed
10478
10561
  __webpack_require__(/*! ./edit-default/edit-default */ "./frontend/src/edit-default/edit-default.js")(app);
10479
10562
  __webpack_require__(/*! ./edit-number/edit-number */ "./frontend/src/edit-number/edit-number.js")(app);
10480
10563
  __webpack_require__(/*! ./edit-date/edit-date */ "./frontend/src/edit-date/edit-date.js")(app);
10564
+ __webpack_require__(/*! ./edit-subdocument/edit-subdocument */ "./frontend/src/edit-subdocument/edit-subdocument.js")(app);
10481
10565
  __webpack_require__(/*! ./export-query-results/export-query-results */ "./frontend/src/export-query-results/export-query-results.js")(app);
10482
10566
  __webpack_require__(/*! ./list-array/list-array */ "./frontend/src/list-array/list-array.js")(app);
10483
10567
  __webpack_require__(/*! ./list-default/list-default */ "./frontend/src/list-default/list-default.js")(app);
@@ -12,7 +12,6 @@ module.exports = app => app.component('dashboard-result', {
12
12
  },
13
13
  methods: {
14
14
  getComponentForValue(value) {
15
- console.log('X', value);
16
15
  if (typeof value !== 'object' || value == null) {
17
16
  return 'dashboard-primitive';
18
17
  }
@@ -41,7 +41,8 @@
41
41
  :document="document"
42
42
  :schemaPaths="schemaPaths"
43
43
  :editting="editting"
44
- :changes="changes"></document-details>
44
+ :changes="changes"
45
+ :invalid="invalid"></document-details>
45
46
  <modal v-if="shouldShowConfirmModal">
46
47
  <template v-slot:body>
47
48
  <div class="modal-exit" @click="shouldShowConfirmModal = false;">&times;</div>
@@ -9,7 +9,7 @@ appendCSS(require('./document-details.css'));
9
9
 
10
10
  module.exports = app => app.component('document-details', {
11
11
  template,
12
- props: ['document', 'schemaPaths', 'editting', 'changes'],
12
+ props: ['document', 'schemaPaths', 'editting', 'changes', 'invalid'],
13
13
  methods: {
14
14
  getComponentForPath(schemaPath) {
15
15
  if (schemaPath.instance === 'Array') {
@@ -27,6 +27,9 @@ module.exports = app => app.component('document-details', {
27
27
  if (path.instance === 'Array') {
28
28
  return 'edit-array';
29
29
  }
30
+ if (path.instance === 'Embedded') {
31
+ return 'edit-subdocument';
32
+ }
30
33
  return 'edit-default';
31
34
  },
32
35
  getValueForPath(path) {
@@ -1,3 +1,5 @@
1
1
  <div class="edit-array">
2
- <textarea ref="arrayEditor" v-model="currentValue" class="w-full border border-gray-300 p-1 h-[300px]"></textarea>
2
+ <textarea
3
+ ref="arrayEditor"
4
+ class="w-full border border-gray-300 p-1 h-[300px]"></textarea>
3
5
  </div>
@@ -16,19 +16,28 @@ 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 }),
19
+ data: () => ({ currentValue: null, status: 'init' }),
20
20
  mounted() {
21
- this.currentValue = JSON.stringify(this.value, null, ' ').trim();
21
+ this.currentValue = this.value == null
22
+ ? '' + this.value
23
+ : JSON.stringify(this.value, null, ' ').trim();
22
24
  this.$refs.arrayEditor.value = this.currentValue;
23
25
  this.editor = CodeMirror.fromTextArea(this.$refs.arrayEditor, {
24
26
  mode: 'javascript',
25
27
  lineNumbers: true
26
28
  });
29
+ this.editor.on('change', ev => {
30
+ this.currentValue = this.editor.getValue();
31
+ });
32
+ this.status = 'loaded';
27
33
  },
28
34
  watch: {
29
35
  currentValue() {
36
+ if (this.status === 'init') {
37
+ return;
38
+ }
30
39
  try {
31
- this.$emit('input', eval(this.currentValue));
40
+ this.$emit('input', eval(`(${this.currentValue})`));
32
41
  } catch (err) {
33
42
  this.$emit('error', err);
34
43
  }
@@ -0,0 +1,6 @@
1
+ <div class="edit-subdocument">
2
+ <textarea
3
+ ref="editor"
4
+ v-model="currentValue"
5
+ class="w-full border border-gray-300 p-1 h-[300px]"></textarea>
6
+ </div>
@@ -0,0 +1,50 @@
1
+ 'use strict';
2
+
3
+ const template = require('./edit-subdocument.html');
4
+
5
+ const { BSON, EJSON } = require('bson');
6
+
7
+ const ObjectId = new Proxy(BSON.ObjectId, {
8
+ apply (target, thisArg, argumentsList) {
9
+ return new target(...argumentsList);
10
+ }
11
+ });
12
+
13
+ module.exports = app => app.component('edit-subdocument', {
14
+ template: template,
15
+ props: ['value'],
16
+ data: () => ({ currentValue: null, status: 'init' }),
17
+ mounted() {
18
+ this.currentValue = this.value == null
19
+ ? '' + this.value
20
+ : JSON.stringify(this.value, null, ' ').trim();
21
+ this.$refs.editor.value = this.currentValue;
22
+ this.editor = CodeMirror.fromTextArea(this.$refs.editor, {
23
+ mode: 'javascript',
24
+ lineNumbers: true
25
+ });
26
+ this.editor.on('change', ev => {
27
+ this.currentValue = this.editor.getValue();
28
+ });
29
+ this.status = 'loaded';
30
+ },
31
+ watch: {
32
+ currentValue() {
33
+ if (this.status === 'init') {
34
+ return;
35
+ }
36
+ try {
37
+ this.$emit('input', eval(`(${this.currentValue})`));
38
+ } catch (err) {
39
+ console.log('Error', err);
40
+ this.$emit('error', err);
41
+ }
42
+ }
43
+ },
44
+ beforeDestroy() {
45
+ if (this.editor) {
46
+ this.editor.toTextArea();
47
+ }
48
+ },
49
+ emits: ['input', 'error']
50
+ });
@@ -30,6 +30,7 @@ require('./edit-array/edit-array')(app);
30
30
  require('./edit-default/edit-default')(app);
31
31
  require('./edit-number/edit-number')(app);
32
32
  require('./edit-date/edit-date')(app);
33
+ require('./edit-subdocument/edit-subdocument')(app);
33
34
  require('./export-query-results/export-query-results')(app);
34
35
  require('./list-array/list-array')(app);
35
36
  require('./list-default/list-default')(app);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mongoosejs/studio",
3
- "version": "0.0.31",
3
+ "version": "0.0.32",
4
4
  "dependencies": {
5
5
  "archetype": "0.13.0",
6
6
  "csv-stringify": "6.3.0",