Add NPC creation status tracking and progress reporting in Admin module
- Implemented getNPCsCreationStatus method in AdminController to retrieve the status of NPC creation jobs. - Enhanced AdminService to manage NPC creation jobs, including job ID generation, progress updates, and error handling. - Updated frontend CreateNPCView to display progress of NPC creation, including estimated time remaining and job status. - Added localization strings for progress reporting in both German and English. - Improved overall user experience by providing real-time feedback during NPC creation processes.
This commit is contained in:
@@ -45,6 +45,7 @@ class AdminController {
|
||||
this.deleteRegionDistance = this.deleteRegionDistance.bind(this);
|
||||
this.createNPCs = this.createNPCs.bind(this);
|
||||
this.getTitlesOfNobility = this.getTitlesOfNobility.bind(this);
|
||||
this.getNPCsCreationStatus = this.getNPCsCreationStatus.bind(this);
|
||||
}
|
||||
|
||||
async getOpenInterests(req, res) {
|
||||
@@ -393,6 +394,7 @@ class AdminController {
|
||||
if (countValue < 1 || countValue > 500) {
|
||||
return res.status(400).json({ error: 'Count must be between 1 and 500' });
|
||||
}
|
||||
console.log('[createNPCs] Request received:', { userId, regionIds, minAge, maxAge, minTitleId, maxTitleId, count: countValue });
|
||||
const result = await AdminService.createNPCs(userId, {
|
||||
regionIds: regionIds && regionIds.length > 0 ? regionIds : null,
|
||||
minAge: parseInt(minAge) || 0,
|
||||
@@ -401,11 +403,13 @@ class AdminController {
|
||||
maxTitleId: parseInt(maxTitleId) || 19,
|
||||
count: countValue
|
||||
});
|
||||
console.log('[createNPCs] Job created:', result);
|
||||
res.status(200).json(result);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
console.error('[createNPCs] Error:', error);
|
||||
console.error('[createNPCs] Error stack:', error.stack);
|
||||
const status = error.message === 'noaccess' ? 403 : 500;
|
||||
res.status(status).json({ error: error.message });
|
||||
res.status(status).json({ error: error.message || 'Internal server error' });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -421,6 +425,20 @@ class AdminController {
|
||||
}
|
||||
}
|
||||
|
||||
async getNPCsCreationStatus(req, res) {
|
||||
try {
|
||||
const { userid: userId } = req.headers;
|
||||
const { jobId } = req.params;
|
||||
const status = await AdminService.getNPCsCreationStatus(userId, jobId);
|
||||
res.status(200).json(status);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
const status = error.message === 'noaccess' || error.message === 'Access denied' ? 403 :
|
||||
error.message === 'Job not found' ? 404 : 500;
|
||||
res.status(status).json({ error: error.message });
|
||||
}
|
||||
}
|
||||
|
||||
async getRoomTypes(req, res) {
|
||||
try {
|
||||
const userId = req.headers.userid;
|
||||
|
||||
Reference in New Issue
Block a user