This commit is contained in:
2026-01-04 12:38:41 +01:00
parent 96765342d1
commit 1a4b706702
14 changed files with 230 additions and 31 deletions

View File

@@ -17,7 +17,11 @@
<label>
Type :
<input type="number" name="channel_type" v-model="form_inputs.channel_type">
<!-- <input type="number" name="channel_type" v-model="form_inputs.channel_type">-->
<select v-model="form_inputs.channel_type">
<option value="text">Text</option>
<option value="voice">Voice</option>
</select>
</label>
<button type="submit" @click="create_channel">Create</button>
@@ -33,18 +37,22 @@ let form_inputs = ref({
name: '',
server_id: null,
category_id: null,
channel_type: 0,
channel_type: 'text', // Changé de 0 à 'text'
position: 0
})
// defined methods
async function create_channel(){
// Petit nettoyage pour éviter d'envoyer "" au lieu de null pour les UUIDs
const payload = { ...form_inputs.value };
if (!payload.server_id) payload.server_id = null;
if (!payload.category_id) payload.category_id = null;
const response = await fetch("/api/channel/channels/", {
method: 'POST',
headers: {
"Content-Type": "application/json",
"Accept": "application/json",
},
body: JSON.stringify(form_inputs.value)
body: JSON.stringify(payload)
})
if (response.ok) {
emit('created', await response.json())

View File

@@ -2,6 +2,10 @@
<div>
<div>
<h3>server : {{server.name}} ({{server.id}}) <button @click="remove">Remove</button></h3>
<div>
<p>tree :</p>
<pre>{{JSON.stringify(tree, null, 2)}}</pre>
</div>
</div>
<hr>
@@ -19,6 +23,7 @@ const {server} = defineProps({
required: true
}
})
const tree = ref(null)
const emit = defineEmits(['remove'])
// defined methods
@@ -33,8 +38,18 @@ async function remove(){
}
}
onMounted(() => {
async function fetch_tree(){
const response = await fetch(`/api/server/servers/${server.id}/tree/`)
if (response.ok) {
tree.value = await response.json()
console.log(tree)
} else {
console.error("Failed to fetch server tree:", response.statusText)
}
}
onMounted(() => {
fetch_tree()
})
</script>