mirror of
				https://github.com/Fabio286/antares.git
				synced 2025-06-05 21:59:22 +02:00 
			
		
		
		
	refactor: ts and composition api for base components
This commit is contained in:
		| @@ -46,14 +46,12 @@ | |||||||
|    </div> |    </div> | ||||||
| </template> | </template> | ||||||
|  |  | ||||||
| <script lang="ts"> | <script setup lang="ts"> | ||||||
| import { computed, defineComponent, onBeforeUnmount } from 'vue'; | import { computed, onBeforeUnmount, PropType, useSlots } from 'vue'; | ||||||
|  |  | ||||||
| export default defineComponent({ | const props = defineProps({ | ||||||
|    name: 'BaseConfirmModal', |  | ||||||
|    props: { |  | ||||||
|    size: { |    size: { | ||||||
|          type: String, |       type: String as PropType<'small' | 'medium' | '400' | 'large'>, | ||||||
|       validator: (prop: string) => ['small', 'medium', '400', 'large'].includes(prop), |       validator: (prop: string) => ['small', 'medium', '400', 'large'].includes(prop), | ||||||
|       default: 'small' |       default: 'small' | ||||||
|    }, |    }, | ||||||
| @@ -63,9 +61,10 @@ export default defineComponent({ | |||||||
|    }, |    }, | ||||||
|    confirmText: String, |    confirmText: String, | ||||||
|    cancelText: String |    cancelText: String | ||||||
|    }, | }); | ||||||
|    emits: ['confirm', 'hide'], | const emit = defineEmits(['confirm', 'hide']); | ||||||
|    setup (props, { slots, emit }) { | const slots = useSlots(); | ||||||
|  |  | ||||||
| const hasHeader = computed(() => !!slots.header); | const hasHeader = computed(() => !!slots.header); | ||||||
| const hasBody = computed(() => !!slots.body); | const hasBody = computed(() => !!slots.body); | ||||||
| const hasDefault = computed(() => !!slots.default); | const hasDefault = computed(() => !!slots.default); | ||||||
| @@ -99,18 +98,6 @@ export default defineComponent({ | |||||||
| onBeforeUnmount(() => { | onBeforeUnmount(() => { | ||||||
|    window.removeEventListener('keydown', onKey); |    window.removeEventListener('keydown', onKey); | ||||||
| }); | }); | ||||||
|  |  | ||||||
|       return { |  | ||||||
|          hasHeader, |  | ||||||
|          hasBody, |  | ||||||
|          hasDefault, |  | ||||||
|          modalSizeClass, |  | ||||||
|          confirmModal, |  | ||||||
|          hideModal, |  | ||||||
|          onKey |  | ||||||
|       }; |  | ||||||
|    } |  | ||||||
| }); |  | ||||||
| </script> | </script> | ||||||
|  |  | ||||||
| <style scoped> | <style scoped> | ||||||
|   | |||||||
| @@ -15,37 +15,32 @@ | |||||||
|    </div> |    </div> | ||||||
| </template> | </template> | ||||||
|  |  | ||||||
| <script> | <script setup lang="ts"> | ||||||
| export default { | import { computed, onBeforeUnmount, onMounted, Ref, ref } from 'vue'; | ||||||
|    name: 'BaseContextMenu', |  | ||||||
|    props: { |  | ||||||
|       contextEvent: MouseEvent |  | ||||||
|    }, |  | ||||||
|    emits: ['close-context'], |  | ||||||
|    data () { |  | ||||||
|       return { |  | ||||||
|          contextSize: null, |  | ||||||
|          isBottom: false |  | ||||||
|       }; |  | ||||||
|    }, |  | ||||||
|    computed: { |  | ||||||
|       position () { |  | ||||||
|          let topCord = 0; |  | ||||||
|          let leftCord = 0; |  | ||||||
|  |  | ||||||
|          if (this.contextEvent) { | const contextContent: Ref<HTMLDivElement> = ref(null); | ||||||
|             const { clientY, clientX } = this.contextEvent; | const contextSize: Ref<DOMRect> = ref(null); | ||||||
|  | const isBottom: Ref<boolean> = ref(false); | ||||||
|  | const props = defineProps<{contextEvent: MouseEvent}>(); | ||||||
|  | const emit = defineEmits(['close-context']); | ||||||
|  |  | ||||||
|  | const position = computed(() => { | ||||||
|  |    let topCord = '0px'; | ||||||
|  |    let leftCord = '0px'; | ||||||
|  |  | ||||||
|  |    if (props.contextEvent) { | ||||||
|  |       const { clientY, clientX } = props.contextEvent; | ||||||
|       topCord = `${clientY + 2}px`; |       topCord = `${clientY + 2}px`; | ||||||
|       leftCord = `${clientX + 5}px`; |       leftCord = `${clientX + 5}px`; | ||||||
|  |  | ||||||
|             if (this.contextSize) { |       if (contextSize.value) { | ||||||
|                if (clientY + (this.contextSize.height < 200 ? 200 : this.contextSize.height) + 5 >= window.innerHeight) { |          if (clientY + (contextSize.value.height < 200 ? 200 : contextSize.value.height) + 5 >= window.innerHeight) { | ||||||
|                   topCord = `${clientY + 3 - this.contextSize.height}px`; |             topCord = `${clientY + 3 - contextSize.value.height}px`; | ||||||
|                   this.isBottom = true; |             isBottom.value = true; | ||||||
|          } |          } | ||||||
|  |  | ||||||
|                if (clientX + this.contextSize.width + 5 >= window.innerWidth) |          if (clientX + contextSize.value.width + 5 >= window.innerWidth) | ||||||
|                   leftCord = `${clientX - this.contextSize.width}px`; |             leftCord = `${clientX - contextSize.value.width}px`; | ||||||
|       } |       } | ||||||
|    } |    } | ||||||
|  |  | ||||||
| @@ -53,29 +48,27 @@ export default { | |||||||
|       top: topCord, |       top: topCord, | ||||||
|       left: leftCord |       left: leftCord | ||||||
|    }; |    }; | ||||||
|       } | }); | ||||||
|    }, |  | ||||||
|    created () { | const close = () => { | ||||||
|       window.addEventListener('keydown', this.onKey); |    emit('close-context'); | ||||||
|    }, | }; | ||||||
|    mounted () { | const onKey = (e: KeyboardEvent) => { | ||||||
|       if (this.$refs.contextContent) |  | ||||||
|          this.contextSize = this.$refs.contextContent.getBoundingClientRect(); |  | ||||||
|    }, |  | ||||||
|    beforeUnmount () { |  | ||||||
|       window.removeEventListener('keydown', this.onKey); |  | ||||||
|    }, |  | ||||||
|    methods: { |  | ||||||
|       close () { |  | ||||||
|          this.$emit('close-context'); |  | ||||||
|       }, |  | ||||||
|       onKey (e) { |  | ||||||
|    e.stopPropagation(); |    e.stopPropagation(); | ||||||
|    if (e.key === 'Escape') |    if (e.key === 'Escape') | ||||||
|             this.close(); |       close(); | ||||||
|       } |  | ||||||
|    } |  | ||||||
| }; | }; | ||||||
|  |  | ||||||
|  | window.addEventListener('keydown', onKey); | ||||||
|  |  | ||||||
|  | onMounted(() => { | ||||||
|  |    if (contextContent.value) | ||||||
|  |       contextSize.value = contextContent.value.getBoundingClientRect(); | ||||||
|  | }); | ||||||
|  |  | ||||||
|  | onBeforeUnmount(() => { | ||||||
|  |    window.removeEventListener('keydown', onKey); | ||||||
|  | }); | ||||||
| </script> | </script> | ||||||
|  |  | ||||||
| <style lang="scss"> | <style lang="scss"> | ||||||
|   | |||||||
| @@ -4,11 +4,6 @@ | |||||||
|    </div> |    </div> | ||||||
| </template> | </template> | ||||||
|  |  | ||||||
| <script> |  | ||||||
| export default { |  | ||||||
|    name: 'BaseLoader' |  | ||||||
| }; |  | ||||||
| </script> |  | ||||||
| <style scoped> | <style scoped> | ||||||
| .empty { | .empty { | ||||||
|   position: absolute; |   position: absolute; | ||||||
|   | |||||||
| @@ -1,50 +1,61 @@ | |||||||
| <template> | <template> | ||||||
|    <div id="map" class="map" /> |    <div id="map" class="map" /> | ||||||
| </template> | </template> | ||||||
| <script> |  | ||||||
| import L from 'leaflet'; | <script setup lang="ts"> | ||||||
|  | import { onMounted, PropType, Ref, ref } from 'vue'; | ||||||
|  | import * as L from 'leaflet'; | ||||||
| import { | import { | ||||||
|    point, |    point, | ||||||
|    lineString, |    lineString, | ||||||
|    polygon |    polygon | ||||||
| } from '@turf/helpers'; | } from '@turf/helpers'; | ||||||
|  | import { GeoJsonObject } from 'geojson'; | ||||||
| import { getArrayDepth } from 'common/libs/getArrayDepth'; | import { getArrayDepth } from 'common/libs/getArrayDepth'; | ||||||
|  |  | ||||||
| export default { | interface Coordinates { x: number; y: number } | ||||||
|    name: 'BaseMap', |  | ||||||
|    props: { | const props = defineProps({ | ||||||
|       points: [Object, Array], |    points: [Object, Array] as PropType<Coordinates | Coordinates[]>, | ||||||
|    isMultiSpatial: Boolean |    isMultiSpatial: Boolean | ||||||
|    }, | }); | ||||||
|    data () { | const map: Ref<L.Map> = ref(null); | ||||||
|       return { | const markers: Ref<GeoJsonObject | GeoJsonObject[]> = ref(null); | ||||||
|          map: null, | const center: Ref<[number, number]> = ref(null); | ||||||
|          markers: [], |  | ||||||
|          center: null | const getMarkers = (points: Coordinates) => { | ||||||
|  |    if (Array.isArray(points)) { | ||||||
|  |       if (getArrayDepth(points) === 1) | ||||||
|  |          return lineString(points.reduce((acc, curr) => [...acc, [curr.x, curr.y]], [])); | ||||||
|  |       else | ||||||
|  |          return polygon(points.map(arr => arr.reduce((acc: Coordinates[], curr: Coordinates) => [...acc, [curr.x, curr.y]], []))); | ||||||
|  |    } | ||||||
|  |    else | ||||||
|  |       return point([points.x, points.y]); | ||||||
| }; | }; | ||||||
|    }, |  | ||||||
|    mounted () { | onMounted(() => { | ||||||
|       if (this.isMultiSpatial) { |    if (props.isMultiSpatial) { | ||||||
|          for (const element of this.points) |       for (const element of props.points as Coordinates[]) | ||||||
|             this.markers.push(this.getMarkers(element)); |          (markers.value as GeoJsonObject[]).push(getMarkers(element)); | ||||||
|    } |    } | ||||||
|    else { |    else { | ||||||
|          this.markers = this.getMarkers(this.points); |       markers.value = getMarkers(props.points as Coordinates); | ||||||
|  |  | ||||||
|          if (!Array.isArray(this.points)) |       if (!Array.isArray(props.points)) | ||||||
|             this.center = [this.points.y, this.points.x]; |          center.value = [props.points.y, props.points.x]; | ||||||
|    } |    } | ||||||
|  |  | ||||||
|       this.map = L.map('map', { |    map.value = L.map('map', { | ||||||
|          center: this.center || [0, 0], |       center: center.value || [0, 0], | ||||||
|       zoom: 15, |       zoom: 15, | ||||||
|       minZoom: 1, |       minZoom: 1, | ||||||
|       attributionControl: false |       attributionControl: false | ||||||
|    }); |    }); | ||||||
|  |  | ||||||
|       L.control.attribution({ prefix: '<b>Leaflet</b>' }).addTo(this.map); |    L.control.attribution({ prefix: '<b>Leaflet</b>' }).addTo(map.value); | ||||||
|  |  | ||||||
|       const geoJsonObj = L.geoJSON(this.markers, { |    const geoJsonObj = L.geoJSON((markers.value as GeoJsonObject), { | ||||||
|       style: function () { |       style: function () { | ||||||
|          return { |          return { | ||||||
|             weight: 2, |             weight: 2, | ||||||
| @@ -64,32 +75,19 @@ export default { | |||||||
|             fillOpacity: 0.4 |             fillOpacity: 0.4 | ||||||
|          }); |          }); | ||||||
|       } |       } | ||||||
|       }).addTo(this.map); |    }).addTo(map.value); | ||||||
|  |  | ||||||
|    const southWest = L.latLng(-90, -180); |    const southWest = L.latLng(-90, -180); | ||||||
|    const northEast = L.latLng(90, 180); |    const northEast = L.latLng(90, 180); | ||||||
|    const bounds = L.latLngBounds(southWest, northEast); |    const bounds = L.latLngBounds(southWest, northEast); | ||||||
|       this.map.setMaxBounds(bounds); |    map.value.setMaxBounds(bounds); | ||||||
|  |  | ||||||
|       if (!this.center) this.map.fitBounds(geoJsonObj.getBounds()); |    if (!center.value) map.value.fitBounds(geoJsonObj.getBounds()); | ||||||
|  |  | ||||||
|    L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { |    L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { | ||||||
|       attribution: '© <b>OpenStreetMap</b>' |       attribution: '© <b>OpenStreetMap</b>' | ||||||
|       }).addTo(this.map); |    }).addTo(map.value); | ||||||
|    }, | }); | ||||||
|    methods: { |  | ||||||
|       getMarkers (points) { |  | ||||||
|          if (Array.isArray(points)) { |  | ||||||
|             if (getArrayDepth(points) === 1) |  | ||||||
|                return lineString(points.reduce((acc, curr) => [...acc, [curr.x, curr.y]], [])); |  | ||||||
|             else |  | ||||||
|                return polygon(points.map(arr => arr.reduce((acc, curr) => [...acc, [curr.x, curr.y]], []))); |  | ||||||
|          } |  | ||||||
|          else |  | ||||||
|             return point([points.x, points.y]); |  | ||||||
|       } |  | ||||||
|    } |  | ||||||
| }; |  | ||||||
| </script> | </script> | ||||||
|  |  | ||||||
| <style lang="scss"> | <style lang="scss"> | ||||||
|   | |||||||
| @@ -14,10 +14,10 @@ | |||||||
|    </div> |    </div> | ||||||
| </template> | </template> | ||||||
|  |  | ||||||
| <script> | <script setup lang="ts"> | ||||||
| export default { | import { computed, ref } from 'vue'; | ||||||
|    name: 'BaseNotification', |  | ||||||
|    props: { | const props = defineProps({ | ||||||
|    message: { |    message: { | ||||||
|       type: String, |       type: String, | ||||||
|       default: '' |       default: '' | ||||||
| @@ -26,18 +26,14 @@ export default { | |||||||
|       type: String, |       type: String, | ||||||
|       default: '' |       default: '' | ||||||
|    } |    } | ||||||
|    }, | }); | ||||||
|    emits: ['close'], | const isExpanded = ref(false); | ||||||
|    data () { | const emit = defineEmits(['close']); | ||||||
|       return { |  | ||||||
|          isExpanded: false | const notificationStatus = computed(() => { | ||||||
|       }; |  | ||||||
|    }, |  | ||||||
|    computed: { |  | ||||||
|       notificationStatus () { |  | ||||||
|    let className = ''; |    let className = ''; | ||||||
|    let iconName = ''; |    let iconName = ''; | ||||||
|          switch (this.status) { |    switch (props.status) { | ||||||
|       case 'success': |       case 'success': | ||||||
|          className = 'toast-success'; |          className = 'toast-success'; | ||||||
|          iconName = 'mdi-check'; |          iconName = 'mdi-check'; | ||||||
| @@ -57,21 +53,19 @@ export default { | |||||||
|    } |    } | ||||||
|  |  | ||||||
|    return { className, iconName }; |    return { className, iconName }; | ||||||
|       }, | }); | ||||||
|       isExpandable () { |  | ||||||
|          return this.message.length > 80; | const isExpandable = computed(() => props.message.length > 80); | ||||||
|       } |  | ||||||
|    }, | const hideToast = () => { | ||||||
|    methods: { |    emit('close'); | ||||||
|       hideToast () { | }; | ||||||
|          this.$emit('close'); |  | ||||||
|       }, | const toggleExpand = () => { | ||||||
|       toggleExpand () { |    isExpanded.value = !isExpanded.value; | ||||||
|          this.isExpanded = !this.isExpanded; |  | ||||||
|       } |  | ||||||
|    } |  | ||||||
| }; | }; | ||||||
| </script> | </script> | ||||||
|  |  | ||||||
| <style scoped> | <style scoped> | ||||||
|   .toast { |   .toast { | ||||||
|     display: flex; |     display: flex; | ||||||
|   | |||||||
| @@ -9,16 +9,15 @@ | |||||||
|    </div> |    </div> | ||||||
| </template> | </template> | ||||||
|  |  | ||||||
| <script> | <script setup lang="ts"> | ||||||
|  | import { onMounted, ref, watch } from 'vue'; | ||||||
| import * as ace from 'ace-builds'; | import * as ace from 'ace-builds'; | ||||||
| import { storeToRefs } from 'pinia'; |  | ||||||
| import 'ace-builds/webpack-resolver'; | import 'ace-builds/webpack-resolver'; | ||||||
|  | import { storeToRefs } from 'pinia'; | ||||||
| import { useSettingsStore } from '@/stores/settings'; | import { useSettingsStore } from '@/stores/settings'; | ||||||
| import { uidGen } from 'common/libs/uidGen'; | import { uidGen } from 'common/libs/uidGen'; | ||||||
|  |  | ||||||
| export default { | const props = defineProps({ | ||||||
|    name: 'BaseTextEditor', |  | ||||||
|    props: { |  | ||||||
|    modelValue: String, |    modelValue: String, | ||||||
|    mode: { type: String, default: 'text' }, |    mode: { type: String, default: 'text' }, | ||||||
|    editorClass: { type: String, default: '' }, |    editorClass: { type: String, default: '' }, | ||||||
| @@ -26,10 +25,10 @@ export default { | |||||||
|    readOnly: { type: Boolean, default: false }, |    readOnly: { type: Boolean, default: false }, | ||||||
|    showLineNumbers: { type: Boolean, default: true }, |    showLineNumbers: { type: Boolean, default: true }, | ||||||
|    height: { type: Number, default: 200 } |    height: { type: Number, default: 200 } | ||||||
|    }, | }); | ||||||
|    emits: ['update:modelValue'], | const emit = defineEmits(['update:modelValue']); | ||||||
|    setup () { |  | ||||||
| const settingsStore = useSettingsStore(); | const settingsStore = useSettingsStore(); | ||||||
|  | const mode = ref(props.mode); | ||||||
|  |  | ||||||
| const { | const { | ||||||
|    editorTheme, |    editorTheme, | ||||||
| @@ -38,92 +37,84 @@ export default { | |||||||
|    lineWrap |    lineWrap | ||||||
| } = storeToRefs(settingsStore); | } = storeToRefs(settingsStore); | ||||||
|  |  | ||||||
|       return { | let editor: ace.Ace.Editor; | ||||||
|          editorTheme, | const id = uidGen(); | ||||||
|          editorFontSize, |  | ||||||
|          autoComplete, | watch(mode, () => { | ||||||
|          lineWrap |    if (editor) | ||||||
|       }; |       editor.session.setMode(`ace/mode/${props.mode}`); | ||||||
|    }, | }); | ||||||
|    data () { |  | ||||||
|       return { | watch(editorTheme, () => { | ||||||
|          editor: null, |    if (editor) | ||||||
|          id: uidGen() |       editor.setTheme(`ace/theme/${editorTheme.value}`); | ||||||
|       }; | }); | ||||||
|    }, |  | ||||||
|    watch: { | watch(editorFontSize, () => { | ||||||
|       mode () { |  | ||||||
|          if (this.editor) |  | ||||||
|             this.editor.session.setMode(`ace/mode/${this.mode}`); |  | ||||||
|       }, |  | ||||||
|       editorTheme () { |  | ||||||
|          if (this.editor) |  | ||||||
|             this.editor.setTheme(`ace/theme/${this.editorTheme}`); |  | ||||||
|       }, |  | ||||||
|       editorFontSize () { |  | ||||||
|    const sizes = { |    const sizes = { | ||||||
|             small: '12px', |       small: 12, | ||||||
|             medium: '14px', |       medium: 14, | ||||||
|             large: '16px' |       large: 16 | ||||||
|    }; |    }; | ||||||
|  |  | ||||||
|          if (this.editor) { |    if (editor) { | ||||||
|             this.editor.setOptions({ |       editor.setOptions({ | ||||||
|                fontSize: sizes[this.editorFontSize] |          fontSize: sizes[editorFontSize.value as undefined as 'small' | 'medium' | 'large'] | ||||||
|       }); |       }); | ||||||
|    } |    } | ||||||
|       }, |  | ||||||
|       autoComplete () { |  | ||||||
|          if (this.editor) { |  | ||||||
|             this.editor.setOptions({ |  | ||||||
|                enableLiveAutocompletion: this.autoComplete |  | ||||||
|             }); |  | ||||||
|          } |  | ||||||
|       }, |  | ||||||
|       lineWrap () { |  | ||||||
|          if (this.editor) { |  | ||||||
|             this.editor.setOptions({ |  | ||||||
|                wrap: this.lineWrap |  | ||||||
|             }); |  | ||||||
|          } |  | ||||||
|       } |  | ||||||
|    }, |  | ||||||
|    mounted () { |  | ||||||
|       this.editor = ace.edit(`editor-${this.id}`, { |  | ||||||
|          mode: `ace/mode/${this.mode}`, |  | ||||||
|          theme: `ace/theme/${this.editorTheme}`, |  | ||||||
|          value: this.modelValue || '', |  | ||||||
|          fontSize: '14px', |  | ||||||
|          printMargin: false, |  | ||||||
|          readOnly: this.readOnly, |  | ||||||
|          showLineNumbers: this.showLineNumbers, |  | ||||||
|          showGutter: this.showLineNumbers |  | ||||||
| }); | }); | ||||||
|  |  | ||||||
|       this.editor.setOptions({ | watch(autoComplete, () => { | ||||||
|  |    if (editor) { | ||||||
|  |       editor.setOptions({ | ||||||
|  |          enableLiveAutocompletion: autoComplete.value | ||||||
|  |       }); | ||||||
|  |    } | ||||||
|  | }); | ||||||
|  |  | ||||||
|  | watch(lineWrap, () => { | ||||||
|  |    if (editor) { | ||||||
|  |       editor.setOptions({ | ||||||
|  |          wrap: lineWrap.value | ||||||
|  |       }); | ||||||
|  |    } | ||||||
|  | }); | ||||||
|  |  | ||||||
|  | onMounted(() => { | ||||||
|  |    editor = ace.edit(`editor-${id}`, { | ||||||
|  |       mode: `ace/mode/${mode.value}`, | ||||||
|  |       theme: `ace/theme/${editorTheme.value}`, | ||||||
|  |       value: props.modelValue || '', | ||||||
|  |       fontSize: 14, | ||||||
|  |       printMargin: false, | ||||||
|  |       readOnly: props.readOnly, | ||||||
|  |       showLineNumbers: props.showLineNumbers, | ||||||
|  |       showGutter: props.showLineNumbers | ||||||
|  |    }); | ||||||
|  |  | ||||||
|  |    editor.setOptions({ | ||||||
|       enableBasicAutocompletion: false, |       enableBasicAutocompletion: false, | ||||||
|          wrap: this.lineWrap, |       wrap: lineWrap, | ||||||
|       enableSnippets: false, |       enableSnippets: false, | ||||||
|       enableLiveAutocompletion: false |       enableLiveAutocompletion: false | ||||||
|    }); |    }); | ||||||
|  |  | ||||||
|       this.editor.session.on('change', () => { |    editor.session.on('changeFold', () => { | ||||||
|          const content = this.editor.getValue(); |       const content = editor.getValue(); | ||||||
|          this.$emit('update:modelValue', content); |       emit('update:modelValue', content); | ||||||
|    }); |    }); | ||||||
|  |  | ||||||
|       if (this.autoFocus) { |    if (props.autoFocus) { | ||||||
|       setTimeout(() => { |       setTimeout(() => { | ||||||
|             this.editor.focus(); |          editor.focus(); | ||||||
|             this.editor.resize(); |          editor.resize(); | ||||||
|       }, 20); |       }, 20); | ||||||
|    } |    } | ||||||
|  |  | ||||||
|    setTimeout(() => { |    setTimeout(() => { | ||||||
|          this.editor.resize(); |       editor.resize(); | ||||||
|    }, 20); |    }, 20); | ||||||
|    } | }); | ||||||
| }; |  | ||||||
| </script> | </script> | ||||||
|  |  | ||||||
| <style lang="scss" scoped> | <style lang="scss" scoped> | ||||||
|   | |||||||
| @@ -9,10 +9,11 @@ | |||||||
|    </div> |    </div> | ||||||
| </template> | </template> | ||||||
|  |  | ||||||
| <script> | <script setup lang="ts"> | ||||||
| export default { | import { computed } from '@vue/reactivity'; | ||||||
|    name: 'BaseToast', | import { ref, watch } from 'vue'; | ||||||
|    props: { |  | ||||||
|  | const props = defineProps({ | ||||||
|    message: { |    message: { | ||||||
|       type: String, |       type: String, | ||||||
|       default: '' |       default: '' | ||||||
| @@ -21,18 +22,17 @@ export default { | |||||||
|       type: String, |       type: String, | ||||||
|       default: '' |       default: '' | ||||||
|    } |    } | ||||||
|    }, | }); | ||||||
|    emits: ['close'], |  | ||||||
|    data () { | const isVisible = ref(false); | ||||||
|       return { | const message = ref(props.message); | ||||||
|          isVisible: false |  | ||||||
|       }; | const emit = defineEmits(['close']); | ||||||
|    }, |  | ||||||
|    computed: { | const toastStatus = computed(() => { | ||||||
|       toastStatus () { |  | ||||||
|    let className = ''; |    let className = ''; | ||||||
|    let iconName = ''; |    let iconName = ''; | ||||||
|          switch (this.status) { |    switch (props.status) { | ||||||
|       case 'success': |       case 'success': | ||||||
|          className = 'toast-success'; |          className = 'toast-success'; | ||||||
|          iconName = 'mdi-check'; |          iconName = 'mdi-check'; | ||||||
| @@ -52,24 +52,21 @@ export default { | |||||||
|    } |    } | ||||||
|  |  | ||||||
|    return { className, iconName }; |    return { className, iconName }; | ||||||
|       } | }); | ||||||
|    }, |  | ||||||
|    watch: { | watch(message, () => { | ||||||
|       message: function () { |    if (message.value) | ||||||
|          if (this.message) |       isVisible.value = true; | ||||||
|             this.isVisible = true; |  | ||||||
|    else |    else | ||||||
|             this.isVisible = false; |       isVisible.value = false; | ||||||
|       } | }); | ||||||
|    }, |  | ||||||
|    methods: { | const hideToast = () => { | ||||||
|       hideToast () { |    isVisible.value = false; | ||||||
|          this.isVisible = false; |    emit('close'); | ||||||
|          this.$emit('close'); |  | ||||||
|       } |  | ||||||
|    } |  | ||||||
| }; | }; | ||||||
| </script> | </script> | ||||||
|  |  | ||||||
| <style scoped> | <style scoped> | ||||||
|   .toast { |   .toast { | ||||||
|     display: flex; |     display: flex; | ||||||
|   | |||||||
| @@ -7,7 +7,7 @@ | |||||||
|          {{ lastPart(modelValue) }} |          {{ lastPart(modelValue) }} | ||||||
|       </span> |       </span> | ||||||
|       <i |       <i | ||||||
|          v-if="modelValue.length" |          v-if="modelValue" | ||||||
|          class="file-uploader-reset mdi mdi-close" |          class="file-uploader-reset mdi mdi-close" | ||||||
|          @click.prevent="clear" |          @click.prevent="clear" | ||||||
|       /> |       /> | ||||||
| @@ -22,10 +22,10 @@ | |||||||
|    </label> |    </label> | ||||||
| </template> | </template> | ||||||
|  |  | ||||||
| <script> | <script setup lang="ts"> | ||||||
| export default { | import { uidGen } from 'common/libs/uidGen'; | ||||||
|    name: 'BaseUploadInput', |  | ||||||
|    props: { | defineProps({ | ||||||
|    message: { |    message: { | ||||||
|       default: 'Browse', |       default: 'Browse', | ||||||
|       type: String |       type: String | ||||||
| @@ -34,29 +34,23 @@ export default { | |||||||
|       default: '', |       default: '', | ||||||
|       type: String |       type: String | ||||||
|    } |    } | ||||||
|    }, | }); | ||||||
|    emits: ['change', 'clear'], |  | ||||||
|    data () { | const emit = defineEmits(['change', 'clear']); | ||||||
|       return { |  | ||||||
|          id: null | const id = uidGen(); | ||||||
|  |  | ||||||
|  | const clear = () => { | ||||||
|  |    emit('clear'); | ||||||
| }; | }; | ||||||
|    }, |  | ||||||
|    mounted () { | const lastPart = (string: string) => { | ||||||
|       this.id = this._uid; |  | ||||||
|    }, |  | ||||||
|    methods: { |  | ||||||
|       clear () { |  | ||||||
|          this.$emit('clear'); |  | ||||||
|       }, |  | ||||||
|       lastPart (string) { |  | ||||||
|    if (!string) return ''; |    if (!string) return ''; | ||||||
|  |  | ||||||
|    string = string.split(/[/\\]+/).pop(); |    string = string.split(/[/\\]+/).pop(); | ||||||
|    if (string.length >= 19) |    if (string.length >= 19) | ||||||
|       string = `...${string.slice(-19)}`; |       string = `...${string.slice(-19)}`; | ||||||
|    return string; |    return string; | ||||||
|       } |  | ||||||
|    } |  | ||||||
| }; | }; | ||||||
| </script> | </script> | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,5 +1,5 @@ | |||||||
| <template> | <template> | ||||||
|    <div class="vscroll-holder"> |    <div ref="root" class="vscroll-holder"> | ||||||
|       <div |       <div | ||||||
|          class="vscroll-spacer" |          class="vscroll-spacer" | ||||||
|          :style="{ |          :style="{ | ||||||
| @@ -20,10 +20,10 @@ | |||||||
|    </div> |    </div> | ||||||
| </template> | </template> | ||||||
|  |  | ||||||
| <script> | <script setup lang="ts"> | ||||||
| export default { | import { onBeforeUnmount, onMounted, Ref, ref, watch } from 'vue'; | ||||||
|    name: 'BaseVirtualScroll', |  | ||||||
|    props: { | const props = defineProps({ | ||||||
|    items: Array, |    items: Array, | ||||||
|    itemHeight: Number, |    itemHeight: Number, | ||||||
|    visibleHeight: Number, |    visibleHeight: Number, | ||||||
| @@ -31,60 +31,66 @@ export default { | |||||||
|       type: HTMLDivElement, |       type: HTMLDivElement, | ||||||
|       default: null |       default: null | ||||||
|    } |    } | ||||||
|    }, | }); | ||||||
|    data () { |  | ||||||
|       return { |  | ||||||
|          topHeight: 0, |  | ||||||
|          bottomHeight: 0, |  | ||||||
|          visibleItems: [], |  | ||||||
|          renderTimeout: null, |  | ||||||
|          localScrollElement: null |  | ||||||
|       }; |  | ||||||
|    }, |  | ||||||
|    watch: { |  | ||||||
|       scrollElement () { |  | ||||||
|          this.setScrollElement(); |  | ||||||
|       } |  | ||||||
|    }, |  | ||||||
|    mounted () { |  | ||||||
|       this.setScrollElement(); |  | ||||||
|    }, |  | ||||||
|    beforeUnmount () { |  | ||||||
|       this.localScrollElement.removeEventListener('scroll', this.checkScrollPosition); |  | ||||||
|    }, |  | ||||||
|    methods: { |  | ||||||
|       checkScrollPosition (e) { |  | ||||||
|          clearTimeout(this.renderTimeout); |  | ||||||
|  |  | ||||||
|          this.renderTimeout = setTimeout(() => { | const root = ref(null); | ||||||
|             this.updateWindow(e); | const topHeight: Ref<number> = ref(0); | ||||||
|  | const bottomHeight: Ref<number> = ref(0); | ||||||
|  | // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||||||
|  | const visibleItems: Ref<any[]> = ref([]); | ||||||
|  | const renderTimeout: Ref<NodeJS.Timeout> = ref(null); | ||||||
|  | const localScrollElement: Ref<HTMLDivElement> = ref(null); | ||||||
|  | const scrollElement = ref(props.scrollElement); | ||||||
|  |  | ||||||
|  | const checkScrollPosition = () => { | ||||||
|  |    clearTimeout(renderTimeout.value); | ||||||
|  |  | ||||||
|  |    renderTimeout.value = setTimeout(() => { | ||||||
|  |       updateWindow(); | ||||||
|    }, 200); |    }, 200); | ||||||
|       }, | }; | ||||||
|       updateWindow () { |  | ||||||
|          const visibleItemsCount = Math.ceil(this.visibleHeight / this.itemHeight); | const updateWindow = () => { | ||||||
|          const totalScrollHeight = this.items.length * this.itemHeight; |    const visibleItemsCount = Math.ceil(props.visibleHeight / props.itemHeight); | ||||||
|  |    const totalScrollHeight = props.items.length * props.itemHeight; | ||||||
|    const offset = 50; |    const offset = 50; | ||||||
|  |  | ||||||
|          const scrollTop = this.localScrollElement.scrollTop; |    const scrollTop = localScrollElement.value.scrollTop; | ||||||
|  |  | ||||||
|          const firstVisibleIndex = Math.floor(scrollTop / this.itemHeight); |    const firstVisibleIndex = Math.floor(scrollTop / props.itemHeight); | ||||||
|    const lastVisibleIndex = firstVisibleIndex + visibleItemsCount; |    const lastVisibleIndex = firstVisibleIndex + visibleItemsCount; | ||||||
|    const firstCutIndex = Math.max(firstVisibleIndex - offset, 0); |    const firstCutIndex = Math.max(firstVisibleIndex - offset, 0); | ||||||
|    const lastCutIndex = lastVisibleIndex + offset; |    const lastCutIndex = lastVisibleIndex + offset; | ||||||
|  |  | ||||||
|          this.visibleItems = this.items.slice(firstCutIndex, lastCutIndex); |    visibleItems.value = props.items.slice(firstCutIndex, lastCutIndex); | ||||||
|  |  | ||||||
|          this.topHeight = firstCutIndex * this.itemHeight; |    topHeight.value = firstCutIndex * props.itemHeight; | ||||||
|          this.bottomHeight = totalScrollHeight - this.visibleItems.length * this.itemHeight - this.topHeight; |    bottomHeight.value = totalScrollHeight - visibleItems.value.length * props.itemHeight - topHeight.value; | ||||||
|       }, |  | ||||||
|       setScrollElement () { |  | ||||||
|          if (this.localScrollElement) |  | ||||||
|             this.localScrollElement.removeEventListener('scroll', this.checkScrollPosition); |  | ||||||
|  |  | ||||||
|          this.localScrollElement = this.scrollElement ? this.scrollElement : this.$el; |  | ||||||
|          this.updateWindow(); |  | ||||||
|          this.localScrollElement.addEventListener('scroll', this.checkScrollPosition); |  | ||||||
|       } |  | ||||||
|    } |  | ||||||
| }; | }; | ||||||
|  |  | ||||||
|  | const setScrollElement = () => { | ||||||
|  |    if (localScrollElement.value) | ||||||
|  |       localScrollElement.value.removeEventListener('scroll', checkScrollPosition); | ||||||
|  |  | ||||||
|  |    localScrollElement.value = scrollElement.value ? scrollElement.value : root.value; | ||||||
|  |    updateWindow(); | ||||||
|  |    localScrollElement.value.addEventListener('scroll', checkScrollPosition); | ||||||
|  | }; | ||||||
|  |  | ||||||
|  | watch(scrollElement, () => { | ||||||
|  |    setScrollElement(); | ||||||
|  | }); | ||||||
|  |  | ||||||
|  | onMounted(() => { | ||||||
|  |    setScrollElement(); | ||||||
|  | }); | ||||||
|  |  | ||||||
|  | onBeforeUnmount(() => { | ||||||
|  |    localScrollElement.value.removeEventListener('scroll', checkScrollPosition); | ||||||
|  | }); | ||||||
|  |  | ||||||
|  | defineExpose({ | ||||||
|  |    updateWindow | ||||||
|  | }); | ||||||
|  |  | ||||||
| </script> | </script> | ||||||
|   | |||||||
| @@ -52,7 +52,7 @@ | |||||||
|       > |       > | ||||||
|       <BaseUploadInput |       <BaseUploadInput | ||||||
|          v-else-if="inputProps().type === 'file'" |          v-else-if="inputProps().type === 'file'" | ||||||
|          :value="selectedValue" |          :model-value="selectedValue" | ||||||
|          :message="$t('word.browse')" |          :message="$t('word.browse')" | ||||||
|          @clear="clearValue" |          @clear="clearValue" | ||||||
|          @change="filesChange($event)" |          @change="filesChange($event)" | ||||||
|   | |||||||
| @@ -134,7 +134,7 @@ | |||||||
| </template> | </template> | ||||||
|  |  | ||||||
| <script> | <script> | ||||||
| import arrayToFile from '../libs/arrayToFile'; | import { arrayToFile } from '../libs/arrayToFile'; | ||||||
| import { useNotificationsStore } from '@/stores/notifications'; | import { useNotificationsStore } from '@/stores/notifications'; | ||||||
| import Schema from '@/ipc-api/Schema'; | import Schema from '@/ipc-api/Schema'; | ||||||
| import { useConnectionsStore } from '@/stores/connections'; | import { useConnectionsStore } from '@/stores/connections'; | ||||||
|   | |||||||
| @@ -328,7 +328,7 @@ import { storeToRefs } from 'pinia'; | |||||||
| import { useApplicationStore } from '@/stores/application'; | import { useApplicationStore } from '@/stores/application'; | ||||||
| import { useSettingsStore } from '@/stores/settings'; | import { useSettingsStore } from '@/stores/settings'; | ||||||
| import { useWorkspacesStore } from '@/stores/workspaces'; | import { useWorkspacesStore } from '@/stores/workspaces'; | ||||||
| import localesNames from '@/i18n/supported-locales'; | import { localesNames } from '@/i18n/supported-locales'; | ||||||
| import ModalSettingsUpdate from '@/components/ModalSettingsUpdate'; | import ModalSettingsUpdate from '@/components/ModalSettingsUpdate'; | ||||||
| import ModalSettingsChangelog from '@/components/ModalSettingsChangelog'; | import ModalSettingsChangelog from '@/components/ModalSettingsChangelog'; | ||||||
| import BaseTextEditor from '@/components/BaseTextEditor'; | import BaseTextEditor from '@/components/BaseTextEditor'; | ||||||
|   | |||||||
| @@ -96,7 +96,7 @@ | |||||||
|                         </div> |                         </div> | ||||||
|                         <div class="column col-8 col-sm-12"> |                         <div class="column col-8 col-sm-12"> | ||||||
|                            <BaseUploadInput |                            <BaseUploadInput | ||||||
|                               :value="connection.databasePath" |                               :model-value="connection.databasePath" | ||||||
|                               :message="$t('word.browse')" |                               :message="$t('word.browse')" | ||||||
|                               @clear="pathClear('databasePath')" |                               @clear="pathClear('databasePath')" | ||||||
|                               @change="pathSelection($event, 'databasePath')" |                               @change="pathSelection($event, 'databasePath')" | ||||||
| @@ -211,7 +211,7 @@ | |||||||
|                         </div> |                         </div> | ||||||
|                         <div class="column col-8 col-sm-12"> |                         <div class="column col-8 col-sm-12"> | ||||||
|                            <BaseUploadInput |                            <BaseUploadInput | ||||||
|                               :value="connection.key" |                               :model-value="connection.key" | ||||||
|                               :message="$t('word.browse')" |                               :message="$t('word.browse')" | ||||||
|                               @clear="pathClear('key')" |                               @clear="pathClear('key')" | ||||||
|                               @change="pathSelection($event, 'key')" |                               @change="pathSelection($event, 'key')" | ||||||
| @@ -224,7 +224,7 @@ | |||||||
|                         </div> |                         </div> | ||||||
|                         <div class="column col-8 col-sm-12"> |                         <div class="column col-8 col-sm-12"> | ||||||
|                            <BaseUploadInput |                            <BaseUploadInput | ||||||
|                               :value="connection.cert" |                               :model-value="connection.cert" | ||||||
|                               :message="$t('word.browse')" |                               :message="$t('word.browse')" | ||||||
|                               @clear="pathClear('cert')" |                               @clear="pathClear('cert')" | ||||||
|                               @change="pathSelection($event, 'cert')" |                               @change="pathSelection($event, 'cert')" | ||||||
| @@ -237,7 +237,7 @@ | |||||||
|                         </div> |                         </div> | ||||||
|                         <div class="column col-8 col-sm-12"> |                         <div class="column col-8 col-sm-12"> | ||||||
|                            <BaseUploadInput |                            <BaseUploadInput | ||||||
|                               :value="connection.ca" |                               :model-value="connection.ca" | ||||||
|                               :message="$t('word.browse')" |                               :message="$t('word.browse')" | ||||||
|                               @clear="pathClear('ca')" |                               @clear="pathClear('ca')" | ||||||
|                               @change="pathSelection($event, 'ca')" |                               @change="pathSelection($event, 'ca')" | ||||||
| @@ -342,7 +342,7 @@ | |||||||
|                         </div> |                         </div> | ||||||
|                         <div class="column col-8 col-sm-12"> |                         <div class="column col-8 col-sm-12"> | ||||||
|                            <BaseUploadInput |                            <BaseUploadInput | ||||||
|                               :value="connection.sshKey" |                               :model-value="connection.sshKey" | ||||||
|                               :message="$t('word.browse')" |                               :message="$t('word.browse')" | ||||||
|                               @clear="pathClear('sshKey')" |                               @clear="pathClear('sshKey')" | ||||||
|                               @change="pathSelection($event, 'sshKey')" |                               @change="pathSelection($event, 'sshKey')" | ||||||
|   | |||||||
| @@ -92,7 +92,7 @@ | |||||||
|                         </div> |                         </div> | ||||||
|                         <div class="column col-8 col-sm-12"> |                         <div class="column col-8 col-sm-12"> | ||||||
|                            <BaseUploadInput |                            <BaseUploadInput | ||||||
|                               :value="localConnection.databasePath" |                               :model-value="localConnection.databasePath" | ||||||
|                               :message="$t('word.browse')" |                               :message="$t('word.browse')" | ||||||
|                               @clear="pathClear('databasePath')" |                               @clear="pathClear('databasePath')" | ||||||
|                               @change="pathSelection($event, 'databasePath')" |                               @change="pathSelection($event, 'databasePath')" | ||||||
| @@ -207,7 +207,7 @@ | |||||||
|                         </div> |                         </div> | ||||||
|                         <div class="column col-8 col-sm-12"> |                         <div class="column col-8 col-sm-12"> | ||||||
|                            <BaseUploadInput |                            <BaseUploadInput | ||||||
|                               :value="localConnection.key" |                               :model-value="localConnection.key" | ||||||
|                               :message="$t('word.browse')" |                               :message="$t('word.browse')" | ||||||
|                               @clear="pathClear('key')" |                               @clear="pathClear('key')" | ||||||
|                               @change="pathSelection($event, 'key')" |                               @change="pathSelection($event, 'key')" | ||||||
| @@ -220,7 +220,7 @@ | |||||||
|                         </div> |                         </div> | ||||||
|                         <div class="column col-8 col-sm-12"> |                         <div class="column col-8 col-sm-12"> | ||||||
|                            <BaseUploadInput |                            <BaseUploadInput | ||||||
|                               :value="localConnection.cert" |                               :model-value="localConnection.cert" | ||||||
|                               :message="$t('word.browse')" |                               :message="$t('word.browse')" | ||||||
|                               @clear="pathClear('cert')" |                               @clear="pathClear('cert')" | ||||||
|                               @change="pathSelection($event, 'cert')" |                               @change="pathSelection($event, 'cert')" | ||||||
| @@ -233,7 +233,7 @@ | |||||||
|                         </div> |                         </div> | ||||||
|                         <div class="column col-8 col-sm-12"> |                         <div class="column col-8 col-sm-12"> | ||||||
|                            <BaseUploadInput |                            <BaseUploadInput | ||||||
|                               :value="localConnection.ca" |                               :model-value="localConnection.ca" | ||||||
|                               :message="$t('word.browse')" |                               :message="$t('word.browse')" | ||||||
|                               @clear="pathClear('ca')" |                               @clear="pathClear('ca')" | ||||||
|                               @change="pathSelection($event, 'ca')" |                               @change="pathSelection($event, 'ca')" | ||||||
| @@ -330,7 +330,7 @@ | |||||||
|                         </div> |                         </div> | ||||||
|                         <div class="column col-8 col-sm-12"> |                         <div class="column col-8 col-sm-12"> | ||||||
|                            <BaseUploadInput |                            <BaseUploadInput | ||||||
|                               :value="localConnection.sshKey" |                               :model-value="localConnection.sshKey" | ||||||
|                               :message="$t('word.browse')" |                               :message="$t('word.browse')" | ||||||
|                               @clear="pathClear('sshKey')" |                               @clear="pathClear('sshKey')" | ||||||
|                               @change="pathSelection($event, 'sshKey')" |                               @change="pathSelection($event, 'sshKey')" | ||||||
|   | |||||||
| @@ -90,7 +90,7 @@ | |||||||
|          </label> |          </label> | ||||||
|       </div> |       </div> | ||||||
|       <div class="td p-0 type-int" tabindex="0"> |       <div class="td p-0 type-int" tabindex="0"> | ||||||
|          <template v-if="fieldType.length"> |          <template v-if="fieldType?.length"> | ||||||
|             <span |             <span | ||||||
|                v-if="!isInlineEditor.length" |                v-if="!isInlineEditor.length" | ||||||
|                class="cell-content" |                class="cell-content" | ||||||
| @@ -355,7 +355,7 @@ export default { | |||||||
|    }, |    }, | ||||||
|    props: { |    props: { | ||||||
|       row: Object, |       row: Object, | ||||||
|       dataTypes: Array, |       dataTypes: { type: Array, default: () => [] }, | ||||||
|       indexes: Array, |       indexes: Array, | ||||||
|       foreigns: Array, |       foreigns: Array, | ||||||
|       customizations: Object |       customizations: Object | ||||||
|   | |||||||
| @@ -112,7 +112,7 @@ import { uidGen } from 'common/libs/uidGen'; | |||||||
| import { useNotificationsStore } from '@/stores/notifications'; | import { useNotificationsStore } from '@/stores/notifications'; | ||||||
| import { useSettingsStore } from '@/stores/settings'; | import { useSettingsStore } from '@/stores/settings'; | ||||||
| import { useWorkspacesStore } from '@/stores/workspaces'; | import { useWorkspacesStore } from '@/stores/workspaces'; | ||||||
| import arrayToFile from '../libs/arrayToFile'; | import { arrayToFile } from '../libs/arrayToFile'; | ||||||
| import { TEXT, LONG_TEXT, BLOB } from 'common/fieldTypes'; | import { TEXT, LONG_TEXT, BLOB } from 'common/fieldTypes'; | ||||||
| import BaseVirtualScroll from '@/components/BaseVirtualScroll'; | import BaseVirtualScroll from '@/components/BaseVirtualScroll'; | ||||||
| import WorkspaceTabQueryTableRow from '@/components/WorkspaceTabQueryTableRow'; | import WorkspaceTabQueryTableRow from '@/components/WorkspaceTabQueryTableRow'; | ||||||
|   | |||||||
| @@ -1,4 +1,4 @@ | |||||||
| export default { | export const localesNames = { | ||||||
|    'en-US': 'English', |    'en-US': 'English', | ||||||
|    'it-IT': 'Italiano', |    'it-IT': 'Italiano', | ||||||
|    'ar-SA': 'العربية', |    'ar-SA': 'العربية', | ||||||
| @@ -29,7 +29,7 @@ createApp(App) | |||||||
|    .mount('#app'); |    .mount('#app'); | ||||||
| 
 | 
 | ||||||
| const { locale } = useSettingsStore(); | const { locale } = useSettingsStore(); | ||||||
| i18n.global.locale = locale; | i18n.global.locale = locale as string;// TODO: temp
 | ||||||
| 
 | 
 | ||||||
| // IPC exceptions
 | // IPC exceptions
 | ||||||
| ipcRenderer.on('unhandled-exception', (event, error) => { | ipcRenderer.on('unhandled-exception', (event, error) => { | ||||||
| @@ -59,7 +59,7 @@ ipcRenderer.on('no-auto-update', () => { | |||||||
| 
 | 
 | ||||||
| ipcRenderer.on('download-progress', (event, data) => { | ipcRenderer.on('download-progress', (event, data) => { | ||||||
|    useApplicationStore().updateStatus = 'downloading'; |    useApplicationStore().updateStatus = 'downloading'; | ||||||
|    useApplicationStore().downloadprogress = data.percent; |    useApplicationStore().downloadProgress = data.percent; | ||||||
| }); | }); | ||||||
| 
 | 
 | ||||||
| ipcRenderer.on('update-downloaded', () => { | ipcRenderer.on('update-downloaded', () => { | ||||||
| @@ -4,6 +4,9 @@ import Connection from '@/ipc-api/Connection'; | |||||||
| import Schema from '@/ipc-api/Schema'; | import Schema from '@/ipc-api/Schema'; | ||||||
| import Users from '@/ipc-api/Users'; | import Users from '@/ipc-api/Users'; | ||||||
| import { uidGen } from 'common/libs/uidGen'; | import { uidGen } from 'common/libs/uidGen'; | ||||||
|  |  | ||||||
|  | import customizations from 'common/customizations'; | ||||||
|  |  | ||||||
| import { useConnectionsStore } from '@/stores/connections'; | import { useConnectionsStore } from '@/stores/connections'; | ||||||
| import { useNotificationsStore } from '@/stores/notifications'; | import { useNotificationsStore } from '@/stores/notifications'; | ||||||
| import { useSettingsStore } from '@/stores/settings'; | import { useSettingsStore } from '@/stores/settings'; | ||||||
| @@ -22,14 +25,14 @@ export const useWorkspacesStore = defineStore('workspaces', { | |||||||
|          if (state.selectedWorkspace) return state.selectedWorkspace; |          if (state.selectedWorkspace) return state.selectedWorkspace; | ||||||
|          return state.workspaces[0].uid; |          return state.workspaces[0].uid; | ||||||
|       }, |       }, | ||||||
|       getWorkspace: state => uid => { |       getWorkspace: state => (uid) => { | ||||||
|          return state.workspaces.find(workspace => workspace.uid === uid); |          return state.workspaces.find(workspace => workspace.uid === uid); | ||||||
|       }, |       }, | ||||||
|       getDatabaseVariable: state => (uid, name) => { |       getDatabaseVariable: state => (uid, name) => { | ||||||
|          return state.workspaces.find(workspace => workspace.uid === uid).variables.find(variable => variable.name === name); |          return state.workspaces.find(workspace => workspace.uid === uid).variables.find(variable => variable.name === name); | ||||||
|       }, |       }, | ||||||
|       getWorkspaceTab (state) { |       getWorkspaceTab (state) { | ||||||
|          return tUid => { |          return (tUid) => { | ||||||
|             if (!this.getSelected) return; |             if (!this.getSelected) return; | ||||||
|             const workspace = state.workspaces.find(workspace => workspace.uid === this.getSelected); |             const workspace = state.workspaces.find(workspace => workspace.uid === this.getSelected); | ||||||
|             if ('tabs' in workspace) |             if ('tabs' in workspace) | ||||||
| @@ -89,24 +92,24 @@ export const useWorkspacesStore = defineStore('workspaces', { | |||||||
|             else { |             else { | ||||||
|                let dataTypes = []; |                let dataTypes = []; | ||||||
|                let indexTypes = []; |                let indexTypes = []; | ||||||
|                let customizations = {}; |                let clientCustomizations; | ||||||
|  |  | ||||||
|                switch (connection.client) { |                switch (connection.client) { | ||||||
|                   case 'mysql': |                   case 'mysql': | ||||||
|                   case 'maria': |                   case 'maria': | ||||||
|                      dataTypes = require('common/data-types/mysql'); |                      dataTypes = require('common/data-types/mysql').default; | ||||||
|                      indexTypes = require('common/index-types/mysql'); |                      indexTypes = require('common/index-types/mysql').default; | ||||||
|                      customizations = require('common/customizations/mysql'); |                      clientCustomizations = customizations.mysql; | ||||||
|                      break; |                      break; | ||||||
|                   case 'pg': |                   case 'pg': | ||||||
|                      dataTypes = require('common/data-types/postgresql'); |                      dataTypes = require('common/data-types/postgresql').default; | ||||||
|                      indexTypes = require('common/index-types/postgresql'); |                      indexTypes = require('common/index-types/postgresql').default; | ||||||
|                      customizations = require('common/customizations/postgresql'); |                      clientCustomizations = customizations.pg; | ||||||
|                      break; |                      break; | ||||||
|                   case 'sqlite': |                   case 'sqlite': | ||||||
|                      dataTypes = require('common/data-types/sqlite'); |                      dataTypes = require('common/data-types/sqlite').default; | ||||||
|                      indexTypes = require('common/index-types/sqlite'); |                      indexTypes = require('common/index-types/sqlite').default; | ||||||
|                      customizations = require('common/customizations/sqlite'); |                      clientCustomizations = customizations.sqlite; | ||||||
|                      break; |                      break; | ||||||
|                } |                } | ||||||
|  |  | ||||||
| @@ -144,7 +147,7 @@ export const useWorkspacesStore = defineStore('workspaces', { | |||||||
|                      client: connection.client, |                      client: connection.client, | ||||||
|                      dataTypes, |                      dataTypes, | ||||||
|                      indexTypes, |                      indexTypes, | ||||||
|                      customizations, |                      customizations: clientCustomizations, | ||||||
|                      structure: response, |                      structure: response, | ||||||
|                      connectionStatus: 'connected', |                      connectionStatus: 'connected', | ||||||
|                      tabs: cachedTabs, |                      tabs: cachedTabs, | ||||||
|   | |||||||
							
								
								
									
										2
									
								
								src/renderer/untyped.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								src/renderer/untyped.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,2 @@ | |||||||
|  | declare module '@/App.vue'; | ||||||
|  | declare module 'v-mask'; | ||||||
		Reference in New Issue
	
	Block a user