-
-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Update provision_content_pack_route description * added stack provisioning api/types * Fix customer_meta retrieval and use dictionary key access for field values * added stack provisioning form * precommit fixes --------- Co-authored-by: Davide Di Modica <webmaster.ddm@gmail.com>
- Loading branch information
1 parent
4c582db
commit 8fa4f66
Showing
10 changed files
with
271 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { type FlaskBaseResponse } from "@/types/flask.d" | ||
import { HttpClient } from "./httpClient" | ||
import type { AvailableContentPack } from "@/types/stackProvisioning" | ||
|
||
export default { | ||
getAvailableContentPacks() { | ||
return HttpClient.get<FlaskBaseResponse & { available_content_packs: AvailableContentPack[] }>( | ||
`/stack_provisioning/graylog/available/content_packs` | ||
) | ||
}, | ||
provisionContentPack(contentPackName: string) { | ||
return HttpClient.post<FlaskBaseResponse>(`/stack_provisioning/graylog/provision/content_pack`, { | ||
content_pack_name: contentPackName | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
frontend/src/components/stackProvisioning/StackProvisioningButton.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<template> | ||
<n-button :size="size" :type="type" @click="showForm = true"> | ||
<template #icon><Icon :name="PackIcon"></Icon></template> | ||
Stack Provisioning | ||
</n-button> | ||
|
||
<n-modal | ||
v-model:show="showForm" | ||
display-directive="show" | ||
preset="card" | ||
:style="{ maxWidth: 'min(600px, 90vw)', minHeight: 'min(300px, 90vh)', overflow: 'hidden' }" | ||
title="Deploy Content Packs" | ||
:bordered="false" | ||
segmented | ||
> | ||
<StackProvisioningList /> | ||
</n-modal> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { ref } from "vue" | ||
import { NButton, NModal } from "naive-ui" | ||
import Icon from "@/components/common/Icon.vue" | ||
import StackProvisioningList from "./StackProvisioningList.vue" | ||
const { type, size } = defineProps<{ | ||
size?: "tiny" | "small" | "medium" | "large" | ||
type?: "default" | "tertiary" | "primary" | "info" | "success" | "warning" | "error" | ||
}>() | ||
const PackIcon = "mdi:package-variant" | ||
const showForm = ref(false) | ||
</script> |
114 changes: 114 additions & 0 deletions
114
frontend/src/components/stackProvisioning/StackProvisioningItem.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
<template> | ||
<div class="item flex flex-col gap-2 px-5 py-3"> | ||
<div class="header-box flex justify-between gap-4"> | ||
<div class="name">{{ contentPack.name }}</div> | ||
</div> | ||
<div class="main-box flex justify-between gap-4"> | ||
<div class="description">{{ contentPack.description }}</div> | ||
<div class="actions-box"> | ||
<n-button :loading="loadingProvision" type="success" secondary @click="provision(contentPack.name)"> | ||
<template #icon><Icon :name="DeployIcon"></Icon></template> | ||
Deploy | ||
</n-button> | ||
</div> | ||
</div> | ||
<div class="footer-box flex justify-between items-center gap-4"> | ||
<div class="actions-box"> | ||
<n-button | ||
:loading="loadingProvision" | ||
type="success" | ||
secondary | ||
size="small" | ||
@click="provision(contentPack.name)" | ||
> | ||
<template #icon><Icon :name="DeployIcon"></Icon></template> | ||
Deploy | ||
</n-button> | ||
</div> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { ref } from "vue" | ||
import Icon from "@/components/common/Icon.vue" | ||
import { NButton, useMessage } from "naive-ui" | ||
import Api from "@/api" | ||
import type { AvailableContentPack } from "@/types/stackProvisioning" | ||
const emit = defineEmits<{ | ||
(e: "provisioned"): void | ||
}>() | ||
const { contentPack } = defineProps<{ contentPack: AvailableContentPack }>() | ||
const DeployIcon = "mdi:package-variant-closed-check" | ||
const loadingProvision = ref(false) | ||
const message = useMessage() | ||
function provision(contentPackName: string) { | ||
loadingProvision.value = true | ||
Api.stackProvisioning | ||
.provisionContentPack(contentPackName) | ||
.then(res => { | ||
if (res.data.success) { | ||
message.success(res.data?.message || "Content Pack Provisioned Successfully") | ||
emit("provisioned") | ||
} else { | ||
message.warning(res.data?.message || "An error occurred. Please try again later.") | ||
} | ||
}) | ||
.catch(err => { | ||
message.error(err.response?.data?.message || "An error occurred. Please try again later.") | ||
}) | ||
.finally(() => { | ||
loadingProvision.value = false | ||
}) | ||
} | ||
</script> | ||
|
||
<style lang="scss" scoped> | ||
.item { | ||
border-radius: var(--border-radius); | ||
background-color: var(--bg-secondary-color); | ||
transition: all 0.2s var(--bezier-ease); | ||
border: var(--border-small-050); | ||
.header-box { | ||
font-size: 13px; | ||
.name { | ||
font-family: var(--font-family-mono); | ||
word-break: break-word; | ||
color: var(--fg-secondary-color); | ||
} | ||
} | ||
.main-box { | ||
.description { | ||
word-break: break-word; | ||
} | ||
} | ||
.footer-box { | ||
display: none; | ||
font-size: 13px; | ||
margin-top: 10px; | ||
} | ||
&:hover { | ||
box-shadow: 0px 0px 0px 1px inset var(--primary-color); | ||
} | ||
@container (max-width: 450px) { | ||
.main-box { | ||
.actions-box { | ||
display: none; | ||
} | ||
} | ||
.footer-box { | ||
display: flex; | ||
} | ||
} | ||
} | ||
</style> |
58 changes: 58 additions & 0 deletions
58
frontend/src/components/stackProvisioning/StackProvisioningList.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<template> | ||
<div class="stack-provisioning-list"> | ||
<n-spin :show="loading"> | ||
<div class="list my-3"> | ||
<template v-if="list.length"> | ||
<StackProvisioningItem v-for="item of list" :key="item.name" :content-pack="item" class="mb-2" /> | ||
</template> | ||
<template v-else> | ||
<n-empty description="No items found" class="justify-center h-48" v-if="!loading" /> | ||
</template> | ||
</div> | ||
</n-spin> | ||
</div> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { ref, onBeforeMount, computed } from "vue" | ||
import { useMessage, NSpin, NEmpty } from "naive-ui" | ||
import Api from "@/api" | ||
import StackProvisioningItem from "./StackProvisioningItem.vue" | ||
import type { AvailableContentPack } from "@/types/stackProvisioning" | ||
const message = useMessage() | ||
const loadingList = ref(false) | ||
const list = ref<AvailableContentPack[]>([]) | ||
const loading = computed(() => loadingList.value) | ||
function getData() { | ||
loadingList.value = true | ||
Api.stackProvisioning | ||
.getAvailableContentPacks() | ||
.then(res => { | ||
if (res.data.success) { | ||
list.value = res.data.available_content_packs || [] | ||
} else { | ||
message.warning(res.data?.message || "An error occurred. Please try again later.") | ||
} | ||
}) | ||
.catch(err => { | ||
message.error(err.response?.data?.message || "An error occurred. Please try again later.") | ||
}) | ||
.finally(() => { | ||
loadingList.value = false | ||
}) | ||
} | ||
onBeforeMount(() => { | ||
getData() | ||
}) | ||
</script> | ||
|
||
<style lang="scss" scoped> | ||
.list { | ||
container-type: inline-size; | ||
min-height: 200px; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export interface AvailableContentPack { | ||
name: string | ||
description: string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters