Skip to content
This repository has been archived by the owner on Dec 14, 2023. It is now read-only.

Commit

Permalink
Possible to edit title
Browse files Browse the repository at this point in the history
  • Loading branch information
Tolfx committed Jul 26, 2021
1 parent 5f9943a commit 3732ba7
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
37 changes: 37 additions & 0 deletions src/Routers/Config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,5 +153,42 @@ export default class ConfigRouter {
return res.redirect("back");
});

this.router.post("/edit/title", async (req, res) => {

const title = req.body.title;

if(!title)
{
req.flash("error", `Please include a title in the body`);
return res.redirect("back");
}

const [Config, C_Error] = await AW<IConfig[]>(ConfigModel.find());

if(!Config || C_Error)
{
if(C_Error)
log.error(C_Error);

req.flash("error", `Something went wrong, try again later.`);
return res.redirect("back");
};

let config = Config[0];

config.title = config.title === title ? config.title : title;

ConfigMap.set("title", title);

EditEnvFile({
TITLE: title
});

await config.save();

req.flash("success", "Succesfully changed domain settings, ensure to restart too.");
return res.redirect("back");
});

}
}
11 changes: 11 additions & 0 deletions views/Config/Main.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,17 @@
<button type="submit" class="btn btn-danger">Change Domain Settings</button>
</form>
</div>
<div>
<form action="/config/edit/title" method="POST">

<div class="mb-3">
<label for="password">Domain settings</label>
<input class="form-control mb-2" type="text" name="title" value="<%= title %>" placeholder="DMCD" required>
</div>

<button type="submit" class="btn btn-danger">Change Title</button>
</form>
</div>
</div>
</div>
<div>
Expand Down

0 comments on commit 3732ba7

Please sign in to comment.