🐛 Server > Fix alert
This commit is contained in:
+4
-8
@@ -1,7 +1,5 @@
|
||||
const ids = require('./ids.js')
|
||||
const robotNames = require('./assets/data/robot-names.json')
|
||||
const nodeNotifier = require('node-notifier')
|
||||
const path = require('path')
|
||||
const HTMLEntities = require('html-entities')
|
||||
|
||||
class Chat
|
||||
@@ -10,6 +8,8 @@ class Chat
|
||||
{
|
||||
this.config = _config
|
||||
this.slug = _options.slug
|
||||
this.watcherSocket = _options.watcherSocket
|
||||
|
||||
this.users = {}
|
||||
this.messages = []
|
||||
this.availableRobotNames = this.shuffle(robotNames.slice())
|
||||
@@ -100,12 +100,8 @@ 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
|
||||
})
|
||||
// Transfer to the watcher socket
|
||||
this.watcherSocket.emit('alert')
|
||||
|
||||
// Debug
|
||||
if(this.config.debug >= 1)
|
||||
|
||||
@@ -218,6 +218,7 @@ class App
|
||||
// Start project
|
||||
socket.on('start_project', (data) =>
|
||||
{
|
||||
data.watcherSocket = socket // Add watcher socket
|
||||
project = this.projects.createProject(data)
|
||||
|
||||
this.site.createProjectRoute(project)
|
||||
|
||||
+2
-1
@@ -13,6 +13,7 @@ class Project
|
||||
{
|
||||
this.config = _config
|
||||
this.path = _options.path
|
||||
this.watcherSocket = _options.watcherSocket
|
||||
|
||||
this.setName(_options.name)
|
||||
this.setSocket()
|
||||
@@ -20,7 +21,7 @@ class Project
|
||||
this.excludeRegex = new RegExp(_options.excludeRegex)
|
||||
this.zipNeedsUpdate = true
|
||||
this.files = new Files(this.config, { projectSocket: this.projectSocket })
|
||||
this.chat = new Chat(this.config, { slug: this.slug })
|
||||
this.chat = new Chat(this.config, { slug: this.slug, watcherSocket: this.watcherSocket })
|
||||
this.date = new Date()
|
||||
|
||||
// Add test contents
|
||||
|
||||
@@ -4,6 +4,8 @@ const fs = require('fs')
|
||||
const mime = require('mime')
|
||||
const socketIoClient = require('socket.io-client')
|
||||
const opener = require('opener')
|
||||
const nodeNotifier = require('node-notifier')
|
||||
const path = require('path')
|
||||
|
||||
/**
|
||||
* Watcher class
|
||||
@@ -64,6 +66,17 @@ class Watcher
|
||||
opener(url)
|
||||
}
|
||||
})
|
||||
|
||||
// Alert event
|
||||
this.socket.on('alert', () =>
|
||||
{
|
||||
nodeNotifier.notify({
|
||||
title: 'Keppler',
|
||||
message: 'Alert!',
|
||||
icon: path.join(__dirname, 'assets/images/notification-icon-200x200.png'),
|
||||
wait: true
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
setExcludeRegex()
|
||||
|
||||
Reference in New Issue
Block a user