@mixd-id/web-scaffold 0.1.230406345 → 0.1.230406346

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mixd-id/web-scaffold",
3
3
  "private": false,
4
- "version": "0.1.230406345",
4
+ "version": "0.1.230406346",
5
5
  "scripts": {
6
6
  "dev": "vite serve",
7
7
  "build": "vite build",
@@ -112,9 +112,10 @@ export default{
112
112
  this.context = context
113
113
 
114
114
  if(this.hash){
115
+ const hash = context.hash ?? this.hash
115
116
  this.$router.push({
116
117
  ...this.$route,
117
- hash: this.$route.hash.replace(this.hash, '') + this.hash
118
+ hash: this.$route.hash.replace(hash, '') + hash
118
119
  })
119
120
  }
120
121
  else{
@@ -15,17 +15,11 @@
15
15
  </div>
16
16
  </template>
17
17
  <template v-slot:foot>
18
- <div v-if="analyseSrc && saveSrc"
19
- class="p-6 flex justify-center">
20
- <button type="button" class="text-primary"
21
- @click="$refs.creator.open()">
22
- Create Datasource...
23
- </button>
24
-
25
- <DatasourceCreator ref="creator"
26
- :analyse-src="analyseSrc"
27
- :save-src="saveSrc"
28
- @save="load" />
18
+ <div class="p-6 flex justify-center">
19
+ <router-link :to="listSrc" target="_blank" class="text-primary flex flex-row items-center">
20
+ Datasource Manager
21
+ <svg class="inline ml-2 fill-primary" width="11" height="11" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Pro 6.0.0-alpha3 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) --><path d="M392 320c-13.25 0-24 10.75-24 24v112c0 4.406-3.594 8-8 8h-304c-4.406 0-8-3.594-8-8v-304c0-4.406 3.594-8 8-8h112C181.3 144 192 133.3 192 120S181.3 96 168 96h-112C25.13 96 0 121.1 0 152v304C0 486.9 25.13 512 56 512h304c30.88 0 56-25.12 56-56v-112C416 330.8 405.3 320 392 320zM488 0H320c-13.25 0-24 10.75-24 24S306.8 48 320 48h110.1L183 295c-9.375 9.375-9.375 24.56 0 33.94C187.7 333.7 193.8 336 200 336s12.28-2.344 16.97-7.031L464 81.94V192c0 13.25 10.75 24 24 24S512 205.3 512 192V24C512 10.75 501.3 0 488 0z"/></svg>
22
+ </router-link>
29
23
  </div>
30
24
  </template>
31
25
  <div class="flex-1 p-6 flex">
@@ -36,24 +30,7 @@
36
30
  :class="dashboardStyle.button"
37
31
  class="flex flex-row items-start gap-2">
38
32
  <button type="button" class="flex-1 text-left" @click="add(datasource)">{{ datasource.name }}</button>
39
- <button v-if="contextMenuItems.length > 0" type="button" class="py-1" :ref="`btn${idx}`" @click="$refs.contextMenu.open($refs[`btn${idx}`][0], { datasource })">
40
- <svg width="14" height="14" class="fill-text-300 hover:fill-primary" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 128 512"><!--! Font Awesome Pro 6.0.0-alpha3 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) --><path d="M128 64c0-35.39-28.62-64-64-64S0 28.61 0 64s28.62 64 64 64S128 99.39 128 64zM128 256c0-35.39-28.62-64-64-64S0 220.6 0 256s28.62 64 64 64S128 291.4 128 256zM128 448c0-35.39-28.62-64-64-64s-64 28.61-64 64s28.62 64 64 64S128 483.4 128 448z"/></svg>
41
- </button>
42
33
  </div>
43
-
44
- <ContextMenu ref="contextMenu" position="bottom-right">
45
- <template #default="{ context }">
46
- <div class="flex flex-col min-w-[200px]">
47
- <div v-for="item in contextMenuItems">
48
- <button v-if="item.type === 'remove'" class="w-full p-3 text-left flex flex-row" :class="appStyle.menuItem"
49
- @click="remove(context.datasource)">
50
- {{ $t('Remove') }}
51
- </button>
52
- </div>
53
-
54
- </div>
55
- </template>
56
- </ContextMenu>
57
34
  </div>
58
35
 
59
36
  <div v-else class="flex-1 flex items-center justify-center">
@@ -69,12 +46,10 @@
69
46
  <script>
70
47
 
71
48
  import Modal from "../../components/Modal.vue"
72
- import md5 from "md5";
73
- import DatasourceCreator from "./DatasourceCreator.vue";
74
49
 
75
50
  export default{
76
51
 
77
- components: {DatasourceCreator, Modal },
52
+ components: { Modal },
78
53
 
79
54
  emits: [ 'add' ],
80
55
 
@@ -82,11 +57,7 @@ export default{
82
57
 
83
58
  props: {
84
59
 
85
- analyseSrc: String,
86
-
87
- saveSrc: String,
88
-
89
- removeSrc: String,
60
+ listSrc: String,
90
61
 
91
62
  src: String,
92
63
 
@@ -94,13 +65,6 @@ export default{
94
65
 
95
66
  computed: {
96
67
 
97
- contextMenuItems(){
98
- return [
99
- this.removeSrc ? { type:'remove' } : null
100
- ]
101
- .filter(_=>_)
102
- }
103
-
104
68
  },
105
69
 
106
70
  data(){
@@ -713,9 +713,7 @@
713
713
 
714
714
  <DatasourceSelector ref="chooseDatasource"
715
715
  :src="datasourceSrc"
716
- :analyseSrc="analyseDatasourceSrc"
717
- :saveSrc="saveDatasourceSrc"
718
- :removeSrc="removeDatasourceSrc"
716
+ :list-src="datasourceListSrc"
719
717
  @add="addDatasource" />
720
718
 
721
719
  <ViewSelector ref="chooseView" />
@@ -1218,9 +1216,10 @@ export default{
1218
1216
  if(!uids) this.readyState = 0
1219
1217
  this.socket.send(this.src, { views })
1220
1218
  .then(_ => {
1221
- this.readyState = 1
1222
1219
  Object.assign(this.values, _)
1223
1220
  })
1221
+ .catch(err => this.alert(err))
1222
+ .finally(_ => this.readyState = 1)
1224
1223
  },
1225
1224
 
1226
1225
  async loadNext(component){
@@ -1309,15 +1308,10 @@ export default{
1309
1308
 
1310
1309
  config: Object,
1311
1310
 
1312
- analyseDatasourceSrc: String,
1313
-
1314
1311
  src: String,
1315
1312
 
1316
- removeDatasourceSrc: String,
1317
-
1318
- saveDatasourceSrc: String,
1319
-
1320
1313
  datasourceSrc: String,
1314
+ datasourceListSrc: String,
1321
1315
 
1322
1316
  previewSrc: String,
1323
1317
 
@@ -1,197 +0,0 @@
1
- <template>
2
- <Modal ref="modal"
3
- :width="width"
4
- :height="height">
5
- <template v-slot:head>
6
- <div class="relative p-6 flex flex-col gap-5">
7
- <div class="absolute top-0 right-0 p-2">
8
- <button type="button" class="p-2" @click="close">
9
- <svg width="24" height="24" viewBox="0 0 24 24" class="fill-text-300 hover:fill-red-500" xmlns="http://www.w3.org/2000/svg">
10
- <path d="M6.53034 5.46965C6.23745 5.17676 5.76257 5.17676 5.46968 5.46965C5.17679 5.76255 5.17679 6.23742 5.46968 6.53031L10.9393 12L5.46967 17.4697C5.17678 17.7626 5.17678 18.2374 5.46967 18.5303C5.76256 18.8232 6.23744 18.8232 6.53033 18.5303L12 13.0606L17.4697 18.5303C17.7626 18.8232 18.2375 18.8232 18.5303 18.5303C18.8232 18.2374 18.8232 17.7626 18.5303 17.4697L13.0607 12L18.5303 6.53032C18.8232 6.23743 18.8232 5.76256 18.5303 5.46966C18.2374 5.17677 17.7626 5.17677 17.4697 5.46966L12 10.9393L6.53034 5.46965Z"/>
11
- </svg>
12
- </button>
13
- </div>
14
-
15
- <h3>Create New Datasource</h3>
16
-
17
- <div>
18
- <Textbox placeholder="Name" v-model="instance.name" />
19
- </div>
20
-
21
- </div>
22
- </template>
23
- <template v-slot:foot>
24
- <div class="p-6">
25
- <Button ref="saveBtn"
26
- class="w-[80px]"
27
- :state="canSave ? 1 : -1"
28
- @click="save">
29
- Save
30
- </Button>
31
- </div>
32
- </template>
33
- <div class="flex-1 px-6 flex">
34
-
35
- <div v-if="readyState === 2" class="flex-1 flex items-center justify-center flex-col">
36
- <svg class="animate-spin aspect-square" width="36" height="36" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"><circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle><path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path></svg>
37
- </div>
38
-
39
- <VirtualTable v-else-if="instance?.columns"
40
- class="flex-1"
41
- :columns="instance.columns"
42
- :items="instance.items" />
43
-
44
- <div v-else class="flex-1 flex items-center justify-center flex-col">
45
- <button type="button" class="text-primary" @click="$refs.file.click()">
46
- Import from File...
47
- </button>
48
- </div>
49
-
50
- <input ref="file" type="file" class="hidden" accept=".csv,.xls,.xlsx" @change="analyse"/>
51
-
52
- <Modal ref="selectSheets" width="300" height="360">
53
- <template v-slot:head>
54
- <div class="relative p-5">
55
- <h3>Select Worksheet</h3>
56
- <div class="absolute top-0 right-0 p-2">
57
- <button type="button" class="p-2" @click="$refs.modal.close()">
58
- <svg width="24" height="24" viewBox="0 0 24 24" class="fill-text-300 hover:fill-red-500" xmlns="http://www.w3.org/2000/svg">
59
- <path d="M6.53034 5.46965C6.23745 5.17676 5.76257 5.17676 5.46968 5.46965C5.17679 5.76255 5.17679 6.23742 5.46968 6.53031L10.9393 12L5.46967 17.4697C5.17678 17.7626 5.17678 18.2374 5.46967 18.5303C5.76256 18.8232 6.23744 18.8232 6.53033 18.5303L12 13.0606L17.4697 18.5303C17.7626 18.8232 18.2375 18.8232 18.5303 18.5303C18.8232 18.2374 18.8232 17.7626 18.5303 17.4697L13.0607 12L18.5303 6.53032C18.8232 6.23743 18.8232 5.76256 18.5303 5.46966C18.2374 5.17677 17.7626 5.17677 17.4697 5.46966L12 10.9393L6.53034 5.46965Z"/>
60
- </svg>
61
- </button>
62
- </div>
63
- </div>
64
- </template>
65
- <div class="flex-1 p-5">
66
-
67
- <div class="flex flex-col">
68
- <div v-for="sheet in multipleSheets"
69
- :class="dashboardStyle.button" @click="analyse({ sheetName:sheet })">
70
- {{ sheet }}
71
- </div>
72
- </div>
73
-
74
- </div>
75
- </Modal>
76
-
77
- </div>
78
- </Modal>
79
- </template>
80
-
81
- <script>
82
-
83
- export default{
84
-
85
- emits: [ 'save' ],
86
-
87
- inject: [ 'alert', 'dashboardStyle', 'socket', 'toast' ],
88
-
89
- props: {
90
-
91
- analyseSrc: String,
92
-
93
- saveSrc: String
94
-
95
- },
96
-
97
- computed: {
98
-
99
- canSave(){
100
- return this.instance &&
101
- this.instance.name &&
102
- this.instance.columns &&
103
- this.instance.items
104
- },
105
-
106
- height(){
107
- if(Array.isArray(this.instance?.items))
108
- return 600
109
- return 480
110
- },
111
-
112
- width(){
113
- if(Array.isArray(this.instance?.items))
114
- return 800
115
- return 420
116
- },
117
-
118
- },
119
-
120
- data(){
121
- return {
122
- instance: null,
123
- readyState: 1,
124
- multipleSheets: null
125
- }
126
- },
127
-
128
- methods: {
129
-
130
- analyse(opt = { sheetName:undefined }){
131
- this.instance.name = this.$refs.file.files[0].name
132
-
133
- this.readyState = 2
134
- this.$refs.selectSheets?.close()
135
- this.socket.send(this.analyseSrc, {
136
- file:this.$refs.file.files[0],
137
- name:this.$refs.file.files[0].name,
138
- mimeType:this.$refs.file.files[0].type,
139
- sheetName: opt.sheetName
140
- })
141
- .then(res => {
142
- Object.assign(this.instance, res)
143
- })
144
- .catch(err => {
145
-
146
- if(err.errors?.multipleSheets){
147
- this.multipleSheets = err.errors.multipleSheets
148
- this.$refs.selectSheets.open()
149
- }
150
- else{
151
- this.alert(err)
152
- }
153
- })
154
- .finally(_ => {
155
- this.readyState = 1
156
- })
157
- },
158
-
159
- open(){
160
- this.instance = {}
161
- this.$refs.modal.open()
162
- },
163
-
164
- close(){
165
- this.$refs.modal.close()
166
- },
167
-
168
- save(){
169
- this.$refs.saveBtn.setState(2)
170
- this.socket.send(this.saveSrc, {
171
- ...this.instance,
172
- file:this.$refs.file.files[0],
173
- name:this.$refs.file.files[0].name,
174
- mimeType:this.$refs.file.files[0].type
175
- })
176
- .then(_ => {
177
- this.toast('Datasource created')
178
- this.close()
179
- this.$emit('save')
180
- })
181
- .catch(err => this.alert(err))
182
- .finally(_ => this.$refs.saveBtn?.resetState())
183
- }
184
-
185
- }
186
-
187
- }
188
-
189
- </script>
190
-
191
- <style module>
192
-
193
- .comp{
194
-
195
- }
196
-
197
- </style>