mirror of
https://github.com/m1k1o/neko-rooms.git
synced 2026-11-02 22:51:34 -06:00
resources client side.
This commit is contained in:
@@ -160,10 +160,10 @@
|
|||||||
<v-simple-table>
|
<v-simple-table>
|
||||||
<template v-slot:default>
|
<template v-slot:default>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr><th style="width:50%;"> CPU Shares </th><td :title="settings.resources.cpu_shares"><span v-if="settings.resources.cpu_shares">{{ settings.resources.cpu_shares | bytes }}</span><i v-else>--unlimited--</i></td></tr>
|
<tr><th style="width:50%;"> CPUs </th><td :title="settings.resources.nano_cpus"><span v-if="settings.resources.nano_cpus">{{ settings.resources.nano_cpus | nanocpus }}</span><i v-else>--undefined--</i></td></tr>
|
||||||
<tr><th> Nano CPUs </th><td :title="settings.resources.nano_cpus"><span v-if="settings.resources.nano_cpus">{{ settings.resources.nano_cpus | bytes }}</span><i v-else>--unlimited--</i></td></tr>
|
<tr><th> Memory </th><td :title="settings.resources.memory"><span v-if="settings.resources.memory">{{ settings.resources.memory | memory }}</span><i v-else>--undefined--</i></td></tr>
|
||||||
<tr><th> Shm Size </th><td :title="settings.resources.shm_size">{{ settings.resources.shm_size | bytes }}</td></tr>
|
<tr><th> CPU Shares </th><td :title="settings.resources.cpu_shares"><span v-if="settings.resources.cpu_shares">{{ settings.resources.cpu_shares }}</span><i v-else>--undefined--</i></td></tr>
|
||||||
<tr><th> Memory </th><td :title="settings.resources.memory"><span v-if="settings.resources.memory">{{ settings.resources.memory | bytes }}</span><i v-else>--unlimited--</i></td></tr>
|
<tr><th> Shm Size </th><td :title="settings.resources.shm_size">{{ settings.resources.shm_size | memory }}</td></tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</template>
|
</template>
|
||||||
</v-simple-table>
|
</v-simple-table>
|
||||||
|
|||||||
@@ -270,6 +270,45 @@
|
|||||||
<strong>Public</strong>: Host path must be whitelisted in config and exists on the host.
|
<strong>Public</strong>: Host path must be whitelisted in config and exists on the host.
|
||||||
</p>
|
</p>
|
||||||
</v-row>
|
</v-row>
|
||||||
|
<v-row align="center" no-gutters>
|
||||||
|
<h2> Resources </h2>
|
||||||
|
</v-row>
|
||||||
|
<v-row align="center">
|
||||||
|
<v-col>
|
||||||
|
<v-slider
|
||||||
|
v-model="data.resources.memory"
|
||||||
|
label="Memory"
|
||||||
|
thumb-label="always"
|
||||||
|
:thumb-size="30"
|
||||||
|
:min="0"
|
||||||
|
:max="8*1e9"
|
||||||
|
:step="0.2*1e9"
|
||||||
|
color="blue"
|
||||||
|
>
|
||||||
|
<template v-slot:thumb-label="{ value }">
|
||||||
|
<span v-if="value">{{ value | memory }}</span>
|
||||||
|
<span v-else>N/A</span>
|
||||||
|
</template>
|
||||||
|
</v-slider>
|
||||||
|
</v-col>
|
||||||
|
<v-col>
|
||||||
|
<v-slider
|
||||||
|
v-model="data.resources.nano_cpus"
|
||||||
|
label="CPUs"
|
||||||
|
thumb-label="always"
|
||||||
|
:thumb-size="30"
|
||||||
|
:min="0"
|
||||||
|
:max="8*1e9"
|
||||||
|
:step="0.2*1e9"
|
||||||
|
color="blue"
|
||||||
|
>
|
||||||
|
<template v-slot:thumb-label="{ value }">
|
||||||
|
<span v-if="value">{{ value | nanocpus }}</span>
|
||||||
|
<span v-else>N/A</span>
|
||||||
|
</template>
|
||||||
|
</v-slider>
|
||||||
|
</v-col>
|
||||||
|
</v-row>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<hr />
|
<hr />
|
||||||
@@ -578,6 +617,11 @@ export default class RoomsCreate extends Vue {
|
|||||||
...this.$store.state.defaultRoomSettings,
|
...this.$store.state.defaultRoomSettings,
|
||||||
// eslint-disable-next-line
|
// eslint-disable-next-line
|
||||||
neko_image: this.nekoImages[0],
|
neko_image: this.nekoImages[0],
|
||||||
|
resources: {
|
||||||
|
// eslint-disable-next-line
|
||||||
|
nano_cpus: 0,
|
||||||
|
memory: 0,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
this.browserPolicyContent = { ...this.$store.state.defaultBrowserPolicyContent }
|
this.browserPolicyContent = { ...this.$store.state.defaultBrowserPolicyContent }
|
||||||
this.envList = Object.entries({...this.data.envs}).map(([ key, val ]) => ({ key, val, }))
|
this.envList = Object.entries({...this.data.envs}).map(([ key, val ]) => ({ key, val, }))
|
||||||
|
|||||||
@@ -21,20 +21,23 @@ Vue.filter('percent', function(value: any) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
// eslint-disable-next-line
|
// eslint-disable-next-line
|
||||||
Vue.filter('bytes', function(value: any) {
|
Vue.filter('memory', function(value: any) {
|
||||||
if (Math.abs(value) < 1000) {
|
if (value < 1e3) {
|
||||||
return value + ' B';
|
return value + 'B'
|
||||||
}
|
}
|
||||||
|
|
||||||
const units = ['K', 'M', 'G']
|
if (value < 1e6) {
|
||||||
let u = -1;
|
return (value / 1e3).toFixed(0) + 'K'
|
||||||
const r = 10**2;
|
}
|
||||||
|
|
||||||
do {
|
if (value < 1e9) {
|
||||||
value /= 1000;
|
return (value / 1e6).toFixed(0) + 'M'
|
||||||
++u;
|
}
|
||||||
} while (Math.round(Math.abs(value) * r) / r >= 1000 && u < units.length - 1);
|
|
||||||
|
|
||||||
|
return (value / 1e9).toFixed(1) + 'G'
|
||||||
return value.toFixed(2) + units[u];
|
})
|
||||||
|
|
||||||
|
// eslint-disable-next-line
|
||||||
|
Vue.filter('nanocpus', function(value: any) {
|
||||||
|
return (value / 1e9).toFixed(1) + 'x'
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user