|
| 1 | +<template> |
| 2 | + <v-container> |
| 3 | + <h1 class="text-h6 my-4">New task</h1> |
| 4 | + |
| 5 | + <form-dialog @create="createTask($event)"> |
| 6 | + <template #activator="{ props: activatorProps }"> |
| 7 | + <v-card |
| 8 | + v-bind="activatorProps" |
| 9 | + title="Add a repository" |
| 10 | + subtitle="Collect data from a single git repository" |
| 11 | + prepend-icon="mdi-git" |
| 12 | + variant="outlined" |
| 13 | + ></v-card> |
| 14 | + </template> |
| 15 | + </form-dialog> |
| 16 | + |
| 17 | + <v-card |
| 18 | + :to="{ name: 'loadSbom' }" |
| 19 | + title="Load SPDX SBoM file" |
| 20 | + subtitle="Load repositories from an SBoM file in SPDX format" |
| 21 | + prepend-icon="mdi-file-upload-outline" |
| 22 | + variant="outlined" |
| 23 | + ></v-card> |
| 24 | + |
| 25 | + <v-snackbar v-model="snackbar.open" :color="snackbar.color"> |
| 26 | + {{ snackbar.text }} |
| 27 | + </v-snackbar> |
| 28 | + </v-container> |
| 29 | +</template> |
| 30 | +<script> |
| 31 | +import { API } from '@/services/api' |
| 32 | +import FormDialog from '@/components/FormDialog.vue' |
| 33 | +
|
| 34 | +export default { |
| 35 | + name: 'NewTask', |
| 36 | + components: { FormDialog }, |
| 37 | + data() { |
| 38 | + return { |
| 39 | + snackbar: { |
| 40 | + open: false, |
| 41 | + color: 'success', |
| 42 | + text: '' |
| 43 | + } |
| 44 | + } |
| 45 | + }, |
| 46 | + methods: { |
| 47 | + async createTask(formData) { |
| 48 | + try { |
| 49 | + const response = await API.scheduler.create(formData) |
| 50 | + Object.assign(this.snackbar, { |
| 51 | + open: true, |
| 52 | + color: 'success', |
| 53 | + text: response.data.message |
| 54 | + }) |
| 55 | + this.$router.push({ name: 'taskList' }) |
| 56 | + } catch (error) { |
| 57 | + Object.assign(this.snackbar, { |
| 58 | + open: true, |
| 59 | + color: 'error', |
| 60 | + text: error.response?.data?.message || error |
| 61 | + }) |
| 62 | + } |
| 63 | + } |
| 64 | + } |
| 65 | +} |
| 66 | +</script> |
| 67 | +<style lang="scss" scoped> |
| 68 | +@media (min-width: 1280px) { |
| 69 | + .v-container { |
| 70 | + max-width: 900px; |
| 71 | + } |
| 72 | +} |
| 73 | +:deep(.v-card) { |
| 74 | + background: rgb(var(--v-theme-surface)); |
| 75 | + border: thin solid rgba(0, 0, 0, 0.08); |
| 76 | + margin-bottom: 12px; |
| 77 | +
|
| 78 | + .v-card-title { |
| 79 | + font-size: 1rem; |
| 80 | + } |
| 81 | +
|
| 82 | + .v-card-item__prepend { |
| 83 | + margin-inline-end: 1rem; |
| 84 | + background: #fff8f2; |
| 85 | + padding: 8px; |
| 86 | + border-radius: 4px; |
| 87 | + border: thin solid currentColor; |
| 88 | + color: rgb(var(--v-theme-secondary), 0.08); |
| 89 | +
|
| 90 | + .v-icon { |
| 91 | + color: rgb(var(--v-theme-secondary)); |
| 92 | + } |
| 93 | + } |
| 94 | +} |
| 95 | +</style> |
0 commit comments