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:
33
backend-nest/src/entities/furnacesplitter-config.entity.ts
Normal file
33
backend-nest/src/entities/furnacesplitter-config.entity.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import { Entity, PrimaryGeneratedColumn, Column, ManyToOne, JoinColumn } from 'typeorm';
|
||||
import { License } from './license.entity';
|
||||
|
||||
@Entity('furnacesplitter_configs')
|
||||
export class FurnaceSplitterConfig {
|
||||
@PrimaryGeneratedColumn('uuid')
|
||||
id: string;
|
||||
|
||||
@Column({ type: 'uuid' })
|
||||
license_id: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 100 })
|
||||
config_name: string;
|
||||
|
||||
@Column({ type: 'text', nullable: true })
|
||||
description: string | null;
|
||||
|
||||
@Column({ type: 'jsonb', default: () => "'{}'" })
|
||||
config_data: Record<string, any>;
|
||||
|
||||
@Column({ type: 'boolean', default: false })
|
||||
is_active: boolean;
|
||||
|
||||
@Column({ type: 'timestamptz', default: () => 'NOW()' })
|
||||
created_at: Date;
|
||||
|
||||
@Column({ type: 'timestamptz', default: () => 'NOW()' })
|
||||
updated_at: Date;
|
||||
|
||||
@ManyToOne(() => License, { onDelete: 'CASCADE' })
|
||||
@JoinColumn({ name: 'license_id' })
|
||||
license: License;
|
||||
}
|
||||
33
backend-nest/src/entities/kits-config.entity.ts
Normal file
33
backend-nest/src/entities/kits-config.entity.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import { Entity, PrimaryGeneratedColumn, Column, ManyToOne, JoinColumn } from 'typeorm';
|
||||
import { License } from './license.entity';
|
||||
|
||||
@Entity('kits_configs')
|
||||
export class KitsConfig {
|
||||
@PrimaryGeneratedColumn('uuid')
|
||||
id: string;
|
||||
|
||||
@Column({ type: 'uuid' })
|
||||
license_id: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 100 })
|
||||
config_name: string;
|
||||
|
||||
@Column({ type: 'text', nullable: true })
|
||||
description: string | null;
|
||||
|
||||
@Column({ type: 'jsonb', default: () => "'{}'" })
|
||||
config_data: Record<string, any>;
|
||||
|
||||
@Column({ type: 'boolean', default: false })
|
||||
is_active: boolean;
|
||||
|
||||
@Column({ type: 'timestamptz', default: () => 'NOW()' })
|
||||
created_at: Date;
|
||||
|
||||
@Column({ type: 'timestamptz', default: () => 'NOW()' })
|
||||
updated_at: Date;
|
||||
|
||||
@ManyToOne(() => License, { onDelete: 'CASCADE' })
|
||||
@JoinColumn({ name: 'license_id' })
|
||||
license: License;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
import { IsString, IsOptional, IsObject, MaxLength } from 'class-validator';
|
||||
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
||||
|
||||
export class CreateFurnaceSplitterConfigDto {
|
||||
@ApiProperty({ example: 'Default FurnaceSplitter' })
|
||||
@IsString()
|
||||
@MaxLength(100)
|
||||
config_name: string;
|
||||
|
||||
@ApiPropertyOptional({ example: 'Standard furnace splitter settings' })
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
description?: string;
|
||||
|
||||
@ApiPropertyOptional()
|
||||
@IsObject()
|
||||
@IsOptional()
|
||||
config_data?: Record<string, any>;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
import { IsString, IsOptional, MaxLength } from 'class-validator';
|
||||
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
||||
|
||||
export class ImportFurnaceSplitterConfigDto {
|
||||
@ApiProperty({ example: 'Server Import' })
|
||||
@IsString()
|
||||
@MaxLength(100)
|
||||
config_name: string;
|
||||
|
||||
@ApiPropertyOptional({ example: 'Imported from live server' })
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
description?: string;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
import { IsString, IsOptional, IsObject, IsBoolean, MaxLength } from 'class-validator';
|
||||
import { ApiPropertyOptional } from '@nestjs/swagger';
|
||||
|
||||
export class UpdateFurnaceSplitterConfigDto {
|
||||
@ApiPropertyOptional({ example: 'Updated FurnaceSplitter' })
|
||||
@IsString()
|
||||
@MaxLength(100)
|
||||
@IsOptional()
|
||||
config_name?: string;
|
||||
|
||||
@ApiPropertyOptional({ example: 'Updated description' })
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
description?: string;
|
||||
|
||||
@ApiPropertyOptional()
|
||||
@IsObject()
|
||||
@IsOptional()
|
||||
config_data?: Record<string, any>;
|
||||
|
||||
@ApiPropertyOptional()
|
||||
@IsBoolean()
|
||||
@IsOptional()
|
||||
is_active?: boolean;
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
import {
|
||||
Controller,
|
||||
Get,
|
||||
Post,
|
||||
Put,
|
||||
Delete,
|
||||
Body,
|
||||
Param,
|
||||
UseGuards,
|
||||
} from '@nestjs/common';
|
||||
import { ApiTags, ApiBearerAuth, ApiOperation } from '@nestjs/swagger';
|
||||
import { FurnaceSplitterService } from './furnacesplitter.service';
|
||||
import { CreateFurnaceSplitterConfigDto } from './dto/create-furnacesplitter-config.dto';
|
||||
import { UpdateFurnaceSplitterConfigDto } from './dto/update-furnacesplitter-config.dto';
|
||||
import { ImportFurnaceSplitterConfigDto } from './dto/import-furnacesplitter-config.dto';
|
||||
import { CurrentTenant } from '../../common/decorators/current-tenant.decorator';
|
||||
import { RequirePermission } from '../../common/decorators/require-permission.decorator';
|
||||
import { JwtAuthGuard } from '../../common/guards/jwt-auth.guard';
|
||||
import { PermissionsGuard } from '../../common/guards/permissions.guard';
|
||||
|
||||
@ApiTags('furnacesplitter')
|
||||
@ApiBearerAuth()
|
||||
@Controller('furnacesplitter')
|
||||
@UseGuards(JwtAuthGuard, PermissionsGuard)
|
||||
export class FurnaceSplitterController {
|
||||
constructor(private readonly furnaceSplitterService: FurnaceSplitterService) {}
|
||||
|
||||
@Get('configs')
|
||||
@RequirePermission('furnacesplitter.view')
|
||||
@ApiOperation({ summary: 'List furnace splitter configs (summaries)' })
|
||||
getConfigs(@CurrentTenant() licenseId: string) {
|
||||
return this.furnaceSplitterService.getConfigs(licenseId);
|
||||
}
|
||||
|
||||
@Get('configs/:id')
|
||||
@RequirePermission('furnacesplitter.view')
|
||||
@ApiOperation({ summary: 'Get full furnace splitter config with data' })
|
||||
getConfig(@CurrentTenant() licenseId: string, @Param('id') id: string) {
|
||||
return this.furnaceSplitterService.getConfig(licenseId, id);
|
||||
}
|
||||
|
||||
@Post('configs')
|
||||
@RequirePermission('furnacesplitter.manage')
|
||||
@ApiOperation({ summary: 'Create furnace splitter config' })
|
||||
createConfig(@CurrentTenant() licenseId: string, @Body() dto: CreateFurnaceSplitterConfigDto) {
|
||||
return this.furnaceSplitterService.createConfig(licenseId, dto);
|
||||
}
|
||||
|
||||
@Put('configs/:id')
|
||||
@RequirePermission('furnacesplitter.manage')
|
||||
@ApiOperation({ summary: 'Update furnace splitter config' })
|
||||
updateConfig(
|
||||
@CurrentTenant() licenseId: string,
|
||||
@Param('id') id: string,
|
||||
@Body() dto: UpdateFurnaceSplitterConfigDto,
|
||||
) {
|
||||
return this.furnaceSplitterService.updateConfig(licenseId, id, dto);
|
||||
}
|
||||
|
||||
@Delete('configs/:id')
|
||||
@RequirePermission('furnacesplitter.manage')
|
||||
@ApiOperation({ summary: 'Delete furnace splitter config' })
|
||||
deleteConfig(@CurrentTenant() licenseId: string, @Param('id') id: string) {
|
||||
return this.furnaceSplitterService.deleteConfig(licenseId, id);
|
||||
}
|
||||
|
||||
@Post('configs/:id/apply')
|
||||
@RequirePermission('furnacesplitter.manage')
|
||||
@ApiOperation({ summary: 'Deploy furnace splitter config to server' })
|
||||
applyToServer(@CurrentTenant() licenseId: string, @Param('id') id: string) {
|
||||
return this.furnaceSplitterService.applyToServer(licenseId, id);
|
||||
}
|
||||
|
||||
@Post('import-from-server')
|
||||
@RequirePermission('furnacesplitter.manage')
|
||||
@ApiOperation({ summary: 'Import FurnaceSplitter.json from server via NATS' })
|
||||
importFromServer(@CurrentTenant() licenseId: string, @Body() dto: ImportFurnaceSplitterConfigDto) {
|
||||
return this.furnaceSplitterService.importFromServer(licenseId, dto.config_name, dto.description);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
import { FurnaceSplitterController } from './furnacesplitter.controller';
|
||||
import { FurnaceSplitterService } from './furnacesplitter.service';
|
||||
import { FurnaceSplitterConfig } from '../../entities/furnacesplitter-config.entity';
|
||||
import { NatsService } from '../../services/nats.service';
|
||||
|
||||
@Module({
|
||||
imports: [TypeOrmModule.forFeature([FurnaceSplitterConfig])],
|
||||
controllers: [FurnaceSplitterController],
|
||||
providers: [FurnaceSplitterService, NatsService],
|
||||
exports: [FurnaceSplitterService],
|
||||
})
|
||||
export class FurnaceSplitterModule {}
|
||||
@@ -0,0 +1,180 @@
|
||||
import { Injectable, Logger, NotFoundException, HttpException, HttpStatus } from '@nestjs/common';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { Repository } from 'typeorm';
|
||||
import { FurnaceSplitterConfig } from '../../entities/furnacesplitter-config.entity';
|
||||
import { NatsService } from '../../services/nats.service';
|
||||
import { CreateFurnaceSplitterConfigDto } from './dto/create-furnacesplitter-config.dto';
|
||||
import { UpdateFurnaceSplitterConfigDto } from './dto/update-furnacesplitter-config.dto';
|
||||
|
||||
@Injectable()
|
||||
export class FurnaceSplitterService {
|
||||
private readonly logger = new Logger(FurnaceSplitterService.name);
|
||||
|
||||
constructor(
|
||||
@InjectRepository(FurnaceSplitterConfig)
|
||||
private readonly furnaceRepo: Repository<FurnaceSplitterConfig>,
|
||||
private readonly natsService: NatsService,
|
||||
) {}
|
||||
|
||||
/** List configs for a license (summaries — no JSONB) */
|
||||
async getConfigs(licenseId: string) {
|
||||
const configs = await this.furnaceRepo.find({
|
||||
where: { license_id: licenseId },
|
||||
select: ['id', 'config_name', 'description', 'is_active', 'created_at', 'updated_at'],
|
||||
order: { created_at: 'DESC' },
|
||||
});
|
||||
return { configs };
|
||||
}
|
||||
|
||||
/** Get full config with JSONB data */
|
||||
async getConfig(licenseId: string, configId: string) {
|
||||
const config = await this.furnaceRepo.findOne({
|
||||
where: { id: configId, license_id: licenseId },
|
||||
});
|
||||
if (!config) throw new NotFoundException('FurnaceSplitter config not found');
|
||||
return { config };
|
||||
}
|
||||
|
||||
/** Create a new config */
|
||||
async createConfig(licenseId: string, dto: CreateFurnaceSplitterConfigDto) {
|
||||
const config = this.furnaceRepo.create({
|
||||
license_id: licenseId,
|
||||
config_name: dto.config_name,
|
||||
description: dto.description || null,
|
||||
config_data: dto.config_data || {},
|
||||
});
|
||||
const saved = await this.furnaceRepo.save(config);
|
||||
return { config: saved };
|
||||
}
|
||||
|
||||
/** Update an existing config */
|
||||
async updateConfig(licenseId: string, configId: string, dto: UpdateFurnaceSplitterConfigDto) {
|
||||
const config = await this.furnaceRepo.findOne({
|
||||
where: { id: configId, license_id: licenseId },
|
||||
});
|
||||
if (!config) throw new NotFoundException('FurnaceSplitter config not found');
|
||||
|
||||
if (dto.config_name !== undefined) config.config_name = dto.config_name;
|
||||
if (dto.description !== undefined) config.description = dto.description;
|
||||
if (dto.config_data !== undefined) config.config_data = dto.config_data;
|
||||
if (dto.is_active !== undefined) config.is_active = dto.is_active;
|
||||
config.updated_at = new Date();
|
||||
|
||||
const saved = await this.furnaceRepo.save(config);
|
||||
return { config: saved };
|
||||
}
|
||||
|
||||
/** Delete a config */
|
||||
async deleteConfig(licenseId: string, configId: string) {
|
||||
const result = await this.furnaceRepo.delete({ id: configId, license_id: licenseId });
|
||||
if (result.affected === 0) throw new NotFoundException('FurnaceSplitter config not found');
|
||||
return { deleted: true };
|
||||
}
|
||||
|
||||
/** Deploy config to game server via NATS */
|
||||
async applyToServer(licenseId: string, configId: string) {
|
||||
const config = await this.furnaceRepo.findOne({
|
||||
where: { id: configId, license_id: licenseId },
|
||||
});
|
||||
if (!config) throw new NotFoundException('FurnaceSplitter config not found');
|
||||
|
||||
const jsonString = JSON.stringify(config.config_data, null, 2);
|
||||
|
||||
try {
|
||||
// Write FurnaceSplitter.json via file manager NATS
|
||||
await this.natsService.request(
|
||||
`corrosion.${licenseId}.files.cmd`,
|
||||
{
|
||||
func: 'fm_save',
|
||||
path: 'server://oxide/config/FurnaceSplitter.json',
|
||||
content: jsonString,
|
||||
},
|
||||
30000,
|
||||
);
|
||||
|
||||
// Reload FurnaceSplitter plugin via RCON
|
||||
await this.natsService.publish(
|
||||
`corrosion.${licenseId}.cmd.server`,
|
||||
{
|
||||
action: 'command',
|
||||
command: 'oxide.reload FurnaceSplitter',
|
||||
timestamp: new Date().toISOString(),
|
||||
},
|
||||
);
|
||||
|
||||
// Mark this config as active, deactivate others
|
||||
await this.furnaceRepo.update({ license_id: licenseId }, { is_active: false });
|
||||
await this.furnaceRepo.update(
|
||||
{ id: configId, license_id: licenseId },
|
||||
{ is_active: true, updated_at: new Date() },
|
||||
);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
message: `Config "${config.config_name}" deployed to server`,
|
||||
config_name: config.config_name,
|
||||
};
|
||||
} catch (error) {
|
||||
this.logger.error(`Failed to deploy furnace splitter config: ${(error as Error).message}`);
|
||||
throw new HttpException(
|
||||
'Failed to deploy furnace splitter config — agent may be offline',
|
||||
HttpStatus.SERVICE_UNAVAILABLE,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/** Import FurnaceSplitter.json from game server via NATS */
|
||||
async importFromServer(licenseId: string, configName: string, description?: string) {
|
||||
try {
|
||||
// Read FurnaceSplitter.json from server via file manager NATS
|
||||
const response = await this.natsService.request(
|
||||
`corrosion.${licenseId}.files.cmd`,
|
||||
{
|
||||
func: 'fm_preview',
|
||||
path: 'server://oxide/config/FurnaceSplitter.json',
|
||||
},
|
||||
30000,
|
||||
);
|
||||
|
||||
if (!response) {
|
||||
throw new HttpException(
|
||||
'No response from agent — it may be offline',
|
||||
HttpStatus.SERVICE_UNAVAILABLE,
|
||||
);
|
||||
}
|
||||
|
||||
// Parse the response content as JSON
|
||||
const responseData = response as Record<string, any>;
|
||||
let configData: Record<string, any>;
|
||||
|
||||
if (typeof responseData.content === 'string') {
|
||||
configData = JSON.parse(responseData.content);
|
||||
} else if (typeof responseData.content === 'object') {
|
||||
configData = responseData.content;
|
||||
} else {
|
||||
throw new HttpException(
|
||||
'Unexpected response format from agent',
|
||||
HttpStatus.BAD_GATEWAY,
|
||||
);
|
||||
}
|
||||
|
||||
// Create new furnace splitter config row
|
||||
const config = this.furnaceRepo.create({
|
||||
license_id: licenseId,
|
||||
config_name: configName,
|
||||
description: description || 'Imported from server',
|
||||
config_data: configData,
|
||||
});
|
||||
const saved = await this.furnaceRepo.save(config);
|
||||
|
||||
return { config: saved };
|
||||
} catch (error) {
|
||||
if (error instanceof HttpException) throw error;
|
||||
this.logger.error(`Failed to import furnace splitter config from server: ${(error as Error).message}`);
|
||||
throw new HttpException(
|
||||
'Failed to import furnace splitter config — agent may be offline',
|
||||
HttpStatus.SERVICE_UNAVAILABLE,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
19
backend-nest/src/modules/kits/dto/create-kits-config.dto.ts
Normal file
19
backend-nest/src/modules/kits/dto/create-kits-config.dto.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import { IsString, IsOptional, IsObject, MaxLength } from 'class-validator';
|
||||
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
||||
|
||||
export class CreateKitsConfigDto {
|
||||
@ApiProperty({ example: 'Default Kits' })
|
||||
@IsString()
|
||||
@MaxLength(100)
|
||||
config_name: string;
|
||||
|
||||
@ApiPropertyOptional({ example: 'Standard kit configuration' })
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
description?: string;
|
||||
|
||||
@ApiPropertyOptional()
|
||||
@IsObject()
|
||||
@IsOptional()
|
||||
config_data?: Record<string, any>;
|
||||
}
|
||||
14
backend-nest/src/modules/kits/dto/import-kits-config.dto.ts
Normal file
14
backend-nest/src/modules/kits/dto/import-kits-config.dto.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import { IsString, IsOptional, MaxLength } from 'class-validator';
|
||||
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
||||
|
||||
export class ImportKitsConfigDto {
|
||||
@ApiProperty({ example: 'Server Import' })
|
||||
@IsString()
|
||||
@MaxLength(100)
|
||||
config_name: string;
|
||||
|
||||
@ApiPropertyOptional({ example: 'Imported from live server' })
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
description?: string;
|
||||
}
|
||||
25
backend-nest/src/modules/kits/dto/update-kits-config.dto.ts
Normal file
25
backend-nest/src/modules/kits/dto/update-kits-config.dto.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { IsString, IsOptional, IsObject, IsBoolean, MaxLength } from 'class-validator';
|
||||
import { ApiPropertyOptional } from '@nestjs/swagger';
|
||||
|
||||
export class UpdateKitsConfigDto {
|
||||
@ApiPropertyOptional({ example: 'Updated Kits' })
|
||||
@IsString()
|
||||
@MaxLength(100)
|
||||
@IsOptional()
|
||||
config_name?: string;
|
||||
|
||||
@ApiPropertyOptional({ example: 'Updated description' })
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
description?: string;
|
||||
|
||||
@ApiPropertyOptional()
|
||||
@IsObject()
|
||||
@IsOptional()
|
||||
config_data?: Record<string, any>;
|
||||
|
||||
@ApiPropertyOptional()
|
||||
@IsBoolean()
|
||||
@IsOptional()
|
||||
is_active?: boolean;
|
||||
}
|
||||
80
backend-nest/src/modules/kits/kits.controller.ts
Normal file
80
backend-nest/src/modules/kits/kits.controller.ts
Normal file
@@ -0,0 +1,80 @@
|
||||
import {
|
||||
Controller,
|
||||
Get,
|
||||
Post,
|
||||
Put,
|
||||
Delete,
|
||||
Body,
|
||||
Param,
|
||||
UseGuards,
|
||||
} from '@nestjs/common';
|
||||
import { ApiTags, ApiBearerAuth, ApiOperation } from '@nestjs/swagger';
|
||||
import { KitsService } from './kits.service';
|
||||
import { CreateKitsConfigDto } from './dto/create-kits-config.dto';
|
||||
import { UpdateKitsConfigDto } from './dto/update-kits-config.dto';
|
||||
import { ImportKitsConfigDto } from './dto/import-kits-config.dto';
|
||||
import { CurrentTenant } from '../../common/decorators/current-tenant.decorator';
|
||||
import { RequirePermission } from '../../common/decorators/require-permission.decorator';
|
||||
import { JwtAuthGuard } from '../../common/guards/jwt-auth.guard';
|
||||
import { PermissionsGuard } from '../../common/guards/permissions.guard';
|
||||
|
||||
@ApiTags('kits')
|
||||
@ApiBearerAuth()
|
||||
@Controller('kits')
|
||||
@UseGuards(JwtAuthGuard, PermissionsGuard)
|
||||
export class KitsController {
|
||||
constructor(private readonly kitsService: KitsService) {}
|
||||
|
||||
@Get('configs')
|
||||
@RequirePermission('kits.view')
|
||||
@ApiOperation({ summary: 'List kits configs (summaries)' })
|
||||
getConfigs(@CurrentTenant() licenseId: string) {
|
||||
return this.kitsService.getConfigs(licenseId);
|
||||
}
|
||||
|
||||
@Get('configs/:id')
|
||||
@RequirePermission('kits.view')
|
||||
@ApiOperation({ summary: 'Get full kits config with data' })
|
||||
getConfig(@CurrentTenant() licenseId: string, @Param('id') id: string) {
|
||||
return this.kitsService.getConfig(licenseId, id);
|
||||
}
|
||||
|
||||
@Post('configs')
|
||||
@RequirePermission('kits.manage')
|
||||
@ApiOperation({ summary: 'Create kits config' })
|
||||
createConfig(@CurrentTenant() licenseId: string, @Body() dto: CreateKitsConfigDto) {
|
||||
return this.kitsService.createConfig(licenseId, dto);
|
||||
}
|
||||
|
||||
@Put('configs/:id')
|
||||
@RequirePermission('kits.manage')
|
||||
@ApiOperation({ summary: 'Update kits config' })
|
||||
updateConfig(
|
||||
@CurrentTenant() licenseId: string,
|
||||
@Param('id') id: string,
|
||||
@Body() dto: UpdateKitsConfigDto,
|
||||
) {
|
||||
return this.kitsService.updateConfig(licenseId, id, dto);
|
||||
}
|
||||
|
||||
@Delete('configs/:id')
|
||||
@RequirePermission('kits.manage')
|
||||
@ApiOperation({ summary: 'Delete kits config' })
|
||||
deleteConfig(@CurrentTenant() licenseId: string, @Param('id') id: string) {
|
||||
return this.kitsService.deleteConfig(licenseId, id);
|
||||
}
|
||||
|
||||
@Post('configs/:id/apply')
|
||||
@RequirePermission('kits.manage')
|
||||
@ApiOperation({ summary: 'Deploy kits config to server' })
|
||||
applyToServer(@CurrentTenant() licenseId: string, @Param('id') id: string) {
|
||||
return this.kitsService.applyToServer(licenseId, id);
|
||||
}
|
||||
|
||||
@Post('import-from-server')
|
||||
@RequirePermission('kits.manage')
|
||||
@ApiOperation({ summary: 'Import Kits.json from server via NATS' })
|
||||
importFromServer(@CurrentTenant() licenseId: string, @Body() dto: ImportKitsConfigDto) {
|
||||
return this.kitsService.importFromServer(licenseId, dto.config_name, dto.description);
|
||||
}
|
||||
}
|
||||
14
backend-nest/src/modules/kits/kits.module.ts
Normal file
14
backend-nest/src/modules/kits/kits.module.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
import { KitsController } from './kits.controller';
|
||||
import { KitsService } from './kits.service';
|
||||
import { KitsConfig } from '../../entities/kits-config.entity';
|
||||
import { NatsService } from '../../services/nats.service';
|
||||
|
||||
@Module({
|
||||
imports: [TypeOrmModule.forFeature([KitsConfig])],
|
||||
controllers: [KitsController],
|
||||
providers: [KitsService, NatsService],
|
||||
exports: [KitsService],
|
||||
})
|
||||
export class KitsModule {}
|
||||
180
backend-nest/src/modules/kits/kits.service.ts
Normal file
180
backend-nest/src/modules/kits/kits.service.ts
Normal file
@@ -0,0 +1,180 @@
|
||||
import { Injectable, Logger, NotFoundException, HttpException, HttpStatus } from '@nestjs/common';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { Repository } from 'typeorm';
|
||||
import { KitsConfig } from '../../entities/kits-config.entity';
|
||||
import { NatsService } from '../../services/nats.service';
|
||||
import { CreateKitsConfigDto } from './dto/create-kits-config.dto';
|
||||
import { UpdateKitsConfigDto } from './dto/update-kits-config.dto';
|
||||
|
||||
@Injectable()
|
||||
export class KitsService {
|
||||
private readonly logger = new Logger(KitsService.name);
|
||||
|
||||
constructor(
|
||||
@InjectRepository(KitsConfig)
|
||||
private readonly kitsRepo: Repository<KitsConfig>,
|
||||
private readonly natsService: NatsService,
|
||||
) {}
|
||||
|
||||
/** List configs for a license (summaries — no JSONB) */
|
||||
async getConfigs(licenseId: string) {
|
||||
const configs = await this.kitsRepo.find({
|
||||
where: { license_id: licenseId },
|
||||
select: ['id', 'config_name', 'description', 'is_active', 'created_at', 'updated_at'],
|
||||
order: { created_at: 'DESC' },
|
||||
});
|
||||
return { configs };
|
||||
}
|
||||
|
||||
/** Get full config with JSONB data */
|
||||
async getConfig(licenseId: string, configId: string) {
|
||||
const config = await this.kitsRepo.findOne({
|
||||
where: { id: configId, license_id: licenseId },
|
||||
});
|
||||
if (!config) throw new NotFoundException('Kits config not found');
|
||||
return { config };
|
||||
}
|
||||
|
||||
/** Create a new config */
|
||||
async createConfig(licenseId: string, dto: CreateKitsConfigDto) {
|
||||
const config = this.kitsRepo.create({
|
||||
license_id: licenseId,
|
||||
config_name: dto.config_name,
|
||||
description: dto.description || null,
|
||||
config_data: dto.config_data || {},
|
||||
});
|
||||
const saved = await this.kitsRepo.save(config);
|
||||
return { config: saved };
|
||||
}
|
||||
|
||||
/** Update an existing config */
|
||||
async updateConfig(licenseId: string, configId: string, dto: UpdateKitsConfigDto) {
|
||||
const config = await this.kitsRepo.findOne({
|
||||
where: { id: configId, license_id: licenseId },
|
||||
});
|
||||
if (!config) throw new NotFoundException('Kits config not found');
|
||||
|
||||
if (dto.config_name !== undefined) config.config_name = dto.config_name;
|
||||
if (dto.description !== undefined) config.description = dto.description;
|
||||
if (dto.config_data !== undefined) config.config_data = dto.config_data;
|
||||
if (dto.is_active !== undefined) config.is_active = dto.is_active;
|
||||
config.updated_at = new Date();
|
||||
|
||||
const saved = await this.kitsRepo.save(config);
|
||||
return { config: saved };
|
||||
}
|
||||
|
||||
/** Delete a config */
|
||||
async deleteConfig(licenseId: string, configId: string) {
|
||||
const result = await this.kitsRepo.delete({ id: configId, license_id: licenseId });
|
||||
if (result.affected === 0) throw new NotFoundException('Kits config not found');
|
||||
return { deleted: true };
|
||||
}
|
||||
|
||||
/** Deploy config to game server via NATS */
|
||||
async applyToServer(licenseId: string, configId: string) {
|
||||
const config = await this.kitsRepo.findOne({
|
||||
where: { id: configId, license_id: licenseId },
|
||||
});
|
||||
if (!config) throw new NotFoundException('Kits config not found');
|
||||
|
||||
const jsonString = JSON.stringify(config.config_data, null, 2);
|
||||
|
||||
try {
|
||||
// Write Kits.json via file manager NATS
|
||||
await this.natsService.request(
|
||||
`corrosion.${licenseId}.files.cmd`,
|
||||
{
|
||||
func: 'fm_save',
|
||||
path: 'server://oxide/config/Kits.json',
|
||||
content: jsonString,
|
||||
},
|
||||
30000,
|
||||
);
|
||||
|
||||
// Reload Kits plugin via RCON
|
||||
await this.natsService.publish(
|
||||
`corrosion.${licenseId}.cmd.server`,
|
||||
{
|
||||
action: 'command',
|
||||
command: 'oxide.reload Kits',
|
||||
timestamp: new Date().toISOString(),
|
||||
},
|
||||
);
|
||||
|
||||
// Mark this config as active, deactivate others
|
||||
await this.kitsRepo.update({ license_id: licenseId }, { is_active: false });
|
||||
await this.kitsRepo.update(
|
||||
{ id: configId, license_id: licenseId },
|
||||
{ is_active: true, updated_at: new Date() },
|
||||
);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
message: `Config "${config.config_name}" deployed to server`,
|
||||
config_name: config.config_name,
|
||||
};
|
||||
} catch (error) {
|
||||
this.logger.error(`Failed to deploy kits config: ${(error as Error).message}`);
|
||||
throw new HttpException(
|
||||
'Failed to deploy kits config — agent may be offline',
|
||||
HttpStatus.SERVICE_UNAVAILABLE,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/** Import Kits.json from game server via NATS */
|
||||
async importFromServer(licenseId: string, configName: string, description?: string) {
|
||||
try {
|
||||
// Read Kits.json from server via file manager NATS
|
||||
const response = await this.natsService.request(
|
||||
`corrosion.${licenseId}.files.cmd`,
|
||||
{
|
||||
func: 'fm_preview',
|
||||
path: 'server://oxide/config/Kits.json',
|
||||
},
|
||||
30000,
|
||||
);
|
||||
|
||||
if (!response) {
|
||||
throw new HttpException(
|
||||
'No response from agent — it may be offline',
|
||||
HttpStatus.SERVICE_UNAVAILABLE,
|
||||
);
|
||||
}
|
||||
|
||||
// Parse the response content as JSON
|
||||
const responseData = response as Record<string, any>;
|
||||
let configData: Record<string, any>;
|
||||
|
||||
if (typeof responseData.content === 'string') {
|
||||
configData = JSON.parse(responseData.content);
|
||||
} else if (typeof responseData.content === 'object') {
|
||||
configData = responseData.content;
|
||||
} else {
|
||||
throw new HttpException(
|
||||
'Unexpected response format from agent',
|
||||
HttpStatus.BAD_GATEWAY,
|
||||
);
|
||||
}
|
||||
|
||||
// Create new kits config row
|
||||
const config = this.kitsRepo.create({
|
||||
license_id: licenseId,
|
||||
config_name: configName,
|
||||
description: description || 'Imported from server',
|
||||
config_data: configData,
|
||||
});
|
||||
const saved = await this.kitsRepo.save(config);
|
||||
|
||||
return { config: saved };
|
||||
} catch (error) {
|
||||
if (error instanceof HttpException) throw error;
|
||||
this.logger.error(`Failed to import kits config from server: ${(error as Error).message}`);
|
||||
throw new HttpException(
|
||||
'Failed to import kits config — agent may be offline',
|
||||
HttpStatus.SERVICE_UNAVAILABLE,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
backend/migrations/016_kits_configs.sql
Normal file
11
backend/migrations/016_kits_configs.sql
Normal file
@@ -0,0 +1,11 @@
|
||||
CREATE TABLE IF NOT EXISTS kits_configs (
|
||||
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
license_id UUID NOT NULL REFERENCES licenses(id) ON DELETE CASCADE,
|
||||
config_name VARCHAR(100) NOT NULL,
|
||||
description TEXT,
|
||||
config_data JSONB NOT NULL DEFAULT '{}',
|
||||
is_active BOOLEAN NOT NULL DEFAULT false,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||||
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
|
||||
);
|
||||
CREATE INDEX idx_kits_configs_license ON kits_configs(license_id);
|
||||
11
backend/migrations/019_furnacesplitter_configs.sql
Normal file
11
backend/migrations/019_furnacesplitter_configs.sql
Normal file
@@ -0,0 +1,11 @@
|
||||
CREATE TABLE IF NOT EXISTS furnacesplitter_configs (
|
||||
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
license_id UUID NOT NULL REFERENCES licenses(id) ON DELETE CASCADE,
|
||||
config_name VARCHAR(100) NOT NULL,
|
||||
description TEXT,
|
||||
config_data JSONB NOT NULL DEFAULT '{}',
|
||||
is_active BOOLEAN NOT NULL DEFAULT false,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||||
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
|
||||
);
|
||||
CREATE INDEX idx_furnacesplitter_configs_license ON furnacesplitter_configs(license_id);
|
||||
@@ -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