@mongoosejs/studio 0.0.29 → 0.0.31

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.
Files changed (32) hide show
  1. package/backend/actions/Dashboard/createDashboard.js +22 -0
  2. package/backend/actions/Dashboard/getDashboard.js +41 -8
  3. package/backend/actions/Dashboard/index.js +1 -0
  4. package/backend/db/dashboardSchema.js +4 -1
  5. package/frontend/public/app.js +382 -47
  6. package/frontend/public/index.html +1 -0
  7. package/frontend/public/tw.css +331 -0
  8. package/frontend/src/api.js +8 -2
  9. package/frontend/src/create-dashboard/create-dashboard.html +43 -0
  10. package/frontend/src/create-dashboard/create-dashboard.js +40 -0
  11. package/frontend/src/dashboard/dashboard.html +16 -7
  12. package/frontend/src/dashboard/dashboard.js +4 -4
  13. package/frontend/src/dashboard-result/dashboard-chart/dashboard-chart.html +8 -0
  14. package/frontend/src/dashboard-result/dashboard-chart/dashboard-chart.js +20 -0
  15. package/frontend/src/dashboard-result/dashboard-document/dashboard-document.html +8 -0
  16. package/frontend/src/dashboard-result/dashboard-document/dashboard-document.js +29 -0
  17. package/frontend/src/dashboard-result/dashboard-primitive/dashboard-primitive.html +8 -0
  18. package/frontend/src/dashboard-result/dashboard-primitive/dashboard-primitive.js +24 -0
  19. package/frontend/src/dashboard-result/dashboard-result.html +18 -0
  20. package/frontend/src/dashboard-result/dashboard-result.js +30 -0
  21. package/frontend/src/dashboards/dashboards.html +77 -3
  22. package/frontend/src/dashboards/dashboards.js +2 -3
  23. package/frontend/src/document/confirm-changes/confirm-changes.html +2 -2
  24. package/frontend/src/document/document.css +0 -16
  25. package/frontend/src/document/document.html +5 -34
  26. package/frontend/src/document/document.js +0 -34
  27. package/frontend/src/document-details/document-details.css +18 -0
  28. package/frontend/src/document-details/document-details.html +36 -0
  29. package/frontend/src/document-details/document-details.js +59 -0
  30. package/frontend/src/index.js +6 -0
  31. package/package.json +1 -1
  32. package/tailwind.config.js +1 -1
@@ -22,6 +22,7 @@
22
22
  <div id="content"></div>
23
23
 
24
24
  <script src="https://unpkg.com/prismjs@1.29.0/prism.js" data-manual="true"></script>
25
+ <script src="https://unpkg.com/chart.js@4.2.0/dist/chart.umd.js"></script>
25
26
  <script src="app.js"></script>
26
27
  </body>
27
28
  </html>
@@ -594,6 +594,34 @@ video {
594
594
  margin: 0px;
595
595
  }
596
596
 
597
+ .-mx-4 {
598
+ margin-left: -1rem;
599
+ margin-right: -1rem;
600
+ }
601
+
602
+ .-my-2 {
603
+ margin-top: -0.5rem;
604
+ margin-bottom: -0.5rem;
605
+ }
606
+
607
+ .mx-auto {
608
+ margin-left: auto;
609
+ margin-right: auto;
610
+ }
611
+
612
+ .my-4 {
613
+ margin-top: 1rem;
614
+ margin-bottom: 1rem;
615
+ }
616
+
617
+ .-ml-0 {
618
+ margin-left: -0px;
619
+ }
620
+
621
+ .-ml-0\.5 {
622
+ margin-left: -0.125rem;
623
+ }
624
+
597
625
  .-ml-px {
598
626
  margin-left: -1px;
599
627
  }
@@ -606,6 +634,10 @@ video {
606
634
  margin-bottom: 0.5rem;
607
635
  }
608
636
 
637
+ .mb-4 {
638
+ margin-bottom: 1rem;
639
+ }
640
+
609
641
  .mb-\[-1px\] {
610
642
  margin-bottom: -1px;
611
643
  }
