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

Commit 3732ba7

Browse files
committed
Possible to edit title
1 parent 5f9943a commit 3732ba7

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

src/Routers/Config.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,5 +153,42 @@ export default class ConfigRouter {
153153
return res.redirect("back");
154154
});
155155

156+
this.router.post("/edit/title", async (req, res) => {
157+
158+
const title = req.body.title;
159+
160+
if(!title)
161+
{
162+
req.flash("error", `Please include a title in the body`);
163+
return res.redirect("back");
164+
}
165+
166+
const [Config, C_Error] = await AW<IConfig[]>(ConfigModel.find());
167+
168+
if(!Config || C_Error)
169+
{
170+
if(C_Error)
171+
log.error(C_Error);
172+
173+
req.flash("error", `Something went wrong, try again later.`);
174+
return res.redirect("back");
175+
};
176+
177+
let config = Config[0];
178+
179+
config.title = config.title === title ? config.title : title;
180+
181+
ConfigMap.set("title", title);
182+
183+
EditEnvFile({
184+
TITLE: title
185+
});
186+
187+
await config.save();
188+
189+
req.flash("success", "Succesfully changed domain settings, ensure to restart too.");
190+
return res.redirect("back");
191+
});
192+
156193
}
157194
}

views/Config/Main.ejs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,17 @@
7575
<button type="submit" class="btn btn-danger">Change Domain Settings</button>
7676
</form>
7777
</div>
78+
<div>
79+
<form action="/config/edit/title" method="POST">
80+
81+
<div class="mb-3">
82+
<label for="password">Domain settings</label>
83+
<input class="form-control mb-2" type="text" name="title" value="<%= title %>" placeholder="DMCD" required>
84+
</div>
85+
86+
<button type="submit" class="btn btn-danger">Change Title</button>
87+
</form>
88+
</div>
7889
</div>
7990
</div>
8091
<div>

0 commit comments

Comments
 (0)