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