pridany modul Backend pre komuniaciu s API,
pridany template pre Bug Add, implementovana funkcionalita pre Bug Add, doplnene BUILD a DEV premenne
This commit is contained in:
@ -1,6 +1,193 @@
|
||||
<template>
|
||||
<div>
|
||||
<h1>Pridať bug</h1>
|
||||
<router-link to="/">Prejsť na Dashboard</router-link>
|
||||
<div id="bug-add">
|
||||
<h1>Pridať nový bug</h1>
|
||||
|
||||
<form @submit.prevent="submitForm" class="form">
|
||||
<div class="form-group">
|
||||
<label for="title">Názov:</label>
|
||||
<input
|
||||
type="text"
|
||||
id="title"
|
||||
v-model="bugReport.title"
|
||||
required
|
||||
class="form-control"
|
||||
placeholder="Zadajte názov bug reportu"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="description">Popis:</label>
|
||||
<textarea
|
||||
id="description"
|
||||
v-model="bugReport.description"
|
||||
rows="5"
|
||||
class="form-control"
|
||||
placeholder="Detailný popis problému"
|
||||
required
|
||||
></textarea>
|
||||
</div>
|
||||
|
||||
<div class="cols">
|
||||
<div class="form-group">
|
||||
<label for="files">Prílohy:</label>
|
||||
<input
|
||||
type="file"
|
||||
id="files"
|
||||
@change="handleFileUpload"
|
||||
multiple
|
||||
class="form-control file-input"
|
||||
/>
|
||||
<div class="selected-files" v-if="selectedFiles.length > 0">
|
||||
<p>Vybrané súbory:</p>
|
||||
|
||||
<p v-for="(file, index) in selectedFiles" :key="index">
|
||||
<button
|
||||
type="button"
|
||||
class="remove-file"
|
||||
@click="removeFile(index)"
|
||||
>
|
||||
<font-awesome-icon :icon="['fas', 'circle-xmark']" /> Odober
|
||||
súbor
|
||||
</button>
|
||||
|
||||
{{ file.name }} ({{ formatFileSize(file.size) }})
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="priority">Priorita:</label>
|
||||
<select
|
||||
id="priority"
|
||||
v-model="bugReport.priority"
|
||||
class="form-control"
|
||||
required
|
||||
>
|
||||
<option value="" disabled>Vyberte prioritu</option>
|
||||
<option value="0">Nízka</option>
|
||||
<option value="1">Stredná</option>
|
||||
<option value="2">Vysoká</option>
|
||||
<option value="3">Kritická</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="group">Skupina:</label>
|
||||
<select
|
||||
id="group"
|
||||
v-model="bugReport.group"
|
||||
class="form-control"
|
||||
required
|
||||
>
|
||||
<option value="" disabled>Vyberte skupinu</option>
|
||||
<option value="cp">Control Panel</option>
|
||||
<option value="task">Task.Platon.sk</option>
|
||||
<option value="websiteip">WebsiteIP</option>
|
||||
<option value="antispam">Antispam</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-actions">
|
||||
<router-link to="/" class="button"
|
||||
><font-awesome-icon :icon="['fas', 'circle-arrow-left']" />
|
||||
Zrušiť</router-link
|
||||
>
|
||||
<button type="submit">
|
||||
<font-awesome-icon :icon="['fas', 'circle-check']" /> Odoslať
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { backend } from "../backend";
|
||||
|
||||
export default {
|
||||
name: "BugAdd",
|
||||
data() {
|
||||
return {
|
||||
bugReport: {
|
||||
title: "",
|
||||
description: "",
|
||||
priority: "1",
|
||||
group: "cp",
|
||||
files: [],
|
||||
},
|
||||
selectedFiles: [],
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
handleFileUpload(event) {
|
||||
const files = event.target.files;
|
||||
if (files) {
|
||||
for (let i = 0; i < files.length; i++) {
|
||||
this.selectedFiles.push(files[i]);
|
||||
}
|
||||
}
|
||||
},
|
||||
removeFile(index) {
|
||||
this.selectedFiles.splice(index, 1);
|
||||
},
|
||||
formatFileSize(size) {
|
||||
if (size < 1024) {
|
||||
return size + " B";
|
||||
} else if (size < 1024 * 1024) {
|
||||
return (size / 1024).toFixed(2) + " KB";
|
||||
} else {
|
||||
return (size / (1024 * 1024)).toFixed(2) + " MB";
|
||||
}
|
||||
},
|
||||
submitForm() {
|
||||
// Vytvorenie FormData objektu pre odoslanie súborov
|
||||
const formData = new FormData();
|
||||
formData.append("title", this.bugReport.title);
|
||||
formData.append("description", this.bugReport.description);
|
||||
formData.append("priority", this.bugReport.priority);
|
||||
|
||||
// Pridanie súborov do FormData
|
||||
this.selectedFiles.forEach((file, index) => {
|
||||
formData.append(`file${index}`, file);
|
||||
});
|
||||
|
||||
// Tu by nasledovalo odoslanie dát na server
|
||||
console.log("Odosielam bug report:", {
|
||||
title: this.bugReport.title,
|
||||
description: this.bugReport.description,
|
||||
priority: this.bugReport.priority,
|
||||
files: this.selectedFiles.map((f) => f.name),
|
||||
});
|
||||
backend
|
||||
.add(
|
||||
this.bugReport.title,
|
||||
this.bugReport.description,
|
||||
"0",
|
||||
this.bugReport.group,
|
||||
this.bugReport.priority
|
||||
)
|
||||
.then((result) => {
|
||||
console.log(result);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log(error);
|
||||
});
|
||||
|
||||
// this.resetForm();
|
||||
// this.$router.push("/");
|
||||
},
|
||||
resetForm() {
|
||||
this.bugReport = {
|
||||
title: "",
|
||||
description: "",
|
||||
priority: "",
|
||||
files: [],
|
||||
};
|
||||
this.selectedFiles = [];
|
||||
// Resetovanie file input
|
||||
const fileInput = document.getElementById("files");
|
||||
if (fileInput) fileInput.value = "";
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user