Notifications

This commit is contained in:
Tyler 2018-04-17 00:06:11 -04:00
parent 77d4cd1d49
commit 103e117c53
4 changed files with 32 additions and 7 deletions

View File

@ -19,6 +19,8 @@
"event-emitter": "^0.3.5", "event-emitter": "^0.3.5",
"jquery": "^3.2.1", "jquery": "^3.2.1",
"moment": "^2.22.0", "moment": "^2.22.0",
"moment-duration-format": "^2.2.2",
"noty": "^3.2.0-beta",
"tiny-emitter": "^2.0.2", "tiny-emitter": "^2.0.2",
"util.inherits": "^1.0.3", "util.inherits": "^1.0.3",
"vue": "^2.4.2", "vue": "^2.4.2",

View File

@ -19,6 +19,12 @@ import Vue from 'vue'
import job from './components/Job'; import job from './components/Job';
import navbar from './components/Nav'; import navbar from './components/Nav';
import EventWebSocket from './websocket'; import EventWebSocket from './websocket';
import Noty from 'noty';
Noty.overrideDefaults({
theme: 'bootstrap-v4',
timeout: 5000
});
let d = { let d = {
jobs: {}, jobs: {},
@ -27,6 +33,14 @@ let d = {
let ws = new EventWebSocket(window.arm_config.url); let ws = new EventWebSocket(window.arm_config.url);
ws.on('notification', function(data) {
console.log(data);
new Noty({
type: data.type || 'alert',
text: data.message
}).show();
});
ws.on('jobs', function(data) { ws.on('jobs', function(data) {
// Create jobs components // Create jobs components
d.jobs = data; d.jobs = data;

View File

@ -1,7 +1,9 @@
@import '_variables.scss'; @import '_variables.scss';
@import '~bootstrap/scss/bootstrap'; @import '~bootstrap/scss/bootstrap';
@import '~bootstrap-vue/dist/bootstrap-vue.css'; @import '~bootstrap-vue/dist/bootstrap-vue.css';
@import '_sidebar.scss'; @import '~noty/src/noty';
@import '~noty/src/themes/bootstrap-v4';
@import '_sidebar';
.margin-top-10 { .margin-top-10 {
margin-top: 10px; margin-top: 10px;

View File

@ -29,6 +29,11 @@
</template> </template>
<script> <script>
import moment from 'moment';
import momentDurationFormatSetup from 'moment-duration-format';
momentDurationFormatSetup(moment);
export default { export default {
name: 'job', name: 'job',
props: [ 'job' ], props: [ 'job' ],
@ -49,9 +54,11 @@
} }
// Job is in nanoseconds because of Go's time.Duration // Job is in nanoseconds because of Go's time.Duration
let eta = moment.duration(this.job.eta / 1000); let eta = moment.duration(this.job.progress.eta / 1000 / 1000);
return eta.humanize(); return eta.format("w[w] d[d] h[h] m[m] s[s]", {
trim: "both mid"
});
} }
} }
} }