-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2641 from threefoldtech/development_2.5_unify_nod…
…e_resources Unify node resources
- Loading branch information
Showing
3 changed files
with
50 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<template> | ||
<v-row justify="center"> | ||
<div v-for="item in resources" :key="item.name" class="mx-6 d-flex flex-column pt-2 mt-2 align-center"> | ||
<div class="mb-2">{{ item.name }}</div> | ||
<div class="text-center"> | ||
<v-progress-circular :model-value="item.value !== 'NaN' ? item.value : 0" :size="150" :width="15" color="info"> | ||
{{ item.value !== "NaN" ? item.value + "%" : "N/A" }} | ||
</v-progress-circular> | ||
</div> | ||
</div> | ||
</v-row> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import type { GridNode } from "@threefold/gridproxy_client"; | ||
import { computed, type PropType } from "vue"; | ||
const RESOURCES = ["cru", "mru", "sru", "hru"] as const; | ||
const NAMED_RESOURCES = { cru: "CPU", mru: "RAM", sru: "SSD", hru: "HDD" } as const; | ||
export default { | ||
name: "NodeResources", | ||
props: { | ||
node: { type: Object as PropType<GridNode>, required: true }, | ||
}, | ||
setup(props) { | ||
const resources = computed(() => { | ||
return RESOURCES.map(id => { | ||
const value = Reflect.get(props.node.used_resources, id) / Reflect.get(props.node.total_resources, id); | ||
return { | ||
id, | ||
value: (value * 100).toFixed(2), | ||
name: NAMED_RESOURCES[id], | ||
}; | ||
}); | ||
}); | ||
return { resources }; | ||
}, | ||
}; | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters