@mongoosejs/studio 0.0.28 → 0.0.30

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 (31) 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/backend/index.js +1 -1
  6. package/frontend/public/app.js +381 -46
  7. package/frontend/public/index.html +1 -0
  8. package/frontend/public/tw.css +323 -0
  9. package/frontend/src/api.js +6 -0
  10. package/frontend/src/create-dashboard/create-dashboard.html +43 -0
  11. package/frontend/src/create-dashboard/create-dashboard.js +40 -0
  12. package/frontend/src/dashboard/dashboard.html +16 -7
  13. package/frontend/src/dashboard/dashboard.js +4 -4
  14. package/frontend/src/dashboard-result/dashboard-chart/dashboard-chart.html +8 -0
  15. package/frontend/src/dashboard-result/dashboard-chart/dashboard-chart.js +20 -0
  16. package/frontend/src/dashboard-result/dashboard-document/dashboard-document.html +8 -0
  17. package/frontend/src/dashboard-result/dashboard-document/dashboard-document.js +29 -0
  18. package/frontend/src/dashboard-result/dashboard-primitive/dashboard-primitive.html +8 -0
  19. package/frontend/src/dashboard-result/dashboard-primitive/dashboard-primitive.js +24 -0
  20. package/frontend/src/dashboard-result/dashboard-result.html +18 -0
  21. package/frontend/src/dashboard-result/dashboard-result.js +30 -0
  22. package/frontend/src/dashboards/dashboards.html +77 -3
  23. package/frontend/src/dashboards/dashboards.js +2 -3
  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
@@ -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
  }
@@ -674,10 +734,22 @@ video {
674
734
  width: 16rem;
675
735
  }
676
736
 
737
+ .w-\[50\%\] {
738
+ width: 50%;
739
+ }
740
+
677
741
  .w-full {
678
742
  width: 100%;
679
743
  }
680
744
 
745
+ .min-w-full {
746
+ min-width: 100%;
747
+ }
748
+
749
+ .max-w-5xl {
750
+ max-width: 64rem;
751
+ }
752
+
681
753
  .flex-1 {
682
754
  flex: 1 1 0%;
683
755
  }
@@ -686,6 +758,10 @@ video {
686
758
  flex-shrink: 0;
687
759
  }
688
760
 
761
+ .shrink {
762
+ flex-shrink: 1;
763
+ }
764
+
689
765
  .flex-grow {
690
766
  flex-grow: 1;
691
767
  }
@@ -732,10 +808,40 @@ video {
732
808
  margin-bottom: calc(0.25rem * var(--tw-space-y-reverse));
733
809
  }
734
810
 
811
+ .divide-y > :not([hidden]) ~ :not([hidden]) {
812
+ --tw-divide-y-reverse: 0;
813
+ border-top-width: calc(1px * calc(1 - var(--tw-divide-y-reverse)));
814
+ border-bottom-width: calc(1px * var(--tw-divide-y-reverse));
815
+ }
816
+
817
+ .divide-gray-200 > :not([hidden]) ~ :not([hidden]) {
818
+ --tw-divide-opacity: 1;
819
+ border-color: rgb(229 231 235 / var(--tw-divide-opacity));
820
+ }
821
+
822
+ .divide-gray-300 > :not([hidden]) ~ :not([hidden]) {
823
+ --tw-divide-opacity: 1;
824
+ border-color: rgb(209 213 219 / var(--tw-divide-opacity));
825
+ }
826
+
827
+ .overflow-x-auto {
828
+ overflow-x: auto;
829
+ }
830
+
735
831
  .overflow-y-auto {
736
832
  overflow-y: auto;
737
833
  }
738
834
 
835
+ .truncate {
836
+ overflow: hidden;
837
+ text-overflow: ellipsis;
838
+ white-space: nowrap;
839
+ }
840
+
841
+ .whitespace-nowrap {
842
+ white-space: nowrap;
843
+ }
844
+
739
845
  .rounded {
740
846
  border-radius: 0.25rem;
741
847
  }
@@ -770,6 +876,14 @@ video {
770
876
  border-width: 1px;
771
877
  }
