Skip to content
This repository has been archived by the owner on Oct 5, 2023. It is now read-only.

Commit

Permalink
feat: server.cpu.vueをscript setupに変更 #122
Browse files Browse the repository at this point in the history
  • Loading branch information
yupix committed Aug 16, 2022
1 parent f126027 commit aae615b
Showing 1 changed file with 20 additions and 24 deletions.
44 changes: 20 additions & 24 deletions src/client/app/common/views/widgets/server.cpu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,28 @@
</div>
</template>

<script lang="ts">
import Vue from 'vue';
<script setup lang="ts">
import { onMounted, onUnmounted, ref } from 'vue';
import Stream from '../../scripts/stream';
import XPie from './server.pie.vue';
export default Vue.extend({
components: {
XPie
},
props: ['connection', 'meta'],
data() {
return {
usage: 0
};
},
mounted() {
this.connection.on('stats', this.onStats);
},
beforeDestroy() {
this.connection.off('stats', this.onStats);
},
methods: {
onStats(stats) {
this.usage = stats.cpu_usage;
}
}
});
const props = defineProps({
connection: { type: Stream},
meta: {type: Object}
})
let usage = ref(0)
const onStats = (stats) => {
usage.value = stats.cpu_usage;
}
onMounted(() => {
props.connection.on('stats', onStats);
}),
onUnmounted(() => {
props.connection.off('stats', onStats);
})
</script>

<style lang="stylus" scoped>
Expand Down

0 comments on commit aae615b

Please sign in to comment.