@live-change/db-admin 0.5.10 → 0.5.13

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.
@@ -49,6 +49,11 @@
49
49
 
50
50
  const code = ref(props.initialCode !== undefined ? props.initialCode : stringify(props.initialData, null, " "))
51
51
 
52
+ watch(() => props.initialCode, () => {
53
+ if(props.initialCode == code.value) return
54
+ code.value = props.initialCode !== undefined ? props.initialCode : stringify(props.initialData, null, " ")
55
+ })
56
+
52
57
  function highlight(code) {
53
58
  return Prism.highlight(code, Prism.languages.js, "js")
54
59
  }
@@ -1,27 +1,35 @@
1
1
  <template>
2
2
 
3
3
  <PathEditor v-model="path"
4
- @update:read="v => read = v"
4
+ @update:read="v => { read = v; version++ }"
5
5
  @update:write="v => write = v"
6
6
  @update:remove="v => remove = v" />
7
7
 
8
8
  <!-- <p>{{ path }}</p>-->
9
9
 
10
10
  <template v-if="read?.external?.includes('range')">
11
- <DataRangeView v-if="read && write && remove" :read="read.result" :write="write.result" :remove="remove.result" />
11
+ <DataRangeView v-if="read && write && remove" :key="'rangeView' + version"
12
+ :dbApi="dbApi" :read="read.result" :write="write.result" :remove="remove.result" />
12
13
  </template>
13
14
  <template v-else>
14
- <DataView v-if="read && write && remove" :read="read.result" :write="write.result" :remove="remove.result" />
15
+ <DataView v-if="read && write && remove" :key="'view' + version"
16
+ :dbApi="dbApi" :read="read.result" :write="write.result" :remove="remove.result" />
15
17
  </template>
16
18
 
17
19
  </template>
18
20
 
19
21
  <script setup>
22
+ import { computed } from 'vue'
23
+
20
24
  import PathEditor from "./PathEditor.vue"
21
25
  import DataRangeView from "./DataRangeView.vue"
22
26
  import DataView from "./DataView.vue"
23
27
 
24
28
  const props = defineProps({
29
+ dbApi: {
30
+ type: String,
31
+ default: 'serverDatabase'
32
+ },
25
33
  position: {
26
34
  type: String,
27
35
  required: true
@@ -44,19 +52,27 @@
44
52
  }
45
53
  })
46
54
 
47
- const pathParams = new Array(props.params.length / 2)
48
- for(let i = 0; i < props.params.length/2; i++) pathParams[i] = [props.params[i * 2], props.params[i * 2 + 1]]
55
+
49
56
 
50
57
  import { ref, watch } from 'vue'
51
58
  import { useRouter, useRoute } from 'vue-router'
52
59
 
53
- const path = ref({ read: props.read, write: props.write, remove: props.remove, params: pathParams })
60
+ function computePath() {
61
+ const pathParams = new Array(props.params.length / 2)
62
+ for(let i = 0; i < props.params.length/2; i++) pathParams[i] = [props.params[i * 2], props.params[i * 2 + 1]]
63
+ return { read: props.read, write: props.write, remove: props.remove, params: pathParams }
64
+ }
65
+
66
+ const propsPath = computed(() => computePath())
67
+
68
+ const path = ref(propsPath.value)
69
+ watch(() => propsPath.value, () => path.value = propsPath.value)
54
70
 
55
71
  const router = useRouter()
56
72
  const route = useRoute()
57
73
 
