Skip to content

Commit

Permalink
- Reldens - v4.0.0 - Installer default values.
Browse files Browse the repository at this point in the history
  • Loading branch information
damian-pastorini committed Nov 30, 2023
1 parent efb4377 commit 16a5dae
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 19 deletions.
33 changes: 24 additions & 9 deletions install/css/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -258,18 +258,12 @@ form {
display: flex;
flex-direction: row;
justify-content: end;
padding: 0 0 6px;
}

.db-basic-config-notice {
display: flex;
margin-top: 10px;
font-size: 12px;
font-weight: bold;
color: $cRed;

span {
padding: 10px;
}
margin-bottom: 0;
background: none;
}

}
Expand Down Expand Up @@ -330,6 +324,27 @@ form {

}

.db-basic-config-notice {
display: flex;
background: $boxBackground;
margin-bottom: 10px;
font-size: 12px;
font-weight: normal;

ul {
margin-bottom: 0;
}

span {
color: $cBlack;
padding: 10px;
&.danger {
font-weight: bold;
color: $cRed;
}
}
}

}

.installation-successful {
Expand Down
30 changes: 21 additions & 9 deletions install/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ <h3 class="form-title">- App -</h3>
<input type="text" name="app-port" id="app-port" value="{{app-port}}" class="required" required/>
</div>
<div class="input-box app-admin-path">
<label for="app-admin-path">Admin Panel path (default /reldens-admin)</label>
<label for="app-admin-path">Admin Panel Path</label>
<input type="text" name="app-admin-path" id="app-admin-path" value="{{app-admin-path}}"/>
</div>
<div class="input-box app-secure-admin">
<label for="app-secure-admin">Secure Admin</label>
<label for="app-secure-admin">Secure Admin (login with normal app users)</label>
<input type="checkbox" value="1" name="app-secure-admin" id="app-secure-admin"{{&app-secure-admin-checked}}/>
</div>
<div class="input-box app-admin-hot-plug">
Expand Down Expand Up @@ -91,6 +91,15 @@ <h3 class="form-title">- App -</h3>

<!-- STORAGE -->
<h3 class="form-title">- Storage -</h3>
<div class="db-basic-config-notice">
<span>
Default samples:
<ul>
<li>Client: mysql - Port: 3306</li>
<li>Client: mongodb - Port: 27017</li>
</ul>
</span>
</div>
<div class="input-box db-storage-driver">
<label for="db-storage-driver">Storage Driver</label>
<select name="db-storage-driver" id="db-storage-driver" class="required" required>
Expand All @@ -99,7 +108,7 @@ <h3 class="form-title">- Storage -</h3>
</select>
</div>
<div class="input-box db-client">
<label for="db-client">Client (mysql / 3306, mongodb / 27017)</label>
<label for="db-client">Client</label>
<input type="text" name="db-client" id="db-client" value="{{db-client}}" class="required" required/>
</div>
<div class="input-box db-host">
Expand Down Expand Up @@ -129,16 +138,19 @@ <h3 class="form-title">- Storage -</h3>
<p class="db-installation-process-failed">There was an error during the installation process.</p>
</div>
<div class="input-box db-basic-config">
<div class="db-basic-config-notice">
<span class="danger">
DANGER:
<ul>
<li>The automatic installation for the basic configuration and the sample data are only available for the mysql client.</li>
<li>Uncheck this is only if you know what you are doing. <br/>Without this you will get all the tables empty, even the ones with default required values.</li>
</ul>
</span>
</div>
<div class="db-basic-config-checkbox">
<label for="db-basic-config">Install minimal configuration</label>
<input type="checkbox" value="1" name="db-basic-config" id="db-basic-config"{{&db-basic-config-checked}}/>
</div>
<div class="db-basic-config-notice">
<span>
DANGER: uncheck this is only if you know what you are doing.
Without this you will get all the tables empty, even the ones with default required values.
</span>
</div>
</div>
<div class="input-box db-sample-data">
<label for="db-sample-data">Install sample data</label>
Expand Down
28 changes: 27 additions & 1 deletion lib/game/server/installer.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ class Installer
this.themeManager.installerPathIndex,
{encoding: this.encoding()}
);
let templateVariables = req?.session?.templateVariables || {};
let templateVariables = req?.session?.templateVariables || this.fetchDefaults();
return res.send(TemplateEngine.render(installerIndexTemplate, templateVariables));
}
if(!req.url.endsWith('.html')){
Expand All @@ -158,6 +158,32 @@ class Installer
next();
}

fetchDefaults()
{
let host = (process.env.RELDENS_HOST || '').toString();
let port = (process.env.RELDENS_PORT || '').toString();
let adminPath = (process.env.RELDENS_ADMIN_ROUTE_PATH || '').toString();
let secureAdmin = Number(process.env.RELDENS_ADMIN_SECURE_LOGIN || 1);
let hotPlug = Number(process.env.RELDENS_HOT_PLUG || 1);
let dbClient = (process.env.RELDENS_DB_CLIENT || '').toString();
let dbHost = (process.env.RELDENS_DB_HOST || '').toString();
let dbPort = (process.env.RELDENS_DB_PORT || '').toString();
let dbName = (process.env.RELDENS_DB_NAME || '').toString();
return {
'app-host': '' !== host ? host : 'http://localhost',
'app-port':'' !== port ? port : '8080',
'app-admin-path': '' !== adminPath ? adminPath : '/reldens-admin',
'app-secure-admin-checked': 1 === secureAdmin ? ' checked="checked"' : '',
'app-admin-hot-plug-checked': 1 === hotPlug ? ' checked="checked"' : '',
'db-client': '' !== dbClient ? dbClient : 'mysql',
'db-host': '' !== dbHost ? dbHost : 'localhost',
'db-port': '' !== dbPort ? dbPort : '3306',
'db-name': '' !== dbName ? dbName : 'reldens',
'db-basic-config-checked': ' checked="checked"',
'db-sample-data-checked': ' checked="checked"'
};
}

async executeQueryFile(migrationsPath, dbDriver, fileName)
{
await dbDriver.rawQuery(
Expand Down

0 comments on commit 16a5dae

Please sign in to comment.