diff --git a/lib/assets/images/notification-icon-200x200.png b/lib/assets/images/notification-icon-200x200.png new file mode 100644 index 0000000..c0a1293 Binary files /dev/null and b/lib/assets/images/notification-icon-200x200.png differ diff --git a/lib/chat.js b/lib/chat.js index 9e8846e..05ad273 100644 --- a/lib/chat.js +++ b/lib/chat.js @@ -1,7 +1,7 @@ -'use strict' - const ids = require('./ids.js') const robotNames = require('./robot-names.json') +const nodeNotifier = require('node-notifier') +const path = require('path') 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 socket.on('disconnect', () => { diff --git a/lib/site.js b/lib/site.js index 70a0fcc..31cf65f 100644 --- a/lib/site.js +++ b/lib/site.js @@ -1,5 +1,3 @@ -'use strict' - // Dependencies const express = require('express') const helmet = require('helmet') diff --git a/package-lock.json b/package-lock.json index b6926a5..6e95e47 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3828,6 +3828,11 @@ "version": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", "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": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/gzip-size/-/gzip-size-3.0.0.tgz", @@ -3994,7 +3999,8 @@ "html-entities": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/html-entities/-/html-entities-1.2.1.tgz", - "integrity": "sha1-DfKTUfByEWNRXfueVUPl9u7VFi8=" + "integrity": "sha1-DfKTUfByEWNRXfueVUPl9u7VFi8=", + "dev": true }, "html-minifier": { "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": { "version": "3.0.6", "resolved": "https://registry.npmjs.org/nopt/-/nopt-3.0.6.tgz", @@ -6689,6 +6706,11 @@ "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": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/sigmund/-/sigmund-1.0.1.tgz", diff --git a/package.json b/package.json index df822a2..dc726ab 100644 --- a/package.json +++ b/package.json @@ -33,6 +33,7 @@ "ip": "^1.1.5", "mime": "^1.3.6", "minimatch": "^3.0.4", + "node-notifier": "^5.1.2", "opener": "^1.4.3", "slug": "^0.9.1", "socket.io": "^2.0.3", diff --git a/site/src/components/alert/index.vue b/site/src/components/alert/index.vue new file mode 100644 index 0000000..246515d --- /dev/null +++ b/site/src/components/alert/index.vue @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/site/src/components/alert/script.js b/site/src/components/alert/script.js new file mode 100644 index 0000000..f2bab88 --- /dev/null +++ b/site/src/components/alert/script.js @@ -0,0 +1,12 @@ +export default +{ + name: 'alert', + + methods: + { + onAlertClick() + { + this.$store.commit('setPendingAlert') + } + } +} \ No newline at end of file diff --git a/site/src/components/alert/style.styl b/site/src/components/alert/style.styl new file mode 100644 index 0000000..2ee7405 --- /dev/null +++ b/site/src/components/alert/style.styl @@ -0,0 +1,4 @@ +.alert + position fixed + bottom 0 + right 30px diff --git a/site/src/components/alert/template.html b/site/src/components/alert/template.html new file mode 100644 index 0000000..e6e6181 --- /dev/null +++ b/site/src/components/alert/template.html @@ -0,0 +1,3 @@ + + /!\ + \ No newline at end of file diff --git a/site/src/components/chat/style.styl b/site/src/components/chat/style.styl index b38c843..0013653 100644 --- a/site/src/components/chat/style.styl +++ b/site/src/components/chat/style.styl @@ -1,7 +1,7 @@ .chat position fixed bottom 0 - right 20px + right 90px .header cursor pointer diff --git a/site/src/components/connexion/script.js b/site/src/components/connexion/script.js index 03baea8..f68fd28 100644 --- a/site/src/components/connexion/script.js +++ b/site/src/components/connexion/script.js @@ -19,6 +19,11 @@ export default pendingMessage() { return this.$store.state.chat.pendingMessage + }, + + pendingAlert() + { + return this.$store.state.chat.pendingAlert } }, @@ -26,7 +31,8 @@ export default { project: 'onProjectChange', pendingUser: 'onPendingUser', - pendingMessage: 'onPendingMessage' + pendingMessage: 'onPendingMessage', + pendingAlert: 'onPendingAlert' }, created() @@ -119,6 +125,14 @@ export default { this.chatSocket.emit('message', value) } + }, + + onPendingAlert(value) + { + if(value) + { + this.chatSocket.emit('alert') + } } } } \ No newline at end of file diff --git a/site/src/components/project/script.js b/site/src/components/project/script.js index fd08fea..5d05603 100644 --- a/site/src/components/project/script.js +++ b/site/src/components/project/script.js @@ -1,6 +1,7 @@ import FilesTree from '@/components/files-tree' import File from '@/components/file' import Chat from '@/components/chat' +import Alert from '@/components/alert' export default { @@ -10,7 +11,8 @@ export default { FilesTree, File, - Chat + Chat, + Alert }, computed: diff --git a/site/src/components/project/template.html b/site/src/components/project/template.html index 3771b45..68e09e3 100644 --- a/site/src/components/project/template.html +++ b/site/src/components/project/template.html @@ -4,4 +4,5 @@ + \ No newline at end of file diff --git a/site/src/store/modules/chat.js b/site/src/store/modules/chat.js index 1df5e8e..05c92a6 100644 --- a/site/src/store/modules/chat.js +++ b/site/src/store/modules/chat.js @@ -4,7 +4,8 @@ export default { user: null, pendingUser: null, messages: [], - pendingMessage: null + pendingMessage: null, + pendingAlert: null }, mutations: @@ -32,6 +33,12 @@ export default { setPendingMessage(state, data) { state.pendingMessage = data + }, + + setPendingAlert(state) + { + const date = new Date() + state.pendingAlert = { date } } } } \ No newline at end of file