Skip to content

Commit

Permalink
- Reldens - v4.0.0 - Maps Wizard WIP.
Browse files Browse the repository at this point in the history
  • Loading branch information
damian-pastorini committed Jul 23, 2024
1 parent d3a1973 commit fb534a8
Show file tree
Hide file tree
Showing 5 changed files with 139 additions and 2 deletions.
51 changes: 49 additions & 2 deletions lib/admin/server/admin-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class AdminManager
this.savePath = '/save';
this.deletePath = '/delete';
this.managementPath = '/management';
this.mapsWizardPath = '/maps-wizard';
this.adminEntitiesGenerator = new AdminEntitiesGenerator();
this.uploaderFactory = new UploaderFactory();
}
Expand Down Expand Up @@ -139,6 +140,7 @@ class AdminManager
this.adminContents.login = await this.buildLogin();
this.adminContents.dashboard = await this.buildDashboard();
this.adminContents.management = await this.buildManagement();
this.adminContents.mapsWizard = await this.buildMapsWizard();
this.adminContents.entities = await this.buildEntitiesContents();
}

Expand All @@ -160,7 +162,14 @@ class AdminManager

async buildSideBar()
{
let navigationContents = {};
let navigationContents = {
'Wizards': {
[this.translations.labels['mapsWizard']]: await this.render(
this.adminFilesContents.sideBarItem,
{name: this.translations.labels['mapsWizard'], path: this.rootPath+this.mapsWizardPath}
)
}
};
for(let driverResource of this.resources){
let navigation = driverResource.options?.navigation;
let name = this.translations.labels[driverResource.id()] || this.translations.labels[driverResource.entityKey];
Expand All @@ -180,7 +189,7 @@ class AdminManager
{name, path}
);
}
navigationContents['Server'] = {'Maintenance': await this.render(
navigationContents['Server'] = {'Management': await this.render(
this.adminFilesContents.sideBarItem,
{name: this.translations.labels['management'], path: this.rootPath+this.managementPath}
)};
Expand Down Expand Up @@ -265,6 +274,27 @@ class AdminManager
);
}

async buildMapsWizard()
{
let pageContent = await this.render(
this.adminFilesContents.mapsWizard,
{
actionPath: this.rootPath+this.mapsWizardPath
}
);
return await this.render(
this.adminContents.layout,
{
sideBar: this.adminContents.sideBar,
pageContent,
stylesFilePath: this.stylesFilePath,
scriptsFilePath: this.scriptsFilePath,
brandingCompanyName: this.branding.companyName,
copyRight: this.branding.copyRight
}
);
}

async buildEntitiesContents()
{
let entitiesContents = {};
Expand Down Expand Up @@ -571,6 +601,23 @@ class AdminManager
return res.redirect(redirectManagementPath+'?result=success');
}
);
// maps-wizard routes:
this.adminRouter.get(
this.mapsWizardPath,
this.isAuthenticated.bind(this),
async (req, res) => {
let rendererContent = await this.render(this.adminContents.mapsWizard, this.fetchShuttingDownData());
return res.send(rendererContent);
}
);
this.adminRouter.post(
this.mapsWizardPath,
this.isAuthenticated.bind(this),
async (req, res) => {
let redirectManagementPath = this.rootPath+this.mapsWizardPath;
return res.redirect(redirectManagementPath+'?result=success');
}
);
// apply the adminRouter to the /admin path:
this.app.use(this.rootPath, this.adminRouter);
}
Expand Down
1 change: 1 addition & 0 deletions lib/admin/server/admin-translations.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class AdminTranslations
loginWelcome: 'Reldens',
pages: 'Server Management',
management: 'Management',
mapsWizard: 'Maps Generation',
shuttingDown: 'Server is shutting down in:',
submitShutdownLabel: 'Shutdown Server',
submitCancelLabel: 'Cancel Server Shutdown',
Expand Down
1 change: 1 addition & 0 deletions lib/admin/server/templates-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ module.exports.TemplatesList = {
login: 'login.html',
dashboard: 'dashboard.html',
management: 'management.html',
mapsWizard: 'maps-wizard.html',
list: 'list.html',
listContent: 'list-content.html',
view: 'view.html',
Expand Down
16 changes: 16 additions & 0 deletions theme/admin/reldens-admin-client.scss
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,22 @@ $darkGreen: #27ae60;

}
}

