From f11d1696062a60a0f155b58e56c105d7d9190e0f Mon Sep 17 00:00:00 2001 From: kolitha warnakulasooriya Date: Wed, 14 Aug 2019 13:58:08 +0530 Subject: [PATCH 1/6] change the after saving redirection --- index.js | 1 + public/styles/addpath.css | 8 +++ routes/pathRoutes.js | 2 +- views/paths/addPath.ejs | 96 +++++++++++++++++++---------------- views/paths/editPath.ejs | 102 ++++++++++++++++++++------------------ 5 files changed, 116 insertions(+), 93 deletions(-) diff --git a/index.js b/index.js index 6284d27..f02357d 100644 --- a/index.js +++ b/index.js @@ -61,6 +61,7 @@ systemApp.use((req, res, next) => { }); const sessionChecker = (req, res, next) => { + return next(); if (req.session.user && req.cookies.userId) { next(); } else { diff --git a/public/styles/addpath.css b/public/styles/addpath.css index eb92fe7..64f4627 100644 --- a/public/styles/addpath.css +++ b/public/styles/addpath.css @@ -15,6 +15,14 @@ body { background-color: #91c0dc1a; } +.body-text{ + padding-left: 32px; +} + +.body-text textarea{ + overflow-x: auto; + white-space: nowrap; +} .container { width: 100%; diff --git a/routes/pathRoutes.js b/routes/pathRoutes.js index 598caa1..628e308 100644 --- a/routes/pathRoutes.js +++ b/routes/pathRoutes.js @@ -186,7 +186,7 @@ pathRouter.post("/:domainId/:pathId/edit", async function(req, res) { `Domain New Path Edited Error {id : ${domainId}, error:${error}}` ); } - res.redirect(`/admin/domain/paths/${domainId}`); + res.redirect(`/admin/domain/paths/${domainId}/${pathId}/edit`); }); pathRouter.get("/:domainId/:pathId/delete", async function(req, res) { diff --git a/views/paths/addPath.ejs b/views/paths/addPath.ejs index c3ea930..5fb936a 100644 --- a/views/paths/addPath.ejs +++ b/views/paths/addPath.ejs @@ -77,51 +77,59 @@ required /> -
- Method - - -
-
- Status Code - - -
-
- - -
-
- Header (Shoud use JSON format) - - -
-
- Body - - -
- +
+
+
+ Method + + +
+
+ Status Code + + +
+
+ + +
+
+ Header (Shoud use JSON format) + + +
+ + +
+ +
+
+ Body + + +
+
+
diff --git a/views/paths/editPath.ejs b/views/paths/editPath.ejs index a199ba5..4f2fad1 100644 --- a/views/paths/editPath.ejs +++ b/views/paths/editPath.ejs @@ -80,54 +80,60 @@ required /> -
- Method - - -
-
- Status Code - - -
-
- name="authentication"> - -
-
- Header (Shoud use JSON format) - - -
-
- Body - - -
- - +
+
+
+ Method + + +
+
+ Status Code + + +
+
+ name="authentication"> + +
+
+ Header (Shoud use JSON format) + + +
+ + +
+
+
+ Body + + +
+
+
From a86a4aab69ecffde6b0b709b88188078bae9a6fe Mon Sep 17 00:00:00 2001 From: kolitha warnakulasooriya Date: Wed, 14 Aug 2019 13:59:52 +0530 Subject: [PATCH 2/6] change button location --- views/paths/addPath.ejs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/views/paths/addPath.ejs b/views/paths/addPath.ejs index 5fb936a..0f2cb1d 100644 --- a/views/paths/addPath.ejs +++ b/views/paths/addPath.ejs @@ -114,7 +114,7 @@ class="form-control" rows="5" required>{"Content-Type":"application/json"} - + From 38014a1695c108988cb5a7bcfee2a956dcb32a10 Mon Sep 17 00:00:00 2001 From: kolitha warnakulasooriya Date: Wed, 14 Aug 2019 15:02:18 +0530 Subject: [PATCH 3/6] added dulicate funcationality --- routes/pathRoutes.js | 24 ++++++++++++++++++++++-- views/paths/addPath.ejs | 23 +++++++++++++---------- views/paths/viewPaths.ejs | 3 +++ 3 files changed, 38 insertions(+), 12 deletions(-) diff --git a/routes/pathRoutes.js b/routes/pathRoutes.js index 628e308..d3749c1 100644 --- a/routes/pathRoutes.js +++ b/routes/pathRoutes.js @@ -31,12 +31,32 @@ pathRouter.get("/:domainId", async function(req, res) { pathRouter.get("/:domainId/new", async function(req, res) { const domainId = req.params.domainId; + const duplicationPathId = req.query.pathId; try { const domain = await Database.getDomainFromId(domainId); - const params = { + let params = { domainName: domain.domainName, - domainId + domainId, + pathName: "", + pathDescription: "", + pathUrl: "", + pathMethod:'post', + authentication:false, + pathStatus:200, + header: {"Content-Type":"application/json"}, + body: "" }; + if(duplicationPathId){ + const duplicationPath = await Database.getPath(domainId,duplicationPathId); + console.log() + params = { + ...params, + ...duplicationPath.paths[0], + pathName: `${duplicationPath.paths[0].pathName} [Copy]`, + header: JSON.parse(duplicationPath.paths[0].header), + pathUrl:"" + } + } Logger.info( `Domain New Path View {Id: ${domainId},domains:${JSON.stringify(params)}}` ); diff --git a/views/paths/addPath.ejs b/views/paths/addPath.ejs index 0f2cb1d..efea4ec 100644 --- a/views/paths/addPath.ejs +++ b/views/paths/addPath.ejs @@ -52,6 +52,7 @@ name="name" placeholder="Name" class="form-control" + value="<%= pathName%>" required /> @@ -64,6 +65,7 @@ name="desc" placeholder="Description" class="form-control" + value="<%= pathDescription%>" />
@@ -74,6 +76,7 @@ name="path" placeholder="Path" class="form-control" + value="<%= pathUrl%>" required />
@@ -82,11 +85,11 @@
Method - + + + +
@@ -98,11 +101,12 @@ placeholder="Status Code" value="200" class="form-control" + value="<%= pathStatus%>" required />
- + name="authentication">
@@ -111,11 +115,10 @@ + class="form-control" rows="5" required><%=JSON.stringify(header)%>
- - +
@@ -126,7 +129,7 @@ type="text" name="body" placeholder='' - class="form-control" rows="15"> + class="form-control" rows="15"><%=body%>
diff --git a/views/paths/viewPaths.ejs b/views/paths/viewPaths.ejs index ab418ed..2b92e05 100644 --- a/views/paths/viewPaths.ejs +++ b/views/paths/viewPaths.ejs @@ -78,6 +78,9 @@ + From 89ac6013daaa936b37e9d26a773178c7fdc9ad1d Mon Sep 17 00:00:00 2001 From: kolitha warnakulasooriya Date: Wed, 14 Aug 2019 15:04:07 +0530 Subject: [PATCH 4/6] added back button --- views/paths/addPath.ejs | 3 +++ views/paths/editPath.ejs | 3 +++ 2 files changed, 6 insertions(+) diff --git a/views/paths/addPath.ejs b/views/paths/addPath.ejs index efea4ec..2fdd397 100644 --- a/views/paths/addPath.ejs +++ b/views/paths/addPath.ejs @@ -42,6 +42,9 @@ > +
+ +
diff --git a/views/paths/editPath.ejs b/views/paths/editPath.ejs index 4f2fad1..9aa4919 100644 --- a/views/paths/editPath.ejs +++ b/views/paths/editPath.ejs @@ -42,6 +42,9 @@ >
+
+ +
From 9afda38bc32b39c2a731d68d7fcd57cb8dd4bdb0 Mon Sep 17 00:00:00 2001 From: kolitha warnakulasooriya Date: Wed, 14 Aug 2019 15:06:21 +0530 Subject: [PATCH 5/6] handling admin domains --- routes/domainRouter.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/routes/domainRouter.js b/routes/domainRouter.js index 2644c1f..eeb04fb 100644 --- a/routes/domainRouter.js +++ b/routes/domainRouter.js @@ -32,6 +32,10 @@ domainRouter.post("/add", async function(req, res) { try { let name = req.body.domainName; name = name.startsWith("/") ? name : `/${name}`; + + if(name === '/admin'){ + return; + } await Database.addDomain(name); } catch (error) { Logger.error(`Domain Registration Error ${error}`); @@ -68,6 +72,9 @@ domainRouter.post("/edit/:domainId", async function(req, res) { try { let newDomainName = req.body.domainName; newDomainName = newDomainName.startsWith("/") ? newDomainName : `/${name}`; + if(name === '/admin'){ + return; + } const domain = await Database.getDomainFromId(domainId); const domainName = domain.domainName; const pathNames = await Database.getPathNamesForDomain(domainId); From d2c1182f05b18d37d0a664ca05eefbbeb692605e Mon Sep 17 00:00:00 2001 From: kolitha warnakulasooriya Date: Wed, 14 Aug 2019 15:11:08 +0530 Subject: [PATCH 6/6] fixed next in session checker --- index.js | 1 - 1 file changed, 1 deletion(-) diff --git a/index.js b/index.js index f02357d..6284d27 100644 --- a/index.js +++ b/index.js @@ -61,7 +61,6 @@ systemApp.use((req, res, next) => { }); const sessionChecker = (req, res, next) => { - return next(); if (req.session.user && req.cookies.userId) { next(); } else {