Skip to content

Commit

Permalink
feat: Refactor useNotificationsClientStore.ts and clean up unused fil…
Browse files Browse the repository at this point in the history
…es and code

- Deleted unused files to improve project organization.
- Added translations for component elements.
- Refactored constants in useNotificationsClientsStore for better readability and maintainability.
- Cleaned up unused code in NotificationsClientsTable.vue to streamline the component.

See: BEDS-324
  • Loading branch information
benji-bitfly committed Sep 10, 2024
1 parent ad074c3 commit 7742b30
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 50 deletions.
65 changes: 47 additions & 18 deletions frontend/components/notifications/NotificationsClientsTable.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
<script setup lang="ts">
import { useNotificationsClientsStore } from '~/stores/notifications/useNotificationsClientsStore'
import { useNotificationsClientStore } from '~/stores/notifications/useNotificationsClientsStore'
import type { Cursor } from '~/types/datatable'
defineEmits<{ (e: 'openDialog'): void }>()
const { width } = useWindowSize()
const cursor = ref<Cursor>()
const pageSize = ref<number>(10)
const { t: $t } = useTranslation()
Expand All @@ -17,12 +16,11 @@ const {
setCursor,
setPageSize,
setSearch,
} = useNotificationsClientsStore()
} = useNotificationsClientStore()
const colsVisible = computed(() => {
return {
footer: 1024,
threshold: width.value > 830,
}
})
Expand All @@ -38,7 +36,7 @@ const clientLink = computed(() => {
<div>
<BcTableControl
:title="$t('notifications.clients.title')"
:search-placeholder="$t('notifications.dashboards.search_placeholder')"
:search-placeholder="$t('notifications.clients.search_placeholder')"
@set-search="setSearch"
>
<template #table>
Expand All @@ -50,34 +48,29 @@ const clientLink = computed(() => {
:page-size
:selected-sort="query?.sort"
:loading="isLoading"
:add-spacer="true"
@set-cursor="setCursor"
@sort="onSort"
@set-page-size="setPageSize"
>
<Column
field="machine_name"
sortable
header-class="col-client-name"
body-class="col-client-name"
:header="$t('notifications.clients.col.client_name')"
>
<template #body="slotProps">
<pre>
{{ slotProps.data.client_name }}
</pre>
{{ slotProps.data.client_name }}
</template>
</Column>
<Column
field="machine_name"
header-class="col-client-name"
body-class="col-client-name"
header-class="col-version"
body-class="col-version"
:header="$t('notifications.clients.col.version')"
>
<template #body="slotProps">
<BcLink
:to="clientLink"
class="link link-dashboard"
class="link"
target="_blank"
>
{{ slotProps.data.version }}
Expand All @@ -96,7 +89,6 @@ const clientLink = computed(() => {
<template #body="slotProps">
<BcFormatTimePassed
:value="slotProps.data.timestamp"
type="go-timestamp"
/>
</template>
</Column>
Expand All @@ -120,16 +112,16 @@ const clientLink = computed(() => {
</template>

<style lang="scss" scoped>
@use "~/assets/css/main.scss";
@use "~/assets/css/utils.scss";
$breakpoint-sm: 630px;
$breakpoint-md: 780px;
$breakpoint-lg: 1024px;
:deep(.col-client-name) {
*:not([data-pc-section="sort"]) {
@include utils.truncate-text;
}
@include utils.truncate-text;
@media (max-width: $breakpoint-lg) {
@include utils.set-all-width(240px);
Expand All @@ -144,6 +136,22 @@ $breakpoint-lg: 1024px;
}
}
:deep(.col-version) {
@include utils.truncate-text;
@media (max-width: $breakpoint-lg) {
@include utils.set-all-width(140px);
}
@media (max-width: $breakpoint-sm) {
@include utils.set-all-width(78px);
}
// *:not([data-pc-section="sort"]) {
// }
}
:deep(.col-age) {
@media (max-width: $breakpoint-lg) {
@include utils.set-all-width(140px);
Expand All @@ -157,4 +165,25 @@ $breakpoint-lg: 1024px;
@include utils.truncate-text;
}
}
.management-table {
@include main.container;
flex-grow: 1;
display: flex;
flex-direction: column;
overflow-y: hidden;
justify-content: space-between;
:deep(.p-datatable-wrapper) {
flex-grow: 1;
}
}
td > .col-client-name > a{
text-overflow: ellipsis !important;
}
td > .col-client-name {
text-overflow: ellipsis !important;
}
</style>
1 change: 1 addition & 0 deletions frontend/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,7 @@
"footer":{
"subscriptions": "Clients ({count} Subscriptions)"
},
"search_placeholder":"Client",
"title": "Clients"
},
"col": {
Expand Down
31 changes: 0 additions & 31 deletions frontend/public/mock/notifications/managementDashboard.json

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const notificationsClientsStore = defineStore('notifications-clients-store', ()
return { data }
})

export function useNotificationsClientsStore() {
export function useNotificationsClientStore() {
const { isLoggedIn } = useUserStore()

const { fetch } = useCustomFetch()
Expand Down

0 comments on commit 7742b30

Please sign in to comment.