@mixd-id/web-scaffold 0.2.240703 → 0.2.240705

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.2.240703",
4
+ "version": "0.2.240705",
5
5
  "scripts": {
6
6
  "dev": "vite serve",
7
7
  "build": "vite build",
@@ -169,21 +169,14 @@ export default{
169
169
 
170
170
  .button-primary {
171
171
  @apply bg-primary-500 text-white rounded-lg;
172
+ @apply hover:bg-primary-600 focus:border-primary-300;
172
173
  box-shadow: 0 2px 1px rgba(0, 0, 0, .05);
173
174
  border: solid 1px rgb(var(--primary-500));
174
175
  }
175
176
 
176
- .button-primary:focus {
177
- border-color: rgb(var(--primary-600));
178
- }
179
-
180
- .button-primary:hover {
181
- @apply bg-primary-600;
182
- }
183
-
184
177
  .button-primary-disabled,
185
178
  .button-primary-disabled:hover {
186
- @apply bg-primary-500 top-0 left-0 cursor-not-allowed text-opacity-50;
179
+ @apply bg-primary-300 border-primary-300 top-0 left-0 cursor-not-allowed text-opacity-50;
187
180
  @apply top-0 left-0;
188
181
  }
189
182
 
@@ -634,7 +634,9 @@ export default{
634
634
  else{
635
635
  return this.socket.send(this.presetSrc, { key:this.presetKey })
636
636
  .then(async (config) => {
637
- this._config = config
637
+ !config ?
638
+ await this.loadDefaultConfig() :
639
+ this._config = config
638
640
  })
639
641
  .catch(() => {})
640
642
  }
package/src/index.js CHANGED
@@ -686,6 +686,8 @@ export default{
686
686
  app.component('PolarArea', defineAsyncComponent(() => import("./widgets/Dashboard/PolarArea.vue")))
687
687
  app.component('Metric', defineAsyncComponent(() => import("./widgets/Dashboard/Metric.vue")))
688
688
  app.component('BarChart', defineAsyncComponent(() => import("./widgets/Dashboard/BarChart.vue")))
689
+
690
+ app.component('BotEditor', defineAsyncComponent(() => import("./widgets/BotEditor.vue")))
689
691
  }
690
692
 
691
693
  }
@@ -0,0 +1,162 @@
1
+ <template>
2
+ <div v-if="!action" :class="$style.comp" class="flex items-center justify-center">
3
+ <p class="text-text-400">No action selected</p>
4
+ </div>
5
+
6
+ <div v-else class="flex-1 flex flex-col">
7
+
8
+ <div class="flex flex-row items-center p-2 pt-3 px-6 bg-base-300 border-b-[1px] border-text-50">
9
+ <div class="flex-1">
10
+ <strong>{{ action.name }}</strong>
11
+ </div>
12
+ <Button ref="saveBtn" :state="canSave ? 1 : -1" class="w-[80px] rounded-full" @click="save">Save</Button>
13
+ </div>
14
+
15
+ <div class="flex-1 flex flex-row">
16
+ <div class="flex-1 p-12 overflow-auto">
17
+ <UserActionItem :config="config"
18
+ :item="action"
19
+ :removable="false"
20
+ @select="(item) => config.selectedUid = item.uid" />
21
+ </div>
22
+
23
+ <div :style="sidebarStyle"
24
+ class="relative flex flex-col border-l-[1px] border-text-50 panel-400 overflow-hidden">
25
+ <div :class="$style.resize1"
26
+ @mousedown="(e) => $util.dragResize(e, resize1)"></div>
27
+
28
+ <UserActionProps ref="userActionProps" :instance="selectedItem" />
29
+
30
+ </div>
31
+ </div>
32
+
33
+
34
+ </div>
35
+ </template>
36
+
37
+ <script>
38
+
39
+ import UserActionItem from "../UserActionBuilder/UserActionItem.vue";
40
+ import UserActionProps from "../UserActionBuilder/UserActionProps.vue";
41
+
42
+ const findComponents = (items, uid) => {
43
+ for (let item of items) {
44
+ if (item.uid === uid)
45
+ return item
46
+
47
+ if (item.items) {
48
+ const component = findComponents(item.items, uid)
49
+ if (component)
50
+ return component
51
+ }
52
+ }
53
+ }
54
+
55
+ export default{
56
+ components: {UserActionProps, UserActionItem},
57
+
58
+ computed: {
59
+
60
+ canSave(){
61
+ return JSON.stringify(this.action) !== this.initialAction
62
+ },
63
+
64
+ selectedItem(){
65
+ if (!this.config.selectedUid) return
66
+ if (!this.action) return
67
+
68
+ if(this.action.uid === this.config.selectedUid)
69
+ return this.action
70
+ return findComponents(this.action.items ?? [], this.config.selectedUid)
71
+ },
72
+
73
+ sidebar(){
74
+ if (!this.config.actionSidebar)
75
+ this.config.actionSidebar = {
76
+ open: true,
77
+ width: 300
78
+ }
79
+
80
+ return this.config.actionSidebar
81
+ },
82
+
83
+ sidebarStyle() {
84
+ return {
85
+ width: this.sidebar.width + 'px'
86
+ }
87
+ },
88
+
89
+ },
90
+
91
+ data(){
92
+ return {
93
+ action: null,
94
+ initialAction: null,
95
+ }
96
+ },
97
+
98
+ inject: [ 'socket' ],
99
+
100
+ props: {
101
+
102
+ config: Object,
103
+ controller: String,
104
+
105
+ },
106
+
107
+ methods: {
108
+
109
+ load(uid){
110
+ if(!uid) return
111
+
112
+ this.socket.send(`${this.controller}.open-action`, { uid })
113
+ .then(_ => {
114
+ this.action = _.item
115
+ this.initialAction = JSON.stringify(this.action)
116
+ })
117
+ },
118
+
119
+ resize1(w) {
120
+ if (this.sidebar.width - w >= 200 && this.sidebar.width - w <= 600) {
121
+ this.sidebar.width -= w
122
+ }
123
+ },
124
+
125
+ save(){
126
+ this.$refs.saveBtn.setState(2)
127
+ this.socket.send(`${this.controller}.save-action`, {
128
+ item: this.action
129
+ })
130
+ .then(_ => this.initialAction = JSON.stringify(this.action))
131
+ .catch(err => this.alert(err))
132
+ .finally(_ => this.$refs.saveBtn?.resetState())
133
+ }
134
+
135
+ },
136
+
137
+ watch: {
138
+
139
+ '$route.query.actionUid': {
140
+ immediate: true,
141
+ handler(to){
142
+ this.load(to)
143
+ }
144
+ }
145
+
146
+ }
147
+
148
+ }
149
+
150
+ </script>
151
+
152
+ <style module>
153
+
154
+ .comp{
155
+ @apply flex-1;
156
+ }
157
+
158
+ .resize1 {
159
+ @apply w-[3px] cursor-ew-resize absolute top-0 left-0 bottom-0;
160
+ }
161
+
162
+ </style>
@@ -0,0 +1,228 @@
1
+ <template>
2
+ <div v-if="cConfig" :class="$style.comp">
3
+
4
+ <div :style="sidebarStyle"
5
+ class="relative flex flex-col border-r-[1px] border-text-50 panel-400 overflow-hidden">
6
+
7
+ <div v-if="page !== 'Actions'" class="flex-1 flex flex-col">
8
+ <div class="p-5">
9
+ <h5>Bot Settings</h5>
10
+ <br />
11
+ </div>
12
+
13
+ <div class="flex-1">
14
+
15
+ <div class="flex flex-col divide-y divide-text-50 border-y-[1px] border-text-50">
16
+ <router-link :to="{ query:{ t:'actions' } }" type="button" class="p-3 px-5 text-left">Actions</router-link>
17
+ <router-link :to="{ query:{ t:'knowledge' } }" type="button" class="p-3 px-5 text-left">Knowledge</router-link>
18
+ <router-link :to="{ query:{ t:'classifications' } }" type="button" class="p-3 px-5 text-left">Classifications</router-link>
19
+ <router-link :to="{ query:{ t:'settings' } }" type="button" class="p-3 px-5 text-left">Settings</router-link>
20
+ </div>
21
+
22
+ </div>
23
+ </div>
24
+
25
+ <div v-else-if="page === 'Actions'" class="flex-1 flex flex-col">
26
+ <div class="p-5 flex flex-row gap-2">
27
+ <button type="button" @click="$router.replace({ query:{} })">
28
+ <svg width="16" height="16" class="fill-text" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--! Font Awesome Pro 6.0.0-alpha3 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) --><path d="M447.1 256C447.1 273.7 433.7 288 416 288H109.3l105.4 105.4c12.5 12.5 12.5 32.75 0 45.25C208.4 444.9 200.2 448 192 448s-16.38-3.125-22.62-9.375l-160-160c-12.5-12.5-12.5-32.75 0-45.25l160-160c12.5-12.5 32.75-12.5 45.25 0s12.5 32.75 0 45.25L109.3 224H416C433.7 224 447.1 238.3 447.1 256z"/></svg>
29
+ </button>
30
+ <h5>Actions</h5>
31
+ </div>
32
+
33
+ <br />
34
+
35
+ <ListItem :items="actions"
36
+ container-class="divide-y divide-text-50"
37
+ @reorder="(from, to) => { actions.splice(to, 0, actions.splice(from, 1)[0]); }">
38
+ <template v-slot="{ item }">
39
+ <div class="p-3 hover:bg-base-500 flex flex-row gap-3 items-center">
40
+ <div data-reorder>
41
+ <svg width="14" height="14" class="fill-text-300" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path d="M496 288H16c-8.8 0-16 7.2-16 16v32c0 8.8 7.2 16 16 16h480c8.8 0 16-7.2 16-16v-32c0-8.8-7.2-16-16-16zm0-128H16c-8.8 0-16 7.2-16 16v32c0 8.8 7.2 16 16 16h480c8.8 0 16-7.2 16-16v-32c0-8.8-7.2-16-16-16z"/></svg>
42
+ </div>
43
+ <label class="flex-1 text-ellipsis overflow-hidden whitespace-nowrap"
44
+ @click="$router.push({ query:{ t:'actions', actionUid:item.uid } })">
45
+ {{ item.name }}
46
+ </label>
47
+ <button type="button" @click="">
48
+ <svg width="14" height="14" class="fill-text-300 hover:fill-red-600" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 512"><!--! Font Awesome Pro 6.0.0-alpha3 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) --><path d="M310.6 361.4c12.5 12.5 12.5 32.75 0 45.25C304.4 412.9 296.2 416 288 416s-16.38-3.125-22.62-9.375L160 301.3L54.63 406.6C48.38 412.9 40.19 416 32 416S15.63 412.9 9.375 406.6c-12.5-12.5-12.5-32.75 0-45.25l105.4-105.4L9.375 150.6c-12.5-12.5-12.5-32.75 0-45.25s32.75-12.5 45.25 0L160 210.8l105.4-105.4c12.5-12.5 32.75-12.5 45.25 0s12.5 32.75 0 45.25l-105.4 105.4L310.6 361.4z"/></svg>
49
+ </button>
50
+ </div>
51
+ </template>
52
+ </ListItem>
53
+
54
+ </div>
55
+
56
+ <div class="flex flex-col border-t-[1px] border-text-50 relative" :style="bottombarStyle">
57
+ <div :class="$style.resize2"
58
+ @mousedown="(e) => $util.dragResize(e, resize2)"></div>
59
+
60
+ <UserActionConsole class="flex-1"
61
+ ref="console"
62
+ @test-message="testMessage"
63
+ @test-reset="testReset" />
64
+
65
+ </div>
66
+
67
+ <div :class="$style.resize1"
68
+ @mousedown="(e) => $util.dragResize(e, resize1)"></div>
69
+ </div>
70
+
71
+ <div v-if="page" class="flex-1 overflow-y-auto flex flex-col">
72
+
73
+ <component :is="`BotEditor${page}`"
74
+ :config="config"
75
+ :controller="controller" />
76
+
77
+ </div>
78
+
79
+ </div>
80
+ </template>
81
+
82
+ <script>
83
+
84
+ import {capitalize} from "../utils/helpers.mjs";
85
+ import BotEditorActions from "./BotEditor/BotEditorActions.vue";
86
+ import VirtualGrid from "../components/VirtualGrid.vue";
87
+ import UserActionConsole from "./UserActionBuilder/UserActionConsole.vue";
88
+
89
+
90
+ export default{
91
+
92
+ components: {
93
+ UserActionConsole,
94
+ VirtualGrid,
95
+ BotEditorActions,
96
+ },
97
+
98
+ inject: [ 'alert', 'confirm', 'socket', 'toast' ],
99
+
100
+ computed: {
101
+
102
+ bottombar(){
103
+ if (!this.cConfig.bottombar)
104
+ this.cConfig.bottombar = {
105
+ open: true,
106
+ height: 240
107
+ }
108
+
109
+ return this.cConfig.bottombar
110
+ },
111
+
112
+ bottombarStyle(){
113
+ return {
114
+ height: !this.bottombar.open ? 0 : this.bottombar.height + 'px'
115
+ }
116
+ },
117
+
118
+ cConfig(){
119
+ return this.config
120
+ },
121
+
122
+ sidebar() {
123
+ if (!this.cConfig.sidebar || !('open' in this.cConfig.sidebar))
124
+ this.cConfig.sidebar = {
125
+ open: true,
126
+ width: 360
127
+ }
128
+
129
+ return this.cConfig.sidebar
130
+ },
131
+
132
+ sidebarStyle() {
133
+ return {
134
+ width: !this.sidebar.open ? 0 : this.sidebar.width + 'px'
135
+ }
136
+ },
137
+
138
+ },
139
+
140
+ data(){
141
+ return {
142
+ actions: null,
143
+ page: '',
144
+ }
145
+ },
146
+
147
+ methods: {
148
+
149
+ load(){
150
+
151
+ },
152
+
153
+ loadActions(){
154
+ this.socket.send(`${this.controller}.load-actions`, {})
155
+ .then(_ => {
156
+ this.actions = _.items
157
+ })
158
+ },
159
+
160
+ resize1(w) {
161
+ if (this.sidebar.width + w >= 200 && this.sidebar.width + w <= 600) {
162
+ this.sidebar.width += w
163
+ }
164
+ },
165
+
166
+ resize2(_, h) {
167
+ if (this.bottombar.height - h >= 200 && this.bottombar.height - h <= 400) {
168
+ this.bottombar.height -= h
169
+ }
170
+ },
171
+
172
+ testMessage(){
173
+
174
+ },
175
+
176
+ testReset(){
177
+
178
+ },
179
+
180
+ },
181
+
182
+ props: {
183
+
184
+ config: Object,
185
+ configSrc: String,
186
+
187
+ controller: String,
188
+
189
+ },
190
+
191
+ watch: {
192
+
193
+ '$route.query.t': {
194
+ immediate: true,
195
+ handler(to){
196
+ this.page = to ? capitalize(to) : ''
197
+ }
198
+ },
199
+
200
+ page: {
201
+ immediate: true,
202
+ handler(to){
203
+ if(this[`load${to}`])
204
+ this[`load${to}`]()
205
+ }
206
+ }
207
+
208
+ }
209
+
210
+ }
211
+
212
+ </script>
213
+
214
+ <style module>
215
+
216
+ .comp{
217
+ @apply flex flex-row;
218
+ }
219
+
220
+ .resize1 {
221
+ @apply w-[3px] cursor-ew-resize absolute top-0 right-0 bottom-0;
222
+ }
223
+
224
+ .resize2 {
225
+ @apply h-[3px] cursor-n-resize absolute top-0 right-0 left-0 bg-red-500 z-50;
226
+ }
227
+
228
+ </style>
@@ -53,7 +53,7 @@
53
53
 
54
54
  <div v-if="mode === 'select'" class="flex-1 flex flex-col">
55
55
  <div class="flex flex-col bg-base-300 border-t-[1px] border-b-[1px] border-text-50 divide-y divide-text-50">
56
- <button v-for="(preset, idx) in config.presets" type="button"
56
+ <div v-for="(preset, idx) in config.presets"
57
57
  class="px-6 text-left hover:bg-primary-200 hover:text-white flex flex-row items-center">
58
58
  <div class="flex-1 py-4" @click="select(idx)">
59
59
  {{ preset.name }}
@@ -64,7 +64,7 @@
64
64
  @click="$refs.contextMenu.open($refs.btn[idx], { idx })">
65
65
  <svg width="16" height="16" class="fill-text-300 hover:fill-primary" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 128 512"><path d="M64 208c26.5 0 48 21.5 48 48s-21.5 48-48 48-48-21.5-48-48 21.5-48 48-48zM16 104c0 26.5 21.5 48 48 48s48-21.5 48-48-21.5-48-48-48-48 21.5-48 48zm0 304c0 26.5 21.5 48 48 48s48-21.5 48-48-21.5-48-48-48-48 21.5-48 48z"/></svg>
66
66
  </button>
67
- </button>
67
+ </div>
68
68
  </div>
69
69
 
70
70
  <ContextMenu ref="contextMenu" position="bottom-right">
@@ -34,9 +34,11 @@
34
34
  <label>Operator</label>
35
35
  <Dropdown v-model="instance.op" class="mt-1">
36
36
  <option value="=">Equal</option>
37
+ <option value="contains">Contains</option>
38
+ <option value="startsWith">Starts With</option>
39
+ <option value="endsWith">Ends With</option>
37
40
  <option value="intent">Intent</option>
38
- <option value="extractVariables">Extract Information</option>
39
- <option value="askLlm">Ask LLM</option>
41
+ <option value="classification">Classification</option>
40
42
  </Dropdown>
41
43
  </div>
42
44
 
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <div class="h-[200px] panel-400 border-[1px] border-text-50 flex flex-col relative">
2
+ <div class="flex flex-col relative">
3
3
 
4
4
  <div class="flex-1 overflow-y-auto flex flex-col-reverse px-3 gap-2">
5
5
  <div v-for="_message in reversedMessages"
@@ -6,7 +6,7 @@
6
6
  <div class="flex flex-col self-stretch" :class="debug ? '' : ''">
7
7
 
8
8
  <div class="flex flex-row items-center">
9
- <div class="bg-primary-300 h-[1px]" :style="{ width:`${size[2]}px` }"></div>
9
+ <div class="h-[1px]" :class="item.parentId > 0 ? 'bg-primary-300' : ''" :style="{ width:`${size[2]}px` }"></div>
10
10
 
11
11
  <div :style="{ width:`${size[0]}px` }"
12
12
  ref="item"
@@ -14,7 +14,7 @@
14
14
  @mouseover="hoverMouseOver">
15
15
  <div class="rounded-xl p-3 border-[1px] flex relative overflow-hidden"
16
16
  :class="isSelected ? 'border-primary bg-base-500' : 'border-primary-300 bg-base-400'"
17
- @click="$emit('select', item)" :style="{ }">
17
+ @click="$emit('select', item)">
18
18
  <div class="flex-1 flex flex-row">
19
19
  <div class="flex-1 cursor-default whitespace-nowrap overflow-hidden text-ellipsis">
20
20
  {{ item.name }}
@@ -70,7 +70,7 @@
70
70
  :index="idx"
71
71
  :parent="item.items"
72
72
  :isLast="idx === item.items.length - 1"
73
- @select="(item) => $emit('select', item)"
73
+ @select="(item0) => $emit('select', item0)"
74
74
  @remove="item.items.splice(idx, 1)"
75
75
  :useAdd="idx === (item.items ?? []).length - 1"
76
76
  @add="addItem(item)" />
@@ -80,6 +80,7 @@
80
80
  <div v-if="level > 0 && index > 0" class="absolute w-[1px] bg-primary-300" :style="vBorder0"></div>
81
81
  <div v-if="level > 0 && !isLast" class="absolute w-[1px] bg-primary-300" :style="vBorder"></div>
82
82
 
83
+
83
84
  </div>
84
85
  </template>
85
86
 
@@ -218,6 +219,8 @@ export default{
218
219
 
219
220
  },
220
221
 
222
+ name: "UserActionItem",
223
+
221
224
  props: {
222
225
 
223
226
  config: Object,
@@ -6,7 +6,7 @@
6
6
  <label>Name</label>
7
7
  <Textbox v-model="instance.name" class="mt-2"/>
8
8
  </div>
9
- <div>
9
+ <div v-if="instance.parentId > 0">
10
10
  <label>Enabled</label>
11
11
  <Switch v-model="instance.enabled" class="mt-2"/>
12
12
  </div>
@@ -23,7 +23,7 @@
23
23
  </div>
24
24
  </div>
25
25
 
26
- <div>
26
+ <div v-if="instance.type === 1">
27
27
  <label>Event</label>
28
28
  <div class="flex flex-row gap-3 mt-2">
29
29
  <Dropdown v-model.number="instance.key" class="w-full">
@@ -43,7 +43,7 @@
43
43
  </button>
44
44
  </div>
45
45
  <ListItem :items="instance.conditions"
46
- class="mt-2 bg-transparent"
46
+ class="mt-2 bg-transparent border-[1px] border-text-200 rounded-xl overflow-hidden"
47
47
  container-class="flex flex-col gap-2"
48
48
  @reorder="(from, to) => { instance.conditions.splice(to, 0, instance.conditions.splice(from, 1)[0]); }">
49
49
  <template v-slot="{ item, index }">
@@ -53,7 +53,9 @@
53
53
  </div>
54
54
 
55
55
  <div class="flex-1 flex flex-row gap-2" @click="$refs.userActionCondition.open(item, _ => Object.assign(item, _))">
56
- {{ item }}
56
+ <label>{{ item.key }}</label>
57
+ <p class="text-text-400 flex-1 text-ellipsis whitespace-nowrap overflow-hidden">{{ item.op }}</p>
58
+ <p class="text-text-400 flex-1 text-ellipsis whitespace-nowrap overflow-hidden">{{ item.value }}</p>
57
59
  </div>
58
60
 
59
61
  <div>