textarea {
position: relative;
display: block;
width: 98%;
padding: 1%;
margin: 1rem 0;
}
}

.maps-wizard {
.main-option {
display: inline-block;
cursor: pointer;
margin-bottom: 1rem;
}
}

.entity-view, .entity-edit {
Expand Down
72 changes: 72 additions & 0 deletions theme/admin/templates/maps-wizard.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<h2>Maps Wizard</h2>
<div class="sub-content maps-wizard">
<div class="sub-content-box">
<form class="sub-content-form maps-wizard-form confirmation-required"
name="maps-wizard-form"
id="maps-wizard-form"
action="{{&actionPath}}"
method="post"
enctype="multipart/form-data">
<div>
<p>What would you like to do?</p>
<ul>
<li>
<input type="radio" name="maps-wizard-action" id="maps-wizard-action-1" value="elements-object-loader" checked="checked"/>
<label class="main-option" for="maps-wizard-action-1">
Generate a random maps with Layer Elements Object Loader
</label>
<div class="maps-wizard-action-1-data">
<div class="input-box">
<label for="tileSheetPath">Tile Sheet (tileSheetPath)</label>
<input type="file" name="tileSheetPath" id="tileSheetPath"/>
</div>
<div class="input-box">
<label for="layerElementsFiles">Layer Elements (layerElementsFiles)</label>
<input type="file" name="layerElementsFiles" id="layerElementsFiles" multiple="multiple"/>
</div>
</div>
</li>
<li>
<input type="radio" name="maps-wizard-action" id="maps-wizard-action-2" value="elements-composite-loader"/>
<label class="main-option" for="maps-wizard-action-2">
Generate a random maps with Layer Elements Composite Loader
</label>
<div class="maps-wizard-action-2-data">
<div class="input-box">
<label for="compositeElementsFile">Composite Elements (compositeElementsFile)</label>
<input type="file" name="compositeElementsFile" id="compositeElementsFile"/>
</div>
<div class="input-box">
<label for="mapDataFile">Map Data (mapDataFile)</label>
<input type="file" name="mapDataFile" id="mapDataFile"/>
</div>
</div>
</li>
<li>
<input type="radio" name="maps-wizard-action" id="maps-wizard-action-3" value="3"/>
<label class="main-option" for="maps-wizard-action-3">
Generate a random maps with Multiple
</label>
</li>
<li>
<input type="radio" name="maps-wizard-action" id="maps-wizard-action-4" value="4"/>
<label class="main-option" for="maps-wizard-action-4">
Generate a random maps with Layer Elements Composite Loader
</label>
</li>
<!-- sample commands:
$ npx reldens-generate maps ./generate-data/map-data.json LayerElementsObjectLoader
$ npx reldens-generate maps ./generate-data/map-composite-data.json LayerElementsCompositeLoader
$ npx reldens-generate maps ./generate-data/map-composite-data-with-names.json MultipleByLoaderGenerator
$ RELDENS_LOG_LEVEL=9 npx reldens-generate maps ./generate-data/map-composite-data-with-associations.json MultipleWithAssociationsByLoaderGenerator
-->
</ul>
<label for="additional-map-data">Additional map data:</label>
<textarea name="additional-map-data" id="additional-map-data" cols="30" rows="10" placeholder="JSON data for map process"></textarea>
</div>
</form>
</div>
</div>

0 comments on commit fb534a8

Please # to comment.