Skip to content

Commit

Permalink
add notification system
Browse files Browse the repository at this point in the history
  • Loading branch information
A1Gard committed Nov 16, 2017
1 parent e0bb658 commit 9a16d62
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 12 deletions.
15 changes: 15 additions & 0 deletions assets/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
32 changes: 23 additions & 9 deletions pm2panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -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': '/'
});
Expand Down Expand Up @@ -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();
});

Expand All @@ -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();
});

Expand All @@ -206,16 +203,33 @@ 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();
});


}
});

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) {
Expand Down
11 changes: 8 additions & 3 deletions www/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ <h2>
Welcome to PM2 panel
</h2>
<br />
<div id="notification">
</div>
<pre id="notification">

</pre>
<table>
<thead>
<tr>
Expand Down Expand Up @@ -136,6 +136,11 @@ <h2>
$.get('/folder', function (e) {
vue.folders = e;
});
$.get('/notification', function (e) {
if (e !== '-') {
$("#notification").text(e).slideDown(300);
}
});
}
var now = 0;
vue = new Vue({
Expand Down

0 comments on commit 9a16d62

Please sign in to comment.