58
74
  watch(() => path.value, value => {
59
- console.log("PATH VALUE UPDATED", value)
75
+ console.log("PATH VALUE UPDATED", JSON.stringify(value, null, ' '))
60
76
  const paramsArray = value.params.flat()
61
77
  router.replace({ name: route.name, params: {
62
78
  read: value.read,
@@ -67,6 +83,7 @@
67
83
  /// TODO: update URL
68
84
  })
69
85
 
86
+ const version = ref(0)
70
87
  const read = ref()
71
88
  const write = ref()
72
89
  const remove = ref()
@@ -9,7 +9,7 @@
9
9
  class="surface-0 shadow-1 w-full">
10
10
  <!-- {{ JSON.stringify(row) }}-->
11
11
  <object-editor :currentData="JSON.stringify(row)"
12
- :write="write" :remove="remove"
12
+ :write="props.write" :remove="props.remove"
13
13
  :dbApi="dbApi" />
14
14
  </div>
15
15
  </div>
@@ -27,7 +27,7 @@
27
27
 
28
28
  import { dbViewSugar } from "./dbSugar.js"
29
29
 
30
- const { dbApi, read, write, remove } = defineProps({
30
+ const props = defineProps({
31
31
  dbApi: {
32
32
  type: String,
33
33
  default: 'serverDatabase'
@@ -46,6 +46,7 @@
46
46
  }
47
47
  })
48
48
 
49
+ const { dbApi, read } = props
49
50
 
50
51
  const [ dataBuckets ] = await Promise.all([
51
52
  rangeBuckets((range, p) => [dbApi, ...JSON.parse(JSON.stringify(read({ range }, dbViewSugar)))])
@@ -4,7 +4,7 @@
4
4
  class="surface-0 shadow-1 w-full">
5
5
  <!-- {{ JSON.stringify(row) }}-->
6
6
  <object-editor :currentData="JSON.stringify(row)"
7
- :write="write" :remove="remove"
7
+ :write="props.write" :remove="props.remove"
8
8
  :dbApi="dbApi" />
9
9
  </div>
10
10
  </div>
@@ -18,7 +18,7 @@
18
18
 
19
19
  import { dbViewSugar } from "./dbSugar.js"
20
20
 
21
- const { dbApi, read, write, remove } = defineProps({
21
+ const props = defineProps({
22
22
  dbApi: {
23
23
  type: String,
24
24
  default: 'serverDatabase'
@@ -37,6 +37,7 @@
37
37
  }
38
38
  })
39
39
 
40
+ const { dbApi, read } = props
40
41
 
41
42
  const [ dataRows ] = await Promise.all([
42
43
  live({
@@ -16,7 +16,7 @@
16
16
  <form v-if="tableRename == slotProps.data.id" @submit="ev => finishTableRename(ev, slotProps.data.id)">
17
17
  <InputText v-model="tableNewName" />
18
18
  </form>
19
- <router-link v-else :to="tableLink(slotProps.data.id)">
19
+ <router-link v-else :to="tableLink(dbName, slotProps.data.id)">
20
20
  {{ slotProps.data.id }}
21
21
  </router-link>
22
22
  </template>
@@ -55,7 +55,7 @@
55
55
  <form v-if="logRename == slotProps.data.id" @submit="ev => finishLogRename(ev, slotProps.data.id)">
56
56
  <InputText v-model="logNewName" />
57
57
  </form>
58
- <router-link v-else :to="logLink(slotProps.data.id)">
58
+ <router-link v-else :to="logLink(dbName, slotProps.data.id)">
59
59
  {{ slotProps.data.id }}
60
60
  </router-link>
61
61
  </template>
@@ -94,7 +94,7 @@
94
94
  <form v-if="indexRename == slotProps.data.id" @submit="ev => finishIndexRename(ev, slotProps.data.id)">
95
95
  <InputText v-model="indexNewName" />
96
96
  </form>
97
- <router-link v-else :to="indexLink(slotProps.data.id)">
97
+ <router-link v-else :to="indexLink(dbName, slotProps.data.id)">
98
98
  {{ slotProps.data.id }}
99
99
  </router-link>
100
100
  </template>
@@ -126,6 +126,8 @@
126
126
  import ConfirmPopup from 'primevue/confirmpopup'
127
127
  import Toast from 'primevue/toast'
128
128
 
129
+ import { tableLink, logLink, indexLink } from "./links.js"
130
+
129
131
  const { dbApi, dbName } = defineProps({
130
132
  dbApi: {
131
133
  type: String,
@@ -307,45 +309,6 @@
307
309
  })())
308
310
  }
309
311
 
310
- function tableLink(table) {
311
- return { name: 'db:data', params: {
312
- position: " ",
313
- read: `db.tableRange($.db,$.table,$.range)`,
314
- write: `db.put($.db,$.table,$.object)`,
315
- remove: `db.delete($.db,$.table,$.object.id)`,
316
- params: [
317
- 'db', JSON.stringify(dbName),
318
- 'table', JSON.stringify(table)
319
- ]
320
- } }
321
- }
322
-
323
- function logLink(table) {
324
- return { name: 'db:data', params: {
325
- position: " ",
326
- read: `db.logRange($.db,$.table,$.range)`,
327
- write: false,
328
- remove: false,
329
- params: [
330
- 'db', JSON.stringify(dbName),
331
- 'table', JSON.stringify(table)
332
- ]
333
- } }
334
- }
335
-
336
- function indexLink(table) {
337
- return { name: 'db:data', params: {
338
- position: " ",
339
- read: `db.indexRange($.db,$.table,$.range)`,
340
- write: false,
341
- remove: false,
342
- params: [
343
- 'db', JSON.stringify(dbName),
344
- 'table', JSON.stringify(table)
345
- ]
346
- } }
347
- }
348
-
349
312
  const [ tables, indexes, logs ] = await Promise.all([
350
313
  live(dao, {
351
314
  what: [dbApi, 'tables', dbName],
@@ -21,8 +21,8 @@
21
21
  </div>
22
22
  <ul class="list-none p-0 m-0 ml-3 overflow-hidden hidden" :id="`db-menu-${database.id}`">
23
23
  <li>
24
- <a v-ripple class="flex align-items-center cursor-pointer p-3 border-round text-700 hover:surface-100
25
- transition-duration-150 transition-colors p-ripple"
24
+ <a v-ripple class="flex align-items-center cursor-pointer p-3 border-round text-700
25
+ hover:surface-100 transition-duration-150 transition-colors p-ripple"
26
26
  v-styleclass="{ selector: '@next', enterClass: 'hidden', enterActiveClass: 'slidedown',
27
27
  leaveToClass: 'hidden', leaveActiveClass: 'slideup' }">
28
28
  <i class="pi pi-table mr-2"></i>
@@ -32,48 +32,54 @@
32
32
  <ul class="list-none py-0 pl-3 pr-0 m-0 hidden overflow-y-hidden transition-all
33
33
  transition-duration-400 transition-ease-in-out">
34
34
  <li v-for="table in database?.tables">
35
- <a v-ripple class="flex align-items-center cursor-pointer p-3 border-round text-700
35
+ <router-link
36
+ :to="tableLink(database.id, table)"
37
+ v-ripple class="flex align-items-center cursor-pointer p-3 border-round text-700
36
38
  hover:surface-100 transition-duration-150 transition-colors p-ripple">
37
39
  <span class="font-medium">{{ table }}</span>
38
- </a>
40
+ </router-link>
39
41
  </li>
40
42
  </ul>
41
43
  </li>
42
44
  <li>
43
- <a v-ripple class="flex align-items-center cursor-pointer p-3 border-round text-700 hover:surface-100
44
- transition-duration-150 transition-colors p-ripple"
45
+ <a v-ripple class="flex align-items-center cursor-pointer p-3 border-round text-700
46
+ hover:surface-100 transition-duration-150 transition-colors p-ripple"
45
47
  v-styleclass="{ selector: '@next', enterClass: 'hidden', enterActiveClass: 'slidedown',
46
48
  leaveToClass: 'hidden', leaveActiveClass: 'slideup' }">
47
- <i class="pi pi-external-link mr-2"></i>
48
- <span class="font-medium">{{ database?.indexes?.length }} INDEXES</span>
49
+ <i class="pi pi-list mr-2"></i>
50
+ <span class="font-medium">{{ database?.logs?.length }} LOGS</span>
49
51
  <i class="pi pi-chevron-down ml-auto"></i>
50
52
  </a>
51
53
  <ul class="list-none py-0 pl-3 pr-0 m-0 hidden overflow-y-hidden transition-all
52
54
  transition-duration-400 transition-ease-in-out">
53
- <li v-for="index in database?.indexes">
54
- <a v-ripple class="flex align-items-center cursor-pointer p-3 border-round text-700
55
- hover:surface-100 transition-duration-150 transition-colors p-ripple">
56
- <span class="font-medium">{{ index }}</span>
57
- </a>
55
+ <li v-for="log in database?.logs">
56
+ <router-link
57
+ :to="logLink(database.id, log)"
58
+ v-ripple class="flex align-items-center cursor-pointer p-3 border-round text-700
59
+ hover:surface-100 transition-duration-150 transition-colors p-ripple">
60
+ <span class="font-medium">{{ log }}</span>
61
+ </router-link>
58
62
  </li>
59
63
  </ul>
60
64
  </li>
61
65
  <li>
62
- <a v-ripple class="flex align-items-center cursor-pointer p-3 border-round text-700 hover:surface-100
63
- transition-duration-150 transition-colors p-ripple"
66
+ <a v-ripple class="flex align-items-center cursor-pointer p-3 border-round text-700
67
+ hover:surface-100 transition-duration-150 transition-colors p-ripple"
64
68
  v-styleclass="{ selector: '@next', enterClass: 'hidden', enterActiveClass: 'slidedown',
65
69
  leaveToClass: 'hidden', leaveActiveClass: 'slideup' }">
66
- <i class="pi pi-list mr-2"></i>
67
- <span class="font-medium">{{ database?.logs?.length }} LOGS</span>
70
+ <i class="pi pi-external-link mr-2"></i>
71
+ <span class="font-medium">{{ database?.indexes?.length }} INDEXES</span>
68
72
  <i class="pi pi-chevron-down ml-auto"></i>
69
73
  </a>
70
74
  <ul class="list-none py-0 pl-3 pr-0 m-0 hidden overflow-y-hidden transition-all
71
75
  transition-duration-400 transition-ease-in-out">
72
- <li v-for="log in database?.logs">
73
- <a v-ripple class="flex align-items-center cursor-pointer p-3 border-round text-700
74
- hover:surface-100 transition-duration-150 transition-colors p-ripple">
75
- <span class="font-medium">{{ log }}</span>
76
- </a>
76
+ <li v-for="index in database?.indexes">
77
+ <router-link
78
+ :to="indexLink(database.id, index)"
79
+ v-ripple class="flex align-items-center cursor-pointer p-3 border-round text-700
80
+ hover:surface-100 transition-duration-150 transition-colors p-ripple">
81
+ <span class="font-medium">{{ index }}</span>
82
+ </router-link>
77
83
  </li>
78
84
  </ul>
79
85
  </li>
@@ -104,6 +110,7 @@
104
110
  </template>
105
111
 
106
112
  <script setup>
113
+ import { tableLink, logLink, indexLink } from "./links.js"
107
114
 
108
115
  const { dbApi } = defineProps({
109
116
  dbApi: {
@@ -63,8 +63,9 @@
63
63
  import { dbRequestSugar, dbViewSugar } from "./dbSugar.js";
64
64
 
65
65
  import { ref, reactive, computed, watch } from "vue"
66
+ import { toRefs } from "@vueuse/core"
66
67
 
67
- const { modelValue } = defineProps({
68
+ const props = defineProps({
68
69
  modelValue: {
69
70
  type: Object,
70
71
  required: true
@@ -73,7 +74,16 @@
73
74
 
74
75
  const emit = defineEmits(['update:modelValue', 'update:read', 'update:write', 'update:remove'])
75
76
 
76
- const path = reactive(modelValue)
77
+ const path = reactive(JSON.parse(JSON.stringify(props.modelValue)))
78
+
79
+ watch(() => props.modelValue, value => {
80
+ if(JSON.stringify(path) != JSON.stringify(value)) {
81
+ path.read = value.read
82
+ path.write = value.write
83
+ path.remove = value.remove
84
+ path.params = JSON.parse(JSON.stringify(value.params))
85
+ }
86
+ })
77
87
 
78
88
 
79
89
  function handleReadChange(result) {
@@ -112,10 +122,9 @@
112
122
  allParams.push(...extractParams(path.write))
113
123
  allParams.push(...extractParams(path.remove))
114
124
  for(const field of path.params) {
115
- console.log("FD", field, "=>", extractParams(field[1]))
125
+ //console.log("FD", field, "=>", extractParams(field[1]))
116
126
  allParams.push(...extractParams(field[1]))
117
127
  }
118
-
119
128
  const paramsSet = new Set(allParams)
120
129
  paramsSet.delete('range')
121
130
  paramsSet.delete('object')
@@ -149,8 +158,12 @@
149
158
  })
150
159
 
151
160
  watch(() => output.value, value => {
152
- console.log("EMIT OUTPUT!")
153
- emit('update:modelValue', output.value)
161
+ if(JSON.stringify(props.modelValue) != JSON.stringify(value)) {
162
+ console.log("EMIT OUTPUT!", JSON.stringify(props.modelValue), JSON.stringify(value))
163
+ emit('update:modelValue', output.value)
164
+ } else {
165
+ console.log("DROP OUTPUT CHANGE", JSON.stringify(props.modelValue), JSON.stringify(value))
166
+ }
154
167
  })
155
168
 
156
169
  const readCompiled = computed(() => {
@@ -0,0 +1,39 @@
1
+
2
+ export function tableLink(dbName, table) {
3
+ return { name: 'db:data', params: {
4
+ position: " ",
5
+ read: `db.tableRange($.db,$.table,$.range)`,
6
+ write: `db.put($.db,$.table,$.object)`,
7
+ remove: `db.delete($.db,$.table,$.object.id)`,
8
+ params: [
9
+ 'db', JSON.stringify(dbName),
10
+ 'table', JSON.stringify(table)
11
+ ]
12
+ } }
13
+ }
14
+
15
+ export function logLink(dbName, table) {
16
+ return { name: 'db:data', params: {
17
+ position: " ",
18
+ read: `db.logRange($.db,$.table,$.range)`,
19
+ write: false,
20
+ remove: false,
21
+ params: [
22
+ 'db', JSON.stringify(dbName),
23
+ 'table', JSON.stringify(table)
24
+ ]
25
+ } }
26
+ }
27
+
28
+ export function indexLink(dbName, table) {
29
+ return { name: 'db:data', params: {
30
+ position: " ",
31
+ read: `db.indexRange($.db,$.table,$.range)`,
32
+ write: false,
33
+ remove: false,
34
+ params: [
35
+ 'db', JSON.stringify(dbName),
36
+ 'table', JSON.stringify(table)
37
+ ]
38
+ } }
39
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@live-change/db-admin",
3
- "version": "0.5.10",
3
+ "version": "0.5.13",
4
4
  "scripts": {
5
5
  "memDev": "lcli memDev --initScript ./init.js --dbAccess",
6
6
  "localDevInit": "rm tmp.db; lcli localDev --initScript ./init.js --dbAccess",
@@ -17,16 +17,16 @@
17
17
  "debug": "node --inspect-brk server"
18
18
  },
19
19
  "dependencies": {
20
- "@live-change/cli": "0.6.3",
21
- "@live-change/dao": "0.4.10",
22
- "@live-change/dao-vue3": "0.4.11",
23
- "@live-change/dao-websocket": "0.4.10",
24
- "@live-change/framework": "0.6.4",
25
- "@live-change/message-authentication-service": "0.2.29",
26
- "@live-change/secret-code-service": "0.2.29",
27
- "@live-change/secret-link-service": "0.2.29",
28
- "@live-change/vue3-components": "0.2.8",
29
- "@live-change/vue3-ssr": "0.2.9",
20
+ "@live-change/cli": "0.6.5",
21
+ "@live-change/dao": "0.4.13",
22
+ "@live-change/dao-vue3": "0.4.13",
23
+ "@live-change/dao-websocket": "0.4.13",
24
+ "@live-change/framework": "0.6.5",
25
+ "@live-change/message-authentication-service": "0.2.37",
26
+ "@live-change/secret-code-service": "0.2.39",
27
+ "@live-change/secret-link-service": "0.2.39",
28
+ "@live-change/vue3-components": "0.2.12",
29
+ "@live-change/vue3-ssr": "0.2.14",
30
30
  "@vitejs/plugin-vue": "^2.3.1",
31
31
  "@vitejs/plugin-vue-jsx": "^1.3.10",
32
32
  "@vue/compiler-sfc": "^3.2.33",
@@ -36,9 +36,9 @@
36
36
  "cross-env": "^7.0.3",
37
37
  "find-free-ports": "^3.0.0",
38
38
  "javascript-stringify": "^2.1.0",
39
- "primeflex": "^3.1.3",
39
+ "primeflex": "^3.2.1",
40
40
  "primeicons": "^5.0.0",
41
- "primevue": "^3.12.6",
41
+ "primevue": "^3.15.0",
42
42
  "prism-es6": "^1.2.0",
43
43
  "prismjs": "^1.28.0",
44
44
  "rollup-plugin-node-builtins": "^2.1.2",
@@ -56,7 +56,7 @@
56
56
  "vue3-scroll-border": "0.1.2"
57
57
  },
58
58
  "devDependencies": {
59
- "@live-change/codeceptjs-helper": "0.6.0",
59
+ "@live-change/codeceptjs-helper": "0.6.5",
60
60
  "@wdio/selenium-standalone-service": "^7.19.5",
61
61
  "codeceptjs": "^3.3.1",
62
62
  "generate-password": "1.7.0",
@@ -68,5 +68,5 @@
68
68
  "author": "",
69
69
  "license": "ISC",
70
70
  "description": "",
71
- "gitHead": "6236c001558f60998b0e5bce5e97e7ebb1f50e45"
71
+ "gitHead": "e75a92ac01b8422076b660cf0dd5d8f4a80fe13c"
72
72
  }