|
|
@ -52,6 +52,12 @@ class Loader {
|
|
|
|
<input name="name" type="text" value="hydro">
|
|
|
|
<input name="name" type="text" value="hydro">
|
|
|
|
</label>
|
|
|
|
</label>
|
|
|
|
</div></div>
|
|
|
|
</div></div>
|
|
|
|
|
|
|
|
<div class="row"><div class="columns">
|
|
|
|
|
|
|
|
<label class="inverse material textbox">
|
|
|
|
|
|
|
|
{{ _('Table Prefix') }}
|
|
|
|
|
|
|
|
<input name="prefix" type="text" placeholder="{{ _('Leave blank if none') }}">>
|
|
|
|
|
|
|
|
</label>
|
|
|
|
|
|
|
|
</div></div>
|
|
|
|
<div class="row"><div class="columns">
|
|
|
|
<div class="row"><div class="columns">
|
|
|
|
<label class="inverse material textbox">
|
|
|
|
<label class="inverse material textbox">
|
|
|
|
{{ _('Database Username') }}
|
|
|
|
{{ _('Database Username') }}
|
|
|
@ -103,7 +109,7 @@ async function get(ctx: Context) {
|
|
|
|
|
|
|
|
|
|
|
|
async function post(ctx: Context) {
|
|
|
|
async function post(ctx: Context) {
|
|
|
|
const {
|
|
|
|
const {
|
|
|
|
host, port, name, username, password,
|
|
|
|
host, port, name, username, password, prefix,
|
|
|
|
} = ctx.request.body;
|
|
|
|
} = ctx.request.body;
|
|
|
|
let mongourl = 'mongodb://';
|
|
|
|
let mongourl = 'mongodb://';
|
|
|
|
if (username) mongourl += `${username}:${password}@`;
|
|
|
|
if (username) mongourl += `${username}:${password}@`;
|
|
|
@ -113,23 +119,24 @@ async function post(ctx: Context) {
|
|
|
|
useNewUrlParser: true, useUnifiedTopology: true,
|
|
|
|
useNewUrlParser: true, useUnifiedTopology: true,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
const db = Database.db(name);
|
|
|
|
const db = Database.db(name);
|
|
|
|
|
|
|
|
const coll = prefix ? db.collection('system') : db.collection(`${prefix}.system`);
|
|
|
|
await Promise.all([
|
|
|
|
await Promise.all([
|
|
|
|
db.collection('system').updateOne(
|
|
|
|
coll.updateOne(
|
|
|
|
{ _id: 'server.host' },
|
|
|
|
{ _id: 'server.host' },
|
|
|
|
{ $set: { value: ctx.request.host } },
|
|
|
|
{ $set: { value: ctx.request.host } },
|
|
|
|
{ upsert: true },
|
|
|
|
{ upsert: true },
|
|
|
|
),
|
|
|
|
),
|
|
|
|
db.collection('system').updateOne(
|
|
|
|
coll.updateOne(
|
|
|
|
{ _id: 'server.hostname' },
|
|
|
|
{ _id: 'server.hostname' },
|
|
|
|
{ $set: { value: ctx.request.hostname } },
|
|
|
|
{ $set: { value: ctx.request.hostname } },
|
|
|
|
{ upsert: true },
|
|
|
|
{ upsert: true },
|
|
|
|
),
|
|
|
|
),
|
|
|
|
db.collection('system').updateOne(
|
|
|
|
coll.updateOne(
|
|
|
|
{ _id: 'server.url' },
|
|
|
|
{ _id: 'server.url' },
|
|
|
|
{ $set: { value: ctx.request.href } },
|
|
|
|
{ $set: { value: ctx.request.href } },
|
|
|
|
{ upsert: true },
|
|
|
|
{ upsert: true },
|
|
|
|
),
|
|
|
|
),
|
|
|
|
db.collection('system').updateOne(
|
|
|
|
coll.updateOne(
|
|
|
|
{ _id: 'server.port' },
|
|
|
|
{ _id: 'server.port' },
|
|
|
|
{ $set: { value: parseInt(listenPort as string, 10) } },
|
|
|
|
{ $set: { value: parseInt(listenPort as string, 10) } },
|
|
|
|
{ upsert: true },
|
|
|
|
{ upsert: true },
|
|
|
|