Skip to content

Commit

Permalink
optimize code
Browse files Browse the repository at this point in the history
  • Loading branch information
tinohager committed Jul 19, 2024
1 parent d87f982 commit 11af617
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 13 deletions.
21 changes: 19 additions & 2 deletions src/Frontend/src/components/LetterWithEnvelope.vue
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,19 @@ defineProps<Props>()
style="fill:none;stroke:#263238;stroke-width:.8;stroke-linejoin:round;"
/></g>

<!-- <g>
<circle
cx="23.5"
cy="9"
r="2"
fill="gold"
/><text
x="22.5"
y="9.2"
style="font:normal 0.5px sans-serif; fill: #666;;"
>Signature</text>
</g> -->

<g
id="letter"
transform="translate(0,-2)"
Expand Down Expand Up @@ -81,13 +94,17 @@ defineProps<Props>()

<g>
<text
x="11"
x="16"
y="26"
dominant-baseline="middle"
text-anchor="middle"
style="font:normal 0.5px sans-serif; fill: #666;;"
>ReturnPath</text>
<text
x="11"
x="16"
y="27"
dominant-baseline="middle"
text-anchor="middle"
style="font:italic 1.0px sans-serif;"
>{{ returnPath }}</text>
</g>
Expand Down
67 changes: 56 additions & 11 deletions src/Frontend/src/components/MailFlowTable.vue
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<script setup lang="ts">
import { computed } from 'vue'
import { QTableProps } from 'quasar'
import { ReceivedHeaderParts } from 'src/models/ReceivedHeaderParts'
Expand All @@ -7,7 +8,30 @@ interface Props {
receivedHeaders: ReceivedHeaderParts[]
}
defineProps<Props>()
const myProps = defineProps<Props>()
const delays = computed(() => {
const differences: (number | undefined)[] = []
differences.push(undefined)
for (let i = 1; i < myProps.receivedHeaders.length; i++) {
const previousDate = myProps.receivedHeaders[i - 1].dateTime
const currentDate = myProps.receivedHeaders[i].dateTime
if (!previousDate || !currentDate) {
differences.push(0)
continue
}
const diffInMs = currentDate.getTime() - previousDate.getTime()
const diffInMinutes = diffInMs / 1000
differences.push(diffInMinutes)
}
return differences
})
const columns : QTableProps['columns'] = [
{
Expand All @@ -18,17 +42,10 @@ const columns : QTableProps['columns'] = [
sortable: false
},
{
name: 'fromDomain',
align: 'left',
label: 'From Domain',
field: 'fromDomain',
sortable: false
},
{
name: 'fromIpAddress',
name: 'delay',
align: 'left',
label: 'From IpAddress',
field: 'fromIpAddress',
label: 'Delay',
field: 'delay',
sortable: false
},
{
Expand All @@ -45,6 +62,27 @@ const columns : QTableProps['columns'] = [
field: 'byIpAddress',
sortable: false
},
{
name: 'fromDomain',
align: 'left',
label: 'From Domain',
field: 'fromDomain',
sortable: false
},
{
name: 'fromIpAddress',
align: 'left',
label: 'From IpAddress',
field: 'fromIpAddress',
sortable: false
},
{
name: 'via',
align: 'left',
label: 'Via',
field: 'via',
sortable: false
},
{
name: 'with',
align: 'left',
Expand Down Expand Up @@ -84,5 +122,12 @@ const columns : QTableProps['columns'] = [
{{ props.row.dateTime.toISOString() }}
</q-td>
</template>
<template #body-cell-delay="props">
<q-td>
<template v-if="delays[props.rowIndex] !== undefined">
{{ delays[props.rowIndex].toFixed(1) }}s
</template>
</q-td>
</template>
</q-table>
</template>

0 comments on commit 11af617

Please sign in to comment.