From 6cb59e6ad107d8d4c61a0898c05f03e68e2640ef Mon Sep 17 00:00:00 2001 From: hwong0305 Date: Thu, 12 Dec 2019 22:08:15 -0800 Subject: [PATCH 01/15] Added endpoint to clear logs --- src/api/logs.ts | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/api/logs.ts b/src/api/logs.ts index 842cf916..44d10845 100644 --- a/src/api/logs.ts +++ b/src/api/logs.ts @@ -40,4 +40,25 @@ logsRouter.get('/out/:domain', (req, res) => { } }) +logsRouter.delete('/:domain', (req, res) => { + const { domain } = req.params + + fs.writeFile( + `/home/myproxy/.pm2/logs/${domain}-out.log`, + 'Log cleared', + err => { + if (err) console.log('Error deleting output log') + } + ) + fs.writeFile( + `/home/myproxy/.pm2/logs/${domain}-err.log`, + 'Log cleared', + err => { + if (err) console.log('Error deleting error log') + } + ) + + res.send('LOGS DELETED') +}) + export default logsRouter From bef3503d506fa73fed41ae6935ceb93139182c36 Mon Sep 17 00:00:00 2001 From: hwong0305 Date: Thu, 12 Dec 2019 22:36:32 -0800 Subject: [PATCH 02/15] Added code for UI --- src/public/client.ts | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/public/client.ts b/src/public/client.ts index 7cb0a53a..1b58df41 100644 --- a/src/public/client.ts +++ b/src/public/client.ts @@ -41,14 +41,16 @@ class MappingItem { const mappingElement = document.createElement('li') let iconClass let iconColor - // LogClass is used to hide the button to download logs when - // pm2 is not managing the apps. Since pm2 is not managing the apps, - // the logs will not be located at the same location + // The variables below are to hide log related icons when pm2 is not + // being used to monitor the apps. These apps will not have status since + // they are not managed by pm2. + let settingClass let logClass if (data.status === 'online') { iconClass = 'fa fa-circle mr-1 mt-1' iconColor = 'rgba(50,255,50,0.5)' logClass = 'fa fa-file-text-o ml-1 mt-1' + settingClass = 'fa fa-cog' } else if (data.status === 'not started') { iconClass = '' iconColor = 'transparent' @@ -56,6 +58,7 @@ class MappingItem { iconClass = 'fa fa-circle mr-1 mt-1' iconColor = 'rgba(255, 50, 50, 0.5)' logClass = 'fa fa-file-text-o ml-1 mt-1' + settingClass = 'fa fa-cog' } mappingElement.classList.add( 'list-group-item', @@ -83,6 +86,16 @@ class MappingItem { style="font-size: 15px; color: rgba(40,167,70,0.5)" href="/api/logs/out/${data.fullDomain}"> +
+ + +
${data.gitLink} From 875ee7f4993d1318bc074ab5d5c570f9f8475755 Mon Sep 17 00:00:00 2001 From: hwong0305 Date: Thu, 12 Dec 2019 23:43:52 -0800 Subject: [PATCH 03/15] Updated UI --- src/public/client.ts | 12 ++++++++---- views/layout/head.ejs | 4 ++++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/public/client.ts b/src/public/client.ts index 1b58df41..d7de85c8 100644 --- a/src/public/client.ts +++ b/src/public/client.ts @@ -87,13 +87,17 @@ class MappingItem { href="/api/logs/out/${data.fullDomain}">
- -