feat: Add GatherManager + AutoDoors plugin config modules
All checks were successful
Test Asgard Runner / test (push) Successful in 3s
All checks were successful
Test Asgard Runner / test (push) Successful in 3s
- GatherManager: 2-tab editor (Resource Rates with 1x-10x presets, Advanced with Pickup/Quarry/Excavator/Survey modifiers), 9 resource types with slider+number inputs, CRUD + deploy + import via NATS - AutoDoors: Global settings (delay sliders, 6 toggles), 7 door type toggles, permission group overrides table, CRUD + deploy + import - DB: migrations 015 (gather_configs) + 018 (autodoors_configs) - Backend: GatherModule + AutoDoorsModule registered in app.module.ts - Frontend: Pinia stores, Vue views, router routes, sidebar nav items - Icons: Pickaxe (gather), DoorOpen (autodoors) - All type checks pass: tsc + vue-tsc zero errors Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -37,6 +37,10 @@ import { ChangelogModule } from './modules/changelog/changelog.module';
|
||||
import { FilesModule } from './modules/files/files.module';
|
||||
import { LootModule } from './modules/loot/loot.module';
|
||||
import { TeleportModule } from './modules/teleport/teleport.module';
|
||||
import { GatherModule } from './modules/gather/gather.module';
|
||||
import { AutoDoorsModule } from './modules/autodoors/autodoors.module';
|
||||
import { KitsModule } from './modules/kits/kits.module';
|
||||
import { FurnaceSplitterModule } from './modules/furnacesplitter/furnacesplitter.module';
|
||||
|
||||
// Shared Services
|
||||
import { NatsService } from './services/nats.service';
|
||||
@@ -109,6 +113,10 @@ import { NatsBridgeGateway } from './gateways/nats-bridge.gateway';
|
||||
FilesModule,
|
||||
LootModule,
|
||||
TeleportModule,
|
||||
GatherModule,
|
||||
AutoDoorsModule,
|
||||
KitsModule,
|
||||
FurnaceSplitterModule,
|
||||
],
|
||||
providers: [
|
||||
// Global guards (order matters: auth first, then license, then permissions)
|
||||
|
||||
33
backend-nest/src/entities/autodoors-config.entity.ts
Normal file
33
backend-nest/src/entities/autodoors-config.entity.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import { Entity, PrimaryGeneratedColumn, Column, ManyToOne, JoinColumn } from 'typeorm';
|
||||
import { License } from './license.entity';
|
||||
|
||||
@Entity('autodoors_configs')
|
||||
export class AutoDoorsConfig {
|
||||
@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/gather-config.entity.ts
Normal file
33
backend-nest/src/entities/gather-config.entity.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import { Entity, PrimaryGeneratedColumn, Column, ManyToOne, JoinColumn } from 'typeorm';
|
||||
import { License } from './license.entity';
|
||||
|
||||
@Entity('gather_configs')
|
||||
export class GatherConfig {
|
||||
@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;
|
||||
}
|
||||
80
backend-nest/src/modules/autodoors/autodoors.controller.ts
Normal file
80
backend-nest/src/modules/autodoors/autodoors.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 { AutoDoorsService } from './autodoors.service';
|
||||
import { CreateAutoDoorsConfigDto } from './dto/create-autodoors-config.dto';
|
||||
import { UpdateAutoDoorsConfigDto } from './dto/update-autodoors-config.dto';
|
||||
import { ImportAutoDoorsConfigDto } from './dto/import-autodoors-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('autodoors')
|
||||
@ApiBearerAuth()
|
||||
@Controller('autodoors')
|
||||
@UseGuards(JwtAuthGuard, PermissionsGuard)
|
||||
export class AutoDoorsController {
|
||||
constructor(private readonly autoDoorsService: AutoDoorsService) {}
|
||||
|
||||
@Get('configs')
|
||||
@RequirePermission('autodoors.view')
|
||||
@ApiOperation({ summary: 'List AutoDoors configs' })
|
||||
getConfigs(@CurrentTenant() licenseId: string) {
|
||||
return this.autoDoorsService.getConfigs(licenseId);
|
||||
}
|
||||
|
||||
@Get('configs/:id')
|
||||
@RequirePermission('autodoors.view')
|
||||
@ApiOperation({ summary: 'Get full AutoDoors config' })
|
||||
getConfig(@CurrentTenant() licenseId: string, @Param('id') id: string) {
|
||||
return this.autoDoorsService.getConfig(licenseId, id);
|
||||
}
|
||||
|
||||
@Post('configs')
|
||||
@RequirePermission('autodoors.manage')
|
||||
@ApiOperation({ summary: 'Create AutoDoors config' })
|
||||
createConfig(@CurrentTenant() licenseId: string, @Body() dto: CreateAutoDoorsConfigDto) {
|
||||
return this.autoDoorsService.createConfig(licenseId, dto);
|
||||
}
|
||||
|
||||
@Put('configs/:id')
|
||||
@RequirePermission('autodoors.manage')
|
||||
@ApiOperation({ summary: 'Update AutoDoors config' })
|
||||
updateConfig(
|
||||
@CurrentTenant() licenseId: string,
|
||||
@Param('id') id: string,
|
||||
@Body() dto: UpdateAutoDoorsConfigDto,
|
||||
) {
|
||||
return this.autoDoorsService.updateConfig(licenseId, id, dto);
|
||||
}
|
||||
|
||||
@Delete('configs/:id')
|
||||
@RequirePermission('autodoors.manage')
|
||||
@ApiOperation({ summary: 'Delete AutoDoors config' })
|
||||
deleteConfig(@CurrentTenant() licenseId: string, @Param('id') id: string) {
|
||||
return this.autoDoorsService.deleteConfig(licenseId, id);
|
||||
}
|
||||
|
||||
@Post('configs/:id/apply')
|
||||
@RequirePermission('autodoors.manage')
|
||||
@ApiOperation({ summary: 'Deploy AutoDoors config to server' })
|
||||
applyToServer(@CurrentTenant() licenseId: string, @Param('id') id: string) {
|
||||
return this.autoDoorsService.applyToServer(licenseId, id);
|
||||
}
|
||||
|
||||
@Post('import-from-server')
|
||||
@RequirePermission('autodoors.manage')
|
||||
@ApiOperation({ summary: 'Import AutoDoors.json from server' })
|
||||
importFromServer(@CurrentTenant() licenseId: string, @Body() dto: ImportAutoDoorsConfigDto) {
|
||||
return this.autoDoorsService.importFromServer(licenseId, dto.config_name, dto.description);
|
||||
}
|
||||
}
|
||||
14
backend-nest/src/modules/autodoors/autodoors.module.ts
Normal file
14
backend-nest/src/modules/autodoors/autodoors.module.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
import { AutoDoorsController } from './autodoors.controller';
|
||||
import { AutoDoorsService } from './autodoors.service';
|
||||
import { AutoDoorsConfig } from '../../entities/autodoors-config.entity';
|
||||
import { NatsService } from '../../services/nats.service';
|
||||
|
||||
@Module({
|
||||
imports: [TypeOrmModule.forFeature([AutoDoorsConfig])],
|
||||
controllers: [AutoDoorsController],
|
||||
providers: [AutoDoorsService, NatsService],
|
||||
exports: [AutoDoorsService],
|
||||
})
|
||||
export class AutoDoorsModule {}
|
||||
180
backend-nest/src/modules/autodoors/autodoors.service.ts
Normal file
180
backend-nest/src/modules/autodoors/autodoors.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 { AutoDoorsConfig } from '../../entities/autodoors-config.entity';
|
||||
import { NatsService } from '../../services/nats.service';
|
||||
import { CreateAutoDoorsConfigDto } from './dto/create-autodoors-config.dto';
|
||||
import { UpdateAutoDoorsConfigDto } from './dto/update-autodoors-config.dto';
|
||||
|
||||
@Injectable()
|
||||
export class AutoDoorsService {
|
||||
private readonly logger = new Logger(AutoDoorsService.name);
|
||||
|
||||
constructor(
|
||||
@InjectRepository(AutoDoorsConfig)
|
||||
private readonly autoDoorsRepo: Repository<AutoDoorsConfig>,
|
||||
private readonly natsService: NatsService,
|
||||
) {}
|
||||
|
||||
/** List configs for a license (summaries — no JSONB) */
|
||||
async getConfigs(licenseId: string) {
|
||||
const configs = await this.autoDoorsRepo.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.autoDoorsRepo.findOne({
|
||||
where: { id: configId, license_id: licenseId },
|
||||
});
|
||||
if (!config) throw new NotFoundException('AutoDoors config not found');
|
||||
return { config };
|
||||
}
|
||||
|
||||
/** Create a new config */
|
||||
async createConfig(licenseId: string, dto: CreateAutoDoorsConfigDto) {
|
||||
const config = this.autoDoorsRepo.create({
|
||||
license_id: licenseId,
|
||||
config_name: dto.config_name,
|
||||
description: dto.description || null,
|
||||
config_data: dto.config_data || {},
|
||||
});
|
||||
const saved = await this.autoDoorsRepo.save(config);
|
||||
return { config: saved };
|
||||
}
|
||||
|
||||
/** Update an existing config */
|
||||
async updateConfig(licenseId: string, configId: string, dto: UpdateAutoDoorsConfigDto) {
|
||||
const config = await this.autoDoorsRepo.findOne({
|
||||
where: { id: configId, license_id: licenseId },
|
||||
});
|
||||
if (!config) throw new NotFoundException('AutoDoors 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.autoDoorsRepo.save(config);
|
||||
return { config: saved };
|
||||
}
|
||||
|
||||
/** Delete a config */
|
||||
async deleteConfig(licenseId: string, configId: string) {
|
||||
const result = await this.autoDoorsRepo.delete({ id: configId, license_id: licenseId });
|
||||
if (result.affected === 0) throw new NotFoundException('AutoDoors config not found');
|
||||
return { deleted: true };
|
||||
}
|
||||
|
||||
/** Deploy config to game server via NATS */
|
||||
async applyToServer(licenseId: string, configId: string) {
|
||||
const config = await this.autoDoorsRepo.findOne({
|
||||
where: { id: configId, license_id: licenseId },
|
||||
});
|
||||
if (!config) throw new NotFoundException('AutoDoors config not found');
|
||||
|
||||
const jsonString = JSON.stringify(config.config_data, null, 2);
|
||||
|
||||
try {
|
||||
// Write AutoDoors.json via file manager NATS
|
||||
await this.natsService.request(
|
||||
`corrosion.${licenseId}.files.cmd`,
|
||||
{
|
||||
func: 'fm_save',
|
||||
path: 'server://oxide/config/AutoDoors.json',
|
||||
content: jsonString,
|
||||
},
|
||||
30000,
|
||||
);
|
||||
|
||||
// Reload AutoDoors plugin via RCON
|
||||
await this.natsService.publish(
|
||||
`corrosion.${licenseId}.cmd.server`,
|
||||
{
|
||||
action: 'command',
|
||||
command: 'oxide.reload AutoDoors',
|
||||
timestamp: new Date().toISOString(),
|
||||
},
|
||||
);
|
||||
|
||||
// Mark this config as active, deactivate others
|
||||
await this.autoDoorsRepo.update({ license_id: licenseId }, { is_active: false });
|
||||
await this.autoDoorsRepo.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 AutoDoors config: ${(error as Error).message}`);
|
||||
throw new HttpException(
|
||||
'Failed to deploy AutoDoors config — agent may be offline',
|
||||
HttpStatus.SERVICE_UNAVAILABLE,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/** Import AutoDoors.json from game server via NATS */
|
||||
async importFromServer(licenseId: string, configName: string, description?: string) {
|
||||
try {
|
||||
// Read AutoDoors.json from server via file manager NATS
|
||||
const response = await this.natsService.request(
|
||||
`corrosion.${licenseId}.files.cmd`,
|
||||
{
|
||||
func: 'fm_preview',
|
||||
path: 'server://oxide/config/AutoDoors.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 AutoDoors config row
|
||||
const config = this.autoDoorsRepo.create({
|
||||
license_id: licenseId,
|
||||
config_name: configName,
|
||||
description: description || 'Imported from server',
|
||||
config_data: configData,
|
||||
});
|
||||
const saved = await this.autoDoorsRepo.save(config);
|
||||
|
||||
return { config: saved };
|
||||
} catch (error) {
|
||||
if (error instanceof HttpException) throw error;
|
||||
this.logger.error(`Failed to import AutoDoors config from server: ${(error as Error).message}`);
|
||||
throw new HttpException(
|
||||
'Failed to import AutoDoors config — agent may be offline',
|
||||
HttpStatus.SERVICE_UNAVAILABLE,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
import { IsString, IsOptional, IsObject, MaxLength } from 'class-validator';
|
||||
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
||||
|
||||
export class CreateAutoDoorsConfigDto {
|
||||
@ApiProperty({ example: 'Default AutoDoors' })
|
||||
@IsString()
|
||||
@MaxLength(100)
|
||||
config_name: string;
|
||||
|
||||
@ApiPropertyOptional({ example: 'Standard auto-close 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 ImportAutoDoorsConfigDto {
|
||||
@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 UpdateAutoDoorsConfigDto {
|
||||
@ApiPropertyOptional({ example: 'Updated Config' })
|
||||
@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,19 @@
|
||||
import { IsString, IsOptional, IsObject, MaxLength } from 'class-validator';
|
||||
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
||||
|
||||
export class CreateGatherConfigDto {
|
||||
@ApiProperty({ example: 'Default 2x Rates' })
|
||||
@IsString()
|
||||
@MaxLength(100)
|
||||
config_name: string;
|
||||
|
||||
@ApiPropertyOptional({ example: 'Standard 2x gather rates' })
|
||||
@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 ImportGatherConfigDto {
|
||||
@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 UpdateGatherConfigDto {
|
||||
@ApiPropertyOptional({ example: 'Updated Rates' })
|
||||
@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/gather/gather.controller.ts
Normal file
80
backend-nest/src/modules/gather/gather.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 { GatherService } from './gather.service';
|
||||
import { CreateGatherConfigDto } from './dto/create-gather-config.dto';
|
||||
import { UpdateGatherConfigDto } from './dto/update-gather-config.dto';
|
||||
import { ImportGatherConfigDto } from './dto/import-gather-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('gather')
|
||||
@ApiBearerAuth()
|
||||
@Controller('gather')
|
||||
@UseGuards(JwtAuthGuard, PermissionsGuard)
|
||||
export class GatherController {
|
||||
constructor(private readonly gatherService: GatherService) {}
|
||||
|
||||
@Get('configs')
|
||||
@RequirePermission('gather.view')
|
||||
@ApiOperation({ summary: 'List gather configs' })
|
||||
getConfigs(@CurrentTenant() licenseId: string) {
|
||||
return this.gatherService.getConfigs(licenseId);
|
||||
}
|
||||
|
||||
@Get('configs/:id')
|
||||
@RequirePermission('gather.view')
|
||||
@ApiOperation({ summary: 'Get full gather config' })
|
||||
getConfig(@CurrentTenant() licenseId: string, @Param('id') id: string) {
|
||||
return this.gatherService.getConfig(licenseId, id);
|
||||
}
|
||||
|
||||
@Post('configs')
|
||||
@RequirePermission('gather.manage')
|
||||
@ApiOperation({ summary: 'Create gather config' })
|
||||
createConfig(@CurrentTenant() licenseId: string, @Body() dto: CreateGatherConfigDto) {
|
||||
return this.gatherService.createConfig(licenseId, dto);
|
||||
}
|
||||
|
||||
@Put('configs/:id')
|
||||
@RequirePermission('gather.manage')
|
||||
@ApiOperation({ summary: 'Update gather config' })
|
||||
updateConfig(
|
||||
@CurrentTenant() licenseId: string,
|
||||
@Param('id') id: string,
|
||||
@Body() dto: UpdateGatherConfigDto,
|
||||
) {
|
||||
return this.gatherService.updateConfig(licenseId, id, dto);
|
||||
}
|
||||
|
||||
@Delete('configs/:id')
|
||||
@RequirePermission('gather.manage')
|
||||
@ApiOperation({ summary: 'Delete gather config' })
|
||||
deleteConfig(@CurrentTenant() licenseId: string, @Param('id') id: string) {
|
||||
return this.gatherService.deleteConfig(licenseId, id);
|
||||
}
|
||||
|
||||
@Post('configs/:id/apply')
|
||||
@RequirePermission('gather.manage')
|
||||
@ApiOperation({ summary: 'Deploy gather config to server' })
|
||||
applyToServer(@CurrentTenant() licenseId: string, @Param('id') id: string) {
|
||||
return this.gatherService.applyToServer(licenseId, id);
|
||||
}
|
||||
|
||||
@Post('import-from-server')
|
||||
@RequirePermission('gather.manage')
|
||||
@ApiOperation({ summary: 'Import GatherManager.json from server' })
|
||||
importFromServer(@CurrentTenant() licenseId: string, @Body() dto: ImportGatherConfigDto) {
|
||||
return this.gatherService.importFromServer(licenseId, dto.config_name, dto.description);
|
||||
}
|
||||
}
|
||||
14
backend-nest/src/modules/gather/gather.module.ts
Normal file
14
backend-nest/src/modules/gather/gather.module.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
import { GatherController } from './gather.controller';
|
||||
import { GatherService } from './gather.service';
|
||||
import { GatherConfig } from '../../entities/gather-config.entity';
|
||||
import { NatsService } from '../../services/nats.service';
|
||||
|
||||
@Module({
|
||||
imports: [TypeOrmModule.forFeature([GatherConfig])],
|
||||
controllers: [GatherController],
|
||||
providers: [GatherService, NatsService],
|
||||
exports: [GatherService],
|
||||
})
|
||||
export class GatherModule {}
|
||||
180
backend-nest/src/modules/gather/gather.service.ts
Normal file
180
backend-nest/src/modules/gather/gather.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 { GatherConfig } from '../../entities/gather-config.entity';
|
||||
import { NatsService } from '../../services/nats.service';
|
||||
import { CreateGatherConfigDto } from './dto/create-gather-config.dto';
|
||||
import { UpdateGatherConfigDto } from './dto/update-gather-config.dto';
|
||||
|
||||
@Injectable()
|
||||
export class GatherService {
|
||||
private readonly logger = new Logger(GatherService.name);
|
||||
|
||||
constructor(
|
||||
@InjectRepository(GatherConfig)
|
||||
private readonly gatherRepo: Repository<GatherConfig>,
|
||||
private readonly natsService: NatsService,
|
||||
) {}
|
||||
|
||||
/** List configs for a license (summaries — no JSONB) */
|
||||
async getConfigs(licenseId: string) {
|
||||
const configs = await this.gatherRepo.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.gatherRepo.findOne({
|
||||
where: { id: configId, license_id: licenseId },
|
||||
});
|
||||
if (!config) throw new NotFoundException('Gather config not found');
|
||||
return { config };
|
||||
}
|
||||
|
||||
/** Create a new config */
|
||||
async createConfig(licenseId: string, dto: CreateGatherConfigDto) {
|
||||
const config = this.gatherRepo.create({
|
||||
license_id: licenseId,
|
||||
config_name: dto.config_name,
|
||||
description: dto.description || null,
|
||||
config_data: dto.config_data || {},
|
||||
});
|
||||
const saved = await this.gatherRepo.save(config);
|
||||
return { config: saved };
|
||||
}
|
||||
|
||||
/** Update an existing config */
|
||||
async updateConfig(licenseId: string, configId: string, dto: UpdateGatherConfigDto) {
|
||||
const config = await this.gatherRepo.findOne({
|
||||
where: { id: configId, license_id: licenseId },
|
||||
});
|
||||
if (!config) throw new NotFoundException('Gather 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.gatherRepo.save(config);
|
||||
return { config: saved };
|
||||
}
|
||||
|
||||
/** Delete a config */
|
||||
async deleteConfig(licenseId: string, configId: string) {
|
||||
const result = await this.gatherRepo.delete({ id: configId, license_id: licenseId });
|
||||
if (result.affected === 0) throw new NotFoundException('Gather config not found');
|
||||
return { deleted: true };
|
||||
}
|
||||
|
||||
/** Deploy config to game server via NATS */
|
||||
async applyToServer(licenseId: string, configId: string) {
|
||||
const config = await this.gatherRepo.findOne({
|
||||
where: { id: configId, license_id: licenseId },
|
||||
});
|
||||
if (!config) throw new NotFoundException('Gather config not found');
|
||||
|
||||
const jsonString = JSON.stringify(config.config_data, null, 2);
|
||||
|
||||
try {
|
||||
// Write GatherManager.json via file manager NATS
|
||||
await this.natsService.request(
|
||||
`corrosion.${licenseId}.files.cmd`,
|
||||
{
|
||||
func: 'fm_save',
|
||||
path: 'server://oxide/config/GatherManager.json',
|
||||
content: jsonString,
|
||||
},
|
||||
30000,
|
||||
);
|
||||
|
||||
// Reload GatherManager plugin via RCON
|
||||
await this.natsService.publish(
|
||||
`corrosion.${licenseId}.cmd.server`,
|
||||
{
|
||||
action: 'command',
|
||||
command: 'oxide.reload GatherManager',
|
||||
timestamp: new Date().toISOString(),
|
||||
},
|
||||
);
|
||||
|
||||
// Mark this config as active, deactivate others
|
||||
await this.gatherRepo.update({ license_id: licenseId }, { is_active: false });
|
||||
await this.gatherRepo.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 gather config: ${(error as Error).message}`);
|
||||
throw new HttpException(
|
||||
'Failed to deploy gather config — agent may be offline',
|
||||
HttpStatus.SERVICE_UNAVAILABLE,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/** Import GatherManager.json from game server via NATS */
|
||||
async importFromServer(licenseId: string, configName: string, description?: string) {
|
||||
try {
|
||||
// Read GatherManager.json from server via file manager NATS
|
||||
const response = await this.natsService.request(
|
||||
`corrosion.${licenseId}.files.cmd`,
|
||||
{
|
||||
func: 'fm_preview',
|
||||
path: 'server://oxide/config/GatherManager.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 gather config row
|
||||
const config = this.gatherRepo.create({
|
||||
license_id: licenseId,
|
||||
config_name: configName,
|
||||
description: description || 'Imported from server',
|
||||
config_data: configData,
|
||||
});
|
||||
const saved = await this.gatherRepo.save(config);
|
||||
|
||||
return { config: saved };
|
||||
} catch (error) {
|
||||
if (error instanceof HttpException) throw error;
|
||||
this.logger.error(`Failed to import gather config from server: ${(error as Error).message}`);
|
||||
throw new HttpException(
|
||||
'Failed to import gather config — agent may be offline',
|
||||
HttpStatus.SERVICE_UNAVAILABLE,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
backend/migrations/015_gather_configs.sql
Normal file
11
backend/migrations/015_gather_configs.sql
Normal file
@@ -0,0 +1,11 @@
|
||||
CREATE TABLE IF NOT EXISTS gather_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_gather_configs_license ON gather_configs(license_id);
|
||||
11
backend/migrations/018_autodoors_configs.sql
Normal file
11
backend/migrations/018_autodoors_configs.sql
Normal file
@@ -0,0 +1,11 @@
|
||||
CREATE TABLE IF NOT EXISTS autodoors_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_autodoors_configs_license ON autodoors_configs(license_id);
|
||||
@@ -29,6 +29,8 @@ import {
|
||||
FolderOpen,
|
||||
Crosshair,
|
||||
Navigation2,
|
||||
Pickaxe,
|
||||
DoorOpen,
|
||||
Menu,
|
||||
X,
|
||||
} from 'lucide-vue-next'
|
||||
@@ -48,6 +50,8 @@ const navItems = [
|
||||
{ name: 'File Manager', path: '/files', icon: FolderOpen, permission: 'files.view' },
|
||||
{ name: 'Loot Builder', path: '/loot-builder', icon: Crosshair, permission: 'loot.view' },
|
||||
{ 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: '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' },
|
||||
|
||||
@@ -120,6 +120,16 @@ const panelRoutes: RouteRecordRaw[] = [
|
||||
name: 'teleport-config',
|
||||
component: () => import('@/views/admin/TeleportConfigView.vue'),
|
||||
},
|
||||
{
|
||||
path: 'gather-manager',
|
||||
name: 'gather-manager',
|
||||
component: () => import('@/views/admin/GatherManagerView.vue'),
|
||||
},
|
||||
{
|
||||
path: 'autodoors',
|
||||
name: 'autodoors',
|
||||
component: () => import('@/views/admin/AutoDoorsView.vue'),
|
||||
},
|
||||
{
|
||||
path: 'wipes',
|
||||
name: 'wipes',
|
||||
|
||||
145
frontend/src/stores/autodoors.ts
Normal file
145
frontend/src/stores/autodoors.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 { AutoDoorsConfigSummary, AutoDoorsConfigFull, AutoDoorsApplyResult } from '@/types'
|
||||
|
||||
export const useAutoDoorsStore = defineStore('autodoors', () => {
|
||||
const configs = ref<AutoDoorsConfigSummary[]>([])
|
||||
const currentConfig = ref<AutoDoorsConfigFull | 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: AutoDoorsConfigSummary[] }>('/autodoors/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: AutoDoorsConfigFull }>(`/autodoors/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: AutoDoorsConfigFull }>('/autodoors/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(`/autodoors/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(`/autodoors/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<AutoDoorsApplyResult>(`/autodoors/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: AutoDoorsConfigFull }>('/autodoors/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/gather.ts
Normal file
145
frontend/src/stores/gather.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 { GatherConfigSummary, GatherConfigFull, GatherApplyResult } from '@/types'
|
||||
|
||||
export const useGatherStore = defineStore('gather', () => {
|
||||
const configs = ref<GatherConfigSummary[]>([])
|
||||
const currentConfig = ref<GatherConfigFull | 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: GatherConfigSummary[] }>('/gather/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: GatherConfigFull }>(`/gather/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: GatherConfigFull }>('/gather/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(`/gather/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(`/gather/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<GatherApplyResult>(`/gather/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: GatherConfigFull }>('/gather/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,
|
||||
}
|
||||
})
|
||||
@@ -546,3 +546,111 @@ export interface TeleportApplyResult {
|
||||
message: string
|
||||
config_name: string
|
||||
}
|
||||
|
||||
// GatherManager Config types
|
||||
export interface GatherConfigSummary {
|
||||
id: string
|
||||
config_name: string
|
||||
description: string | null
|
||||
is_active: boolean
|
||||
created_at: string
|
||||
updated_at: string
|
||||
}
|
||||
|
||||
export interface GatherConfigFull {
|
||||
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 GatherApplyResult {
|
||||
success: boolean
|
||||
message: string
|
||||
config_name: string
|
||||
}
|
||||
|
||||
// AutoDoors Config types
|
||||
export interface AutoDoorsConfigSummary {
|
||||
id: string
|
||||
config_name: string
|
||||
description: string | null
|
||||
is_active: boolean
|
||||
created_at: string
|
||||
updated_at: string
|
||||
}
|
||||
|
||||
export interface AutoDoorsConfigFull {
|
||||
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 AutoDoorsApplyResult {
|
||||
success: boolean
|
||||
message: string
|
||||
config_name: string
|
||||
}
|
||||
|
||||
// Kits Config types
|
||||
export interface KitsConfigSummary {
|
||||
id: string
|
||||
config_name: string
|
||||
description: string | null
|
||||
is_active: boolean
|
||||
created_at: string
|
||||
updated_at: string
|
||||
}
|
||||
|
||||
export interface KitsConfigFull {
|
||||
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 KitsApplyResult {
|
||||
success: boolean
|
||||
message: string
|
||||
config_name: string
|
||||
}
|
||||
|
||||
// FurnaceSplitter Config types
|
||||
export interface FurnaceSplitterConfigSummary {
|
||||
id: string
|
||||
config_name: string
|
||||
description: string | null
|
||||
is_active: boolean
|
||||
created_at: string
|
||||
updated_at: string
|
||||
}
|
||||
|
||||
export interface FurnaceSplitterConfigFull {
|
||||
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 FurnaceSplitterApplyResult {
|
||||
success: boolean
|
||||
message: string
|
||||
config_name: string
|
||||
}
|
||||
|
||||
595
frontend/src/views/admin/AutoDoorsView.vue
Normal file
595
frontend/src/views/admin/AutoDoorsView.vue
Normal file
@@ -0,0 +1,595 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { useAutoDoorsStore } from '@/stores/autodoors'
|
||||
import {
|
||||
Save,
|
||||
Play,
|
||||
Download,
|
||||
Plus,
|
||||
Trash2,
|
||||
DoorOpen,
|
||||
Settings as SettingsIcon,
|
||||
} from 'lucide-vue-next'
|
||||
|
||||
const store = useAutoDoorsStore()
|
||||
|
||||
const showCreateModal = ref(false)
|
||||
const showImportModal = ref(false)
|
||||
const newConfigName = ref('')
|
||||
const newConfigDesc = ref('')
|
||||
const importConfigName = ref('')
|
||||
|
||||
// Door types from the AutoDoors plugin
|
||||
const doorTypes = [
|
||||
{ key: 'door.hinged.wood', label: 'Wooden Door', displayName: 'Wooden Door' },
|
||||
{ key: 'door.hinged.metal', label: 'Sheet Metal Door', displayName: 'Sheet Metal Door' },
|
||||
{ key: 'door.hinged.toptier', label: 'Armored Door', displayName: 'Armored Door' },
|
||||
{ key: 'door.double.hinged.wood', label: 'Double Wooden Door', displayName: 'Double Wooden Door' },
|
||||
{ key: 'door.double.hinged.metal', label: 'Double Sheet Metal Door', displayName: 'Double Sheet Metal Door' },
|
||||
{ key: 'door.double.hinged.toptier', label: 'Double Armored Door', displayName: 'Double Armored Door' },
|
||||
{ key: 'floor.ladder.hatch', label: 'Ladder Hatch', displayName: 'Ladder Hatch' },
|
||||
]
|
||||
|
||||
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()
|
||||
}
|
||||
|
||||
// --- Permission group helpers ---
|
||||
|
||||
function getPermissionGroups(): Array<{ name: string; delay: number }> {
|
||||
const groups = getConfigValue('PermissionGroups', {})
|
||||
if (typeof groups !== 'object' || groups === null) return []
|
||||
return Object.entries(groups).map(([name, delay]) => ({
|
||||
name,
|
||||
delay: Number(delay) || 5,
|
||||
}))
|
||||
}
|
||||
|
||||
function addPermissionGroup() {
|
||||
const groups = getConfigValue('PermissionGroups', {})
|
||||
const newGroups = { ...groups, '': 5 }
|
||||
setConfigValue('PermissionGroups', newGroups)
|
||||
}
|
||||
|
||||
function updatePermissionGroupName(oldName: string, newName: string) {
|
||||
if (!store.currentConfig) return
|
||||
const groups = getConfigValue('PermissionGroups', {})
|
||||
const delay = groups[oldName] ?? 5
|
||||
const newGroups: Record<string, number> = {}
|
||||
for (const [key, val] of Object.entries(groups)) {
|
||||
if (key === oldName) {
|
||||
newGroups[newName] = delay
|
||||
} else {
|
||||
newGroups[key] = val as number
|
||||
}
|
||||
}
|
||||
setConfigValue('PermissionGroups', newGroups)
|
||||
}
|
||||
|
||||
function updatePermissionGroupDelay(name: string, delay: number) {
|
||||
setConfigValue(`PermissionGroups.${name}`, delay)
|
||||
}
|
||||
|
||||
function removePermissionGroup(name: string) {
|
||||
const groups = getConfigValue('PermissionGroups', {})
|
||||
const newGroups = { ...groups }
|
||||
delete newGroups[name]
|
||||
setConfigValue('PermissionGroups', newGroups)
|
||||
}
|
||||
|
||||
// --- 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 AutoDoors config to the server? This will overwrite the current AutoDoors 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">Auto Doors</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">
|
||||
<DoorOpen class="w-12 h-12 text-neutral-600 mx-auto mb-4" />
|
||||
<h2 class="text-lg font-semibold text-neutral-300 mb-2">No AutoDoors 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">
|
||||
<!-- Settings Section -->
|
||||
<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-4 h-4 text-neutral-400" />
|
||||
<h3 class="text-sm font-semibold text-neutral-300 uppercase tracking-wider">Global Settings</h3>
|
||||
</div>
|
||||
|
||||
<!-- Delay Settings -->
|
||||
<div class="grid grid-cols-1 md:grid-cols-3 gap-6">
|
||||
<div>
|
||||
<label class="block text-sm text-neutral-200 mb-1">Default Delay (seconds)</label>
|
||||
<p class="text-xs text-neutral-500 mb-2">Time before door auto-closes</p>
|
||||
<div class="flex items-center gap-3">
|
||||
<input
|
||||
type="range"
|
||||
:value="getConfigValue('DefaultDelay', 5)"
|
||||
@input="setConfigValue('DefaultDelay', Number(($event.target as HTMLInputElement).value))"
|
||||
min="1"
|
||||
max="30"
|
||||
step="1"
|
||||
class="flex-1 accent-oxide-500"
|
||||
/>
|
||||
<input
|
||||
type="number"
|
||||
:value="getConfigValue('DefaultDelay', 5)"
|
||||
@input="setConfigValue('DefaultDelay', Number(($event.target as HTMLInputElement).value))"
|
||||
min="1"
|
||||
max="30"
|
||||
class="w-16 bg-neutral-800 border border-neutral-700 rounded-lg px-2 py-1 text-neutral-200 text-sm text-center"
|
||||
/>
|
||||
<span class="text-xs text-neutral-500">sec</span>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-sm text-neutral-200 mb-1">Minimum Delay (seconds)</label>
|
||||
<p class="text-xs text-neutral-500 mb-2">Lowest delay a player can set</p>
|
||||
<div class="flex items-center gap-3">
|
||||
<input
|
||||
type="range"
|
||||
:value="getConfigValue('MinimumDelay', 5)"
|
||||
@input="setConfigValue('MinimumDelay', Number(($event.target as HTMLInputElement).value))"
|
||||
min="1"
|
||||
max="30"
|
||||
step="1"
|
||||
class="flex-1 accent-oxide-500"
|
||||
/>
|
||||
<input
|
||||
type="number"
|
||||
:value="getConfigValue('MinimumDelay', 5)"
|
||||
@input="setConfigValue('MinimumDelay', Number(($event.target as HTMLInputElement).value))"
|
||||
min="1"
|
||||
max="30"
|
||||
class="w-16 bg-neutral-800 border border-neutral-700 rounded-lg px-2 py-1 text-neutral-200 text-sm text-center"
|
||||
/>
|
||||
<span class="text-xs text-neutral-500">sec</span>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-sm text-neutral-200 mb-1">Maximum Delay (seconds)</label>
|
||||
<p class="text-xs text-neutral-500 mb-2">Highest delay a player can set</p>
|
||||
<div class="flex items-center gap-3">
|
||||
<input
|
||||
type="range"
|
||||
:value="getConfigValue('MaximumDelay', 30)"
|
||||
@input="setConfigValue('MaximumDelay', Number(($event.target as HTMLInputElement).value))"
|
||||
min="1"
|
||||
max="60"
|
||||
step="1"
|
||||
class="flex-1 accent-oxide-500"
|
||||
/>
|
||||
<input
|
||||
type="number"
|
||||
:value="getConfigValue('MaximumDelay', 30)"
|
||||
@input="setConfigValue('MaximumDelay', Number(($event.target as HTMLInputElement).value))"
|
||||
min="1"
|
||||
max="60"
|
||||
class="w-16 bg-neutral-800 border border-neutral-700 rounded-lg px-2 py-1 text-neutral-200 text-sm text-center"
|
||||
/>
|
||||
<span class="text-xs text-neutral-500">sec</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Global Toggles -->
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
|
||||
<div class="flex items-center justify-between">
|
||||
<div>
|
||||
<label class="text-sm text-neutral-200">Default Enabled</label>
|
||||
<p class="text-xs text-neutral-500">Auto-close enabled for new players by default</p>
|
||||
</div>
|
||||
<button
|
||||
@click="setConfigValue('GlobalSettings.defaultEnabled', !getConfigValue('GlobalSettings.defaultEnabled', true))"
|
||||
class="relative w-11 h-6 rounded-full transition-colors"
|
||||
:class="getConfigValue('GlobalSettings.defaultEnabled', 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('GlobalSettings.defaultEnabled', true) ? 'translate-x-5' : 'translate-x-0'"
|
||||
/>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="flex items-center justify-between">
|
||||
<div>
|
||||
<label class="text-sm text-neutral-200">Allow Unowned Doors</label>
|
||||
<p class="text-xs text-neutral-500">Auto-close doors that the player does not own</p>
|
||||
</div>
|
||||
<button
|
||||
@click="setConfigValue('GlobalSettings.useUnownedDoor', !getConfigValue('GlobalSettings.useUnownedDoor', false))"
|
||||
class="relative w-11 h-6 rounded-full transition-colors"
|
||||
:class="getConfigValue('GlobalSettings.useUnownedDoor', 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('GlobalSettings.useUnownedDoor', false) ? 'translate-x-5' : 'translate-x-0'"
|
||||
/>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="flex items-center justify-between">
|
||||
<div>
|
||||
<label class="text-sm text-neutral-200">Exclude Door Controller</label>
|
||||
<p class="text-xs text-neutral-500">Skip doors that have a Code Lock or Key Lock</p>
|
||||
</div>
|
||||
<button
|
||||
@click="setConfigValue('GlobalSettings.excludeDoorController', !getConfigValue('GlobalSettings.excludeDoorController', false))"
|
||||
class="relative w-11 h-6 rounded-full transition-colors"
|
||||
:class="getConfigValue('GlobalSettings.excludeDoorController', 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('GlobalSettings.excludeDoorController', false) ? 'translate-x-5' : 'translate-x-0'"
|
||||
/>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="flex items-center justify-between">
|
||||
<div>
|
||||
<label class="text-sm text-neutral-200">Cancel on Player Death</label>
|
||||
<p class="text-xs text-neutral-500">Cancel auto-close if the player dies</p>
|
||||
</div>
|
||||
<button
|
||||
@click="setConfigValue('GlobalSettings.cancelOnKill', !getConfigValue('GlobalSettings.cancelOnKill', false))"
|
||||
class="relative w-11 h-6 rounded-full transition-colors"
|
||||
:class="getConfigValue('GlobalSettings.cancelOnKill', 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('GlobalSettings.cancelOnKill', false) ? 'translate-x-5' : 'translate-x-0'"
|
||||
/>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="flex items-center justify-between">
|
||||
<div>
|
||||
<label class="text-sm text-neutral-200">Use Permissions</label>
|
||||
<p class="text-xs text-neutral-500">Require Oxide permission to use auto-close</p>
|
||||
</div>
|
||||
<button
|
||||
@click="setConfigValue('UsePermissions', !getConfigValue('UsePermissions', false))"
|
||||
class="relative w-11 h-6 rounded-full transition-colors"
|
||||
:class="getConfigValue('UsePermissions', 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('UsePermissions', false) ? 'translate-x-5' : 'translate-x-0'"
|
||||
/>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="flex items-center justify-between">
|
||||
<div>
|
||||
<label class="text-sm text-neutral-200">Clear Data on Map Wipe</label>
|
||||
<p class="text-xs text-neutral-500">Reset all player preferences on map wipe</p>
|
||||
</div>
|
||||
<button
|
||||
@click="setConfigValue('ClearDataOnWipe', !getConfigValue('ClearDataOnWipe', false))"
|
||||
class="relative w-11 h-6 rounded-full transition-colors"
|
||||
:class="getConfigValue('ClearDataOnWipe', 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('ClearDataOnWipe', false) ? 'translate-x-5' : 'translate-x-0'"
|
||||
/>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Door Types Section -->
|
||||
<div class="bg-neutral-900 border border-neutral-800 rounded-xl p-6 space-y-4">
|
||||
<div class="flex items-center gap-2">
|
||||
<DoorOpen class="w-4 h-4 text-neutral-400" />
|
||||
<h3 class="text-sm font-semibold text-neutral-300 uppercase tracking-wider">Door Types</h3>
|
||||
</div>
|
||||
<p class="text-xs text-neutral-500">Enable or disable auto-close for each door type.</p>
|
||||
|
||||
<div class="space-y-3">
|
||||
<div
|
||||
v-for="door in doorTypes"
|
||||
:key="door.key"
|
||||
class="flex items-center justify-between py-2 border-b border-neutral-800 last:border-0"
|
||||
>
|
||||
<div>
|
||||
<label class="text-sm text-neutral-200">{{ door.label }}</label>
|
||||
<p class="text-xs text-neutral-500 font-mono">{{ door.key }}</p>
|
||||
</div>
|
||||
<button
|
||||
@click="setConfigValue(`DoorSettings.${door.key}.enabled`, !getConfigValue(`DoorSettings.${door.key}.enabled`, true))"
|
||||
class="relative w-11 h-6 rounded-full transition-colors"
|
||||
:class="getConfigValue(`DoorSettings.${door.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(`DoorSettings.${door.key}.enabled`, true) ? 'translate-x-5' : 'translate-x-0'"
|
||||
/>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Permission Groups Section -->
|
||||
<div class="bg-neutral-900 border border-neutral-800 rounded-xl p-6 space-y-4">
|
||||
<div class="flex items-center justify-between">
|
||||
<div class="flex items-center gap-2">
|
||||
<SettingsIcon class="w-4 h-4 text-neutral-400" />
|
||||
<h3 class="text-sm font-semibold text-neutral-300 uppercase tracking-wider">Permission Group Overrides</h3>
|
||||
</div>
|
||||
<button
|
||||
@click="addPermissionGroup"
|
||||
class="flex items-center gap-1 px-3 py-1 bg-neutral-800 text-neutral-300 rounded-lg hover:bg-neutral-700 text-sm"
|
||||
>
|
||||
<Plus class="w-3 h-3" />
|
||||
Add Group
|
||||
</button>
|
||||
</div>
|
||||
<p class="text-xs text-neutral-500">Override the default delay for specific Oxide permission groups.</p>
|
||||
|
||||
<div v-if="getPermissionGroups().length === 0" class="text-sm text-neutral-500 text-center py-4">
|
||||
No permission group overrides configured.
|
||||
</div>
|
||||
|
||||
<div v-else class="space-y-3">
|
||||
<div
|
||||
v-for="(group, index) in getPermissionGroups()"
|
||||
:key="index"
|
||||
class="flex items-center gap-3"
|
||||
>
|
||||
<input
|
||||
:value="group.name"
|
||||
@input="updatePermissionGroupName(group.name, ($event.target as HTMLInputElement).value)"
|
||||
placeholder="Group name (e.g. vip)"
|
||||
class="flex-1 bg-neutral-800 border border-neutral-700 rounded-lg px-3 py-2 text-neutral-200 text-sm"
|
||||
/>
|
||||
<input
|
||||
type="number"
|
||||
:value="group.delay"
|
||||
@input="updatePermissionGroupDelay(group.name, Number(($event.target as HTMLInputElement).value))"
|
||||
min="1"
|
||||
max="60"
|
||||
class="w-20 bg-neutral-800 border border-neutral-700 rounded-lg px-2 py-2 text-neutral-200 text-sm text-center"
|
||||
/>
|
||||
<span class="text-xs text-neutral-500">sec</span>
|
||||
<button
|
||||
@click="removePermissionGroup(group.name)"
|
||||
class="p-2 text-red-400 hover:text-red-300 hover:bg-red-500/10 rounded-lg transition-colors"
|
||||
>
|
||||
<Trash2 class="w-4 h-4" />
|
||||
</button>
|
||||
</div>
|
||||
</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 AutoDoors 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. 5 Second Close"
|
||||
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 AutoDoors 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>
|
||||
534
frontend/src/views/admin/GatherManagerView.vue
Normal file
534
frontend/src/views/admin/GatherManagerView.vue
Normal file
@@ -0,0 +1,534 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { useGatherStore } from '@/stores/gather'
|
||||
import {
|
||||
Save,
|
||||
Play,
|
||||
Download,
|
||||
Plus,
|
||||
Trash2,
|
||||
Pickaxe,
|
||||
Settings as SettingsIcon,
|
||||
} from 'lucide-vue-next'
|
||||
|
||||
const store = useGatherStore()
|
||||
|
||||
const activeTab = ref<'resources' | 'advanced'>('resources')
|
||||
const showCreateModal = ref(false)
|
||||
const showImportModal = ref(false)
|
||||
const newConfigName = ref('')
|
||||
const newConfigDesc = ref('')
|
||||
const importConfigName = ref('')
|
||||
|
||||
const tabs = [
|
||||
{ key: 'resources', label: 'Resource Rates', icon: Pickaxe },
|
||||
{ key: 'advanced', label: 'Advanced', icon: SettingsIcon },
|
||||
]
|
||||
|
||||
// Resource definitions for the main gather tab
|
||||
const gatherResources = [
|
||||
{ key: 'Wood', label: 'Wood' },
|
||||
{ key: 'Stones', label: 'Stones' },
|
||||
{ key: 'Metal Ore', label: 'Metal Ore' },
|
||||
{ key: 'Sulfur Ore', label: 'Sulfur Ore' },
|
||||
{ key: 'HQM Ore', label: 'HQM Ore' },
|
||||
{ key: 'Cloth', label: 'Cloth' },
|
||||
{ key: 'Leather', label: 'Leather' },
|
||||
{ key: 'Animal Fat', label: 'Animal Fat' },
|
||||
{ key: 'Bone Fragments', label: 'Bone Fragments' },
|
||||
]
|
||||
|
||||
// Advanced resource categories
|
||||
const pickupResources = [
|
||||
{ key: 'Wood', label: 'Wood' },
|
||||
{ key: 'Stones', label: 'Stones' },
|
||||
{ key: 'Metal Ore', label: 'Metal Ore' },
|
||||
{ key: 'Sulfur Ore', label: 'Sulfur Ore' },
|
||||
]
|
||||
|
||||
const quarryResources = [
|
||||
{ key: 'HQM Ore', label: 'HQM Ore' },
|
||||
{ key: 'Metal Ore', label: 'Metal Ore' },
|
||||
{ key: 'Sulfur Ore', label: 'Sulfur Ore' },
|
||||
{ key: 'Stones', label: 'Stones' },
|
||||
]
|
||||
|
||||
const excavatorResources = [
|
||||
{ key: 'HQM Ore', label: 'HQM Ore' },
|
||||
{ key: 'Metal Ore', label: 'Metal Ore' },
|
||||
{ key: 'Sulfur Ore', label: 'Sulfur Ore' },
|
||||
{ key: 'Stones', label: 'Stones' },
|
||||
]
|
||||
|
||||
const surveyResources = [
|
||||
{ key: 'Metal Ore', label: 'Metal Ore' },
|
||||
{ key: 'Sulfur Ore', label: 'Sulfur Ore' },
|
||||
{ key: 'Stones', label: 'Stones' },
|
||||
{ key: 'HQM Ore', label: 'HQM Ore' },
|
||||
]
|
||||
|
||||
const presets = [
|
||||
{ label: '1x', value: 1 },
|
||||
{ label: '2x', value: 2 },
|
||||
{ label: '3x', value: 3 },
|
||||
{ label: '5x', value: 5 },
|
||||
{ label: '10x', value: 10 },
|
||||
]
|
||||
|
||||
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 = 1): 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()
|
||||
}
|
||||
|
||||
// --- Preset handler ---
|
||||
|
||||
function applyPreset(multiplier: number) {
|
||||
for (const resource of gatherResources) {
|
||||
setConfigValue(`GatherResourceModifiers.${resource.key}`, multiplier)
|
||||
}
|
||||
}
|
||||
|
||||
// --- 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 gather config to the server? This will overwrite the current GatherManager 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">Gather Rates</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">
|
||||
<Pickaxe class="w-12 h-12 text-neutral-600 mx-auto mb-4" />
|
||||
<h2 class="text-lg font-semibold text-neutral-300 mb-2">No Gather 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>
|
||||
|
||||
<!-- Resource Rates Tab -->
|
||||
<div v-if="activeTab === 'resources'" class="bg-neutral-900 border border-neutral-800 rounded-xl p-6 space-y-6">
|
||||
<div class="flex items-center justify-between">
|
||||
<h3 class="text-sm font-semibold text-neutral-300 uppercase tracking-wider">Gather Resource Modifiers</h3>
|
||||
<div class="flex items-center gap-2">
|
||||
<span class="text-xs text-neutral-500 mr-2">Presets:</span>
|
||||
<button
|
||||
v-for="preset in presets"
|
||||
:key="preset.value"
|
||||
@click="applyPreset(preset.value)"
|
||||
class="px-3 py-1 text-xs bg-neutral-800 text-neutral-300 rounded-lg hover:bg-neutral-700 hover:text-white transition-colors"
|
||||
>
|
||||
{{ preset.label }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="space-y-4">
|
||||
<div
|
||||
v-for="resource in gatherResources"
|
||||
:key="resource.key"
|
||||
class="flex items-center gap-4"
|
||||
>
|
||||
<label class="text-sm text-neutral-200 w-32 flex-shrink-0">{{ resource.label }}</label>
|
||||
<input
|
||||
type="range"
|
||||
:value="getConfigValue(`GatherResourceModifiers.${resource.key}`, 1)"
|
||||
@input="setConfigValue(`GatherResourceModifiers.${resource.key}`, Number(($event.target as HTMLInputElement).value))"
|
||||
min="0.1"
|
||||
max="100"
|
||||
step="0.1"
|
||||
class="flex-1 accent-oxide-500"
|
||||
/>
|
||||
<input
|
||||
type="number"
|
||||
:value="getConfigValue(`GatherResourceModifiers.${resource.key}`, 1)"
|
||||
@input="setConfigValue(`GatherResourceModifiers.${resource.key}`, Number(($event.target as HTMLInputElement).value))"
|
||||
min="0.1"
|
||||
max="1000"
|
||||
step="0.1"
|
||||
class="w-20 bg-neutral-800 border border-neutral-700 rounded-lg px-2 py-1 text-neutral-200 text-sm text-center"
|
||||
/>
|
||||
<span class="text-xs text-neutral-500 w-4">x</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Advanced Tab -->
|
||||
<div v-else-if="activeTab === 'advanced'" class="space-y-6">
|
||||
<!-- Pickup Resource Modifiers -->
|
||||
<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">Pickup Resource Modifiers</h3>
|
||||
<p class="text-xs text-neutral-500">Modify rates for resources picked up from the ground (small rocks, wood piles).</p>
|
||||
<div class="space-y-4">
|
||||
<div
|
||||
v-for="resource in pickupResources"
|
||||
:key="resource.key"
|
||||
class="flex items-center gap-4"
|
||||
>
|
||||
<label class="text-sm text-neutral-200 w-32 flex-shrink-0">{{ resource.label }}</label>
|
||||
<input
|
||||
type="range"
|
||||
:value="getConfigValue(`PickupResourceModifiers.${resource.key}`, 1)"
|
||||
@input="setConfigValue(`PickupResourceModifiers.${resource.key}`, Number(($event.target as HTMLInputElement).value))"
|
||||
min="0.1"
|
||||
max="100"
|
||||
step="0.1"
|
||||
class="flex-1 accent-oxide-500"
|
||||
/>
|
||||
<input
|
||||
type="number"
|
||||
:value="getConfigValue(`PickupResourceModifiers.${resource.key}`, 1)"
|
||||
@input="setConfigValue(`PickupResourceModifiers.${resource.key}`, Number(($event.target as HTMLInputElement).value))"
|
||||
min="0.1"
|
||||
max="1000"
|
||||
step="0.1"
|
||||
class="w-20 bg-neutral-800 border border-neutral-700 rounded-lg px-2 py-1 text-neutral-200 text-sm text-center"
|
||||
/>
|
||||
<span class="text-xs text-neutral-500 w-4">x</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Quarry Resource Modifiers -->
|
||||
<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">Quarry Resource Modifiers</h3>
|
||||
<p class="text-xs text-neutral-500">Scale resource output from Mining Quarries.</p>
|
||||
<div class="space-y-4">
|
||||
<div
|
||||
v-for="resource in quarryResources"
|
||||
:key="resource.key"
|
||||
class="flex items-center gap-4"
|
||||
>
|
||||
<label class="text-sm text-neutral-200 w-32 flex-shrink-0">{{ resource.label }}</label>
|
||||
<input
|
||||
type="range"
|
||||
:value="getConfigValue(`QuarryResourceModifiers.${resource.key}`, 1)"
|
||||
@input="setConfigValue(`QuarryResourceModifiers.${resource.key}`, Number(($event.target as HTMLInputElement).value))"
|
||||
min="0.1"
|
||||
max="100"
|
||||
step="0.1"
|
||||
class="flex-1 accent-oxide-500"
|
||||
/>
|
||||
<input
|
||||
type="number"
|
||||
:value="getConfigValue(`QuarryResourceModifiers.${resource.key}`, 1)"
|
||||
@input="setConfigValue(`QuarryResourceModifiers.${resource.key}`, Number(($event.target as HTMLInputElement).value))"
|
||||
min="0.1"
|
||||
max="1000"
|
||||
step="0.1"
|
||||
class="w-20 bg-neutral-800 border border-neutral-700 rounded-lg px-2 py-1 text-neutral-200 text-sm text-center"
|
||||
/>
|
||||
<span class="text-xs text-neutral-500 w-4">x</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Excavator Resource Modifiers -->
|
||||
<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">Excavator Resource Modifiers</h3>
|
||||
<p class="text-xs text-neutral-500">Scale resource output from the Giant Excavator.</p>
|
||||
<div class="space-y-4">
|
||||
<div
|
||||
v-for="resource in excavatorResources"
|
||||
:key="resource.key"
|
||||
class="flex items-center gap-4"
|
||||
>
|
||||
<label class="text-sm text-neutral-200 w-32 flex-shrink-0">{{ resource.label }}</label>
|
||||
<input
|
||||
type="range"
|
||||
:value="getConfigValue(`ExcavatorResourceModifiers.${resource.key}`, 1)"
|
||||
@input="setConfigValue(`ExcavatorResourceModifiers.${resource.key}`, Number(($event.target as HTMLInputElement).value))"
|
||||
min="0.1"
|
||||
max="100"
|
||||
step="0.1"
|
||||
class="flex-1 accent-oxide-500"
|
||||
/>
|
||||
<input
|
||||
type="number"
|
||||
:value="getConfigValue(`ExcavatorResourceModifiers.${resource.key}`, 1)"
|
||||
@input="setConfigValue(`ExcavatorResourceModifiers.${resource.key}`, Number(($event.target as HTMLInputElement).value))"
|
||||
min="0.1"
|
||||
max="1000"
|
||||
step="0.1"
|
||||
class="w-20 bg-neutral-800 border border-neutral-700 rounded-lg px-2 py-1 text-neutral-200 text-sm text-center"
|
||||
/>
|
||||
<span class="text-xs text-neutral-500 w-4">x</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Survey Resource Modifiers -->
|
||||
<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">Survey Charge Resource Modifiers</h3>
|
||||
<p class="text-xs text-neutral-500">Modify resource amounts from Survey Charge grenades.</p>
|
||||
<div class="space-y-4">
|
||||
<div
|
||||
v-for="resource in surveyResources"
|
||||
:key="resource.key"
|
||||
class="flex items-center gap-4"
|
||||
>
|
||||
<label class="text-sm text-neutral-200 w-32 flex-shrink-0">{{ resource.label }}</label>
|
||||
<input
|
||||
type="range"
|
||||
:value="getConfigValue(`SurveyResourceModifiers.${resource.key}`, 1)"
|
||||
@input="setConfigValue(`SurveyResourceModifiers.${resource.key}`, Number(($event.target as HTMLInputElement).value))"
|
||||
min="0.1"
|
||||
max="100"
|
||||
step="0.1"
|
||||
class="flex-1 accent-oxide-500"
|
||||
/>
|
||||
<input
|
||||
type="number"
|
||||
:value="getConfigValue(`SurveyResourceModifiers.${resource.key}`, 1)"
|
||||
@input="setConfigValue(`SurveyResourceModifiers.${resource.key}`, Number(($event.target as HTMLInputElement).value))"
|
||||
min="0.1"
|
||||
max="1000"
|
||||
step="0.1"
|
||||
class="w-20 bg-neutral-800 border border-neutral-700 rounded-lg px-2 py-1 text-neutral-200 text-sm text-center"
|
||||
/>
|
||||
<span class="text-xs text-neutral-500 w-4">x</span>
|
||||
</div>
|
||||
</div>
|
||||
</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 Gather 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. 3x Gather Rates"
|
||||
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 GatherManager 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>
|
||||
Reference in New Issue
Block a user