Skip to content

Commit

Permalink
Fix sonar
Browse files Browse the repository at this point in the history
  • Loading branch information
haslinghuis committed Dec 6, 2024
1 parent 2c5fc37 commit 62f48e5
Showing 1 changed file with 26 additions and 36 deletions.
62 changes: 26 additions & 36 deletions src/components/data-flash/DataFlash.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,43 +39,33 @@ export default defineComponent({
},
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,
)}%`;
return this.fcTotalSize > 0 ? true : 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 `${Math.min((this.fcUsedSize / this.fcTotalSize) * 100, 100)}%`;
}
},
},
indicatorWidth() {
if (!this.supportDataflash) return;
return `${Math.min(
(this.fcUsedSize / this.fcTotalSize) * 100,
100,
)}%`;
},
},
});
Expand Down

0 comments on commit 62f48e5

Please sign in to comment.