Add alert

This commit is contained in:
brunosimon
2017-08-15 18:13:14 +02:00
parent 4b4977cc1b
commit 0ff61b0c99
14 changed files with 93 additions and 9 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

+19 -2
View File
@@ -1,7 +1,7 @@
'use strict'
const ids = require('./ids.js') const ids = require('./ids.js')
const robotNames = require('./robot-names.json') const robotNames = require('./robot-names.json')
const nodeNotifier = require('node-notifier')
const path = require('path')
class Chat class Chat
{ {
@@ -94,6 +94,23 @@ class Chat
} }
}) })
// On alert
socket.on('alert', () =>
{
nodeNotifier.notify({
title: 'Keppler',
message: 'Alert!',
icon: path.join(__dirname, 'assets/images/notification-icon-200x200.png'),
wait: true
})
// Debug
if(this.config.debug >= 1)
{
console.log('chat > socket'.green.bold + ' - ' + 'alert'.cyan + ' - ' + user.name.cyan)
}
})
// On disconnect // On disconnect
socket.on('disconnect', () => socket.on('disconnect', () =>
{ {
-2
View File
@@ -1,5 +1,3 @@
'use strict'
// Dependencies // Dependencies
const express = require('express') const express = require('express')
const helmet = require('helmet') const helmet = require('helmet')
+23 -1
View File
@@ -3828,6 +3828,11 @@
"version": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", "version": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz",
"integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=" "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg="
}, },
"growly": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/growly/-/growly-1.3.0.tgz",
"integrity": "sha1-8QdIy+dq+WS3yWyTxrzCivEgwIE="
},
"gzip-size": { "gzip-size": {
"version": "3.0.0", "version": "3.0.0",
"resolved": "https://registry.npmjs.org/gzip-size/-/gzip-size-3.0.0.tgz", "resolved": "https://registry.npmjs.org/gzip-size/-/gzip-size-3.0.0.tgz",
@@ -3994,7 +3999,8 @@
"html-entities": { "html-entities": {
"version": "1.2.1", "version": "1.2.1",
"resolved": "https://registry.npmjs.org/html-entities/-/html-entities-1.2.1.tgz", "resolved": "https://registry.npmjs.org/html-entities/-/html-entities-1.2.1.tgz",
"integrity": "sha1-DfKTUfByEWNRXfueVUPl9u7VFi8=" "integrity": "sha1-DfKTUfByEWNRXfueVUPl9u7VFi8=",
"dev": true
}, },
"html-minifier": { "html-minifier": {
"version": "3.5.3", "version": "3.5.3",
@@ -5075,6 +5081,17 @@
} }
} }
}, },
"node-notifier": {
"version": "5.1.2",
"resolved": "https://registry.npmjs.org/node-notifier/-/node-notifier-5.1.2.tgz",
"integrity": "sha1-L6nhJgX6EACdRFSdb82KY93g5P8=",
"requires": {
"growly": "1.3.0",
"semver": "5.3.0",
"shellwords": "0.1.0",
"which": "1.2.14"
}
},
"nopt": { "nopt": {
"version": "3.0.6", "version": "3.0.6",
"resolved": "https://registry.npmjs.org/nopt/-/nopt-3.0.6.tgz", "resolved": "https://registry.npmjs.org/nopt/-/nopt-3.0.6.tgz",
@@ -6689,6 +6706,11 @@
"rechoir": "0.6.2" "rechoir": "0.6.2"
} }
}, },
"shellwords": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/shellwords/-/shellwords-0.1.0.tgz",
"integrity": "sha1-Zq/Ue2oSky2Qccv9mKUueFzQuhQ="
},
"sigmund": { "sigmund": {
"version": "1.0.1", "version": "1.0.1",
"resolved": "https://registry.npmjs.org/sigmund/-/sigmund-1.0.1.tgz", "resolved": "https://registry.npmjs.org/sigmund/-/sigmund-1.0.1.tgz",
+1
View File
@@ -33,6 +33,7 @@
"ip": "^1.1.5", "ip": "^1.1.5",
"mime": "^1.3.6", "mime": "^1.3.6",
"minimatch": "^3.0.4", "minimatch": "^3.0.4",
"node-notifier": "^5.1.2",
"opener": "^1.4.3", "opener": "^1.4.3",
"slug": "^0.9.1", "slug": "^0.9.1",
"socket.io": "^2.0.3", "socket.io": "^2.0.3",
+3
View File
@@ -0,0 +1,3 @@
<template src="./template.html"></template>
<script src="./script.js"></script>
<style src="./style.styl" lang="stylus" scoped></style>
+12
View File
@@ -0,0 +1,12 @@
export default
{
name: 'alert',
methods:
{
onAlertClick()
{
this.$store.commit('setPendingAlert')
}
}
}
+4
View File
@@ -0,0 +1,4 @@
.alert
position fixed
bottom 0
right 30px
+3
View File
@@ -0,0 +1,3 @@
<a href="#" class="alert" @click.prevent="onAlertClick">
/!\
</a>
+1 -1
View File
@@ -1,7 +1,7 @@
.chat .chat
position fixed position fixed
bottom 0 bottom 0
right 20px right 90px
.header .header
cursor pointer cursor pointer
+15 -1
View File
@@ -19,6 +19,11 @@ export default
pendingMessage() pendingMessage()
{ {
return this.$store.state.chat.pendingMessage return this.$store.state.chat.pendingMessage
},
pendingAlert()
{
return this.$store.state.chat.pendingAlert
} }
}, },
@@ -26,7 +31,8 @@ export default
{ {
project: 'onProjectChange', project: 'onProjectChange',
pendingUser: 'onPendingUser', pendingUser: 'onPendingUser',
pendingMessage: 'onPendingMessage' pendingMessage: 'onPendingMessage',
pendingAlert: 'onPendingAlert'
}, },
created() created()
@@ -119,6 +125,14 @@ export default
{ {
this.chatSocket.emit('message', value) this.chatSocket.emit('message', value)
} }
},
onPendingAlert(value)
{
if(value)
{
this.chatSocket.emit('alert')
}
} }
} }
} }
+3 -1
View File
@@ -1,6 +1,7 @@
import FilesTree from '@/components/files-tree' import FilesTree from '@/components/files-tree'
import File from '@/components/file' import File from '@/components/file'
import Chat from '@/components/chat' import Chat from '@/components/chat'
import Alert from '@/components/alert'
export default export default
{ {
@@ -10,7 +11,8 @@ export default
{ {
FilesTree, FilesTree,
File, File,
Chat Chat,
Alert
}, },
computed: computed:
@@ -4,4 +4,5 @@
<files-tree></files-tree> <files-tree></files-tree>
<file v-if="file" :content="file.data"></file> <file v-if="file" :content="file.data"></file>
<chat></chat> <chat></chat>
<alert></alert>
</div> </div>
+8 -1
View File
@@ -4,7 +4,8 @@ export default {
user: null, user: null,
pendingUser: null, pendingUser: null,
messages: [], messages: [],
pendingMessage: null pendingMessage: null,
pendingAlert: null
}, },
mutations: mutations:
@@ -32,6 +33,12 @@ export default {
setPendingMessage(state, data) setPendingMessage(state, data)
{ {
state.pendingMessage = data state.pendingMessage = data
},
setPendingAlert(state)
{
const date = new Date()
state.pendingAlert = { date }
} }
} }
} }