diff --git a/components/Forms/PublishForm.vue b/components/Forms/PublishForm.vue new file mode 100644 index 0000000..03b78c6 --- /dev/null +++ b/components/Forms/PublishForm.vue @@ -0,0 +1,73 @@ + + + \ No newline at end of file diff --git a/components/Resources/Services/Overview.vue b/components/Resources/Services/Overview.vue index 727ae55..3781814 100644 --- a/components/Resources/Services/Overview.vue +++ b/components/Resources/Services/Overview.vue @@ -15,10 +15,8 @@ // along with this program. If not, see . import MetricCard from "~/components/Cards/MetricCard.vue"; -import TimedMetricCard from "~/components/Cards/TimedMetricCard.vue"; import type {InfoResponse} from "@throttr/sdk"; import { formatDate } from "~/server/throttr/utils"; -import MemoryChart from "~/components/Charts/MemoryChart.vue"; const route = useRoute() const services = useServices() diff --git a/components/Tables/ChannelsTable.vue b/components/Tables/ChannelsTable.vue index fa1cff8..b48995d 100644 --- a/components/Tables/ChannelsTable.vue +++ b/components/Tables/ChannelsTable.vue @@ -67,8 +67,10 @@ const columns: TableColumn[] = [ open_channel.value = true; } }, { - label: 'Update', + label: 'Publish', async onSelect() { + channel_publish.value = row.original.channel; + open_publish.value = true; } }, { type: 'separator' @@ -103,6 +105,8 @@ const columns: TableColumn[] = [ const props = defineProps(['channels']) const open_channel = ref(false); +const open_publish = ref(false); +const channel_publish = ref(''); const sorting = ref([ { @@ -124,5 +128,15 @@ const sorting = ref([ + + + + diff --git a/components/Tables/ConnectionsTable.vue b/components/Tables/ConnectionsTable.vue index 523ede4..63d078d 100644 --- a/components/Tables/ConnectionsTable.vue +++ b/components/Tables/ConnectionsTable.vue @@ -53,23 +53,12 @@ const columns: TableColumn[] = [ }, { label: 'View', async onSelect() { - - } - }, { - label: 'Update', - async onSelect() { - } - }, { - type: 'separator' - }, { - label: 'Stats', - async onSelect() { } }, { - type: 'separator' - }, { - label: 'Remove', + label: 'Publish', async onSelect() { + publish_channel.value = row.original.id; + open_publish.value = true; } }] @@ -92,8 +81,20 @@ const columns: TableColumn[] = [ const props = defineProps(['connections']) +const open_publish = ref(false); +const publish_channel = ref(''); + diff --git a/server/api/services/[id]/publish.post.ts b/server/api/services/[id]/publish.post.ts new file mode 100644 index 0000000..bae3998 --- /dev/null +++ b/server/api/services/[id]/publish.post.ts @@ -0,0 +1,37 @@ +// Copyright (C) 2025 Ian Torres +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +import {getServices, ServiceWrapper} from '~/server/throttr/instances' +import {RequestType, StatusResponse} from '@throttr/sdk' + +export default defineEventHandler(async (event) => { + const services = getServices(); + const body = await readBody(event) + + const { channel, value } = body + + if (!channel || !value) { + throw createError({ statusCode: 400, statusMessage: 'Missing parameters' }) + } + const { id } = event.context.params!; + + const index = services.findIndex((item) => item.id === id); + const service : ServiceWrapper = services[index]; + return (await service.instance.send({ + type: RequestType.Publish, + channel: channel, + value: value, + })) as StatusResponse; +}) \ No newline at end of file