@@ -614,6 +646,14 @@ video {
614
646
  margin-left: 0.75rem;
615
647
  }
616
648
 
649
+ .mr-1 {
650
+ margin-right: 0.25rem;
651
+ }
652
+
653
+ .mr-1\.5 {
654
+ margin-right: 0.375rem;
655
+ }
656
+
617
657
  .mt-1 {
618
658
  margin-top: 0.25rem;
619
659
  }
@@ -626,10 +666,22 @@ video {
626
666
  margin-top: 1rem;
627
667
  }
628
668
 
669
+ .mt-6 {
670
+ margin-top: 1.5rem;
671
+ }
672
+
673
+ .mt-8 {
674
+ margin-top: 2rem;
675
+ }
676
+
629
677
  .block {
630
678
  display: block;
631
679
  }
632
680
 
681
+ .inline-block {
682
+ display: inline-block;
683
+ }
684
+
633
685
  .inline {
634
686
  display: inline;
635
687
  }
@@ -646,6 +698,10 @@ video {
646
698
  display: table;
647
699
  }
648
700
 
701
+ .flow-root {
702
+ display: flow-root;
703
+ }
704
+
649
705
  .h-5 {
650
706
  height: 1.25rem;
651
707
  }
@@ -654,6 +710,10 @@ video {
654
710
  height: 2rem;
655
711
  }
656
712
 
713
+ .h-\[1em\] {
714
+ height: 1em;
715
+ }
716
+
657
717
  .h-\[300px\] {
658
718
  height: 300px;
659
719
  }
@@ -666,6 +726,10 @@ video {
666
726
  height: 100%;
667
727
  }
668
728
 
729
+ .max-h-\[50vh\] {
730
+ max-height: 50vh;
731
+ }
732
+
669
733
  .w-5 {
670
734
  width: 1.25rem;
671
735
  }
@@ -674,10 +738,22 @@ video {
674
738
  width: 16rem;
675
739
  }
676
740
 
741
+ .w-\[50\%\] {
742
+ width: 50%;
743
+ }
744
+
677
745
  .w-full {
678
746
  width: 100%;
679
747
  }
680
748
 
749
+ .min-w-full {
750
+ min-width: 100%;
751
+ }
752
+
753
+ .max-w-5xl {
754
+ max-width: 64rem;
755
+ }
756
+
681
757
  .flex-1 {
682
758
  flex: 1 1 0%;
683
759
  }
@@ -686,6 +762,10 @@ video {
686
762
  flex-shrink: 0;
687
763
  }
688
764
 
765
+ .shrink {
766
+ flex-shrink: 1;
767
+ }
768
+
689
769
  .flex-grow {
690
770
  flex-grow: 1;
691
771
  }
@@ -732,10 +812,44 @@ video {
732
812
  margin-bottom: calc(0.25rem * var(--tw-space-y-reverse));
733
813
  }
734
814
 
815
+ .divide-y > :not([hidden]) ~ :not([hidden]) {
816
+ --tw-divide-y-reverse: 0;
817
+ border-top-width: calc(1px * calc(1 - var(--tw-divide-y-reverse)));
818
+ border-bottom-width: calc(1px * var(--tw-divide-y-reverse));
819
+ }
820
+
821
+ .divide-gray-200 > :not([hidden]) ~ :not([hidden]) {
822
+ --tw-divide-opacity: 1;
823
+ border-color: rgb(229 231 235 / var(--tw-divide-opacity));
824
+ }
825
+
826
+ .divide-gray-300 > :not([hidden]) ~ :not([hidden]) {
827
+ --tw-divide-opacity: 1;
828
+ border-color: rgb(209 213 219 / var(--tw-divide-opacity));
829
+ }
830
+
831
+ .overflow-auto {
832
+ overflow: auto;
833
+ }
834
+
835
+ .overflow-x-auto {
836
+ overflow-x: auto;
837
+ }
838
+
735
839
  .overflow-y-auto {
736
840
  overflow-y: auto;
737
841
  }
