Skip to content

Commit

Permalink
Fix sonar
Browse files Browse the repository at this point in the history
  • Loading branch information
haslinghuis committed Jan 7, 2025
1 parent c40d626 commit 69626de
Show file tree
Hide file tree
Showing 6 changed files with 269 additions and 17,642 deletions.
60 changes: 21 additions & 39 deletions src/components/data-flash/DataFlash.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,48 +28,30 @@ export default defineComponent({
},
computed: {
supportDataflash() {
if (this.fcTotalSize > 0) return true;
else return false;
return this.fcTotalSize > 0;
},
computed: {
supportDataflash() {
if (this.fcTotalSize > 0) return true;
else return false;
},
freeSpace() {
if (!this.supportDataflash) return;
const bytes = this.fcTotalSize - this.fcUsedSize;
if (this.fcUsedSize >= this.fcTotalSize) {
return "0B";
}
if (bytes < 1024) {
return `${bytes}B`;
}
const kilobytes = bytes / 1024;
if (kilobytes < 1024) {
return `${Math.round(kilobytes)}KB`;
}
const megabytes = kilobytes / 1024;
if (megabytes < 1024) {
return `${megabytes.toFixed(1)}MB`;
}
const gigabytes = megabytes / 1024;
return `${gigabytes.toFixed(1)}GB`;
},
indicatorWidth() {
if (!this.supportDataflash) return;
return `${Math.min(
(this.fcUsedSize / this.fcTotalSize) * 100,
100,
)}%`;
},
freeSpace() {
if (!this.supportDataflash) { return; }
const bytes = this.fcTotalSize - this.fcUsedSize;
if (this.fcUsedSize >= this.fcTotalSize) {
return "0B";
}
if (bytes < 1024) {
return `${bytes}B`;
}
const kilobytes = bytes / 1024;
if (kilobytes < 1024) {
return `${Math.round(kilobytes)}KB`;
}
const megabytes = kilobytes / 1024;
if (megabytes < 1024) {
return `${megabytes.toFixed(1)}MB`;
}
const gigabytes = megabytes / 1024;
return `${gigabytes.toFixed(1)}GB`;
},
indicatorWidth() {
if (!this.supportDataflash) return;
return `${Math.min(
(this.fcUsedSize / this.fcTotalSize) * 100,
100,
)}%`;
return this.supportDataflash ? `${Math.min((this.fcUsedSize / this.fcTotalSize) * 100, 100)}%` : "0%";
},
},
});
Expand Down
2 changes: 1 addition & 1 deletion src/components/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ i18next.on('initialized', function() {

if (process.env.NODE_ENV === 'development') {
console.log("Development mode enabled, installing Vue tools");
// Vue.config.devtools = true;
// TODO Vue.config.devtools = true;
app.config.performance = true;
}
});
Expand Down
159 changes: 66 additions & 93 deletions src/components/port-picker/PortPicker.vue
Original file line number Diff line number Diff line change
@@ -1,123 +1,96 @@
<template>
<<<<<<< HEAD
<div class="web-port-picker">
<PortOverrideOption
v-if="value.selectedPort === 'manual'"
:value="value.portOverride"
@input="updateValue('portOverride', $event)"
v-if="modelValue.selectedPort === 'manual'"
:model-value="modelValue.portOverride"
@update:modelValue="updateValue('portOverride', $event)"
/>
<FirmwareVirtualOption
v-if="value.selectedPort === 'virtual' && !isConnected"
:value="value.virtualMspVersion"
@input="updateValue('virtualMspVersion', $event)"
v-if="modelValue.selectedPort === 'virtual' && !isConnected"
:model-value="modelValue.virtualMspVersion"
@update:modelValue="updateValue('virtualMspVersion', $event)"
/>
<PortsInput
:value="value"
:model-value="modelValue.selectedPort"
:connected-bluetooth-devices="connectedBluetoothDevices"
:connected-serial-devices="connectedSerialDevices"
:connected-usb-devices="connectedUsbDevices"
:disabled="disabled"
:show-virtual-option="showVirtualOption"
:show-manual-option="showManualOption"
@input="updateValue(null, $event)"
@update:modelValue="updateValue(null, $event)"
/>
</div>
=======
<div class="web-port-picker">
<PortOverrideOption
v-if="modelValue.selectedPort === 'manual'"
:model-value="modelValue.portOverride"
@update:modelValue="updateValue('portOverride', $event)"
/>
<FirmwareVirtualOption
v-if="modelValue.selectedPort === 'virtual' && !isConnected"
:model-value="modelValue.virtualMspVersion"
@update:modelValue="updateValue('virtualMspVersion', $event)"
/>
<PortsInput
:model-value="modelValue.selectedPort"
:connected-bluetooth-devices="connectedBluetoothDevices"
:connected-serial-devices="connectedSerialDevices"
:connected-usb-devices="connectedUsbDevices"
:disabled="disabled"
:show-virtual-option="showVirtualOption"
:show-manual-option="showManualOption"
@update:modelValue="updateValue(null, $event)"
/>
</div>
>>>>>>> c85044e6 (Update Vue)
</template>

