Compare commits
1 commit
44c6a3b1a7
...
b773a0dde1
Author | SHA1 | Date | |
---|---|---|---|
b773a0dde1 |
3 changed files with 2 additions and 43 deletions
|
@ -1,22 +0,0 @@
|
||||||
export type ServerConfig = {
|
|
||||||
id: number,
|
|
||||||
serverId: number,
|
|
||||||
systemMessage: string,
|
|
||||||
rateLimit: number,
|
|
||||||
time: string
|
|
||||||
}
|
|
||||||
|
|
||||||
const exampleServerConfig: ServerConfig = {
|
|
||||||
id: 1,
|
|
||||||
serverId: 1091358909513609246,
|
|
||||||
systemMessage: "Foo",
|
|
||||||
rateLimit: 10,
|
|
||||||
time: "1680676051.633872000"
|
|
||||||
}
|
|
||||||
|
|
||||||
export function isServerConfig(serverConfig: ServerConfig | any): serverConfig is ServerConfig {
|
|
||||||
const requiredFields = Object.getOwnPropertyNames(exampleServerConfig)
|
|
||||||
const fieldsToCheck = Object.getOwnPropertyNames(serverConfig)
|
|
||||||
const foundFields = requiredFields.filter(field => fieldsToCheck.filter(fieldToCheck => fieldToCheck === field).length === 1)
|
|
||||||
return foundFields.length >= requiredFields.length
|
|
||||||
}
|
|
|
@ -1,19 +0,0 @@
|
||||||
import { isServerConfig, type ServerConfig } from "@/models/server";
|
|
||||||
|
|
||||||
export async function getConfigs(): Promise<ServerConfig[]> {
|
|
||||||
return fetch(import.meta.env.VITE_API_URL + "/servers/configs")
|
|
||||||
.then(shouldBeSuccess)
|
|
||||||
.then(res => res.json())
|
|
||||||
.then(toArray)
|
|
||||||
.then(list => list.filter(isServerConfig))
|
|
||||||
}
|
|
||||||
|
|
||||||
function shouldBeSuccess(res: Response): Response {
|
|
||||||
if (res.status >= 200 && res.status < 300) return res
|
|
||||||
throw new Error(`Expected success status code but got: ${res.status} ${res.statusText}`)
|
|
||||||
}
|
|
||||||
|
|
||||||
function toArray(subject: any): any[] {
|
|
||||||
if (subject instanceof Array) return subject as any[]
|
|
||||||
throw new Error("Could not be casted to an array")
|
|
||||||
}
|
|
|
@ -1,8 +1,8 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import TableComponent from '@/components/TableComponent.vue';
|
import TableComponent from '@/components/TableComponent.vue';
|
||||||
|
|
||||||
const tableHeader = ["ID", "Server ID", "System Message", "Context Length", "Rate limit", "Created"]
|
const tableHeader = ["ID", "Server ID", "System Message", "Rate limit"]
|
||||||
const tableRows = [["1", "name", "comment", "5", "1", Date.now()]]
|
const tableRows = [["1", "name", "comment", "1"]]
|
||||||
const actions = [{ class: "btn btn-sm btn-info m-1", content: "Edit", event: (_: number) => { } }, { class: "btn btn-sm btn-error m-1", content: "Delete", event: (_: number) => { } }]
|
const actions = [{ class: "btn btn-sm btn-info m-1", content: "Edit", event: (_: number) => { } }, { class: "btn btn-sm btn-error m-1", content: "Delete", event: (_: number) => { } }]
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
|
|
Loading…
Reference in a new issue