feat: Add Kits + FurnaceSplitter plugin config modules
All checks were successful
Test Asgard Runner / test (push) Successful in 2s
All checks were successful
Test Asgard Runner / test (push) Successful in 2s
DB migrations 016 (kits_configs) and 019 (furnacesplitter_configs) applied. Backend: NestJS modules with CRUD, apply-to-server, import-from-server. Frontend: Pinia stores, Vue views with config editor, router + nav wiring. Kits view: 3-tab editor (list/editor/settings), kit items with shortname/amount/skinId/container. FurnaceSplitter view: per-furnace toggles, split count, fuel multiplier settings. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -31,6 +31,8 @@ import {
|
||||
Navigation2,
|
||||
Pickaxe,
|
||||
DoorOpen,
|
||||
Gift,
|
||||
Flame,
|
||||
Menu,
|
||||
X,
|
||||
} from 'lucide-vue-next'
|
||||
@@ -52,6 +54,10 @@ const navItems = [
|
||||
{ name: 'Teleport Config', path: '/teleport-config', icon: Navigation2, permission: 'teleport.view' },
|
||||
{ name: 'Gather Rates', path: '/gather-manager', icon: Pickaxe, permission: 'gather.view' },
|
||||
{ name: 'Auto Doors', path: '/autodoors', icon: DoorOpen, permission: 'autodoors.view' },
|
||||
{ name: 'Kits', path: '/kits', icon: Gift, permission: 'kits.view' },
|
||||
{ name: 'Furnace Splitter', path: '/furnace-splitter', icon: Flame, permission: 'furnacesplitter.view' },
|
||||
{ name: 'Better Chat', path: '/better-chat', icon: MessageSquare, permission: 'betterchat.view' },
|
||||
{ name: 'Timed Execute', path: '/timed-execute', icon: Clock, permission: 'timedexecute.view' },
|
||||
{ name: 'Auto-Wiper', path: '/wipes', icon: RefreshCw, permission: 'wipes.view' },
|
||||
{ name: 'Maps', path: '/maps', icon: Map, permission: 'maps.view' },
|
||||
{ name: 'Chat Log', path: '/chat', icon: MessageSquare, permission: 'chat.view' },
|
||||
|
||||
@@ -130,6 +130,26 @@ const panelRoutes: RouteRecordRaw[] = [
|
||||
name: 'autodoors',
|
||||
component: () => import('@/views/admin/AutoDoorsView.vue'),
|
||||
},
|
||||
{
|
||||
path: 'kits',
|
||||
name: 'kits-config',
|
||||
component: () => import('@/views/admin/KitsView.vue'),
|
||||
},
|
||||
{
|
||||
path: 'furnace-splitter',
|
||||
name: 'furnace-splitter',
|
||||
component: () => import('@/views/admin/FurnaceSplitterView.vue'),
|
||||
},
|
||||
{
|
||||
path: 'better-chat',
|
||||
name: 'better-chat',
|
||||
component: () => import('@/views/admin/BetterChatView.vue'),
|
||||
},
|
||||
{
|
||||
path: 'timed-execute',
|
||||
name: 'timed-execute',
|
||||
component: () => import('@/views/admin/TimedExecuteView.vue'),
|
||||
},
|
||||
{
|
||||
path: 'wipes',
|
||||
name: 'wipes',
|
||||
|
||||
145
frontend/src/stores/furnacesplitter.ts
Normal file
145
frontend/src/stores/furnacesplitter.ts
Normal file
@@ -0,0 +1,145 @@
|
||||
import { defineStore } from 'pinia'
|
||||
import { ref } from 'vue'
|
||||
import { useApi } from '@/composables/useApi'
|
||||
import { useToastStore } from '@/stores/toast'
|
||||
import type { FurnaceSplitterConfigSummary, FurnaceSplitterConfigFull, FurnaceSplitterApplyResult } from '@/types'
|
||||
|
||||
export const useFurnaceSplitterStore = defineStore('furnacesplitter', () => {
|
||||
const configs = ref<FurnaceSplitterConfigSummary[]>([])
|
||||
const currentConfig = ref<FurnaceSplitterConfigFull | null>(null)
|
||||
const isLoading = ref(false)
|
||||
const isSaving = ref(false)
|
||||
const isApplying = ref(false)
|
||||
const isDirty = ref(false)
|
||||
const api = useApi()
|
||||
const toast = useToastStore()
|
||||
|
||||
async function fetchConfigs() {
|
||||
isLoading.value = true
|
||||
try {
|
||||
const res = await api.get<{ configs: FurnaceSplitterConfigSummary[] }>('/furnacesplitter/configs')
|
||||
configs.value = res.configs
|
||||
} catch (err) {
|
||||
toast.error((err as Error).message)
|
||||
} finally {
|
||||
isLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function loadConfig(id: string) {
|
||||
isLoading.value = true
|
||||
try {
|
||||
const res = await api.get<{ config: FurnaceSplitterConfigFull }>(`/furnacesplitter/configs/${id}`)
|
||||
currentConfig.value = res.config
|
||||
isDirty.value = false
|
||||
} catch (err) {
|
||||
toast.error((err as Error).message)
|
||||
} finally {
|
||||
isLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function createConfig(name: string, description?: string) {
|
||||
try {
|
||||
const res = await api.post<{ config: FurnaceSplitterConfigFull }>('/furnacesplitter/configs', {
|
||||
config_name: name,
|
||||
description,
|
||||
})
|
||||
await fetchConfigs()
|
||||
currentConfig.value = res.config
|
||||
isDirty.value = false
|
||||
toast.success(`Config "${name}" created`)
|
||||
return res.config
|
||||
} catch (err) {
|
||||
toast.error((err as Error).message)
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
async function saveCurrentConfig() {
|
||||
if (!currentConfig.value) return
|
||||
isSaving.value = true
|
||||
try {
|
||||
await api.put(`/furnacesplitter/configs/${currentConfig.value.id}`, {
|
||||
config_name: currentConfig.value.config_name,
|
||||
description: currentConfig.value.description,
|
||||
config_data: currentConfig.value.config_data,
|
||||
})
|
||||
isDirty.value = false
|
||||
await fetchConfigs()
|
||||
toast.success('Config saved')
|
||||
} catch (err) {
|
||||
toast.error((err as Error).message)
|
||||
} finally {
|
||||
isSaving.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function deleteConfig(id: string) {
|
||||
try {
|
||||
await api.del(`/furnacesplitter/configs/${id}`)
|
||||
if (currentConfig.value?.id === id) {
|
||||
currentConfig.value = null
|
||||
}
|
||||
await fetchConfigs()
|
||||
toast.success('Config deleted')
|
||||
} catch (err) {
|
||||
toast.error((err as Error).message)
|
||||
}
|
||||
}
|
||||
|
||||
async function applyToServer(id: string) {
|
||||
isApplying.value = true
|
||||
try {
|
||||
const res = await api.post<FurnaceSplitterApplyResult>(`/furnacesplitter/configs/${id}/apply`)
|
||||
await fetchConfigs()
|
||||
toast.success(res.message)
|
||||
return res
|
||||
} catch (err) {
|
||||
toast.error((err as Error).message)
|
||||
return null
|
||||
} finally {
|
||||
isApplying.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function importFromServer(configName: string) {
|
||||
isLoading.value = true
|
||||
try {
|
||||
const res = await api.post<{ config: FurnaceSplitterConfigFull }>('/furnacesplitter/import-from-server', {
|
||||
config_name: configName,
|
||||
})
|
||||
await fetchConfigs()
|
||||
currentConfig.value = res.config
|
||||
isDirty.value = false
|
||||
toast.success(`Config imported from server as "${configName}"`)
|
||||
return res.config
|
||||
} catch (err) {
|
||||
toast.error((err as Error).message)
|
||||
return null
|
||||
} finally {
|
||||
isLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function markDirty() {
|
||||
isDirty.value = true
|
||||
}
|
||||
|
||||
return {
|
||||
configs,
|
||||
currentConfig,
|
||||
isLoading,
|
||||
isSaving,
|
||||
isApplying,
|
||||
isDirty,
|
||||
fetchConfigs,
|
||||
loadConfig,
|
||||
createConfig,
|
||||
saveCurrentConfig,
|
||||
deleteConfig,
|
||||
applyToServer,
|
||||
importFromServer,
|
||||
markDirty,
|
||||
}
|
||||
})
|
||||
145
frontend/src/stores/kits.ts
Normal file
145
frontend/src/stores/kits.ts
Normal file
@@ -0,0 +1,145 @@
|
||||
import { defineStore } from 'pinia'
|
||||
import { ref } from 'vue'
|
||||
import { useApi } from '@/composables/useApi'
|
||||
import { useToastStore } from '@/stores/toast'
|
||||
import type { KitsConfigSummary, KitsConfigFull, KitsApplyResult } from '@/types'
|
||||
|
||||
export const useKitsStore = defineStore('kits', () => {
|
||||
const configs = ref<KitsConfigSummary[]>([])
|
||||
const currentConfig = ref<KitsConfigFull | null>(null)
|
||||
const isLoading = ref(false)
|
||||
const isSaving = ref(false)
|
||||
const isApplying = ref(false)
|
||||
const isDirty = ref(false)
|
||||
const api = useApi()
|
||||
const toast = useToastStore()
|
||||
|
||||
async function fetchConfigs() {
|
||||
isLoading.value = true
|
||||
try {
|
||||
const res = await api.get<{ configs: KitsConfigSummary[] }>('/kits/configs')
|
||||
configs.value = res.configs
|
||||
} catch (err) {
|
||||
toast.error((err as Error).message)
|
||||
} finally {
|
||||
isLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function loadConfig(id: string) {
|
||||
isLoading.value = true
|
||||
try {
|
||||
const res = await api.get<{ config: KitsConfigFull }>(`/kits/configs/${id}`)
|
||||
currentConfig.value = res.config
|
||||
isDirty.value = false
|
||||
} catch (err) {
|
||||
toast.error((err as Error).message)
|
||||
} finally {
|
||||
isLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function createConfig(name: string, description?: string) {
|
||||
try {
|
||||
const res = await api.post<{ config: KitsConfigFull }>('/kits/configs', {
|
||||
config_name: name,
|
||||
description,
|
||||
})
|
||||
await fetchConfigs()
|
||||
currentConfig.value = res.config
|
||||
isDirty.value = false
|
||||
toast.success(`Config "${name}" created`)
|
||||
return res.config
|
||||
} catch (err) {
|
||||
toast.error((err as Error).message)
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
async function saveCurrentConfig() {
|
||||
if (!currentConfig.value) return
|
||||
isSaving.value = true
|
||||
try {
|
||||
await api.put(`/kits/configs/${currentConfig.value.id}`, {
|
||||
config_name: currentConfig.value.config_name,
|
||||
description: currentConfig.value.description,
|
||||
config_data: currentConfig.value.config_data,
|
||||
})
|
||||
isDirty.value = false
|
||||
await fetchConfigs()
|
||||
toast.success('Config saved')
|
||||
} catch (err) {
|
||||
toast.error((err as Error).message)
|
||||
} finally {
|
||||
isSaving.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function deleteConfig(id: string) {
|
||||
try {
|
||||
await api.del(`/kits/configs/${id}`)
|
||||
if (currentConfig.value?.id === id) {
|
||||
currentConfig.value = null
|
||||
}
|
||||
await fetchConfigs()
|
||||
toast.success('Config deleted')
|
||||
} catch (err) {
|
||||
toast.error((err as Error).message)
|
||||
}
|
||||
}
|
||||
|
||||
async function applyToServer(id: string) {
|
||||
isApplying.value = true
|
||||
try {
|
||||
const res = await api.post<KitsApplyResult>(`/kits/configs/${id}/apply`)
|
||||
await fetchConfigs()
|
||||
toast.success(res.message)
|
||||
return res
|
||||
} catch (err) {
|
||||
toast.error((err as Error).message)
|
||||
return null
|
||||
} finally {
|
||||
isApplying.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function importFromServer(configName: string) {
|
||||
isLoading.value = true
|
||||
try {
|
||||
const res = await api.post<{ config: KitsConfigFull }>('/kits/import-from-server', {
|
||||
config_name: configName,
|
||||
})
|
||||
await fetchConfigs()
|
||||
currentConfig.value = res.config
|
||||
isDirty.value = false
|
||||
toast.success(`Config imported from server as "${configName}"`)
|
||||
return res.config
|
||||
} catch (err) {
|
||||
toast.error((err as Error).message)
|
||||
return null
|
||||
} finally {
|
||||
isLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function markDirty() {
|
||||
isDirty.value = true
|
||||
}
|
||||
|
||||
return {
|
||||
configs,
|
||||
currentConfig,
|
||||
isLoading,
|
||||
isSaving,
|
||||
isApplying,
|
||||
isDirty,
|
||||
fetchConfigs,
|
||||
loadConfig,
|
||||
createConfig,
|
||||
saveCurrentConfig,
|
||||
deleteConfig,
|
||||
applyToServer,
|
||||
importFromServer,
|
||||
markDirty,
|
||||
}
|
||||
})
|
||||
@@ -654,3 +654,57 @@ export interface FurnaceSplitterApplyResult {
|
||||
message: string
|
||||
config_name: string
|
||||
}
|
||||
|
||||
// BetterChat Config types
|
||||
export interface BetterChatConfigSummary {
|
||||
id: string
|
||||
config_name: string
|
||||
description: string | null
|
||||
is_active: boolean
|
||||
created_at: string
|
||||
updated_at: string
|
||||
}
|
||||
|
||||
export interface BetterChatConfigFull {
|
||||
id: string
|
||||
license_id: string
|
||||
config_name: string
|
||||
description: string | null
|
||||
config_data: Record<string, any>
|
||||
is_active: boolean
|
||||
created_at: string
|
||||
updated_at: string
|
||||
}
|
||||
|
||||
export interface BetterChatApplyResult {
|
||||
success: boolean
|
||||
message: string
|
||||
config_name: string
|
||||
}
|
||||
|
||||
// TimedExecute Config types
|
||||
export interface TimedExecuteConfigSummary {
|
||||
id: string
|
||||
config_name: string
|
||||
description: string | null
|
||||
is_active: boolean
|
||||
created_at: string
|
||||
updated_at: string
|
||||
}
|
||||
|
||||
export interface TimedExecuteConfigFull {
|
||||
id: string
|
||||
license_id: string
|
||||
config_name: string
|
||||
description: string | null
|
||||
config_data: Record<string, any>
|
||||
is_active: boolean
|
||||
created_at: string
|
||||
updated_at: string
|
||||
}
|
||||
|
||||
export interface TimedExecuteApplyResult {
|
||||
success: boolean
|
||||
message: string
|
||||
config_name: string
|
||||
}
|
||||
|
||||
371
frontend/src/views/admin/FurnaceSplitterView.vue
Normal file
371
frontend/src/views/admin/FurnaceSplitterView.vue
Normal file
@@ -0,0 +1,371 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { useFurnaceSplitterStore } from '@/stores/furnacesplitter'
|
||||
import {
|
||||
Save,
|
||||
Play,
|
||||
Download,
|
||||
Plus,
|
||||
Trash2,
|
||||
Flame,
|
||||
Settings as SettingsIcon,
|
||||
} from 'lucide-vue-next'
|
||||
|
||||
const store = useFurnaceSplitterStore()
|
||||
|
||||
const showCreateModal = ref(false)
|
||||
const showImportModal = ref(false)
|
||||
const newConfigName = ref('')
|
||||
const newConfigDesc = ref('')
|
||||
const importConfigName = ref('')
|
||||
|
||||
onMounted(async () => {
|
||||
await store.fetchConfigs()
|
||||
if (store.configs.length > 0 && store.configs[0]) {
|
||||
await store.loadConfig(store.configs[0].id)
|
||||
}
|
||||
})
|
||||
|
||||
// --- Config data helpers ---
|
||||
|
||||
function getConfigValue(path: string, defaultValue: any = false): any {
|
||||
if (!store.currentConfig?.config_data) return defaultValue
|
||||
const parts = path.split('.')
|
||||
let current: any = store.currentConfig.config_data
|
||||
for (const part of parts) {
|
||||
if (current == null || typeof current !== 'object') return defaultValue
|
||||
current = current[part]
|
||||
}
|
||||
return current ?? defaultValue
|
||||
}
|
||||
|
||||
function setConfigValue(path: string, value: any) {
|
||||
if (!store.currentConfig) return
|
||||
if (!store.currentConfig.config_data) store.currentConfig.config_data = {}
|
||||
const parts = path.split('.')
|
||||
let current: any = store.currentConfig.config_data
|
||||
for (let i = 0; i < parts.length - 1; i++) {
|
||||
const part = parts[i]!
|
||||
if (current[part] == null || typeof current[part] !== 'object') {
|
||||
current[part] = {}
|
||||
}
|
||||
current = current[part]
|
||||
}
|
||||
current[parts[parts.length - 1]!] = value
|
||||
store.markDirty()
|
||||
}
|
||||
|
||||
// Furnace types with display names
|
||||
const furnaceTypes = [
|
||||
{ key: 'furnace', label: 'Small Furnace', description: 'Standard furnace for smelting ores' },
|
||||
{ key: 'furnace.large', label: 'Large Furnace', description: 'Large furnace with more slots' },
|
||||
{ key: 'campfire', label: 'Campfire', description: 'Basic campfire for cooking' },
|
||||
{ key: 'refinery_small_deployed', label: 'Small Oil Refinery', description: 'Refines crude oil into low grade fuel' },
|
||||
{ key: 'skull_fire_pit', label: 'Skull Fire Pit', description: 'Decorative fire pit for cooking' },
|
||||
{ key: 'hobobarrel_static', label: 'Hobo Barrel', description: 'Barrel fire for cooking' },
|
||||
{ key: 'electricfurnace.deployed', label: 'Electric Furnace', description: 'Electricity-powered furnace' },
|
||||
]
|
||||
|
||||
// --- Action handlers ---
|
||||
|
||||
async function handleConfigChange(id: string) {
|
||||
if (store.isDirty) {
|
||||
if (!confirm('Unsaved changes will be lost. Continue?')) return
|
||||
}
|
||||
await store.loadConfig(id)
|
||||
}
|
||||
|
||||
async function handleCreateConfig() {
|
||||
if (!newConfigName.value.trim()) return
|
||||
const config = await store.createConfig(
|
||||
newConfigName.value.trim(),
|
||||
newConfigDesc.value.trim() || undefined,
|
||||
)
|
||||
if (config) {
|
||||
showCreateModal.value = false
|
||||
newConfigName.value = ''
|
||||
newConfigDesc.value = ''
|
||||
}
|
||||
}
|
||||
|
||||
async function handleDeleteConfig() {
|
||||
if (!store.currentConfig) return
|
||||
if (!confirm(`Delete "${store.currentConfig.config_name}"? This cannot be undone.`)) return
|
||||
await store.deleteConfig(store.currentConfig.id)
|
||||
}
|
||||
|
||||
async function handleApply() {
|
||||
if (!store.currentConfig) return
|
||||
if (!confirm('Apply this FurnaceSplitter config to the server? This will overwrite the current config.')) return
|
||||
if (store.isDirty) {
|
||||
await store.saveCurrentConfig()
|
||||
}
|
||||
await store.applyToServer(store.currentConfig.id)
|
||||
}
|
||||
|
||||
async function handleImport() {
|
||||
if (!importConfigName.value.trim()) return
|
||||
const config = await store.importFromServer(importConfigName.value.trim())
|
||||
if (config) {
|
||||
showImportModal.value = false
|
||||
importConfigName.value = ''
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="p-6 space-y-6">
|
||||
<!-- Header -->
|
||||
<div class="flex items-center justify-between">
|
||||
<h1 class="text-2xl font-bold text-white">Furnace Splitter Config</h1>
|
||||
<div class="flex items-center gap-3">
|
||||
<button
|
||||
@click="showCreateModal = true"
|
||||
class="flex items-center gap-2 px-3 py-2 bg-neutral-800 text-neutral-300 rounded-lg hover:bg-neutral-700 text-sm"
|
||||
>
|
||||
<Plus class="w-4 h-4" />
|
||||
New Config
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Config Selector + Action Bar -->
|
||||
<div class="bg-neutral-900 border border-neutral-800 rounded-xl p-4">
|
||||
<div class="flex items-center gap-3 flex-wrap">
|
||||
<!-- Config Selector -->
|
||||
<select
|
||||
v-if="store.configs.length > 0"
|
||||
:value="store.currentConfig?.id || ''"
|
||||
@change="handleConfigChange(($event.target as HTMLSelectElement).value)"
|
||||
class="bg-neutral-800 border border-neutral-700 text-neutral-200 rounded-lg px-3 py-2 text-sm min-w-[200px]"
|
||||
>
|
||||
<option v-for="c in store.configs" :key="c.id" :value="c.id">
|
||||
{{ c.config_name }}
|
||||
<template v-if="c.is_active"> (Active)</template>
|
||||
</option>
|
||||
</select>
|
||||
<span v-else class="text-neutral-500 text-sm">No configs yet</span>
|
||||
|
||||
<!-- Save -->
|
||||
<button
|
||||
@click="store.saveCurrentConfig()"
|
||||
:disabled="!store.currentConfig || !store.isDirty || store.isSaving"
|
||||
class="flex items-center gap-2 px-3 py-2 bg-oxide-500 text-white rounded-lg hover:bg-oxide-600 disabled:opacity-50 disabled:cursor-not-allowed text-sm"
|
||||
>
|
||||
<Save class="w-4 h-4" />
|
||||
{{ store.isSaving ? 'Saving...' : 'Save' }}
|
||||
</button>
|
||||
|
||||
<!-- Apply to Server -->
|
||||
<button
|
||||
@click="handleApply"
|
||||
:disabled="!store.currentConfig || store.isApplying"
|
||||
class="flex items-center gap-2 px-3 py-2 bg-green-600 text-white rounded-lg hover:bg-green-700 disabled:opacity-50 disabled:cursor-not-allowed text-sm"
|
||||
>
|
||||
<Play class="w-4 h-4" />
|
||||
{{ store.isApplying ? 'Applying...' : 'Apply to Server' }}
|
||||
</button>
|
||||
|
||||
<!-- Import from Server -->
|
||||
<button
|
||||
@click="showImportModal = true"
|
||||
class="flex items-center gap-2 px-3 py-2 bg-neutral-800 text-neutral-300 rounded-lg hover:bg-neutral-700 text-sm"
|
||||
>
|
||||
<Download class="w-4 h-4" />
|
||||
Import from Server
|
||||
</button>
|
||||
|
||||
<!-- Delete -->
|
||||
<button
|
||||
@click="handleDeleteConfig"
|
||||
:disabled="!store.currentConfig"
|
||||
class="flex items-center gap-2 px-3 py-2 bg-red-500/10 text-red-400 rounded-lg hover:bg-red-500/20 disabled:opacity-50 text-sm ml-auto"
|
||||
>
|
||||
<Trash2 class="w-4 h-4" />
|
||||
Delete
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Loading State -->
|
||||
<div v-if="store.isLoading" class="flex items-center justify-center py-20">
|
||||
<div class="animate-spin w-8 h-8 border-2 border-oxide-500 border-t-transparent rounded-full" />
|
||||
</div>
|
||||
|
||||
<!-- No Config Selected -->
|
||||
<div v-else-if="!store.currentConfig" class="bg-neutral-900 border border-neutral-800 rounded-xl p-12 text-center">
|
||||
<Flame class="w-12 h-12 text-neutral-600 mx-auto mb-4" />
|
||||
<h2 class="text-lg font-semibold text-neutral-300 mb-2">No FurnaceSplitter Config Selected</h2>
|
||||
<p class="text-neutral-500 mb-4">Create a new config, import from server, or select one from the dropdown above.</p>
|
||||
<button
|
||||
@click="showCreateModal = true"
|
||||
class="px-4 py-2 bg-oxide-500 text-white rounded-lg hover:bg-oxide-600"
|
||||
>
|
||||
Create First Config
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- Config Editor -->
|
||||
<div v-else class="space-y-6">
|
||||
<!-- Furnace Splitter Settings -->
|
||||
<div class="bg-neutral-900 border border-neutral-800 rounded-xl p-6 space-y-6">
|
||||
<div class="flex items-center gap-2">
|
||||
<SettingsIcon class="w-5 h-5 text-neutral-400" />
|
||||
<h3 class="text-sm font-semibold text-neutral-300 uppercase tracking-wider">Splitter Settings</h3>
|
||||
</div>
|
||||
|
||||
<!-- Global enabled -->
|
||||
<div class="flex items-center justify-between">
|
||||
<div>
|
||||
<label class="text-sm text-neutral-200">Enabled</label>
|
||||
<p class="text-xs text-neutral-500">Globally enable or disable furnace splitting</p>
|
||||
</div>
|
||||
<button
|
||||
@click="setConfigValue('Enabled', !getConfigValue('Enabled', true))"
|
||||
class="relative w-11 h-6 rounded-full transition-colors"
|
||||
:class="getConfigValue('Enabled', true) ? 'bg-oxide-500' : 'bg-neutral-700'"
|
||||
>
|
||||
<span
|
||||
class="absolute top-0.5 left-0.5 w-5 h-5 bg-white rounded-full transition-transform"
|
||||
:class="getConfigValue('Enabled', true) ? 'translate-x-5' : 'translate-x-0'"
|
||||
/>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Per-Furnace Type Settings -->
|
||||
<div class="bg-neutral-900 border border-neutral-800 rounded-xl p-6 space-y-6">
|
||||
<div class="flex items-center gap-2">
|
||||
<Flame class="w-5 h-5 text-neutral-400" />
|
||||
<h3 class="text-sm font-semibold text-neutral-300 uppercase tracking-wider">Furnace Type Settings</h3>
|
||||
</div>
|
||||
|
||||
<div class="space-y-4">
|
||||
<div
|
||||
v-for="furnace in furnaceTypes"
|
||||
:key="furnace.key"
|
||||
class="bg-neutral-800/50 border border-neutral-700/50 rounded-lg p-4"
|
||||
>
|
||||
<div class="flex items-center justify-between mb-3">
|
||||
<div>
|
||||
<h4 class="text-sm font-medium text-neutral-200">{{ furnace.label }}</h4>
|
||||
<p class="text-xs text-neutral-500">{{ furnace.description }}</p>
|
||||
</div>
|
||||
<button
|
||||
@click="setConfigValue(`Furnaces.${furnace.key}.Enabled`, !getConfigValue(`Furnaces.${furnace.key}.Enabled`, true))"
|
||||
class="relative w-11 h-6 rounded-full transition-colors"
|
||||
:class="getConfigValue(`Furnaces.${furnace.key}.Enabled`, true) ? 'bg-oxide-500' : 'bg-neutral-700'"
|
||||
>
|
||||
<span
|
||||
class="absolute top-0.5 left-0.5 w-5 h-5 bg-white rounded-full transition-transform"
|
||||
:class="getConfigValue(`Furnaces.${furnace.key}.Enabled`, true) ? 'translate-x-5' : 'translate-x-0'"
|
||||
/>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
<div>
|
||||
<label class="block text-xs text-neutral-500 mb-1">Default Split Stacks</label>
|
||||
<input
|
||||
type="number"
|
||||
:value="getConfigValue(`Furnaces.${furnace.key}.DefaultSplitCount`, 0)"
|
||||
@input="setConfigValue(`Furnaces.${furnace.key}.DefaultSplitCount`, Number(($event.target as HTMLInputElement).value))"
|
||||
min="0"
|
||||
class="w-full bg-neutral-800 border border-neutral-700 rounded px-3 py-2 text-neutral-200 text-sm"
|
||||
placeholder="0 = fill all slots"
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-xs text-neutral-500 mb-1">Fuel Multiplier</label>
|
||||
<input
|
||||
type="number"
|
||||
step="0.1"
|
||||
:value="getConfigValue(`Furnaces.${furnace.key}.FuelMultiplier`, 1.0)"
|
||||
@input="setConfigValue(`Furnaces.${furnace.key}.FuelMultiplier`, Number(($event.target as HTMLInputElement).value))"
|
||||
min="0"
|
||||
class="w-full bg-neutral-800 border border-neutral-700 rounded px-3 py-2 text-neutral-200 text-sm"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Permission Groups -->
|
||||
<div class="bg-neutral-900 border border-neutral-800 rounded-xl p-6 space-y-4">
|
||||
<h3 class="text-sm font-semibold text-neutral-300 uppercase tracking-wider">Permission</h3>
|
||||
<p class="text-xs text-neutral-500">
|
||||
The permission <code class="text-neutral-300 bg-neutral-800 px-1 rounded">furnacesplitter.use</code> controls which players can use the furnace splitting feature. Assign this permission via your Oxide permission system.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Create Config Modal -->
|
||||
<div v-if="showCreateModal" class="fixed inset-0 bg-black/60 z-50 flex items-center justify-center p-4" @click.self="showCreateModal = false">
|
||||
<div class="bg-neutral-900 border border-neutral-800 rounded-xl p-6 w-full max-w-md">
|
||||
<h2 class="text-lg font-semibold text-neutral-100 mb-4">New FurnaceSplitter Config</h2>
|
||||
<div class="space-y-4">
|
||||
<div>
|
||||
<label class="block text-sm text-neutral-400 mb-1">Config Name</label>
|
||||
<input
|
||||
v-model="newConfigName"
|
||||
placeholder="e.g. Default Furnace Settings"
|
||||
class="w-full bg-neutral-800 border border-neutral-700 rounded-lg px-3 py-2 text-neutral-200 text-sm"
|
||||
@keydown.enter="handleCreateConfig"
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-sm text-neutral-400 mb-1">Description (optional)</label>
|
||||
<textarea
|
||||
v-model="newConfigDesc"
|
||||
rows="2"
|
||||
placeholder="What is this config for?"
|
||||
class="w-full bg-neutral-800 border border-neutral-700 rounded-lg px-3 py-2 text-neutral-200 text-sm resize-none"
|
||||
/>
|
||||
</div>
|
||||
<div class="flex justify-end gap-2">
|
||||
<button @click="showCreateModal = false" class="px-4 py-2 text-sm text-neutral-400 hover:text-neutral-200">Cancel</button>
|
||||
<button
|
||||
@click="handleCreateConfig"
|
||||
:disabled="!newConfigName.trim()"
|
||||
class="px-4 py-2 bg-oxide-500 text-white rounded-lg hover:bg-oxide-600 disabled:opacity-50 text-sm"
|
||||
>
|
||||
Create
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Import from Server Modal -->
|
||||
<div v-if="showImportModal" class="fixed inset-0 bg-black/60 z-50 flex items-center justify-center p-4" @click.self="showImportModal = false">
|
||||
<div class="bg-neutral-900 border border-neutral-800 rounded-xl p-6 w-full max-w-md">
|
||||
<h2 class="text-lg font-semibold text-neutral-100 mb-4">Import from Server</h2>
|
||||
<p class="text-sm text-neutral-400 mb-4">
|
||||
Import the current FurnaceSplitter config from your live server. This will create a new config profile.
|
||||
</p>
|
||||
<div class="space-y-4">
|
||||
<div>
|
||||
<label class="block text-sm text-neutral-400 mb-1">Config Name</label>
|
||||
<input
|
||||
v-model="importConfigName"
|
||||
placeholder="e.g. Imported Server Config"
|
||||
class="w-full bg-neutral-800 border border-neutral-700 rounded-lg px-3 py-2 text-neutral-200 text-sm"
|
||||
@keydown.enter="handleImport"
|
||||
/>
|
||||
</div>
|
||||
<div class="flex justify-end gap-2">
|
||||
<button @click="showImportModal = false" class="px-4 py-2 text-sm text-neutral-400 hover:text-neutral-200">Cancel</button>
|
||||
<button
|
||||
@click="handleImport"
|
||||
:disabled="!importConfigName.trim()"
|
||||
class="px-4 py-2 bg-oxide-500 text-white rounded-lg hover:bg-oxide-600 disabled:opacity-50 text-sm"
|
||||
>
|
||||
Import
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
778
frontend/src/views/admin/KitsView.vue
Normal file
778
frontend/src/views/admin/KitsView.vue
Normal file
@@ -0,0 +1,778 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, computed, onMounted } from 'vue'
|
||||
import { useKitsStore } from '@/stores/kits'
|
||||
import {
|
||||
Save,
|
||||
Play,
|
||||
Download,
|
||||
Plus,
|
||||
Trash2,
|
||||
Package,
|
||||
Settings as SettingsIcon,
|
||||
Edit,
|
||||
X,
|
||||
} from 'lucide-vue-next'
|
||||
|
||||
const store = useKitsStore()
|
||||
|
||||
const activeTab = ref<'kits' | 'editor' | 'settings'>('kits')
|
||||
const showCreateModal = ref(false)
|
||||
const showImportModal = ref(false)
|
||||
const newConfigName = ref('')
|
||||
const newConfigDesc = ref('')
|
||||
const importConfigName = ref('')
|
||||
const editingKitIndex = ref<number | null>(null)
|
||||
|
||||
const tabs = [
|
||||
{ key: 'kits', label: 'Kits List', icon: Package },
|
||||
{ key: 'editor', label: 'Kit Editor', icon: Edit },
|
||||
{ key: 'settings', label: 'Settings', icon: SettingsIcon },
|
||||
]
|
||||
|
||||
onMounted(async () => {
|
||||
await store.fetchConfigs()
|
||||
if (store.configs.length > 0 && store.configs[0]) {
|
||||
await store.loadConfig(store.configs[0].id)
|
||||
}
|
||||
})
|
||||
|
||||
// --- Config data helpers ---
|
||||
|
||||
function getConfigValue(path: string, defaultValue: any = false): any {
|
||||
if (!store.currentConfig?.config_data) return defaultValue
|
||||
const parts = path.split('.')
|
||||
let current: any = store.currentConfig.config_data
|
||||
for (const part of parts) {
|
||||
if (current == null || typeof current !== 'object') return defaultValue
|
||||
current = current[part]
|
||||
}
|
||||
return current ?? defaultValue
|
||||
}
|
||||
|
||||
function setConfigValue(path: string, value: any) {
|
||||
if (!store.currentConfig) return
|
||||
if (!store.currentConfig.config_data) store.currentConfig.config_data = {}
|
||||
const parts = path.split('.')
|
||||
let current: any = store.currentConfig.config_data
|
||||
for (let i = 0; i < parts.length - 1; i++) {
|
||||
const part = parts[i]!
|
||||
if (current[part] == null || typeof current[part] !== 'object') {
|
||||
current[part] = {}
|
||||
}
|
||||
current = current[part]
|
||||
}
|
||||
current[parts[parts.length - 1]!] = value
|
||||
store.markDirty()
|
||||
}
|
||||
|
||||
// --- Kit List helpers ---
|
||||
|
||||
const kitsList = computed(() => {
|
||||
return getConfigValue('Kits', []) as any[]
|
||||
})
|
||||
|
||||
function addKit() {
|
||||
const kits = getConfigValue('Kits', []) as any[]
|
||||
kits.push({
|
||||
Name: `New Kit ${kits.length + 1}`,
|
||||
Description: '',
|
||||
Permission: '',
|
||||
Cooldown: 600,
|
||||
MaxUses: 0,
|
||||
IsHidden: false,
|
||||
Items: [],
|
||||
})
|
||||
setConfigValue('Kits', kits)
|
||||
editingKitIndex.value = kits.length - 1
|
||||
activeTab.value = 'editor'
|
||||
}
|
||||
|
||||
function editKit(index: number) {
|
||||
editingKitIndex.value = index
|
||||
activeTab.value = 'editor'
|
||||
}
|
||||
|
||||
function deleteKit(index: number) {
|
||||
const kits = getConfigValue('Kits', []) as any[]
|
||||
if (!confirm(`Delete kit "${kits[index]?.Name}"? This cannot be undone.`)) return
|
||||
kits.splice(index, 1)
|
||||
setConfigValue('Kits', kits)
|
||||
if (editingKitIndex.value === index) {
|
||||
editingKitIndex.value = null
|
||||
activeTab.value = 'kits'
|
||||
} else if (editingKitIndex.value !== null && editingKitIndex.value > index) {
|
||||
editingKitIndex.value--
|
||||
}
|
||||
}
|
||||
|
||||
// --- Kit Editor helpers ---
|
||||
|
||||
const currentKit = computed(() => {
|
||||
if (editingKitIndex.value === null) return null
|
||||
const kits = getConfigValue('Kits', []) as any[]
|
||||
return kits[editingKitIndex.value] || null
|
||||
})
|
||||
|
||||
function setKitField(field: string, value: any) {
|
||||
if (editingKitIndex.value === null) return
|
||||
const kits = getConfigValue('Kits', []) as any[]
|
||||
if (kits[editingKitIndex.value]) {
|
||||
kits[editingKitIndex.value][field] = value
|
||||
setConfigValue('Kits', kits)
|
||||
}
|
||||
}
|
||||
|
||||
function addKitItem() {
|
||||
if (editingKitIndex.value === null) return
|
||||
const kits = getConfigValue('Kits', []) as any[]
|
||||
const kit = kits[editingKitIndex.value]
|
||||
if (!kit) return
|
||||
if (!kit.Items) kit.Items = []
|
||||
kit.Items.push({
|
||||
ShortName: '',
|
||||
Amount: 1,
|
||||
SkinId: 0,
|
||||
Container: 'main',
|
||||
Position: -1,
|
||||
})
|
||||
setConfigValue('Kits', kits)
|
||||
}
|
||||
|
||||
function removeKitItem(itemIndex: number) {
|
||||
if (editingKitIndex.value === null) return
|
||||
const kits = getConfigValue('Kits', []) as any[]
|
||||
const kit = kits[editingKitIndex.value]
|
||||
if (!kit?.Items) return
|
||||
kit.Items.splice(itemIndex, 1)
|
||||
setConfigValue('Kits', kits)
|
||||
}
|
||||
|
||||
function setKitItemField(itemIndex: number, field: string, value: any) {
|
||||
if (editingKitIndex.value === null) return
|
||||
const kits = getConfigValue('Kits', []) as any[]
|
||||
const kit = kits[editingKitIndex.value]
|
||||
if (!kit?.Items?.[itemIndex]) return
|
||||
kit.Items[itemIndex][field] = value
|
||||
setConfigValue('Kits', kits)
|
||||
}
|
||||
|
||||
// --- Action handlers ---
|
||||
|
||||
async function handleConfigChange(id: string) {
|
||||
if (store.isDirty) {
|
||||
if (!confirm('Unsaved changes will be lost. Continue?')) return
|
||||
}
|
||||
await store.loadConfig(id)
|
||||
editingKitIndex.value = null
|
||||
activeTab.value = 'kits'
|
||||
}
|
||||
|
||||
async function handleCreateConfig() {
|
||||
if (!newConfigName.value.trim()) return
|
||||
const config = await store.createConfig(
|
||||
newConfigName.value.trim(),
|
||||
newConfigDesc.value.trim() || undefined,
|
||||
)
|
||||
if (config) {
|
||||
showCreateModal.value = false
|
||||
newConfigName.value = ''
|
||||
newConfigDesc.value = ''
|
||||
}
|
||||
}
|
||||
|
||||
async function handleDeleteConfig() {
|
||||
if (!store.currentConfig) return
|
||||
if (!confirm(`Delete "${store.currentConfig.config_name}"? This cannot be undone.`)) return
|
||||
await store.deleteConfig(store.currentConfig.id)
|
||||
}
|
||||
|
||||
async function handleApply() {
|
||||
if (!store.currentConfig) return
|
||||
if (!confirm('Apply this kits config to the server? This will overwrite the current Kits config.')) return
|
||||
if (store.isDirty) {
|
||||
await store.saveCurrentConfig()
|
||||
}
|
||||
await store.applyToServer(store.currentConfig.id)
|
||||
}
|
||||
|
||||
async function handleImport() {
|
||||
if (!importConfigName.value.trim()) return
|
||||
const config = await store.importFromServer(importConfigName.value.trim())
|
||||
if (config) {
|
||||
showImportModal.value = false
|
||||
importConfigName.value = ''
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="p-6 space-y-6">
|
||||
<!-- Header -->
|
||||
<div class="flex items-center justify-between">
|
||||
<h1 class="text-2xl font-bold text-white">Kits Config</h1>
|
||||
<div class="flex items-center gap-3">
|
||||
<button
|
||||
@click="showCreateModal = true"
|
||||
class="flex items-center gap-2 px-3 py-2 bg-neutral-800 text-neutral-300 rounded-lg hover:bg-neutral-700 text-sm"
|
||||
>
|
||||
<Plus class="w-4 h-4" />
|
||||
New Config
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Config Selector + Action Bar -->
|
||||
<div class="bg-neutral-900 border border-neutral-800 rounded-xl p-4">
|
||||
<div class="flex items-center gap-3 flex-wrap">
|
||||
<!-- Config Selector -->
|
||||
<select
|
||||
v-if="store.configs.length > 0"
|
||||
:value="store.currentConfig?.id || ''"
|
||||
@change="handleConfigChange(($event.target as HTMLSelectElement).value)"
|
||||
class="bg-neutral-800 border border-neutral-700 text-neutral-200 rounded-lg px-3 py-2 text-sm min-w-[200px]"
|
||||
>
|
||||
<option v-for="c in store.configs" :key="c.id" :value="c.id">
|
||||
{{ c.config_name }}
|
||||
<template v-if="c.is_active"> (Active)</template>
|
||||
</option>
|
||||
</select>
|
||||
<span v-else class="text-neutral-500 text-sm">No configs yet</span>
|
||||
|
||||
<!-- Save -->
|
||||
<button
|
||||
@click="store.saveCurrentConfig()"
|
||||
:disabled="!store.currentConfig || !store.isDirty || store.isSaving"
|
||||
class="flex items-center gap-2 px-3 py-2 bg-oxide-500 text-white rounded-lg hover:bg-oxide-600 disabled:opacity-50 disabled:cursor-not-allowed text-sm"
|
||||
>
|
||||
<Save class="w-4 h-4" />
|
||||
{{ store.isSaving ? 'Saving...' : 'Save' }}
|
||||
</button>
|
||||
|
||||
<!-- Apply to Server -->
|
||||
<button
|
||||
@click="handleApply"
|
||||
:disabled="!store.currentConfig || store.isApplying"
|
||||
class="flex items-center gap-2 px-3 py-2 bg-green-600 text-white rounded-lg hover:bg-green-700 disabled:opacity-50 disabled:cursor-not-allowed text-sm"
|
||||
>
|
||||
<Play class="w-4 h-4" />
|
||||
{{ store.isApplying ? 'Applying...' : 'Apply to Server' }}
|
||||
</button>
|
||||
|
||||
<!-- Import from Server -->
|
||||
<button
|
||||
@click="showImportModal = true"
|
||||
class="flex items-center gap-2 px-3 py-2 bg-neutral-800 text-neutral-300 rounded-lg hover:bg-neutral-700 text-sm"
|
||||
>
|
||||
<Download class="w-4 h-4" />
|
||||
Import from Server
|
||||
</button>
|
||||
|
||||
<!-- Delete -->
|
||||
<button
|
||||
@click="handleDeleteConfig"
|
||||
:disabled="!store.currentConfig"
|
||||
class="flex items-center gap-2 px-3 py-2 bg-red-500/10 text-red-400 rounded-lg hover:bg-red-500/20 disabled:opacity-50 text-sm ml-auto"
|
||||
>
|
||||
<Trash2 class="w-4 h-4" />
|
||||
Delete
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Loading State -->
|
||||
<div v-if="store.isLoading" class="flex items-center justify-center py-20">
|
||||
<div class="animate-spin w-8 h-8 border-2 border-oxide-500 border-t-transparent rounded-full" />
|
||||
</div>
|
||||
|
||||
<!-- No Config Selected -->
|
||||
<div v-else-if="!store.currentConfig" class="bg-neutral-900 border border-neutral-800 rounded-xl p-12 text-center">
|
||||
<Package class="w-12 h-12 text-neutral-600 mx-auto mb-4" />
|
||||
<h2 class="text-lg font-semibold text-neutral-300 mb-2">No Kits Config Selected</h2>
|
||||
<p class="text-neutral-500 mb-4">Create a new config, import from server, or select one from the dropdown above.</p>
|
||||
<button
|
||||
@click="showCreateModal = true"
|
||||
class="px-4 py-2 bg-oxide-500 text-white rounded-lg hover:bg-oxide-600"
|
||||
>
|
||||
Create First Config
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- Config Editor -->
|
||||
<div v-else class="space-y-6">
|
||||
<!-- Tab Bar -->
|
||||
<div class="flex border-b border-neutral-800">
|
||||
<button
|
||||
v-for="tab in tabs"
|
||||
:key="tab.key"
|
||||
@click="activeTab = tab.key as typeof activeTab"
|
||||
class="flex items-center gap-2 px-4 py-2 text-sm font-medium border-b-2 transition-colors"
|
||||
:class="activeTab === tab.key
|
||||
? 'border-oxide-500 text-oxide-400'
|
||||
: 'border-transparent text-neutral-500 hover:text-neutral-300'"
|
||||
>
|
||||
<component :is="tab.icon" class="w-4 h-4" />
|
||||
{{ tab.label }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- Kits List Tab -->
|
||||
<div v-if="activeTab === 'kits'" class="space-y-4">
|
||||
<div class="flex items-center justify-between">
|
||||
<h3 class="text-sm font-semibold text-neutral-300 uppercase tracking-wider">Defined Kits</h3>
|
||||
<button
|
||||
@click="addKit"
|
||||
class="flex items-center gap-2 px-3 py-1.5 bg-oxide-500/10 text-oxide-400 rounded-lg hover:bg-oxide-500/20 text-sm"
|
||||
>
|
||||
<Plus class="w-4 h-4" />
|
||||
Add Kit
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div v-if="kitsList.length === 0" class="bg-neutral-900 border border-neutral-800 rounded-xl p-8 text-center">
|
||||
<p class="text-neutral-500">No kits defined yet. Add your first kit or import from server.</p>
|
||||
</div>
|
||||
|
||||
<div v-else class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
|
||||
<div
|
||||
v-for="(kit, index) in kitsList"
|
||||
:key="index"
|
||||
class="bg-neutral-900 border border-neutral-800 rounded-xl p-4 space-y-3"
|
||||
>
|
||||
<div class="flex items-start justify-between">
|
||||
<div>
|
||||
<h4 class="text-sm font-semibold text-neutral-200">{{ kit.Name || 'Unnamed Kit' }}</h4>
|
||||
<p v-if="kit.Description" class="text-xs text-neutral-500 mt-1">{{ kit.Description }}</p>
|
||||
</div>
|
||||
<div class="flex items-center gap-1">
|
||||
<button
|
||||
@click="editKit(index)"
|
||||
class="p-1.5 text-neutral-400 hover:text-oxide-400 transition-colors"
|
||||
title="Edit kit"
|
||||
>
|
||||
<Edit class="w-4 h-4" />
|
||||
</button>
|
||||
<button
|
||||
@click="deleteKit(index)"
|
||||
class="p-1.5 text-neutral-400 hover:text-red-400 transition-colors"
|
||||
title="Delete kit"
|
||||
>
|
||||
<Trash2 class="w-4 h-4" />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-2 gap-2 text-xs">
|
||||
<div>
|
||||
<span class="text-neutral-500">Permission:</span>
|
||||
<span class="text-neutral-300 ml-1">{{ kit.Permission || 'None' }}</span>
|
||||
</div>
|
||||
<div>
|
||||
<span class="text-neutral-500">Cooldown:</span>
|
||||
<span class="text-neutral-300 ml-1">{{ kit.Cooldown || 0 }}s</span>
|
||||
</div>
|
||||
<div>
|
||||
<span class="text-neutral-500">Max Uses:</span>
|
||||
<span class="text-neutral-300 ml-1">{{ kit.MaxUses || 0 }} {{ (kit.MaxUses || 0) === 0 ? '(unlimited)' : '' }}</span>
|
||||
</div>
|
||||
<div>
|
||||
<span class="text-neutral-500">Items:</span>
|
||||
<span class="text-neutral-300 ml-1">{{ (kit.Items || []).length }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="kit.IsHidden" class="text-xs text-yellow-500/80">
|
||||
Hidden (requires permission)
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Kit Editor Tab -->
|
||||
<div v-else-if="activeTab === 'editor'" class="space-y-6">
|
||||
<div v-if="!currentKit" class="bg-neutral-900 border border-neutral-800 rounded-xl p-8 text-center">
|
||||
<p class="text-neutral-500">Select a kit from the Kits List tab to edit it.</p>
|
||||
</div>
|
||||
|
||||
<template v-else>
|
||||
<!-- Kit Metadata -->
|
||||
<div class="bg-neutral-900 border border-neutral-800 rounded-xl p-6 space-y-4">
|
||||
<h3 class="text-sm font-semibold text-neutral-300 uppercase tracking-wider">Kit Details</h3>
|
||||
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
<div>
|
||||
<label class="block text-sm text-neutral-200 mb-1">Kit Name</label>
|
||||
<input
|
||||
type="text"
|
||||
:value="currentKit.Name"
|
||||
@input="setKitField('Name', ($event.target as HTMLInputElement).value)"
|
||||
class="w-full bg-neutral-800 border border-neutral-700 rounded-lg px-3 py-2 text-neutral-200 text-sm"
|
||||
placeholder="e.g. Starter Kit"
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-sm text-neutral-200 mb-1">Permission</label>
|
||||
<input
|
||||
type="text"
|
||||
:value="currentKit.Permission"
|
||||
@input="setKitField('Permission', ($event.target as HTMLInputElement).value)"
|
||||
class="w-full bg-neutral-800 border border-neutral-700 rounded-lg px-3 py-2 text-neutral-200 text-sm"
|
||||
placeholder="e.g. kits.vip"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="block text-sm text-neutral-200 mb-1">Description</label>
|
||||
<textarea
|
||||
:value="currentKit.Description"
|
||||
@input="setKitField('Description', ($event.target as HTMLTextAreaElement).value)"
|
||||
rows="2"
|
||||
class="w-full bg-neutral-800 border border-neutral-700 rounded-lg px-3 py-2 text-neutral-200 text-sm resize-none"
|
||||
placeholder="Kit description..."
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-1 md:grid-cols-3 gap-4">
|
||||
<div>
|
||||
<label class="block text-sm text-neutral-200 mb-1">Cooldown (seconds)</label>
|
||||
<input
|
||||
type="number"
|
||||
:value="currentKit.Cooldown || 0"
|
||||
@input="setKitField('Cooldown', Number(($event.target as HTMLInputElement).value))"
|
||||
min="0"
|
||||
class="w-full bg-neutral-800 border border-neutral-700 rounded-lg px-3 py-2 text-neutral-200 text-sm"
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-sm text-neutral-200 mb-1">Max Uses (0 = unlimited)</label>
|
||||
<input
|
||||
type="number"
|
||||
:value="currentKit.MaxUses || 0"
|
||||
@input="setKitField('MaxUses', Number(($event.target as HTMLInputElement).value))"
|
||||
min="0"
|
||||
class="w-full bg-neutral-800 border border-neutral-700 rounded-lg px-3 py-2 text-neutral-200 text-sm"
|
||||
/>
|
||||
</div>
|
||||
<div class="flex items-center justify-between pt-6">
|
||||
<label class="text-sm text-neutral-200">Hidden (no perm = hidden)</label>
|
||||
<button
|
||||
@click="setKitField('IsHidden', !currentKit.IsHidden)"
|
||||
class="relative w-11 h-6 rounded-full transition-colors"
|
||||
:class="currentKit.IsHidden ? 'bg-oxide-500' : 'bg-neutral-700'"
|
||||
>
|
||||
<span
|
||||
class="absolute top-0.5 left-0.5 w-5 h-5 bg-white rounded-full transition-transform"
|
||||
:class="currentKit.IsHidden ? 'translate-x-5' : 'translate-x-0'"
|
||||
/>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Kit Items -->
|
||||
<div class="bg-neutral-900 border border-neutral-800 rounded-xl p-6 space-y-4">
|
||||
<div class="flex items-center justify-between">
|
||||
<h3 class="text-sm font-semibold text-neutral-300 uppercase tracking-wider">Kit Items</h3>
|
||||
<button
|
||||
@click="addKitItem"
|
||||
class="flex items-center gap-2 px-3 py-1.5 bg-oxide-500/10 text-oxide-400 rounded-lg hover:bg-oxide-500/20 text-sm"
|
||||
>
|
||||
<Plus class="w-4 h-4" />
|
||||
Add Item
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div v-if="!currentKit.Items || currentKit.Items.length === 0" class="text-center py-4">
|
||||
<p class="text-neutral-500 text-sm">No items in this kit. Click "Add Item" to get started.</p>
|
||||
</div>
|
||||
|
||||
<div v-else class="space-y-3">
|
||||
<div
|
||||
v-for="(item, itemIdx) in currentKit.Items"
|
||||
:key="itemIdx"
|
||||
class="flex items-center gap-3 bg-neutral-800/50 border border-neutral-700/50 rounded-lg p-3"
|
||||
>
|
||||
<div class="flex-1 grid grid-cols-2 md:grid-cols-4 gap-3">
|
||||
<div>
|
||||
<label class="block text-xs text-neutral-500 mb-1">Short Name</label>
|
||||
<input
|
||||
type="text"
|
||||
:value="item.ShortName"
|
||||
@input="setKitItemField(itemIdx, 'ShortName', ($event.target as HTMLInputElement).value)"
|
||||
class="w-full bg-neutral-800 border border-neutral-700 rounded px-2 py-1.5 text-neutral-200 text-xs"
|
||||
placeholder="e.g. rifle.ak"
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-xs text-neutral-500 mb-1">Amount</label>
|
||||
<input
|
||||
type="number"
|
||||
:value="item.Amount || 1"
|
||||
@input="setKitItemField(itemIdx, 'Amount', Number(($event.target as HTMLInputElement).value))"
|
||||
min="1"
|
||||
class="w-full bg-neutral-800 border border-neutral-700 rounded px-2 py-1.5 text-neutral-200 text-xs"
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-xs text-neutral-500 mb-1">Skin ID</label>
|
||||
<input
|
||||
type="number"
|
||||
:value="item.SkinId || 0"
|
||||
@input="setKitItemField(itemIdx, 'SkinId', Number(($event.target as HTMLInputElement).value))"
|
||||
min="0"
|
||||
class="w-full bg-neutral-800 border border-neutral-700 rounded px-2 py-1.5 text-neutral-200 text-xs"
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-xs text-neutral-500 mb-1">Container</label>
|
||||
<select
|
||||
:value="item.Container || 'main'"
|
||||
@change="setKitItemField(itemIdx, 'Container', ($event.target as HTMLSelectElement).value)"
|
||||
class="w-full bg-neutral-800 border border-neutral-700 rounded px-2 py-1.5 text-neutral-200 text-xs"
|
||||
>
|
||||
<option value="main">Main</option>
|
||||
<option value="wear">Wear</option>
|
||||
<option value="belt">Belt</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<button
|
||||
@click="removeKitItem(itemIdx)"
|
||||
class="p-1.5 text-neutral-400 hover:text-red-400 transition-colors flex-shrink-0"
|
||||
title="Remove item"
|
||||
>
|
||||
<X class="w-4 h-4" />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
|
||||
<!-- Settings Tab -->
|
||||
<div v-else-if="activeTab === 'settings'" class="bg-neutral-900 border border-neutral-800 rounded-xl p-6 space-y-6">
|
||||
<h3 class="text-sm font-semibold text-neutral-300 uppercase tracking-wider">Global Kit Settings</h3>
|
||||
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
|
||||
<!-- Kit chat command -->
|
||||
<div>
|
||||
<label class="block text-sm text-neutral-200 mb-1">Kit Chat Command</label>
|
||||
<p class="text-xs text-neutral-500 mb-2">The chat command players use to access kits</p>
|
||||
<input
|
||||
type="text"
|
||||
:value="getConfigValue('Kit chat command', 'kit')"
|
||||
@input="setConfigValue('Kit chat command', ($event.target as HTMLInputElement).value)"
|
||||
class="w-full bg-neutral-800 border border-neutral-700 rounded-lg px-3 py-2 text-neutral-200 text-sm"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<!-- Currency -->
|
||||
<div>
|
||||
<label class="block text-sm text-neutral-200 mb-1">Currency for Purchase Costs</label>
|
||||
<p class="text-xs text-neutral-500 mb-2">Scrap, Economics, or ServerRewards</p>
|
||||
<select
|
||||
:value="getConfigValue('Currency used for purchase costs (Scrap, Economics, ServerRewards)', 'Scrap')"
|
||||
@change="setConfigValue('Currency used for purchase costs (Scrap, Economics, ServerRewards)', ($event.target as HTMLSelectElement).value)"
|
||||
class="w-full bg-neutral-800 border border-neutral-700 rounded-lg px-3 py-2 text-neutral-200 text-sm"
|
||||
>
|
||||
<option value="Scrap">Scrap</option>
|
||||
<option value="Economics">Economics</option>
|
||||
<option value="ServerRewards">ServerRewards</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
|
||||
<!-- Log kits given -->
|
||||
<div class="flex items-center justify-between">
|
||||
<div>
|
||||
<label class="text-sm text-neutral-200">Log Kits Given</label>
|
||||
<p class="text-xs text-neutral-500">Log when kits are claimed by players</p>
|
||||
</div>
|
||||
<button
|
||||
@click="setConfigValue('Log kits given', !getConfigValue('Log kits given', false))"
|
||||
class="relative w-11 h-6 rounded-full transition-colors"
|
||||
:class="getConfigValue('Log kits given', false) ? 'bg-oxide-500' : 'bg-neutral-700'"
|
||||
>
|
||||
<span
|
||||
class="absolute top-0.5 left-0.5 w-5 h-5 bg-white rounded-full transition-transform"
|
||||
:class="getConfigValue('Log kits given', false) ? 'translate-x-5' : 'translate-x-0'"
|
||||
/>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- Wipe data on wipe -->
|
||||
<div class="flex items-center justify-between">
|
||||
<div>
|
||||
<label class="text-sm text-neutral-200">Wipe Player Data on Server Wipe</label>
|
||||
<p class="text-xs text-neutral-500">Reset kit cooldowns and usage when server wipes</p>
|
||||
</div>
|
||||
<button
|
||||
@click="setConfigValue('Wipe player data when the server is wiped', !getConfigValue('Wipe player data when the server is wiped', true))"
|
||||
class="relative w-11 h-6 rounded-full transition-colors"
|
||||
:class="getConfigValue('Wipe player data when the server is wiped', true) ? 'bg-oxide-500' : 'bg-neutral-700'"
|
||||
>
|
||||
<span
|
||||
class="absolute top-0.5 left-0.5 w-5 h-5 bg-white rounded-full transition-transform"
|
||||
:class="getConfigValue('Wipe player data when the server is wiped', true) ? 'translate-x-5' : 'translate-x-0'"
|
||||
/>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- Use UI Menu -->
|
||||
<div class="flex items-center justify-between">
|
||||
<div>
|
||||
<label class="text-sm text-neutral-200">Use Kits UI Menu</label>
|
||||
<p class="text-xs text-neutral-500">Show the in-game kits UI menu to players</p>
|
||||
</div>
|
||||
<button
|
||||
@click="setConfigValue('Use the Kits UI menu', !getConfigValue('Use the Kits UI menu', true))"
|
||||
class="relative w-11 h-6 rounded-full transition-colors"
|
||||
:class="getConfigValue('Use the Kits UI menu', true) ? 'bg-oxide-500' : 'bg-neutral-700'"
|
||||
>
|
||||
<span
|
||||
class="absolute top-0.5 left-0.5 w-5 h-5 bg-white rounded-full transition-transform"
|
||||
:class="getConfigValue('Use the Kits UI menu', true) ? 'translate-x-5' : 'translate-x-0'"
|
||||
/>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- Allow autokits toggle -->
|
||||
<div class="flex items-center justify-between">
|
||||
<div>
|
||||
<label class="text-sm text-neutral-200">Allow Auto-Kit Toggle</label>
|
||||
<p class="text-xs text-neutral-500">Let players toggle auto-kits on spawn</p>
|
||||
</div>
|
||||
<button
|
||||
@click="setConfigValue('Allow players to toggle auto-kits on spawn', !getConfigValue('Allow players to toggle auto-kits on spawn', false))"
|
||||
class="relative w-11 h-6 rounded-full transition-colors"
|
||||
:class="getConfigValue('Allow players to toggle auto-kits on spawn', false) ? 'bg-oxide-500' : 'bg-neutral-700'"
|
||||
>
|
||||
<span
|
||||
class="absolute top-0.5 left-0.5 w-5 h-5 bg-white rounded-full transition-transform"
|
||||
:class="getConfigValue('Allow players to toggle auto-kits on spawn', false) ? 'translate-x-5' : 'translate-x-0'"
|
||||
/>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- Show kits without perm -->
|
||||
<div class="flex items-center justify-between">
|
||||
<div>
|
||||
<label class="text-sm text-neutral-200">Show Kits Without Permission</label>
|
||||
<p class="text-xs text-neutral-500">Show permission-locked kits to players who lack them</p>
|
||||
</div>
|
||||
<button
|
||||
@click="setConfigValue('Show kits with permissions assigned to players without the permission', !getConfigValue('Show kits with permissions assigned to players without the permission', false))"
|
||||
class="relative w-11 h-6 rounded-full transition-colors"
|
||||
:class="getConfigValue('Show kits with permissions assigned to players without the permission', false) ? 'bg-oxide-500' : 'bg-neutral-700'"
|
||||
>
|
||||
<span
|
||||
class="absolute top-0.5 left-0.5 w-5 h-5 bg-white rounded-full transition-transform"
|
||||
:class="getConfigValue('Show kits with permissions assigned to players without the permission', false) ? 'translate-x-5' : 'translate-x-0'"
|
||||
/>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- Admin ignore restrictions -->
|
||||
<div class="flex items-center justify-between">
|
||||
<div>
|
||||
<label class="text-sm text-neutral-200">Admins Ignore Restrictions</label>
|
||||
<p class="text-xs text-neutral-500">Players with admin perm skip cooldown and usage limits</p>
|
||||
</div>
|
||||
<button
|
||||
@click="setConfigValue('Players with the admin permission ignore usage restrictions', !getConfigValue('Players with the admin permission ignore usage restrictions', false))"
|
||||
class="relative w-11 h-6 rounded-full transition-colors"
|
||||
:class="getConfigValue('Players with the admin permission ignore usage restrictions', false) ? 'bg-oxide-500' : 'bg-neutral-700'"
|
||||
>
|
||||
<span
|
||||
class="absolute top-0.5 left-0.5 w-5 h-5 bg-white rounded-full transition-transform"
|
||||
:class="getConfigValue('Players with the admin permission ignore usage restrictions', false) ? 'translate-x-5' : 'translate-x-0'"
|
||||
/>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Auto-kits -->
|
||||
<div>
|
||||
<label class="block text-sm text-neutral-200 mb-1">Auto-Kits (ordered by priority)</label>
|
||||
<p class="text-xs text-neutral-500 mb-2">Comma-separated list of kit names given on respawn</p>
|
||||
<input
|
||||
type="text"
|
||||
:value="(getConfigValue('Autokits ordered by priority', []) as string[]).join(', ')"
|
||||
@input="setConfigValue('Autokits ordered by priority', ($event.target as HTMLInputElement).value.split(',').map((s: string) => s.trim()).filter((s: string) => s))"
|
||||
class="w-full bg-neutral-800 border border-neutral-700 rounded-lg px-3 py-2 text-neutral-200 text-sm"
|
||||
placeholder="e.g. StarterKit, VIPKit"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Create Config Modal -->
|
||||
<div v-if="showCreateModal" class="fixed inset-0 bg-black/60 z-50 flex items-center justify-center p-4" @click.self="showCreateModal = false">
|
||||
<div class="bg-neutral-900 border border-neutral-800 rounded-xl p-6 w-full max-w-md">
|
||||
<h2 class="text-lg font-semibold text-neutral-100 mb-4">New Kits Config</h2>
|
||||
<div class="space-y-4">
|
||||
<div>
|
||||
<label class="block text-sm text-neutral-400 mb-1">Config Name</label>
|
||||
<input
|
||||
v-model="newConfigName"
|
||||
placeholder="e.g. Default Kits"
|
||||
class="w-full bg-neutral-800 border border-neutral-700 rounded-lg px-3 py-2 text-neutral-200 text-sm"
|
||||
@keydown.enter="handleCreateConfig"
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-sm text-neutral-400 mb-1">Description (optional)</label>
|
||||
<textarea
|
||||
v-model="newConfigDesc"
|
||||
rows="2"
|
||||
placeholder="What is this config for?"
|
||||
class="w-full bg-neutral-800 border border-neutral-700 rounded-lg px-3 py-2 text-neutral-200 text-sm resize-none"
|
||||
/>
|
||||
</div>
|
||||
<div class="flex justify-end gap-2">
|
||||
<button @click="showCreateModal = false" class="px-4 py-2 text-sm text-neutral-400 hover:text-neutral-200">Cancel</button>
|
||||
<button
|
||||
@click="handleCreateConfig"
|
||||
:disabled="!newConfigName.trim()"
|
||||
class="px-4 py-2 bg-oxide-500 text-white rounded-lg hover:bg-oxide-600 disabled:opacity-50 text-sm"
|
||||
>
|
||||
Create
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Import from Server Modal -->
|
||||
<div v-if="showImportModal" class="fixed inset-0 bg-black/60 z-50 flex items-center justify-center p-4" @click.self="showImportModal = false">
|
||||
<div class="bg-neutral-900 border border-neutral-800 rounded-xl p-6 w-full max-w-md">
|
||||
<h2 class="text-lg font-semibold text-neutral-100 mb-4">Import from Server</h2>
|
||||
<p class="text-sm text-neutral-400 mb-4">
|
||||
Import the current Kits config from your live server. This will create a new config profile.
|
||||
</p>
|
||||
<div class="space-y-4">
|
||||
<div>
|
||||
<label class="block text-sm text-neutral-400 mb-1">Config Name</label>
|
||||
<input
|
||||
v-model="importConfigName"
|
||||
placeholder="e.g. Imported Server Kits"
|
||||
class="w-full bg-neutral-800 border border-neutral-700 rounded-lg px-3 py-2 text-neutral-200 text-sm"
|
||||
@keydown.enter="handleImport"
|
||||
/>
|
||||
</div>
|
||||
<div class="flex justify-end gap-2">
|
||||
<button @click="showImportModal = false" class="px-4 py-2 text-sm text-neutral-400 hover:text-neutral-200">Cancel</button>
|
||||
<button
|
||||
@click="handleImport"
|
||||
:disabled="!importConfigName.trim()"
|
||||
class="px-4 py-2 bg-oxide-500 text-white rounded-lg hover:bg-oxide-600 disabled:opacity-50 text-sm"
|
||||
>
|
||||
Import
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
Reference in New Issue
Block a user