<script>
import { defineComponent } from 'vue';
import PortOverrideOption from './PortOverrideOption.vue';
import FirmwareVirtualOption from './FirmwareVirtualOption.vue';
import PortsInput from './PortsInput.vue';
import CONFIGURATOR from '../../js/data_storage';
import { defineComponent } from "vue";
import PortOverrideOption from "./PortOverrideOption.vue";
import FirmwareVirtualOption from "./FirmwareVirtualOption.vue";
import PortsInput from "./PortsInput.vue";
import CONFIGURATOR from "../../js/data_storage";
export default defineComponent({
components: {
PortOverrideOption,
FirmwareVirtualOption,
PortsInput,
},
props: {
modelValue: {
type: Object,
default: () => ({
selectedPort: 'noselection',
selectedBaud: 115200,
portOverride: '/dev/rfcomm0',
virtualMspVersion: '1.46.0',
autoConnect: true,
}),
},
connectedBluetoothDevices: {
type: Array,
default: () => [],
},
connectedSerialDevices: {
type: Array,
default: () => [],
},
connectedUsbDevices: {
type: Array,
default: () => [],
components: {
PortOverrideOption,
FirmwareVirtualOption,
PortsInput,
},
showVirtualOption: {
type: Boolean,
default: true,
},
showManualOption: {
type: Boolean,
default: true,
},
disabled: {
type: Boolean,
default: false,
props: {
modelValue: {
type: Object,
default: () => ({
selectedPort: "noselection",
selectedBaud: 115200,
portOverride: "/dev/rfcomm0",
virtualMspVersion: "1.46.0",
autoConnect: true,
}),
},
connectedBluetoothDevices: {
type: Array,
default: () => [],
},
connectedSerialDevices: {
type: Array,
default: () => [],
},
connectedUsbDevices: {
type: Array,
default: () => [],
},
showVirtualOption: {
type: Boolean,
default: true,
},
showManualOption: {
type: Boolean,
default: true,
},
disabled: {
type: Boolean,
default: false,
},
},
},
emits: [
'update:modelValue',
],
emits: ["update:modelValue"],
computed: {
isConnected() {
return CONFIGURATOR.connectionValid;
computed: {
isConnected() {
return CONFIGURATOR.connectionValid;
},
},
},
methods: {
updateValue(key, value) {
if (key != null) {
this.$emit('update:modelValue', { ...this.modelValue, [key]: value });
} else {
this.$emit('update:modelValue', { ...this.modelValue, ...value});
}
methods: {
updateValue(key, value) {
if (key != null) {
this.$emit("update:modelValue", { ...this.modelValue, [key]: value });
} else {
this.$emit("update:modelValue", { ...this.modelValue, ...value });
}
},
},
},
});
</script>

Expand Down
Loading

0 comments on commit 69626de

Please sign in to comment.