Skip to content

Commit

Permalink
feature: Asset package-count column
Browse files Browse the repository at this point in the history
  • Loading branch information
abugraokkali committed Dec 29, 2023
1 parent 2812389 commit 2aa53c6
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 23 deletions.
1 change: 1 addition & 0 deletions frontend/src/localization/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@
"vendor": "Vendor",
"model": "Model",
"serial_number": "Serial Number",
"package_count": "Package Count",
"updated_at": "Updated At"
},
"fetch": {
Expand Down
1 change: 1 addition & 0 deletions frontend/src/localization/tr.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@
"vendor": "Sağlayıcı",
"model": "Model",
"serial_number": "Seri Numarası",
"package_count": "Paket Sayısı",
"updated_at": "Güncellenme Tarihi"
},
"fetch": {
Expand Down
1 change: 1 addition & 0 deletions frontend/src/models/Asset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export interface IAsset {
hostname: string
address: string
serial_number: string
package_count: number
vendor: string
model: string
discovery_id: string
Expand Down
7 changes: 4 additions & 3 deletions frontend/src/views/pages/AssetPackages.vue
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
<script setup lang="ts">
import { onMounted, reactive } from "vue"
import { useI18n } from "vue-i18n"
import { useRoute } from "vue-router"
import { useRoute, useRouter } from "vue-router"
import { useAssetStore } from "@/stores/asset"
import type { IColumn } from "@/models/Column"
import AsyncStore from "@/components/Table/AsyncStore.vue"
import Header from "@/components/UIElements/Header.vue"
import type { IColumn } from "@/models/Column"
const { t } = useI18n()
const store = useAssetStore()
const route = useRoute()
const router = useRouter()
onMounted(() => {
store.show(route.params.id)
Expand Down Expand Up @@ -52,7 +53,7 @@ const columns: IColumn[] = reactive([
<template>
<Header :description="t('asset.package.description')">
<template #header>
<n-button size="huge" text @click="$router.back()">
<n-button size="huge" text @click="router.push({ name: 'assets' })">
<i class="fas fa-arrow-left mr-3" />
</n-button>
<i class="fab fa-windows mr-2" />
Expand Down
48 changes: 28 additions & 20 deletions frontend/src/views/pages/Assets.vue
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<script setup lang="ts">
import { h, reactive } from "vue"
import { useI18n } from "vue-i18n"
import { NButton } from "naive-ui"
import AsyncStore from "@/components/Table/AsyncStore.vue"
import type { IColumn } from "@/models/Column"
import { useAssetStore } from "@/stores/asset"
import Header from "@/components/UIElements/Header.vue"
import type { IAsset } from "@/models/Asset"
import { NButton } from "naive-ui"
import router from "@/router"
import type { IColumn } from "@/models/Column"
import type { IAsset } from "@/models/Asset"
import Header from "@/components/UIElements/Header.vue"
const { t } = useI18n()
const store = useAssetStore()
Expand All @@ -23,22 +23,7 @@ const columns: IColumn[] = reactive([
tooltip: true,
},
render: (row: IAsset) => {
return [
h("i", { class: "fab fa-windows mr-2" }),
row.hostname,
h(
NButton,
{
text: true,
size: "small",
type: "primary",
class: "ml-2",
onClick: () =>
router.push({ name: "asset", params: { id: row.id } }),
},
{ default: () => h("i", { class: "fas fa-link" }) },
),
]
return [h("i", { class: "fab fa-windows mr-2" }), row.hostname]
},
},
{
Expand Down Expand Up @@ -81,6 +66,29 @@ const columns: IColumn[] = reactive([
tooltip: true,
},
},
{
title: t("asset.table.package_count"),
key: "package_count",
filterable: true,
sorter: "default",
resizable: true,
ellipsis: {
tooltip: true,
},
render: (row: IAsset) => {
return h(
NButton,
{
text: true,
size: "small",
type: "primary",
class: "ml-2",
onClick: () => router.push({ name: "asset", params: { id: row.id } }),
},
{ default: () => row.package_count },
)
},
},
{
title: t("asset.table.updated_at"),
key: "updated_at",
Expand Down

0 comments on commit 2aa53c6

Please sign in to comment.