diff --git a/assets/css/style.css b/assets/css/style.css index f7d159d..b0fbf39 100644 --- a/assets/css/style.css +++ b/assets/css/style.css @@ -51,3 +51,18 @@ body{ background: #eee ; } + +#notification{ + position: relative; + min-height: 1em; + margin: 1em 0; + padding: 1em 1.5em; + line-height: 1.4285em; + -webkit-transition: opacity .1s ease,color .1s ease,background .1s ease,box-shadow .1s ease; + transition: opacity .1s ease,color .1s ease,background .1s ease,box-shadow .1s ease; + border-radius: .28571429rem; + box-shadow: 0 0 0 1px #a9d5de inset, 0 0 0 0 transparent; + background-color: #f8ffff; + color: #276f86; + display: none; +} diff --git a/pm2panel.js b/pm2panel.js index 6957a55..4e48093 100644 --- a/pm2panel.js +++ b/pm2panel.js @@ -120,6 +120,7 @@ app.post('/addProccess', function (req, res) { //do whatever here // res.write(stdout); // res.end(); + req.session.notication = error + '\n--------\n' + stdout + '\n--------\n' + stderr; res.writeHead(302, { 'Location': '/' }); @@ -153,9 +154,7 @@ app.get('/restart', function (req, res) { res.writeHead(302, { 'Location': '/' }); - console.log(error); - console.log(stdout); - console.log(stderr); + req.session.notication = error + '\n--------\n' + stdout + '\n--------\n' + stderr; res.end(); }); @@ -180,9 +179,7 @@ app.get('/delete', function (req, res) { res.writeHead(302, { 'Location': '/' }); - console.log(error); - console.log(stdout); - console.log(stderr); + req.session.notication = error + '\n--------\n' + stdout + '\n--------\n' + stderr; res.end(); }); @@ -206,9 +203,7 @@ app.get('/dump', function (req, res) { res.writeHead(302, { 'Location': '/' }); - console.log(error); - console.log(stdout); - console.log(stderr); + req.session.notication = error + '\n--------\n' + stdout + '\n--------\n' + stderr; res.end(); }); @@ -216,6 +211,25 @@ app.get('/dump', function (req, res) { } }); +app.get('/notification', function (req, res) { + // send json header + if (!req.session.islogin) { + res.writeHead(302, { + 'Location': '/login' + }); + res.end(); + return false; + } else { + if (!req.session.notication && req.session.notication !== '-') { + res.write('-'); + } else { + delete req.session.notication; + res.write(req.session.notication); + } + res.end(); + } +}); + app.get('/folder', function (req, res) { if (!req.session.islogin) { diff --git a/www/index.html b/www/index.html index d18f85a..70ab1ae 100644 --- a/www/index.html +++ b/www/index.html @@ -22,9 +22,9 @@

Welcome to PM2 panel


-
- -
+
+
+            
@@ -136,6 +136,11 @@

$.get('/folder', function (e) { vue.folders = e; }); + $.get('/notification', function (e) { + if (e !== '-') { + $("#notification").text(e).slideDown(300); + } + }); } var now = 0; vue = new Vue({