772
878
 
879
+ .border-0 {
880
+ border-width: 0px;
881
+ }
882
+
883
+ .border-b {
884
+ border-bottom-width: 1px;
885
+ }
886
+
773
887
  .border-b-2 {
774
888
  border-bottom-width: 2px;
775
889
  }
@@ -778,6 +892,11 @@ video {
778
892
  border-right-width: 1px;
779
893
  }
780
894
 
895
+ .border-gray-100 {
896
+ --tw-border-opacity: 1;
897
+ border-color: rgb(243 244 246 / var(--tw-border-opacity));
898
+ }
899
+
781
900
  .border-gray-200 {
782
901
  --tw-border-opacity: 1;
783
902
  border-color: rgb(229 231 235 / var(--tw-border-opacity));
@@ -837,6 +956,10 @@ video {
837
956
  background-color: rgb(0 168 165 / var(--tw-bg-opacity));
838
957
  }
839
958
 
959
+ .bg-transparent {
960
+ background-color: transparent;
961
+ }
962
+
840
963
  .bg-white {
841
964
  --tw-bg-opacity: 1;
842
965
  background-color: rgb(255 255 255 / var(--tw-bg-opacity));
@@ -869,6 +992,16 @@ video {
869
992
  padding-right: 0.625rem;
870
993
  }
871
994
 
995
+ .px-3 {
996
+ padding-left: 0.75rem;
997
+ padding-right: 0.75rem;
998
+ }
999
+
1000
+ .px-4 {
1001
+ padding-left: 1rem;
1002
+ padding-right: 1rem;
1003
+ }
1004
+
872
1005
  .py-1 {
873
1006
  padding-top: 0.25rem;
874
1007
  padding-bottom: 0.25rem;
@@ -884,10 +1017,41 @@ video {
884
1017
  padding-bottom: 0.5rem;
885
1018
  }
886
1019
 
1020
+ .py-3 {
1021
+ padding-top: 0.75rem;
1022
+ padding-bottom: 0.75rem;
1023
+ }
1024
+
1025
+ .py-3\.5 {
1026
+ padding-top: 0.875rem;
1027
+ padding-bottom: 0.875rem;
1028
+ }
1029
+
1030
+ .py-4 {
1031
+ padding-top: 1rem;
1032
+ padding-bottom: 1rem;
1033
+ }
1034
+
1035
+ .pb-2 {
1036
+ padding-bottom: 0.5rem;
1037
+ }
1038
+
1039
+ .pl-1 {
1040
+ padding-left: 0.25rem;
1041
+ }
1042
+
887
1043
  .pl-2 {
888
1044
  padding-left: 0.5rem;
889
1045
  }
890
1046
 
1047
+ .pl-3 {
1048
+ padding-left: 0.75rem;
1049
+ }
1050
+
1051
+ .pl-4 {
1052
+ padding-left: 1rem;
1053
+ }
1054
+
891
1055
  .pl-5 {
892
1056
  padding-left: 1.25rem;
893
1057
  }
@@ -896,10 +1060,39 @@ video {
896
1060
  padding-right: 0.5rem;
897
1061
  }
898
1062
 
1063
+ .pr-3 {
1064
+ padding-right: 0.75rem;
1065
+ }
1066
+
1067
+ .pr-4 {
1068
+ padding-right: 1rem;
1069
+ }
1070
+
899
1071
  .pt-1 {
900
1072
  padding-top: 0.25rem;
901
1073
  }
902
1074
 
1075
+ .text-left {
1076
+ text-align: left;
1077
+ }
1078
+
1079
+ .text-center {
1080
+ text-align: center;
1081
+ }
1082
+
1083
+ .text-right {
1084
+ text-align: right;
1085
+ }
1086
+
1087
+ .align-middle {
1088
+ vertical-align: middle;
1089
+ }
1090
+
1091
+ .text-base {
1092
+ font-size: 1rem;
1093
+ line-height: 1.5rem;
1094
+ }
1095
+
903
1096
  .text-lg {
904
1097
  font-size: 1.125rem;
905
1098
  line-height: 1.75rem;
@@ -910,6 +1103,11 @@ video {
910
1103
  line-height: 1.25rem;
911
1104
  }
912
1105
 
1106
+ .text-xl {
1107
+ font-size: 1.25rem;
1108
+ line-height: 1.75rem;
1109
+ }
1110
+
913
1111
  .font-bold {
914
1112
  font-weight: 700;
915
1113
  }
@@ -922,6 +1120,10 @@ video {
922
1120
  font-weight: 600;
923
1121
  }
924
1122
 
1123
+ .leading-6 {
1124
+ line-height: 1.5rem;
1125
+ }
1126
+
925
1127
  .text-black {
926
1128
  --tw-text-opacity: 1;
927
1129
  color: rgb(0 0 0 / var(--tw-text-opacity));
@@ -972,6 +1174,11 @@ video {
972
1174
  color: rgb(7 89 133 / var(--tw-text-opacity));
973
1175
  }
974
1176
 
1177
+ .text-teal-600 {
1178
+ --tw-text-opacity: 1;
1179
+ color: rgb(0 168 165 / var(--tw-text-opacity));
1180
+ }
1181
+
975
1182
  .text-white {
976
1183
  --tw-text-opacity: 1;
977
1184
  color: rgb(255 255 255 / var(--tw-text-opacity));
@@ -983,6 +1190,11 @@ video {
983
1190
  box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);
984
1191
  }
985
1192
 
1193
+ .outline-none {
1194
+ outline: 2px solid transparent;
1195
+ outline-offset: 2px;
1196
+ }
1197
+
986
1198
  .outline-0 {
987
1199
  outline-width: 0px;
988
1200
  }
@@ -1006,6 +1218,10 @@ video {
1006
1218
  --tw-ring-color: rgb(209 213 219 / var(--tw-ring-opacity));
1007
1219
  }
1008
1220
 
1221
+ .ring-gray-900\/5 {
1222
+ --tw-ring-color: rgb(17 24 39 / 0.05);
1223
+ }
1224
+
1009
1225
  .filter {
1010
1226
  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
1227
  }
@@ -1018,6 +1234,31 @@ video {
1018
1234
  transition-duration: 150ms;
1019
1235
  }
1020
1236
 
1237
+ .placeholder\:text-gray-400::-moz-placeholder {
1238
+ --tw-text-opacity: 1;
1239
+ color: rgb(156 163 175 / var(--tw-text-opacity));
1240
+ }
1241
+
1242
+ .placeholder\:text-gray-400::placeholder {
1243
+ --tw-text-opacity: 1;
1244
+ color: rgb(156 163 175 / var(--tw-text-opacity));
1245
+ }
1246
+
1247
+ .focus-within\:ring-2:focus-within {
1248
+ --tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);
1249
+ --tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);
1250
+ box-shadow: var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow, 0 0 #0000);
1251
+ }
1252
+
1253
+ .focus-within\:ring-inset:focus-within {
1254
+ --tw-ring-inset: inset;
1255
+ }
1256
+
1257
+ .focus-within\:ring-teal-600:focus-within {
1258
+ --tw-ring-opacity: 1;
1259
+ --tw-ring-color: rgb(0 168 165 / var(--tw-ring-opacity));
1260
+ }
1261
+
1021
1262
  .hover\:border-gray-300:hover {
1022
1263
  --tw-border-opacity: 1;
1023
1264
  border-color: rgb(209 213 219 / var(--tw-border-opacity));
@@ -1068,10 +1309,21 @@ video {
1068
1309
  color: rgb(55 65 81 / var(--tw-text-opacity));
1069
1310
  }
1070
1311
 
1312
+ .hover\:text-teal-900:hover {
1313
+ --tw-text-opacity: 1;
1314
+ color: rgb(10 87 87 / var(--tw-text-opacity));
1315
+ }
1316
+
1071
1317
  .focus\:z-10:focus {
1072
1318
  z-index: 10;
1073
1319
  }
1074
1320
 
1321
+ .focus\:ring-0:focus {
1322
+ --tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);
1323
+ --tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(0px + var(--tw-ring-offset-width)) var(--tw-ring-color);
1324
+ box-shadow: var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow, 0 0 #0000);
1325
+ }
1326
+
1075
1327
  .focus-visible\:outline:focus-visible {
1076
1328
  outline-style: solid;
1077
1329
  }
@@ -1105,17 +1357,88 @@ video {
1105
1357
  }
1106
1358
 
1107
1359
  @media (min-width: 640px) {
1360
+ .sm\:-mx-6 {
1361
+ margin-left: -1.5rem;
1362
+ margin-right: -1.5rem;
1363
+ }
1364
+
1365
+ .sm\:ml-16 {
1366
+ margin-left: 4rem;
1367
+ }
1368
+
1108
1369
  .sm\:ml-6 {
1109
1370
  margin-left: 1.5rem;
1110
1371
  }
1111
1372
 
1373
+ .sm\:mt-0 {
1374
+ margin-top: 0px;
1375
+ }
1376
+
1112
1377
  .sm\:flex {
1113
1378
  display: flex;
1114
1379
  }
1115
1380
 
1381
+ .sm\:flex-auto {
1382
+ flex: 1 1 auto;
1383
+ }
1384
+
1385
+ .sm\:flex-none {
1386
+ flex: none;
1387
+ }
1388
+
1389
+ .sm\:items-center {
1390
+ align-items: center;
1391
+ }
1392
+
1116
1393
  .sm\:space-x-8 > :not([hidden]) ~ :not([hidden]) {
1117
1394
  --tw-space-x-reverse: 0;
1118
1395
  margin-right: calc(2rem * var(--tw-space-x-reverse));
1119
1396
  margin-left: calc(2rem * calc(1 - var(--tw-space-x-reverse)));
1120
1397
  }
1398
+
1399
+ .sm\:rounded-xl {
1400
+ border-radius: 0.75rem;
1401
+ }
1402
+
1403
+ .sm\:px-6 {
1404
+ padding-left: 1.5rem;
1405
+ padding-right: 1.5rem;
1406
+ }
1407
+
1408
+ .sm\:pl-6 {
1409
+ padding-left: 1.5rem;
1410
+ }
1411
+
1412
+ .sm\:pr-6 {
1413
+ padding-right: 1.5rem;
1414
+ }
1415
+
1416
+ .sm\:text-sm {
1417
+ font-size: 0.875rem;
1418
+ line-height: 1.25rem;
1419
+ }
1420
+
1421
+ .sm\:leading-6 {
1422
+ line-height: 1.5rem;
1423
+ }
1424
+ }
1425
+
1426
+ @media (min-width: 1024px) {
1427
+ .lg\:-mx-8 {
1428
+ margin-left: -2rem;
1429
+ margin-right: -2rem;
1430
+ }
1431
+
1432
+ .lg\:px-8 {
1433
+ padding-left: 2rem;
1434
+ padding-right: 2rem;
1435
+ }
1436
+
1437
+ .lg\:pl-8 {
1438
+ padding-left: 2rem;
1439
+ }
1440
+
1441
+ .lg\:pr-8 {
1442
+ padding-right: 2rem;
1443
+ }
1121
1444
  }
@@ -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,6 +61,9 @@ 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
68
  return client.get('/Dashboard/getDashboard', params).then(res => res.data);
63
69
  },
@@ -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({ params: { 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>
@@ -0,0 +1,20 @@
1
+ 'use strict';
2
+
3
+ const template = require('./dashboard-chart.html');
4
+
5
+ module.exports = app => app.component('dashboard-chart', {
6
+ template: template,
7
+ props: ['value'],
8
+ mounted() {
9
+ const ctx = this.$refs.chart.getContext('2d');
10
+ const chart = new Chart(ctx, this.value.$chart);
11
+ },
12
+ computed: {
13
+ header() {
14
+ if (this.value != null && this.value.$chart.header) {
15
+ return this.value.$chart.header;
16
+ }
17
+ return null;
18
+ }
19
+ }
20
+ });