bfg-common 1.5.508 → 1.5.510
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/CODE_STYLE.md +109 -109
- package/assets/img/icons/icons-sprite-dark-3.svg +227 -227
- package/assets/img/icons/icons-sprite-dark-5.svg +488 -488
- package/assets/img/icons/icons-sprite-light-3.svg +227 -227
- package/assets/img/icons/icons-sprite-light-5.svg +488 -488
- package/components/atoms/TheIcon3.vue +50 -50
- package/components/atoms/collapse/CollapseNav.vue +170 -170
- package/components/atoms/perPage/PerPage.vue +58 -58
- package/components/atoms/sortableView/SortableView.vue +528 -0
- package/components/atoms/table/dataGrid/DataGridPagination.vue +97 -97
- package/components/atoms/table/dataGrid/lib/config/settingsTable.ts +94 -94
- package/components/atoms/table/dataGrid/lib/utils/export.ts +16 -16
- package/components/common/backup/storage/actions/add/Add.vue +251 -251
- package/components/common/backup/storage/actions/add/lib/utils.ts +51 -51
- package/components/common/browse/blocks/contents/filesNew/Skeleton.vue +18 -18
- package/components/common/browse/blocks/lib/models/types.ts +1 -1
- package/components/common/browse/lib/models/interfaces.ts +5 -5
- package/components/common/diagramMain/network/Contents.vue +497 -497
- package/components/common/layout/theHeader/helpMenu/About.vue +79 -79
- package/components/common/layout/theHeader/helpMenu/aboutOld/AboutOld.vue +79 -79
- package/components/common/pages/backups/DetailView.vue +52 -52
- package/components/common/pages/backups/lib/models/interfaces.ts +36 -36
- package/components/common/pages/backups/modals/Modals.vue +243 -243
- package/components/common/pages/backups/modals/createBackup/configuration/Configuration.vue +29 -29
- package/components/common/pages/backups/modals/createBackup/configuration/maxBandwidth/lib/config/options.ts +6 -6
- package/components/common/pages/backups/modals/createBackup/datastores/tableView/TableView.vue +95 -95
- package/components/common/pages/backups/modals/createBackup/general/General.vue +141 -141
- package/components/common/pages/backups/modals/createBackup/lib/config/strategyOptions.ts +12 -12
- package/components/common/pages/backups/modals/lib/config/restore.ts +115 -115
- package/components/common/pages/backups/modals/lib/models/interfaces.ts +186 -186
- package/components/common/pages/backups/modals/restore/disks/Disks.vue +27 -27
- package/components/common/pages/backups/modals/restore/disks/tableView/lib/config/table.ts +117 -117
- package/components/common/pages/backups/modals/restore/name/Name.vue +166 -166
- package/components/common/pages/backups/modals/restore/name/lib/models/interfaces.ts +6 -6
- package/components/common/pages/backups/modals/restore/networks/Networks.vue +67 -67
- package/components/common/pages/backups/modals/restore/networks/table/Table.vue +214 -214
- package/components/common/pages/backups/modals/restore/types/lib/config/typeOptions.ts +25 -25
- package/components/common/pages/home/lib/models/interfaces.ts +48 -48
- package/components/common/pages/home/widgets/hosts/Hosts.vue +27 -27
- package/components/common/pages/home/widgets/hosts/lib/config/items.ts +23 -23
- package/components/common/pages/home/widgets/vms/VmsOld.vue +35 -35
- package/components/common/pages/home/widgets/vms/lib/config/items.ts +19 -19
- package/components/common/pages/scheduledTasks/lib/utils/utils.ts +84 -84
- package/components/common/readyToComplete/ReadyToComplete.vue +17 -17
- package/components/common/select/radio/RadioGroup.vue +137 -137
- package/components/common/spiceConsole/Drawer.vue +392 -419
- package/components/common/spiceConsole/SpiceConsole.vue +184 -184
- package/components/common/spiceConsole/lib/models/interfaces.ts +5 -5
- package/components/common/spiceConsole/lib/models/types.ts +0 -1
- package/components/common/tools/Actions.vue +207 -207
- package/components/common/treeView/TreeView.vue +52 -52
- package/components/common/vm/actions/add/Add.vue +895 -895
- package/components/common/vm/actions/add/New.vue +695 -695
- package/components/common/vm/actions/add/Old.vue +414 -414
- package/components/common/vm/actions/add/lib/config/steps.ts +347 -347
- package/components/common/vm/actions/clone/Clone.vue +863 -863
- package/components/common/vm/actions/common/customizeHardware/virtualHardware/cpu/Cpu.vue +368 -368
- package/components/common/vm/actions/common/customizeHardware/virtualHardware/cpu/shares/Shares.vue +140 -140
- package/components/common/vm/actions/common/customizeHardware/virtualHardware/cpu/shares/lib/config/options.ts +28 -28
- package/components/common/vm/actions/common/customizeHardware/virtualHardware/newHardDisk/location/Location.vue +154 -154
- package/components/common/vm/actions/common/customizeHardware/virtualHardware/newNetwork/location/new/table/Table.vue +99 -99
- package/components/common/vm/actions/common/customizeHardware/virtualHardware/newNetwork/macAddress/MacAddress.vue +119 -119
- package/components/common/vm/actions/common/customizeHardware/virtualHardware/newPciDevice/dynamicDirectPathIo/DynamicDirectPathIo.vue +31 -31
- package/components/common/vm/actions/common/customizeHardware/virtualHardware/other/Other.vue +16 -16
- package/components/common/vm/actions/common/customizeHardware/virtualHardware/videoCard/numberDisplays/NumberDisplays.vue +53 -53
- package/components/common/vm/actions/common/customizeHardware/vmoptions/bootOptions/delay/Delay.vue +32 -32
- package/components/common/vm/actions/common/customizeHardware/vmoptions/bootOptions/firmware/Firmware.vue +60 -60
- package/components/common/vm/actions/common/customizeHardware/vmoptions/bootOptions/order/Order.vue +174 -174
- package/components/common/vm/actions/common/customizeHardware/vmoptions/remoteConsoleOptions/keymap/Keymap.vue +32 -32
- package/components/common/vm/actions/common/customizeHardware/vmoptions/remoteConsoleOptions/password/Password.vue +103 -103
- package/components/common/vm/actions/common/customizeHardware/vmoptions/remoteConsoleOptions/usbRedirection/UsbRedirection.vue +28 -28
- package/components/common/vm/actions/common/select/compatibility/Old.vue +107 -107
- package/components/common/vm/actions/common/select/computeResource/ComputeResource.vue +143 -143
- package/components/common/vm/actions/common/select/computeResource/New.vue +184 -184
- package/components/common/vm/actions/common/select/computeResource/treeView/TreeView.vue +131 -131
- package/components/common/vm/actions/common/select/createType/CreateType.vue +38 -38
- package/components/common/vm/actions/common/select/createType/lib/models/interfaces.ts +5 -5
- package/components/common/vm/actions/common/select/os/Old.vue +152 -152
- package/components/common/vm/actions/common/select/os/Os.vue +139 -139
- package/components/common/vm/actions/common/select/storage/new/New.vue +320 -320
- package/components/common/vm/actions/common/select/storage/new/lib/models/interfaces.ts +5 -5
- package/components/common/vm/actions/common/select/storage/new/lib/utils/utils.ts +21 -21
- package/components/common/vm/actions/common/select/template/old/Old.vue +50 -50
- package/components/common/vm/actions/editSettings/new/Skeleton.vue +88 -88
- package/components/common/vm/actions/register/Register.vue +285 -285
- package/components/common/vm/actions/register/lib/config/steps.ts +86 -86
- package/components/common/wizards/common/steps/name/Name.vue +179 -179
- package/components/common/wizards/common/steps/name/New.vue +221 -221
- package/components/common/wizards/common/steps/name/Old.vue +121 -121
- package/components/common/wizards/common/steps/name/lib/models/interfaces.ts +4 -4
- package/components/common/wizards/common/steps/name/location/Location.vue +85 -85
- package/components/common/wizards/common/steps/name/location/New.vue +40 -40
- package/components/common/wizards/datastore/add/Add.vue +228 -228
- package/components/common/wizards/datastore/add/lib/utils.ts +85 -85
- package/components/common/wizards/datastore/add/steps/typeMode/lib/config/typeOptions.ts +43 -43
- package/components/common/wizards/vm/migrate/select/network/Network.vue +103 -103
- package/composables/useAppVersion.ts +21 -21
- package/composables/useLocal.ts +6 -6
- package/composables/useLocalCommon.ts +39 -39
- package/package.json +2 -2
- package/plugins/console.ts +22 -21
- package/plugins/date.ts +233 -233
- package/plugins/panelStates.ts +70 -70
- package/plugins/text.ts +59 -59
- package/public/spice-console/lib/images/bitmap.js +203 -203
- package/public/spice-console/network/spicechannel.js +440 -440
- package/public/spice-console/process/inputprocess.js +203 -227
- package/public/spice-console/process/mainprocess.js +78 -82
- package/public/spice-console/run.js +210 -210
- package/public/spice-console-minify/run.min.js +1 -1
- package/store/main/mutations.ts +7 -7
- package/store/main/state.ts +7 -7
- package/plugins/mouse.ts +0 -21
|
@@ -0,0 +1,528 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div :style="{ height: portletsContainerHeight }" class="portlets">
|
|
3
|
+
<div class="col drop-zone drop-zone-1">
|
|
4
|
+
<template v-for="item in firstCol" :key="item.id">
|
|
5
|
+
<div
|
|
6
|
+
v-if="visibleDropAreaId === `before-${item.id}`"
|
|
7
|
+
:class="[
|
|
8
|
+
'drop-area',
|
|
9
|
+
themeMode,
|
|
10
|
+
{ 'selected-drop-area': !!visibleDropAreaId },
|
|
11
|
+
]"
|
|
12
|
+
data-position="before"
|
|
13
|
+
></div>
|
|
14
|
+
<div
|
|
15
|
+
:id="`item-${item.id}`"
|
|
16
|
+
:class="['portlet-js portlet-container', themeMode]"
|
|
17
|
+
:data-id="item.id"
|
|
18
|
+
:style="item.id === draggedPortletId && style"
|
|
19
|
+
@mousedown.prevent.stop="onmousedown($event, item)"
|
|
20
|
+
>
|
|
21
|
+
<slot :portlet-id="item.id"></slot>
|
|
22
|
+
</div>
|
|
23
|
+
<div
|
|
24
|
+
v-if="visibleDropAreaId === `after-${item.id}`"
|
|
25
|
+
:class="[
|
|
26
|
+
'drop-area',
|
|
27
|
+
themeMode,
|
|
28
|
+
{ 'selected-drop-area': !!visibleDropAreaId },
|
|
29
|
+
]"
|
|
30
|
+
data-position="after"
|
|
31
|
+
></div>
|
|
32
|
+
</template>
|
|
33
|
+
<div
|
|
34
|
+
v-if="isShowDropAreaFirstCol"
|
|
35
|
+
:class="[
|
|
36
|
+
'drop-area',
|
|
37
|
+
themeMode,
|
|
38
|
+
{ 'selected-drop-area': !!visibleDropAreaId },
|
|
39
|
+
]"
|
|
40
|
+
data-position="after"
|
|
41
|
+
></div>
|
|
42
|
+
</div>
|
|
43
|
+
|
|
44
|
+
<div class="col drop-zone drop-zone-2">
|
|
45
|
+
<template v-for="item in secondCol" :key="item.id">
|
|
46
|
+
<div
|
|
47
|
+
v-if="visibleDropAreaId === `before-${item.id}`"
|
|
48
|
+
:class="[
|
|
49
|
+
'drop-area',
|
|
50
|
+
themeMode,
|
|
51
|
+
{ 'selected-drop-area': !!visibleDropAreaId },
|
|
52
|
+
]"
|
|
53
|
+
data-position="before"
|
|
54
|
+
></div>
|
|
55
|
+
<div
|
|
56
|
+
:id="`item-${item.id}`"
|
|
57
|
+
:class="['portlet-js portlet-container', themeMode]"
|
|
58
|
+
:data-id="item.id"
|
|
59
|
+
:style="item.id === draggedPortletId && style"
|
|
60
|
+
@mousedown.prevent.stop="onmousedown($event, item)"
|
|
61
|
+
>
|
|
62
|
+
<slot :portlet-id="item.id"></slot>
|
|
63
|
+
</div>
|
|
64
|
+
<div
|
|
65
|
+
v-if="visibleDropAreaId === `after-${item.id}`"
|
|
66
|
+
:class="[
|
|
67
|
+
'drop-area',
|
|
68
|
+
themeMode,
|
|
69
|
+
{ 'selected-drop-area': !!visibleDropAreaId },
|
|
70
|
+
]"
|
|
71
|
+
data-position="after"
|
|
72
|
+
></div>
|
|
73
|
+
</template>
|
|
74
|
+
<div
|
|
75
|
+
v-if="isShowDropAreaSecondCol"
|
|
76
|
+
:class="[
|
|
77
|
+
'drop-area',
|
|
78
|
+
themeMode,
|
|
79
|
+
{ 'selected-drop-area': !!visibleDropAreaId },
|
|
80
|
+
]"
|
|
81
|
+
data-position="after"
|
|
82
|
+
></div>
|
|
83
|
+
</div>
|
|
84
|
+
</div>
|
|
85
|
+
</template>
|
|
86
|
+
|
|
87
|
+
<script setup lang="ts">
|
|
88
|
+
import type {
|
|
89
|
+
UI_T_PortletsList,
|
|
90
|
+
UI_T_ExpectedHTMLElement,
|
|
91
|
+
} from '~/node_modules/bfg-uikit/components/ui/portlet/lib/models/types'
|
|
92
|
+
import type {
|
|
93
|
+
UI_I_Style,
|
|
94
|
+
UI_I_Portlet,
|
|
95
|
+
UI_I_DropArea,
|
|
96
|
+
} from '~/node_modules/bfg-uikit/components/ui/portlet/lib/models/interfaces'
|
|
97
|
+
import { UI_E_Position } from '~/node_modules/bfg-uikit/components/ui/portlet/lib/models/enums'
|
|
98
|
+
|
|
99
|
+
const props = withDefaults(
|
|
100
|
+
defineProps<{
|
|
101
|
+
name: string
|
|
102
|
+
portlets: UI_I_Portlet[]
|
|
103
|
+
updatable?: boolean
|
|
104
|
+
}>(),
|
|
105
|
+
{
|
|
106
|
+
updatable: undefined,
|
|
107
|
+
}
|
|
108
|
+
)
|
|
109
|
+
const emits = defineEmits<{
|
|
110
|
+
(event: 'update'): void
|
|
111
|
+
}>()
|
|
112
|
+
|
|
113
|
+
const { $store }: any = useNuxtApp()
|
|
114
|
+
|
|
115
|
+
const portletsLocal = ref<UI_I_Portlet[]>([])
|
|
116
|
+
|
|
117
|
+
const setPortlets = (): void => {
|
|
118
|
+
portletsLocal.value = useDeepCopy(
|
|
119
|
+
props.portlets.map((portlet: UI_I_Portlet) => ({
|
|
120
|
+
...portlet,
|
|
121
|
+
isDragged: false,
|
|
122
|
+
}))
|
|
123
|
+
)
|
|
124
|
+
}
|
|
125
|
+
setPortlets()
|
|
126
|
+
|
|
127
|
+
const themeMode = computed<string>(
|
|
128
|
+
() => $store.getters['main/getThemeMode'] || useLocalStorage('themeMode')
|
|
129
|
+
)
|
|
130
|
+
|
|
131
|
+
watch(
|
|
132
|
+
() => props.portlets,
|
|
133
|
+
(newValue: UI_I_Portlet[]) => {
|
|
134
|
+
if (newValue.length) setPortlets()
|
|
135
|
+
}
|
|
136
|
+
)
|
|
137
|
+
|
|
138
|
+
const containerHeight = ref<number | null>(null)
|
|
139
|
+
|
|
140
|
+
const draggedPortletId = ref<string>('')
|
|
141
|
+
const visibleDropAreaId = ref<string>('')
|
|
142
|
+
const style = ref<UI_I_Style>({})
|
|
143
|
+
const dropArea = ref<UI_I_DropArea>({
|
|
144
|
+
id: '-1',
|
|
145
|
+
position: 'initial',
|
|
146
|
+
list: 0,
|
|
147
|
+
})
|
|
148
|
+
|
|
149
|
+
const firstCol = computed<UI_I_Portlet[]>(() =>
|
|
150
|
+
portletsLocal.value.filter((portlet: UI_I_Portlet) => portlet.list === 1)
|
|
151
|
+
)
|
|
152
|
+
|
|
153
|
+
const secondCol = computed<UI_I_Portlet[]>(() =>
|
|
154
|
+
portletsLocal.value.filter((portlet: UI_I_Portlet) => portlet.list === 2)
|
|
155
|
+
)
|
|
156
|
+
|
|
157
|
+
let portletHTMLElement: UI_T_ExpectedHTMLElement = null
|
|
158
|
+
|
|
159
|
+
const isShowDropAreaFirstCol = computed<boolean>(() => {
|
|
160
|
+
return (
|
|
161
|
+
visibleDropAreaId.value === 'after-list-1' &&
|
|
162
|
+
(!firstCol.value.length ||
|
|
163
|
+
(firstCol.value.length === 1 &&
|
|
164
|
+
firstCol.value[0].id === draggedPortletId.value))
|
|
165
|
+
)
|
|
166
|
+
})
|
|
167
|
+
|
|
168
|
+
const isShowDropAreaSecondCol = computed<boolean>(() => {
|
|
169
|
+
return (
|
|
170
|
+
visibleDropAreaId.value === 'after-list-2' &&
|
|
171
|
+
(!secondCol.value.length ||
|
|
172
|
+
(secondCol.value.length === 1 &&
|
|
173
|
+
secondCol.value[0].id === draggedPortletId.value))
|
|
174
|
+
)
|
|
175
|
+
})
|
|
176
|
+
|
|
177
|
+
const addStyles = (styles: UI_I_Style): void => {
|
|
178
|
+
style.value = {
|
|
179
|
+
...style.value,
|
|
180
|
+
...styles,
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
const removeStyles = (): void => {
|
|
184
|
+
style.value = null
|
|
185
|
+
}
|
|
186
|
+
const setDragStartedPortletById = (id: string): void => {
|
|
187
|
+
portletsLocal.value = portletsLocal.value.map((portlet: UI_I_Portlet) =>
|
|
188
|
+
portlet.id === id ? { ...portlet, isDragged: true } : portlet
|
|
189
|
+
)
|
|
190
|
+
}
|
|
191
|
+
const setDragStoppedPortletById = (id: string): void => {
|
|
192
|
+
portletsLocal.value = portletsLocal.value.map((portlet: UI_I_Portlet) =>
|
|
193
|
+
portlet.id === id ? { ...portlet, isDragged: false } : portlet
|
|
194
|
+
)
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
const getPortletIndexById = (draggedPortletId: string): number =>
|
|
198
|
+
portletsLocal.value.findIndex(
|
|
199
|
+
(portlet: UI_I_Portlet) => portlet.id === draggedPortletId
|
|
200
|
+
)
|
|
201
|
+
|
|
202
|
+
const makeDropAreaById = (id: string, position: string): void => {
|
|
203
|
+
visibleDropAreaId.value = `${position}-${id}`
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
const setDropAreaData = (
|
|
207
|
+
id: string,
|
|
208
|
+
position: string,
|
|
209
|
+
list: UI_T_PortletsList
|
|
210
|
+
): void => {
|
|
211
|
+
dropArea.value = {
|
|
212
|
+
id,
|
|
213
|
+
position,
|
|
214
|
+
list,
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
const moveAt = (
|
|
219
|
+
pageX: number,
|
|
220
|
+
pageY: number,
|
|
221
|
+
shiftX: number,
|
|
222
|
+
shiftY: number
|
|
223
|
+
): void => {
|
|
224
|
+
addStyles({
|
|
225
|
+
left: pageX - shiftX + 'px',
|
|
226
|
+
top: pageY - shiftY + 'px',
|
|
227
|
+
})
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
const portletsContainerHeight = computed<string | null>(() =>
|
|
231
|
+
containerHeight.value ? `${containerHeight.value}px` : null
|
|
232
|
+
)
|
|
233
|
+
|
|
234
|
+
const isDraggableAreaOnPortlet = (
|
|
235
|
+
eventTarget: HTMLElement
|
|
236
|
+
): boolean | undefined =>
|
|
237
|
+
eventTarget.classList.contains('portlet-titlebar') ||
|
|
238
|
+
eventTarget.parentElement?.classList.contains('portlet-titlebar')
|
|
239
|
+
|
|
240
|
+
const setPortletsInLocalStorage = (
|
|
241
|
+
name: string,
|
|
242
|
+
value: UI_I_Portlet[]
|
|
243
|
+
): void => {
|
|
244
|
+
useLocalStorage(`${name}-portlets-positions`, value)
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
const reset = (): void => {
|
|
248
|
+
visibleDropAreaId.value = ''
|
|
249
|
+
draggedPortletId.value = ''
|
|
250
|
+
isTranslated = false
|
|
251
|
+
shiftX = 0
|
|
252
|
+
shiftY = 0
|
|
253
|
+
dropArea.value = {
|
|
254
|
+
id: '-1',
|
|
255
|
+
position: 'initial',
|
|
256
|
+
list: 0,
|
|
257
|
+
}
|
|
258
|
+
portletHTMLElement = null
|
|
259
|
+
containerHeight.value = null
|
|
260
|
+
window.onmousemove = null
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
let isUpdatable = false
|
|
264
|
+
let isTranslated = false
|
|
265
|
+
let shiftX: number
|
|
266
|
+
let shiftY: number
|
|
267
|
+
let downClientX: number
|
|
268
|
+
let downClientY: number
|
|
269
|
+
const styles = ref<CSSStyleDeclaration | null>(null)
|
|
270
|
+
|
|
271
|
+
const onmousedown = (
|
|
272
|
+
downEvent: MouseEvent,
|
|
273
|
+
portletItem: UI_I_Portlet
|
|
274
|
+
): void => {
|
|
275
|
+
const containerElement: HTMLElement | null =
|
|
276
|
+
document.querySelector('.portlets')
|
|
277
|
+
containerHeight.value = containerElement
|
|
278
|
+
? containerElement?.clientHeight
|
|
279
|
+
: null
|
|
280
|
+
|
|
281
|
+
portletHTMLElement = document.querySelector(
|
|
282
|
+
`#item-${portletItem.id}`
|
|
283
|
+
) as HTMLElement
|
|
284
|
+
|
|
285
|
+
const eventTarget: HTMLElement = downEvent.target as HTMLElement
|
|
286
|
+
|
|
287
|
+
if (!portletHTMLElement || !isDraggableAreaOnPortlet(eventTarget)) return
|
|
288
|
+
styles.value = getComputedStyle(portletHTMLElement)
|
|
289
|
+
setDragStartedPortletById(portletItem.id)
|
|
290
|
+
|
|
291
|
+
const { left, top } = portletHTMLElement.getBoundingClientRect()
|
|
292
|
+
downClientX = downEvent.clientX
|
|
293
|
+
downClientY = downEvent.clientY
|
|
294
|
+
shiftX = downEvent.clientX - left
|
|
295
|
+
shiftY = downEvent.clientY - top
|
|
296
|
+
|
|
297
|
+
draggedPortletId.value = portletItem.id
|
|
298
|
+
|
|
299
|
+
moveAt(downEvent.pageX, downEvent.pageY, shiftX, shiftY)
|
|
300
|
+
window.onmousemove = (ev): void => onmousemove(ev, portletItem.id)
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
let onmousemove = (moveEvent: MouseEvent, currentPortletId: string): void => {
|
|
304
|
+
moveEvent.stopPropagation()
|
|
305
|
+
moveEvent.preventDefault()
|
|
306
|
+
moveEvent.cancelBubble = true
|
|
307
|
+
|
|
308
|
+
if (
|
|
309
|
+
isTranslated ||
|
|
310
|
+
Math.abs(downClientX - moveEvent.clientX) > 10 ||
|
|
311
|
+
Math.abs(downClientY - moveEvent.clientY) > 10
|
|
312
|
+
) {
|
|
313
|
+
if (!isTranslated && styles.value.width && styles.value.height) {
|
|
314
|
+
addStyles({
|
|
315
|
+
width: styles.value.width,
|
|
316
|
+
height: styles.value.height,
|
|
317
|
+
position: 'fixed',
|
|
318
|
+
zIndex: '1000',
|
|
319
|
+
transform: 'translateX(10px)',
|
|
320
|
+
cursor: 'move',
|
|
321
|
+
})
|
|
322
|
+
|
|
323
|
+
makeDropAreaById(currentPortletId, 'before')
|
|
324
|
+
isTranslated = true
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
moveAt(moveEvent.pageX, moveEvent.pageY, shiftX, shiftY)
|
|
328
|
+
|
|
329
|
+
if (!portletHTMLElement) {
|
|
330
|
+
reset()
|
|
331
|
+
return
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
portletHTMLElement.hidden = true
|
|
335
|
+
const caughtElement: UI_T_ExpectedHTMLElement = document.elementFromPoint(
|
|
336
|
+
moveEvent.clientX,
|
|
337
|
+
moveEvent.clientY
|
|
338
|
+
) as HTMLElement
|
|
339
|
+
portletHTMLElement.hidden = false
|
|
340
|
+
const caughtPortletElement: UI_T_ExpectedHTMLElement =
|
|
341
|
+
caughtElement?.closest('.portlet-js')
|
|
342
|
+
const caughtListElement: UI_T_ExpectedHTMLElement =
|
|
343
|
+
caughtElement?.closest('.drop-zone')
|
|
344
|
+
const list = caughtListElement?.classList.contains('drop-zone-1') ? 1 : 2
|
|
345
|
+
|
|
346
|
+
const container: UI_T_ExpectedHTMLElement =
|
|
347
|
+
document.querySelector('.content')
|
|
348
|
+
|
|
349
|
+
const boundingRect = container?.getBoundingClientRect()
|
|
350
|
+
let scrollTop = container?.scrollTop as number
|
|
351
|
+
const scrollHeight = container?.scrollHeight as number
|
|
352
|
+
const clientHeight = container?.clientHeight as number
|
|
353
|
+
|
|
354
|
+
if (container && boundingRect) {
|
|
355
|
+
if (boundingRect.top + 20 > moveEvent.pageY && scrollTop > 0) {
|
|
356
|
+
const nextScroll: number = scrollTop - 200
|
|
357
|
+
container?.scrollTo({
|
|
358
|
+
top: scrollTop === 0 ? 0 : nextScroll,
|
|
359
|
+
behavior: 'smooth',
|
|
360
|
+
})
|
|
361
|
+
scrollTop = nextScroll
|
|
362
|
+
}
|
|
363
|
+
if (boundingRect.bottom - 20 < moveEvent.pageY) {
|
|
364
|
+
const nextScroll: number = scrollTop + clientHeight + 200
|
|
365
|
+
scrollTop = nextScroll > scrollHeight ? scrollHeight : nextScroll
|
|
366
|
+
container?.scrollTo({ top: scrollTop, behavior: 'smooth' })
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
const portletsInCaughtList: UI_I_Portlet[] = portletsLocal.value.filter(
|
|
371
|
+
(el: UI_I_Portlet) => el.list === list
|
|
372
|
+
)
|
|
373
|
+
const hasNotPortletInList = !portletsInCaughtList.length
|
|
374
|
+
const isOnlyOneMemberOfList =
|
|
375
|
+
portletsInCaughtList.length === 1 &&
|
|
376
|
+
portletsInCaughtList[0].id === currentPortletId
|
|
377
|
+
|
|
378
|
+
if (caughtPortletElement && caughtListElement) {
|
|
379
|
+
const fromTopToMouseY = moveEvent.clientY
|
|
380
|
+
const fromTopToElementY = caughtPortletElement.getClientRects().item(0)?.y
|
|
381
|
+
|
|
382
|
+
const elementHeight = caughtPortletElement.offsetHeight
|
|
383
|
+
const caughtPortletId = caughtPortletElement.dataset.id
|
|
384
|
+
|
|
385
|
+
if (fromTopToElementY && caughtPortletId) {
|
|
386
|
+
if (fromTopToMouseY - fromTopToElementY < elementHeight / 2) {
|
|
387
|
+
makeDropAreaById(caughtPortletId, 'before')
|
|
388
|
+
setDropAreaData(caughtPortletId, 'before', list)
|
|
389
|
+
} else {
|
|
390
|
+
makeDropAreaById(caughtPortletId, 'after')
|
|
391
|
+
setDropAreaData(caughtPortletId, 'after', list)
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
} else if (
|
|
395
|
+
caughtListElement &&
|
|
396
|
+
(hasNotPortletInList || isOnlyOneMemberOfList)
|
|
397
|
+
) {
|
|
398
|
+
makeDropAreaById(`list-${list}`, 'after')
|
|
399
|
+
setDropAreaData('3', 'after', list)
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
onmousemove = useThrottle(onmousemove)
|
|
404
|
+
|
|
405
|
+
const dropPortlet = (
|
|
406
|
+
position: UI_E_Position,
|
|
407
|
+
indexOfDraggedPortlet: number,
|
|
408
|
+
dropAreaId: string,
|
|
409
|
+
dropAreaList: UI_T_PortletsList
|
|
410
|
+
): void => {
|
|
411
|
+
const splicedData: UI_I_Portlet = portletsLocal.value.splice(
|
|
412
|
+
indexOfDraggedPortlet,
|
|
413
|
+
1
|
|
414
|
+
)[0]
|
|
415
|
+
const indexOfDropArea = getPortletIndexById(dropAreaId)
|
|
416
|
+
portletsLocal.value.splice(indexOfDropArea + position, 0, {
|
|
417
|
+
...splicedData,
|
|
418
|
+
list: dropAreaList,
|
|
419
|
+
})
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
const onmouseup = (_event: MouseEvent): void => {
|
|
423
|
+
const dropAreaPosition = dropArea.value.position
|
|
424
|
+
const dropAreaId = dropArea.value.id
|
|
425
|
+
const dropAreaList = dropArea.value.list
|
|
426
|
+
|
|
427
|
+
if (!draggedPortletId.value) {
|
|
428
|
+
window.onmousemove = null
|
|
429
|
+
reset()
|
|
430
|
+
return
|
|
431
|
+
}
|
|
432
|
+
if (dropAreaPosition !== 'initial') {
|
|
433
|
+
const indexOfDraggedPortlet = getPortletIndexById(draggedPortletId.value)
|
|
434
|
+
const hasNotPortletArea = !portletsLocal.value.find(
|
|
435
|
+
(portlet: UI_I_Portlet) => portlet.list === dropAreaList
|
|
436
|
+
)
|
|
437
|
+
if (hasNotPortletArea)
|
|
438
|
+
portletsLocal.value = portletsLocal.value.map((portlet: UI_I_Portlet) =>
|
|
439
|
+
portlet.id === draggedPortletId.value
|
|
440
|
+
? {
|
|
441
|
+
...portlet,
|
|
442
|
+
list: dropAreaList,
|
|
443
|
+
}
|
|
444
|
+
: portlet
|
|
445
|
+
)
|
|
446
|
+
|
|
447
|
+
dropAreaPosition === 'before' &&
|
|
448
|
+
dropPortlet(
|
|
449
|
+
UI_E_Position.BEFORE,
|
|
450
|
+
indexOfDraggedPortlet,
|
|
451
|
+
dropAreaId,
|
|
452
|
+
dropAreaList
|
|
453
|
+
)
|
|
454
|
+
dropAreaPosition === 'after' &&
|
|
455
|
+
dropPortlet(
|
|
456
|
+
UI_E_Position.AFTER,
|
|
457
|
+
indexOfDraggedPortlet,
|
|
458
|
+
dropAreaId,
|
|
459
|
+
dropAreaList
|
|
460
|
+
)
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
isUpdatable = true
|
|
464
|
+
removeStyles()
|
|
465
|
+
setDragStoppedPortletById(draggedPortletId.value)
|
|
466
|
+
reset()
|
|
467
|
+
setPortletsInLocalStorage(props.name, portletsLocal.value)
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
onUpdated(() => {
|
|
471
|
+
if (!props.updatable) return
|
|
472
|
+
|
|
473
|
+
isUpdatable && emits('update')
|
|
474
|
+
isUpdatable = false
|
|
475
|
+
})
|
|
476
|
+
|
|
477
|
+
onMounted(() => {
|
|
478
|
+
document.addEventListener('mouseup', onmouseup)
|
|
479
|
+
})
|
|
480
|
+
|
|
481
|
+
onUnmounted(() => {
|
|
482
|
+
document.removeEventListener('mouseup', onmouseup)
|
|
483
|
+
})
|
|
484
|
+
</script>
|
|
485
|
+
|
|
486
|
+
<style scoped lang="scss">
|
|
487
|
+
.portlets {
|
|
488
|
+
display: grid;
|
|
489
|
+
grid-template-columns: 1fr 1fr;
|
|
490
|
+
column-gap: 10px;
|
|
491
|
+
margin-top: 10px;
|
|
492
|
+
|
|
493
|
+
.col {
|
|
494
|
+
width: 100%;
|
|
495
|
+
|
|
496
|
+
.portlet-container.dark-theme {
|
|
497
|
+
background-color: #1b2a32;
|
|
498
|
+
border-radius: 3px;
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
.health-status {
|
|
502
|
+
&__item {
|
|
503
|
+
display: grid;
|
|
504
|
+
grid-template-columns: 14px 40% 60%;
|
|
505
|
+
}
|
|
506
|
+
&__heading {
|
|
507
|
+
color: var(--global-text-color3) !important;
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
.drop-area {
|
|
512
|
+
box-sizing: border-box;
|
|
513
|
+
width: 100%;
|
|
514
|
+
height: 35px;
|
|
515
|
+
border: 1px solid #e7e7e7;
|
|
516
|
+
background-color: #f2f8fc;
|
|
517
|
+
border-radius: 4px;
|
|
518
|
+
margin: 0 0 12px;
|
|
519
|
+
|
|
520
|
+
&.dark-theme {
|
|
521
|
+
border: 1px solid black;
|
|
522
|
+
background-color: #f2f8fc;
|
|
523
|
+
opacity: 0.5;
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
</style>
|