738
842
 
843
+ .truncate {
844
+ overflow: hidden;
845
+ text-overflow: ellipsis;
846
+ white-space: nowrap;
847
+ }
848
+
849
+ .whitespace-nowrap {
850
+ white-space: nowrap;
851
+ }
852
+
739
853
  .rounded {
740
854
  border-radius: 0.25rem;
741
855
  }
@@ -770,6 +884,14 @@ video {
770
884
  border-width: 1px;
771
885
  }
772
886
 
887
+ .border-0 {
888
+ border-width: 0px;
889
+ }
890
+
891
+ .border-b {
892
+ border-bottom-width: 1px;
893
+ }
894
+
773
895
  .border-b-2 {
774
896
  border-bottom-width: 2px;
775
897
  }
@@ -778,6 +900,11 @@ video {
778
900
  border-right-width: 1px;
779
901
  }
780
902
 
903
+ .border-gray-100 {
904
+ --tw-border-opacity: 1;
905
+ border-color: rgb(243 244 246 / var(--tw-border-opacity));
906
+ }
907
+
781
908
  .border-gray-200 {
782
909
  --tw-border-opacity: 1;
783
910
  border-color: rgb(229 231 235 / var(--tw-border-opacity));
@@ -837,6 +964,10 @@ video {
837
964
  background-color: rgb(0 168 165 / var(--tw-bg-opacity));
838
965
  }
839
966
 
967
+ .bg-transparent {
968
+ background-color: transparent;
969
+ }
970
+
840
971
  .bg-white {
841
972
  --tw-bg-opacity: 1;
842
973
  background-color: rgb(255 255 255 / var(--tw-bg-opacity));
@@ -869,6 +1000,16 @@ video {
869
1000
  padding-right: 0.625rem;
870
1001
  }
871
1002
 
1003
+ .px-3 {
1004
+ padding-left: 0.75rem;
1005
+ padding-right: 0.75rem;
1006
+ }
1007
+
1008
+ .px-4 {
1009
+ padding-left: 1rem;
1010
+ padding-right: 1rem;
1011
+ }
1012
+
872
1013
  .py-1 {
873
1014
  padding-top: 0.25rem;
874
1015
  padding-bottom: 0.25rem;
@@ -884,10 +1025,41 @@ video {
884
1025
  padding-bottom: 0.5rem;
885
1026
  }
886
1027
 
1028
+ .py-3 {
1029
+ padding-top: 0.75rem;
1030
+ padding-bottom: 0.75rem;
1031
+ }
1032
+
1033
+ .py-3\.5 {
1034
+ padding-top: 0.875rem;
1035
+ padding-bottom: 0.875rem;
1036
+ }
1037
+
1038
+ .py-4 {
1039
+ padding-top: 1rem;
1040
+ padding-bottom: 1rem;
1041
+ }
1042
+
1043
+ .pb-2 {
1044
+ padding-bottom: 0.5rem;
1045
+ }
1046
+
1047
+ .pl-1 {
1048
+ padding-left: 0.25rem;
1049
+ }
1050
+
887
1051
  .pl-2 {
888
1052
  padding-left: 0.5rem;
889
1053
  }
890
1054
 
1055
+ .pl-3 {
1056
+ padding-left: 0.75rem;
1057
+ }
1058
+
1059
+ .pl-4 {
1060
+ padding-left: 1rem;
1061
+ }
1062
+
891
1063
  .pl-5 {
892
1064
  padding-left: 1.25rem;
893
1065
  }
@@ -896,10 +1068,39 @@ video {
896
1068
  padding-right: 0.5rem;
897
1069
  }
898
1070
 
1071
+ .pr-3 {
1072
+ padding-right: 0.75rem;
1073
+ }
1074
+
1075
+ .pr-4 {
1076
+ padding-right: 1rem;
1077
+ }
1078
+
899
1079
  .pt-1 {
900
1080
  padding-top: 0.25rem;
901
1081
  }
902
1082
 
1083
+ .text-left {
1084
+ text-align: left;
1085
+ }
1086
+
1087
+ .text-center {
1088
+ text-align: center;
1089
+ }
1090
+
1091
+ .text-right {
1092
+ text-align: right;
1093
+ }
1094
+
1095
+ .align-middle {
1096
+ vertical-align: middle;
1097
+ }
1098
+
1099
+ .text-base {
1100
+ font-size: 1rem;
1101
+ line-height: 1.5rem;
1102
+ }
1103
+
903
1104
  .text-lg {
904
1105
  font-size: 1.125rem;
905
1106
  line-height: 1.75rem;
@@ -910,6 +1111,11 @@ video {
910
1111
  line-height: 1.25rem;
911
1112
  }
912
1113
 
1114
+ .text-xl {
1115
+ font-size: 1.25rem;
1116
+ line-height: 1.75rem;
1117
+ }
1118
+
913
1119
  .font-bold {
914
1120
  font-weight: 700;
915
1121
  }
@@ -922,6 +1128,10 @@ video {
922
1128
  font-weight: 600;
923
1129
  }
924
1130
 
1131
+ .leading-6 {
1132
+ line-height: 1.5rem;
1133
+ }
1134
+
925
1135
  .text-black {
926
1136
  --tw-text-opacity: 1;
927
1137
  color: rgb(0 0 0 / var(--tw-text-opacity));
@@ -972,6 +1182,11 @@ video {
972
1182
  color: rgb(7 89 133 / var(--tw-text-opacity));
973
1183
  }
974
1184
 
1185
+ .text-teal-600 {
1186
+ --tw-text-opacity: 1;
1187
+ color: rgb(0 168 165 / var(--tw-text-opacity));
1188
+ }
1189
+
975
1190
  .text-white {
976
1191
  --tw-text-opacity: 1;
977
1192
  color: rgb(255 255 255 / var(--tw-text-opacity));
@@ -983,6 +1198,11 @@ video {
983
1198
  box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);
984
1199
  }
985
1200
 
1201
+ .outline-none {
1202
+ outline: 2px solid transparent;
1203
+ outline-offset: 2px;
1204
+ }
1205
+
986
1206
  .outline-0 {
987
1207
  outline-width: 0px;
988
1208
  }
@@ -1006,6 +1226,10 @@ video {
1006
1226
  --tw-ring-color: rgb(209 213 219 / var(--tw-ring-opacity));
1007
1227
  }
1008
1228
 
1229
+ .ring-gray-900\/5 {
1230
+ --tw-ring-color: rgb(17 24 39 / 0.05);
1231
+ }
1232
+
1009
1233
  .filter {
1010
1234
  filter: var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow);
1011
1235
  }
@@ -1018,6 +1242,31 @@ video {
1018
1242
  transition-duration: 150ms;
1019
1243
  }
1020
1244
 
1245
+ .placeholder\:text-gray-400::-moz-placeholder {
1246
+ --tw-text-opacity: 1;
1247
+ color: rgb(156 163 175 / var(--tw-text-opacity));
1248
+ }
1249
+
1250
+ .placeholder\:text-gray-400::placeholder {
1251
+ --tw-text-opacity: 1;
1252
+ color: rgb(156 163 175 / var(--tw-text-opacity));
1253
+ }
1254
+
1255
+ .focus-within\:ring-2:focus-within {
1256
+ --tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);
1257
+ --tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);
1258
+ box-shadow: var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow, 0 0 #0000);
1259
+ }
1260
+
1261
+ .focus-within\:ring-inset:focus-within {
1262
+ --tw-ring-inset: inset;
1263
+ }
1264
+
1265
+ .focus-within\:ring-teal-600:focus-within {
1266
+ --tw-ring-opacity: 1;
1267
+ --tw-ring-color: rgb(0 168 165 / var(--tw-ring-opacity));
1268
+ }
1269
+
1021
1270
  .hover\:border-gray-300:hover {
1022
1271
  --tw-border-opacity: 1;
1023
1272
  border-color: rgb(209 213 219 / var(--tw-border-opacity));
@@ -1068,10 +1317,21 @@ video {
1068
1317
  color: rgb(55 65 81 / var(--tw-text-opacity));
1069
1318
  }
1070
1319
 
1320
+ .hover\:text-teal-900:hover {
1321
+ --tw-text-opacity: 1;
1322
+ color: rgb(10 87 87 / var(--tw-text-opacity));
1323
+ }
1324
+
1071
1325
  .focus\:z-10:focus {
1072
1326
  z-index: 10;
1073
1327
  }
1074
1328
 
1329
+ .focus\:ring-0:focus {
1330
+ --tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);
1331
+ --tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(0px + var(--tw-ring-offset-width)) var(--tw-ring-color);
1332
+ box-shadow: var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow, 0 0 #0000);
1333
+ }
1334
+
1075
1335
  .focus-visible\:outline:focus-visible {
1076
1336
  outline-style: solid;
1077
1337
  }
@@ -1105,17 +1365,88 @@ video {
1105
1365
  }
1106
1366
 
1107
1367
  @media (min-width: 640px) {
1368
+ .sm\:-mx-6 {
1369
+ margin-left: -1.5rem;
1370
+ margin-right: -1.5rem;
1371
+ }
1372
+
1373
+ .sm\:ml-16 {
1374
+ margin-left: 4rem;
1375
+ }
1376
+
1108
1377
  .sm\:ml-6 {
1109
1378
  margin-left: 1.5rem;
1110
1379
  }
1111
1380
 
1381
+ .sm\:mt-0 {
1382
+ margin-top: 0px;
1383
+ }
1384
+
1112
1385
  .sm\:flex {
1113
1386
  display: flex;
1114
1387
  }
1115
1388
 
1389
+ .sm\:flex-auto {
1390
+ flex: 1 1 auto;
1391
+ }
1392
+
1393
+ .sm\:flex-none {
1394
+ flex: none;
1395
+ }
1396
+
1397
+ .sm\:items-center {
1398
+ align-items: center;
1399
+ }
1400
+
1116
1401
  .sm\:space-x-8 > :not([hidden]) ~ :not([hidden]) {
1117
1402
  --tw-space-x-reverse: 0;
1118
1403
  margin-right: calc(2rem * var(--tw-space-x-reverse));
1119
1404
  margin-left: calc(2rem * calc(1 - var(--tw-space-x-reverse)));
1120
1405
  }
1406
+
1407
+ .sm\:rounded-xl {
1408
+ border-radius: 0.75rem;
1409
+ }
1410
+
1411
+ .sm\:px-6 {
1412
+ padding-left: 1.5rem;
1413
+ padding-right: 1.5rem;
1414
+ }
1415
+
1416
+ .sm\:pl-6 {
1417
+ padding-left: 1.5rem;
1418
+ }
1419
+
1420
+ .sm\:pr-6 {
1421
+ padding-right: 1.5rem;
1422
+ }
1423
+
1424
+ .sm\:text-sm {
1425
+ font-size: 0.875rem;
1426
+ line-height: 1.25rem;
1427
+ }
1428
+
1429
+ .sm\:leading-6 {
1430
+ line-height: 1.5rem;
1431
+ }
1432
+ }
1433
+
1434
+ @media (min-width: 1024px) {
1435
+ .lg\:-mx-8 {
1436
+ margin-left: -2rem;
1437
+ margin-right: -2rem;
1438
+ }
1439
+
1440
+ .lg\:px-8 {
1441
+ padding-left: 2rem;
1442
+ padding-right: 2rem;
1443
+ }
1444
+
1445
+ .lg\:pl-8 {
1446
+ padding-left: 2rem;
1447
+ }
1448
+
1449
+ .lg\:pr-8 {
1450
+ padding-right: 2rem;
1451
+ }
1121
1452
  }
@@ -20,6 +20,9 @@ if (typeof config__setAuthorizationHeaderFrom === 'string' && config__setAuthori
20
20
 
21
21
  if (config__isLambda) {
22
22
  exports.Dashboard = {
23
+ createDashboard(params) {
24
+ return client.post('', { action: 'Dashboard.createDashboard', ...params }).then(res => res.data);
25
+ },
23
26
  getDashboard(params) {
24
27
  return client.post('', { action: 'Dashboard.getDashboard', ...params }).then(res => res.data);
25
28
  },
@@ -58,11 +61,14 @@ if (config__isLambda) {
58
61
  };
59
62
  } else {
60
63
  exports.Dashboard = {
64
+ createDashboard: function createDashboard(params) {
65
+ return client.post('/Dashboard/createDashboard', params).then(res => res.data);
66
+ },
61
67
  getDashboard: function getDashboard(params) {
62
- return client.get('/Dashboard/getDashboard', params).then(res => res.data);
68
+ return client.put('/Dashboard/getDashboard', params).then(res => res.data);
63
69
  },
64
70
  getDashboards: function getDashboards(params) {
65
- return client.get('/Dashboard/getDashboards', params).then(res => res.data);
71
+ return client.put('/Dashboard/getDashboards', params).then(res => res.data);
66
72
  },
67
73
  updateDashboard: function updateDashboard(params) {
68
74
  return client.post('/Dashboard/updateDashboard', params).then(res => res.data);
@@ -0,0 +1,43 @@
1
+ <div>
2
+ <div class="mt-4 text-gray-900 font-semibold">
3
+ Create New Dashboard
4
+ </div>
5
+ <div class="mt-4">
6
+ <label class="block text-sm font-medium leading-6 text-gray-900">Title</label>
7
+ <div class="mt-2">
8
+ <div class="w-full flex rounded-md shadow-sm ring-1 ring-inset ring-gray-300 focus-within:ring-2 focus-within:ring-inset focus-within:ring-teal-600">
9
+ <input type="text" v-model="title" class="outline-none block flex-1 border-0 bg-transparent py-1.5 pl-1 text-gray-900 placeholder:text-gray-400 focus:ring-0 sm:text-sm sm:leading-6" placeholder="ACME-123">
10
+ </div>
11
+ </div>
12
+ </div>
13
+ <div class="my-4">
14
+ <label class="block text-sm font-medium leading-6 text-gray-900">Code</label>
15
+ <div class="border border-gray-200">
16
+ <textarea class="p-2 h-[300px] w-full" ref="codeEditor"></textarea>
17
+ </div>
18
+ </div>
19
+ <async-button
20
+ @click="createDashboard()"
21
+ 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">
22
+ Submit
23
+ </async-button>
24
+ <div v-if="errors.length > 0" class="rounded-md bg-red-50 p-4 mt-1">
25
+ <div class="flex">
26
+ <div class="flex-shrink-0">
27
+ <svg class="h-5 w-5 text-red-400" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true">
28
+ <path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zM8.28 7.22a.75.75 0 00-1.06 1.06L8.94 10l-1.72 1.72a.75.75 0 101.06 1.06L10 11.06l1.72 1.72a.75.75 0 101.06-1.06L11.06 10l1.72-1.72a.75.75 0 00-1.06-1.06L10 8.94 8.28 7.22z" clip-rule="evenodd" />
29
+ </svg>
30
+ </div>
31
+ <div class="ml-3">
32
+ <h3 class="text-sm font-medium text-red-800">There were {{errors.length}} errors with your submission</h3>
33
+ <div class="mt-2 text-sm text-red-700">
34
+ <ul role="list" class="list-disc space-y-1 pl-5">
35
+ <li v-for="error in errors">
36
+ {{error}}
37
+ </li>
38
+ </ul>
39
+ </div>
40
+ </div>
41
+ </div>
42
+ </div>
43
+ </div>
@@ -0,0 +1,40 @@
1
+ 'use strict';
2
+
3
+ const api = require('../api');
4
+
5
+ const template = require('./create-dashboard.html')
6
+
7
+ module.exports = app => app.component('create-dashboard', {
8
+ template,
9
+ data: function() {
10
+ return {
11
+ title: '',
12
+ code: '',
13
+ errors: []
14
+ }
15
+ },
16
+ methods: {
17
+ async createDashboard() {
18
+ this.code = this._editor.getValue();
19
+ const { dashboard } = await api.Dashboard.createDashboard({ code: this.code, title: this.title }).catch(err => {
20
+ if (err.response?.data?.message) {
21
+ console.log(err.response.data);
22
+ const message = err.response.data.message.split(": ").slice(1).join(": ");
23
+ this.errors = message.split(',').map(error => {
24
+ return error.split(': ').slice(1).join(': ').trim();
25
+ })
26
+ throw new Error(err.response?.data?.message);
27
+ }
28
+ throw err;
29
+ });
30
+ this.errors.length = 0;
31
+ this.$emit('close', dashboard);
32
+ },
33
+ },
34
+ mounted: function() {
35
+ this._editor = CodeMirror.fromTextArea(this.$refs.codeEditor, {
36
+ mode: 'javascript',
37
+ lineNumbers: true
38
+ });
39
+ },
40
+ })
@@ -1,15 +1,24 @@
1
- <div class="dashboard">
2
- <div v-if="dashboard">
3
- <div>
4
- <h2>{{name}}</h2>
1
+ <div class="dashboard px-1">
2
+ <div v-if="dashboard" class="max-w-5xl mx-auto">
3
+ <div class="flex items-center w-full">
4
+ <h2 class="mt-4 mb-4 text-gray-900 font-semibold text-xl grow shrink">{{dashboard.title}}</h2>
5
+ <div>
6
+ <button
7
+ v-if="!showEditor"
8
+ @click="showEditor = true"
9
+ type="button"
10
+ 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">
11
+ <img src="images/edit.svg" class="inline h-[1em]" /> Edit
12
+ </button>
13
+ </div>
5
14
  </div>
6
- <div>
7
- <pre>{{code}}</pre>
8
- <button v-if="!showEditor" @click="toggleEditor" style="color: black;margin-right: 0.5em">Edit</button>
15
+ <div v-if="!showEditor" class="mt-4 mb-4">
16
+ <dashboard-result :result="result"></dashboard-result>
9
17
  </div>
10
18
  <div v-if="showEditor">
11
19
  <edit-dashboard :dashboardId="dashboard._id" :code="code" @close="showEditor=false;" @update="updateCode"></edit-dashboard>
12
20
  </div>
21
+
13
22
  </div>
14
23
  <div v-if="!dashboard && status === 'loaded'">
15
24
  No dashboard with the given id could be found.
@@ -9,9 +9,9 @@ module.exports = app => app.component('dashboard', {
9
9
  return {
10
10
  status: 'loading',
11
11
  code: '',
12
- name: '',
13
12
  showEditor: false,
14
- dashboard: null
13
+ dashboard: null,
14
+ result: null
15
15
  }
16
16
  },
17
17
  methods: {
@@ -24,13 +24,13 @@ module.exports = app => app.component('dashboard', {
24
24
  },
25
25
  mounted: async function() {
26
26
  const dashboardId = this.$route.query.dashboardId;
27
- const { dashboard } = await api.Dashboard.getDashboard({ params: { dashboardId: dashboardId } });
27
+ const { dashboard, result } = await api.Dashboard.getDashboard({ dashboardId: dashboardId, evaluate: true });
28
28
  if (!dashboard) {
29
29
  return;
30
30
  }
31
31
  this.dashboard = dashboard;
32
- this.name = this.dashboard.name;
33
32
  this.code = this.dashboard.code;
33
+ this.result = result;
34
34
  this.status = 'loaded';
35
35
  }
36
36
  });
@@ -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 py-2">
6
+ <canvas ref="chart"></canvas>
7
+ </div>
8
+ </div>