diff --git a/mattermost/bathroom.tar.gz b/mattermost/bathroom.tar.gz index bb856c1..8eba6fd 100644 --- a/mattermost/bathroom.tar.gz +++ b/mattermost/bathroom.tar.gz Binary files differ diff --git a/mattermost/bathroom.tar.gz b/mattermost/bathroom.tar.gz index bb856c1..8eba6fd 100644 --- a/mattermost/bathroom.tar.gz +++ b/mattermost/bathroom.tar.gz Binary files differ diff --git a/mattermost/server/bathroom-linux-amd64 b/mattermost/server/bathroom-linux-amd64 index 481ef68..4a5b7d9 100755 --- a/mattermost/server/bathroom-linux-amd64 +++ b/mattermost/server/bathroom-linux-amd64 Binary files differ diff --git a/mattermost/bathroom.tar.gz b/mattermost/bathroom.tar.gz index bb856c1..8eba6fd 100644 --- a/mattermost/bathroom.tar.gz +++ b/mattermost/bathroom.tar.gz Binary files differ diff --git a/mattermost/server/bathroom-linux-amd64 b/mattermost/server/bathroom-linux-amd64 index 481ef68..4a5b7d9 100755 --- a/mattermost/server/bathroom-linux-amd64 +++ b/mattermost/server/bathroom-linux-amd64 Binary files differ diff --git a/mattermost/server/bathroom.go b/mattermost/server/bathroom.go index 2ed6e07..5be0d1c 100644 --- a/mattermost/server/bathroom.go +++ b/mattermost/server/bathroom.go @@ -184,7 +184,8 @@ if POST_STATUS_TO_ADMIN { p.postAdminChannel(fmt.Sprintf("STATUS: door %d = %s", id, statusStr)) } - p.API.PublishWebSocketEvent("updated", map[string]interface{}{}, &model.WebsocketBroadcast{}) + p.sendUpdate() + go p.resendUpdate(10 * time.Second) } } else { p.log(fmt.Sprintf("Asked to change status from %d to %d ?", p.doors[id - 1].status, status)) @@ -193,6 +194,17 @@ return nil } +func (p *BathroomMonitorPlugin) sendUpdate() { + p.API.PublishWebSocketEvent("updated", map[string]interface{}{}, &model.WebsocketBroadcast{}) +} + +func (p *BathroomMonitorPlugin) resendUpdate(wait time.Duration) { + timer := time.NewTimer(wait) + <-timer.C + p.sendUpdate() +} + + func (p *BathroomMonitorPlugin) init() *BathroomMonitorPlugin { p.config = &Config { NumDoors: "1", diff --git a/mattermost/bathroom.tar.gz b/mattermost/bathroom.tar.gz index bb856c1..8eba6fd 100644 --- a/mattermost/bathroom.tar.gz +++ b/mattermost/bathroom.tar.gz Binary files differ diff --git a/mattermost/server/bathroom-linux-amd64 b/mattermost/server/bathroom-linux-amd64 index 481ef68..4a5b7d9 100755 --- a/mattermost/server/bathroom-linux-amd64 +++ b/mattermost/server/bathroom-linux-amd64 Binary files differ diff --git a/mattermost/server/bathroom.go b/mattermost/server/bathroom.go index 2ed6e07..5be0d1c 100644 --- a/mattermost/server/bathroom.go +++ b/mattermost/server/bathroom.go @@ -184,7 +184,8 @@ if POST_STATUS_TO_ADMIN { p.postAdminChannel(fmt.Sprintf("STATUS: door %d = %s", id, statusStr)) } - p.API.PublishWebSocketEvent("updated", map[string]interface{}{}, &model.WebsocketBroadcast{}) + p.sendUpdate() + go p.resendUpdate(10 * time.Second) } } else { p.log(fmt.Sprintf("Asked to change status from %d to %d ?", p.doors[id - 1].status, status)) @@ -193,6 +194,17 @@ return nil } +func (p *BathroomMonitorPlugin) sendUpdate() { + p.API.PublishWebSocketEvent("updated", map[string]interface{}{}, &model.WebsocketBroadcast{}) +} + +func (p *BathroomMonitorPlugin) resendUpdate(wait time.Duration) { + timer := time.NewTimer(wait) + <-timer.C + p.sendUpdate() +} + + func (p *BathroomMonitorPlugin) init() *BathroomMonitorPlugin { p.config = &Config { NumDoors: "1", diff --git a/mattermost/webapp/dist/main.js b/mattermost/webapp/dist/main.js index 35f1cbe..8e71199 100644 --- a/mattermost/webapp/dist/main.js +++ b/mattermost/webapp/dist/main.js @@ -131,7 +131,7 @@ Registry.registerWebSocketEventHandler("custom_com.mattermost.bathroom_updated", this.updateDoors.bind(this)); this.updateDoors(); - this.interval = setInterval(this.updateDoors.bind(this), 30000); + this.interval = setInterval(this.updateDoors.bind(this), 90000); } componentWillUnmount() { diff --git a/mattermost/bathroom.tar.gz b/mattermost/bathroom.tar.gz index bb856c1..8eba6fd 100644 --- a/mattermost/bathroom.tar.gz +++ b/mattermost/bathroom.tar.gz Binary files differ diff --git a/mattermost/server/bathroom-linux-amd64 b/mattermost/server/bathroom-linux-amd64 index 481ef68..4a5b7d9 100755 --- a/mattermost/server/bathroom-linux-amd64 +++ b/mattermost/server/bathroom-linux-amd64 Binary files differ diff --git a/mattermost/server/bathroom.go b/mattermost/server/bathroom.go index 2ed6e07..5be0d1c 100644 --- a/mattermost/server/bathroom.go +++ b/mattermost/server/bathroom.go @@ -184,7 +184,8 @@ if POST_STATUS_TO_ADMIN { p.postAdminChannel(fmt.Sprintf("STATUS: door %d = %s", id, statusStr)) } - p.API.PublishWebSocketEvent("updated", map[string]interface{}{}, &model.WebsocketBroadcast{}) + p.sendUpdate() + go p.resendUpdate(10 * time.Second) } } else { p.log(fmt.Sprintf("Asked to change status from %d to %d ?", p.doors[id - 1].status, status)) @@ -193,6 +194,17 @@ return nil } +func (p *BathroomMonitorPlugin) sendUpdate() { + p.API.PublishWebSocketEvent("updated", map[string]interface{}{}, &model.WebsocketBroadcast{}) +} + +func (p *BathroomMonitorPlugin) resendUpdate(wait time.Duration) { + timer := time.NewTimer(wait) + <-timer.C + p.sendUpdate() +} + + func (p *BathroomMonitorPlugin) init() *BathroomMonitorPlugin { p.config = &Config { NumDoors: "1", diff --git a/mattermost/webapp/dist/main.js b/mattermost/webapp/dist/main.js index 35f1cbe..8e71199 100644 --- a/mattermost/webapp/dist/main.js +++ b/mattermost/webapp/dist/main.js @@ -131,7 +131,7 @@ Registry.registerWebSocketEventHandler("custom_com.mattermost.bathroom_updated", this.updateDoors.bind(this)); this.updateDoors(); - this.interval = setInterval(this.updateDoors.bind(this), 30000); + this.interval = setInterval(this.updateDoors.bind(this), 90000); } componentWillUnmount() { diff --git a/mattermost/webapp/dist/main.js.map b/mattermost/webapp/dist/main.js.map index c8ea70c..4ac2bfd 100644 --- a/mattermost/webapp/dist/main.js.map +++ b/mattermost/webapp/dist/main.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./src/index.jsx","webpack:///external \"React\""],"names":["BathroomComponent","React","Component","constructor","props","hostTable","createRef","headerLeft","headerCenter","headerRight","state","doors","settings","componentDidMount","getSettings","resizeTable","url","window","location","origin","res","fetch","json","e","console","log","setTimeout","bind","Registry","registerWebSocketEventHandler","updateDoors","interval","setInterval","componentWillUnmount","clearInterval","unregisterWebSocketEventHandler","msg","setState","render","borderString","theme","sidebarText","Host","width","icon","content","columns","keys","Object","sort","Math","floor","widthPx","elems","row","rows","IconImg","src","title","totalRows","length","i","img","key","door","imgFile","push","info_icon","componentDidUpdate","current","max","clientWidth","Store","BathroomMonitorPlugin","initialize","registry","store","registerLeftSidebarHeaderComponent","registerPlugin"],"mappings":";QAAA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;;QAEA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;;;QAGA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA,0CAA0C,gCAAgC;QAC1E;QACA;;QAEA;QACA;QACA;QACA,wDAAwD,kBAAkB;QAC1E;QACA,iDAAiD,cAAc;QAC/D;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA,yCAAyC,iCAAiC;QAC1E,gHAAgH,mBAAmB,EAAE;QACrI;QACA;;QAEA;QACA;QACA;QACA,2BAA2B,0BAA0B,EAAE;QACvD,iCAAiC,eAAe;QAChD;QACA;QACA;;QAEA;QACA,sDAAsD,+DAA+D;;QAErH;QACA;;;QAGA;QACA;;;;;;;;;;;;;;;AClFA;;;;AAEA,MAAMA,iBAAN,SAAgCC,eAAMC,SAAtC,CACA;AACIC,aAAW,CAACC,KAAD,EACX;AACI,UAAMA,KAAN;AAEA,SAAKC,SAAL,GAAiBJ,eAAMK,SAAN,EAAjB;AACA,SAAKC,UAAL,GAAkBN,eAAMK,SAAN,EAAlB;AACA,SAAKE,YAAL,GAAoBP,eAAMK,SA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IAAZ;;AAEA,MAAMC,qBAAN,CACA;AACIC,YAAU,CAACC,QAAD,EAAWC,KAAX,EACV;AACIhD,YAAQ,GAAG+C,QAAX;AACAH,SAAK,GAAGI,KAAR;AACAD,YAAQ,CAACE,kCAAT,CAA4C7E,iBAA5C;AACH;;AANL;;AASAiB,MAAM,CAAC6D,cAAP,CAAsB,yBAAtB,EAAiD,IAAIL,qBAAJ,EAAjD,E;;;;;;;;;;;;;;;;;;;;;;;AC/JA,uB","file":"main.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"/\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 0);\n","import React from 'react';\n\nclass BathroomComponent extends React.Component\n{\n constructor(props)\n {\n super(props);\n\n this.hostTable = React.createRef();\n this.headerLeft = React.createRef();\n this.headerCenter = React.createRef();\n this.headerRight = React.createRef();\n this.state = {doors:{}};\n this.settings = {};\n }\n componentDidMount()\n {\n this.getSettings();\n this.resizeTable();\n }\n async getSettings()\n {\n try\n {\n\n var url = window.location.origin + \"/plugins/com.mattermost.bathroom/settings\";\n var res = await fetch(url);\n this.settings = await res.json();\n }\n catch (e)\n {\n console.log(e);\n setTimeout(this.getSettings.bind(this), 5000);\n return;\n }\n\n Registry.registerWebSocketEventHandler(\"custom_com.mattermost.bathroom_updated\", this.updateDoors.bind(this));\n this.updateDoors();\n this.interval = setInterval(this.updateDoors.bind(this), 30000);\n }\n componentWillUnmount()\n {\n if (this.interval)\n {\n clearInterval(this.interval);\n this.interval = null;\n }\n Registry.unregisterWebSocketEventHandler(\"custom_com.mattermost.bathroom_updated\");\n }\n async updateDoors(msg)\n {\n //var url = Store.getState().entities.general.config.SiteURL + \"/plugins/com.mattermost.bathroom/status\";\n try\n {\n var url = window.location.origin + \"/plugins/com.mattermost.bathroom/status\";\n var res = await fetch(url);\n var json = await res.json();\n this.setState({\"doors\":json});\n }\n catch (e)\n {\n console.log(e);\n setTimeout(this.updateDoors.bind(this), 3000);\n }\n }\n render()\n {\n if (!this.state.doors) return;\n\n var borderString = \"1px solid \" + this.props.theme.sidebarText;\n\n var Host = props =>\n
\n \n \n \n \n \n \n\n \n \n \n \n \n \n \n
{props.content}
\n
;\n\n var columns = 6;\n var keys = Object.keys(this.state.doors).sort();\n var width = Math.floor(100 / (columns /*+ 1*/)) + \"%\";\n var widthPx = \"23px\";\n var elems = [];\n var row = [];\n var rows = 0;\n var IconImg = props => ;\n var totalRows = Math.floor(keys.length / columns) + 1;\n for (var i = 0; i < keys.length /*(Math.floor(keys.length / 6) + 1) * 6*/; i++)\n {\n var img = null;\n if (i < keys.length)\n {\n var key = keys[i];\n var door = this.state.doors[key];\n var imgFile = this.settings[door + \"_icon\"];\n if (imgFile)\n {\n img = ;\n //img = \n }\n }\n row.push({img});\n if (i % columns == columns - 1 || i == keys.length - 1)\n {\n /*\n if (rows == 0)\n {\n row.unshift(\n //\n :\n );\n }\n */\n elems.push({[...row]});\n row.length = 0;\n rows++;\n }\n }\n var content =\n \n {elems}\n
\n return ;\n }\n componentDidUpdate()\n {\n this.resizeTable();\n }\n resizeTable()\n {\n this.headerLeft.current.width = this.headerRight.current.width = Math.max(50, (this.hostTable.current.clientWidth - this.headerCenter.current.clientWidth) / 2);\n }\n}\n\nvar Registry = null;\nvar Store = null;\n\nclass BathroomMonitorPlugin\n{\n initialize(registry, store)\n {\n Registry = registry;\n Store = store;\n registry.registerLeftSidebarHeaderComponent(BathroomComponent);\n }\n}\n\nwindow.registerPlugin('com.mattermost.bathroom', new BathroomMonitorPlugin());\n","module.exports = React;"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./src/index.jsx","webpack:///external \"React\""],"names":["BathroomComponent","React","Component","constructor","props","hostTable","createRef","headerLeft","headerCenter","headerRight","state","doors","settings","componentDidMount","getSettings","resizeTable","url","window","location","origin","res","fetch","json","e","console","log","setTimeout","bind","Registry","registerWebSocketEventHandler","updateDoors","interval","setInterval","componentWillUnmount","clearInterval","unregisterWebSocketEventHandler","msg","setState","render","borderString","theme","sidebarText","Host","width","icon","content","columns","keys","Object","sort","Math","floor","widthPx","elems","row","rows","IconImg","src","title","totalRows","length","i","img","key","door","imgFile","push","info_icon","componentDidUpdate","current","max","clientWidth","Store","BathroomMonitorPlugin","initialize","registry","store","registerLeftSidebarHeaderComponent","registerPlugin"],"mappings":";QAAA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;;QAEA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;;;QAGA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA,0CAA0C,gCAAgC;QAC1E;QACA;;QAEA;QACA;QACA;QACA,wDAAwD,kBAAkB;QAC1E;QACA,iDAAiD,cAAc;QAC/D;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA,yCAAyC,iCAAiC;QAC1E,gHAAgH,mBAAmB,EAAE;QACrI;QACA;;QAEA;QACA;QACA;QACA,2BAA2B,0BAA0B,EAAE;QACvD,iCAAiC,eAAe;QAChD;QACA;QACA;;QAEA;QACA,sDAAsD,+DAA+D;;QAErH;QACA;;;QAGA;QACA;;;;;;;;;;;;;;;AClFA;;;;AAEA,MAAMA,iBAAN,SAAgCC,eAAMC,SAAtC,CACA;AACIC,aAAW,CAACC,KAAD,EACX;AACI,UAAMA,KAAN;AAEA,SAAKC,SAAL,GAAiBJ,eAAMK,SAAN,EAAjB;AACA,SAAKC,UAAL,GAAkBN,eAAMK,SAAN,EAAlB;A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AG,IAAf;AACA,IAAI4C,KAAK,GAAG,IAAZ;;AAEA,MAAMC,qBAAN,CACA;AACIC,YAAU,CAACC,QAAD,EAAWC,KAAX,EACV;AACIhD,YAAQ,GAAG+C,QAAX;AACAH,SAAK,GAAGI,KAAR;AACAD,YAAQ,CAACE,kCAAT,CAA4C7E,iBAA5C;AACH;;AANL;;AASAiB,MAAM,CAAC6D,cAAP,CAAsB,yBAAtB,EAAiD,IAAIL,qBAAJ,EAAjD,E;;;;;;;;;;;;;;;;;;;;;;;AC/JA,uB","file":"main.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"/\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 0);\n","import React from 'react';\n\nclass BathroomComponent extends React.Component\n{\n constructor(props)\n {\n super(props);\n\n this.hostTable = React.createRef();\n this.headerLeft = React.createRef();\n this.headerCenter = React.createRef();\n this.headerRight = React.createRef();\n this.state = {doors:{}};\n this.settings = {};\n }\n componentDidMount()\n {\n this.getSettings();\n this.resizeTable();\n }\n async getSettings()\n {\n try\n {\n\n var url = window.location.origin + \"/plugins/com.mattermost.bathroom/settings\";\n var res = await fetch(url);\n this.settings = await res.json();\n }\n catch (e)\n {\n console.log(e);\n setTimeout(this.getSettings.bind(this), 5000);\n return;\n }\n\n Registry.registerWebSocketEventHandler(\"custom_com.mattermost.bathroom_updated\", this.updateDoors.bind(this));\n this.updateDoors();\n this.interval = setInterval(this.updateDoors.bind(this), 90000);\n }\n componentWillUnmount()\n {\n if (this.interval)\n {\n clearInterval(this.interval);\n this.interval = null;\n }\n Registry.unregisterWebSocketEventHandler(\"custom_com.mattermost.bathroom_updated\");\n }\n async updateDoors(msg)\n {\n //var url = Store.getState().entities.general.config.SiteURL + \"/plugins/com.mattermost.bathroom/status\";\n try\n {\n var url = window.location.origin + \"/plugins/com.mattermost.bathroom/status\";\n var res = await fetch(url);\n var json = await res.json();\n this.setState({\"doors\":json});\n }\n catch (e)\n {\n console.log(e);\n setTimeout(this.updateDoors.bind(this), 3000);\n }\n }\n render()\n {\n if (!this.state.doors) return;\n\n var borderString = \"1px solid \" + this.props.theme.sidebarText;\n\n var Host = props =>\n
\n \n \n \n \n \n \n\n \n \n \n \n \n \n \n
{props.content}
\n
;\n\n var columns = 6;\n var keys = Object.keys(this.state.doors).sort();\n var width = Math.floor(100 / (columns /*+ 1*/)) + \"%\";\n var widthPx = \"23px\";\n var elems = [];\n var row = [];\n var rows = 0;\n var IconImg = props => ;\n var totalRows = Math.floor(keys.length / columns) + 1;\n for (var i = 0; i < keys.length /*(Math.floor(keys.length / 6) + 1) * 6*/; i++)\n {\n var img = null;\n if (i < keys.length)\n {\n var key = keys[i];\n var door = this.state.doors[key];\n var imgFile = this.settings[door + \"_icon\"];\n if (imgFile)\n {\n img = ;\n //img = \n }\n }\n row.push({img});\n if (i % columns == columns - 1 || i == keys.length - 1)\n {\n /*\n if (rows == 0)\n {\n row.unshift(\n //\n :\n );\n }\n */\n elems.push({[...row]});\n row.length = 0;\n rows++;\n }\n }\n var content =\n \n {elems}\n
\n return ;\n }\n componentDidUpdate()\n {\n this.resizeTable();\n }\n resizeTable()\n {\n this.headerLeft.current.width = this.headerRight.current.width = Math.max(50, (this.hostTable.current.clientWidth - this.headerCenter.current.clientWidth) / 2);\n }\n}\n\nvar Registry = null;\nvar Store = null;\n\nclass BathroomMonitorPlugin\n{\n initialize(registry, store)\n {\n Registry = registry;\n Store = store;\n registry.registerLeftSidebarHeaderComponent(BathroomComponent);\n }\n}\n\nwindow.registerPlugin('com.mattermost.bathroom', new BathroomMonitorPlugin());\n","module.exports = React;"],"sourceRoot":""} \ No newline at end of file diff --git a/mattermost/bathroom.tar.gz b/mattermost/bathroom.tar.gz index bb856c1..8eba6fd 100644 --- a/mattermost/bathroom.tar.gz +++ b/mattermost/bathroom.tar.gz Binary files differ diff --git a/mattermost/server/bathroom-linux-amd64 b/mattermost/server/bathroom-linux-amd64 index 481ef68..4a5b7d9 100755 --- a/mattermost/server/bathroom-linux-amd64 +++ b/mattermost/server/bathroom-linux-amd64 Binary files differ diff --git a/mattermost/server/bathroom.go b/mattermost/server/bathroom.go index 2ed6e07..5be0d1c 100644 --- a/mattermost/server/bathroom.go +++ b/mattermost/server/bathroom.go @@ -184,7 +184,8 @@ if POST_STATUS_TO_ADMIN { p.postAdminChannel(fmt.Sprintf("STATUS: door %d = %s", id, statusStr)) } - p.API.PublishWebSocketEvent("updated", map[string]interface{}{}, &model.WebsocketBroadcast{}) + p.sendUpdate() + go p.resendUpdate(10 * time.Second) } } else { p.log(fmt.Sprintf("Asked to change status from %d to %d ?", p.doors[id - 1].status, status)) @@ -193,6 +194,17 @@ return nil } +func (p *BathroomMonitorPlugin) sendUpdate() { + p.API.PublishWebSocketEvent("updated", map[string]interface{}{}, &model.WebsocketBroadcast{}) +} + +func (p *BathroomMonitorPlugin) resendUpdate(wait time.Duration) { + timer := time.NewTimer(wait) + <-timer.C + p.sendUpdate() +} + + func (p *BathroomMonitorPlugin) init() *BathroomMonitorPlugin { p.config = &Config { NumDoors: "1", diff --git a/mattermost/webapp/dist/main.js b/mattermost/webapp/dist/main.js index 35f1cbe..8e71199 100644 --- a/mattermost/webapp/dist/main.js +++ b/mattermost/webapp/dist/main.js @@ -131,7 +131,7 @@ Registry.registerWebSocketEventHandler("custom_com.mattermost.bathroom_updated", this.updateDoors.bind(this)); this.updateDoors(); - this.interval = setInterval(this.updateDoors.bind(this), 30000); + this.interval = setInterval(this.updateDoors.bind(this), 90000); } componentWillUnmount() { diff --git a/mattermost/webapp/dist/main.js.map b/mattermost/webapp/dist/main.js.map index c8ea70c..4ac2bfd 100644 --- a/mattermost/webapp/dist/main.js.map +++ b/mattermost/webapp/dist/main.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./src/index.jsx","webpack:///external \"React\""],"names":["BathroomComponent","React","Component","constructor","props","hostTable","createRef","headerLeft","headerCenter","headerRight","state","doors","settings","componentDidMount","getSettings","resizeTable","url","window","location","origin","res","fetch","json","e","console","log","setTimeout","bind","Registry","registerWebSocketEventHandler","updateDoors","interval","setInterval","componentWillUnmount","clearInterval","unregisterWebSocketEventHandler","msg","setState","render","borderString","theme","sidebarText","Host","width","icon","content","columns","keys","Object","sort","Math","floor","widthPx","elems","row","rows","IconImg","src","title","totalRows","length","i","img","key","door","imgFile","push","info_icon","componentDidUpdate","current","max","clientWidth","Store","BathroomMonitorPlugin","initialize","registry","store","registerLeftSidebarHeaderComponent","registerPlugin"],"mappings":";QAAA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;;QAEA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;;;QAGA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA,0CAA0C,gCAAgC;QAC1E;QACA;;QAEA;QACA;QACA;QACA,wDAAwD,kBAAkB;QAC1E;QACA,iDAAiD,cAAc;QAC/D;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA,yCAAyC,iCAAiC;QAC1E,gHAAgH,mBAAmB,EAAE;QACrI;QACA;;QAEA;QACA;QACA;QACA,2BAA2B,0BAA0B,EAAE;QACvD,iCAAiC,eAAe;QAChD;QACA;QACA;;QAEA;QACA,sDAAsD,+DAA+D;;QAErH;QACA;;;QAGA;QACA;;;;;;;;;;;;;;;AClFA;;;;AAEA,MAAMA,iBAAN,SAAgCC,eAAMC,SAAtC,CACA;AACIC,aAAW,CAACC,KAAD,EACX;AACI,UAAMA,KAAN;AAEA,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AkB6D,OAAlB,CAA0BE,WAAhE,IAA+E,CAA5F,CAAjE;AACH;;AA5IL;;AA+IA,IAAI3C,QAAQ,GAAG,IAAf;AACA,IAAI4C,KAAK,GAAG,IAAZ;;AAEA,MAAMC,qBAAN,CACA;AACIC,YAAU,CAACC,QAAD,EAAWC,KAAX,EACV;AACIhD,YAAQ,GAAG+C,QAAX;AACAH,SAAK,GAAGI,KAAR;AACAD,YAAQ,CAACE,kCAAT,CAA4C7E,iBAA5C;AACH;;AANL;;AASAiB,MAAM,CAAC6D,cAAP,CAAsB,yBAAtB,EAAiD,IAAIL,qBAAJ,EAAjD,E;;;;;;;;;;;;;;;;;;;;;;;AC/JA,uB","file":"main.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"/\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 0);\n","import React from 'react';\n\nclass BathroomComponent extends React.Component\n{\n constructor(props)\n {\n super(props);\n\n this.hostTable = React.createRef();\n this.headerLeft = React.createRef();\n this.headerCenter = React.createRef();\n this.headerRight = React.createRef();\n this.state = {doors:{}};\n this.settings = {};\n }\n componentDidMount()\n {\n this.getSettings();\n this.resizeTable();\n }\n async getSettings()\n {\n try\n {\n\n var url = window.location.origin + \"/plugins/com.mattermost.bathroom/settings\";\n var res = await fetch(url);\n this.settings = await res.json();\n }\n catch (e)\n {\n console.log(e);\n setTimeout(this.getSettings.bind(this), 5000);\n return;\n }\n\n Registry.registerWebSocketEventHandler(\"custom_com.mattermost.bathroom_updated\", this.updateDoors.bind(this));\n this.updateDoors();\n this.interval = setInterval(this.updateDoors.bind(this), 30000);\n }\n componentWillUnmount()\n {\n if (this.interval)\n {\n clearInterval(this.interval);\n this.interval = null;\n }\n Registry.unregisterWebSocketEventHandler(\"custom_com.mattermost.bathroom_updated\");\n }\n async updateDoors(msg)\n {\n //var url = Store.getState().entities.general.config.SiteURL + \"/plugins/com.mattermost.bathroom/status\";\n try\n {\n var url = window.location.origin + \"/plugins/com.mattermost.bathroom/status\";\n var res = await fetch(url);\n var json = await res.json();\n this.setState({\"doors\":json});\n }\n catch (e)\n {\n console.log(e);\n setTimeout(this.updateDoors.bind(this), 3000);\n }\n }\n render()\n {\n if (!this.state.doors) return;\n\n var borderString = \"1px solid \" + this.props.theme.sidebarText;\n\n var Host = props =>\n
\n \n \n \n \n \n \n\n \n \n \n \n \n \n \n
{props.content}
\n
;\n\n var columns = 6;\n var keys = Object.keys(this.state.doors).sort();\n var width = Math.floor(100 / (columns /*+ 1*/)) + \"%\";\n var widthPx = \"23px\";\n var elems = [];\n var row = [];\n var rows = 0;\n var IconImg = props => ;\n var totalRows = Math.floor(keys.length / columns) + 1;\n for (var i = 0; i < keys.length /*(Math.floor(keys.length / 6) + 1) * 6*/; i++)\n {\n var img = null;\n if (i < keys.length)\n {\n var key = keys[i];\n var door = this.state.doors[key];\n var imgFile = this.settings[door + \"_icon\"];\n if (imgFile)\n {\n img = ;\n //img = \n }\n }\n row.push({img});\n if (i % columns == columns - 1 || i == keys.length - 1)\n {\n /*\n if (rows == 0)\n {\n row.unshift(\n //\n :\n );\n }\n */\n elems.push({[...row]});\n row.length = 0;\n rows++;\n }\n }\n var content =\n \n {elems}\n
\n return ;\n }\n componentDidUpdate()\n {\n this.resizeTable();\n }\n resizeTable()\n {\n this.headerLeft.current.width = this.headerRight.current.width = Math.max(50, (this.hostTable.current.clientWidth - this.headerCenter.current.clientWidth) / 2);\n }\n}\n\nvar Registry = null;\nvar Store = null;\n\nclass BathroomMonitorPlugin\n{\n initialize(registry, store)\n {\n Registry = registry;\n Store = store;\n registry.registerLeftSidebarHeaderComponent(BathroomComponent);\n }\n}\n\nwindow.registerPlugin('com.mattermost.bathroom', new BathroomMonitorPlugin());\n","module.exports = React;"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./src/index.jsx","webpack:///external \"React\""],"names":["BathroomComponent","React","Component","constructor","props","hostTable","createRef","headerLeft","headerCenter","headerRight","state","doors","settings","componentDidMount","getSettings","resizeTable","url","window","location","origin","res","fetch","json","e","console","log","setTimeout","bind","Registry","registerWebSocketEventHandler","updateDoors","interval","setInterval","componentWillUnmount","clearInterval","unregisterWebSocketEventHandler","msg","setState","render","borderString","theme","sidebarText","Host","width","icon","content","columns","keys","Object","sort","Math","floor","widthPx","elems","row","rows","IconImg","src","title","totalRows","length","i","img","key","door","imgFile","push","info_icon","componentDidUpdate","current","max","clientWidth","Store","BathroomMonitorPlugin","initialize","registry","store","registerLeftSidebarHeaderComponent","registerPlugin"],"mappings":";QAAA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;;QAEA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;;;QAGA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA,0CAA0C,gCAAgC;QAC1E;QACA;;QAEA;QACA;QACA;QACA,wDAAwD,kBAAkB;QAC1E;QACA,iDAAiD,cAAc;QAC/D;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA,yCAAyC,iCAAiC;QAC1E,gHAAgH,mBAAmB,EAAE;QACrI;QACA;;QAEA;QACA;QACA;QACA,2BAA2B,0BAA0B,EAAE;QACvD,iCAAiC,eAAe;QAChD;QACA;QACA;;QAEA;QACA,sDAAsD,+DAA+D;;QAErH;QACA;;;QAGA;QACA;;;;;;;;;;;;;;;AClFA;;;;AAEA,MAAMA,iBAAN,SAAgCC,eAAMC,SAAtC,CACA;AACIC,aAAW,CAACC,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BE,WAAvB,GAAqC,KAAK/D,YAAL,CAAkB6D,OAAlB,CAA0BE,WAAhE,IAA+E,CAA5F,CAAjE;AACH;;AA5IL;;AA+IA,IAAI3C,QAAQ,GAAG,IAAf;AACA,IAAI4C,KAAK,GAAG,IAAZ;;AAEA,MAAMC,qBAAN,CACA;AACIC,YAAU,CAACC,QAAD,EAAWC,KAAX,EACV;AACIhD,YAAQ,GAAG+C,QAAX;AACAH,SAAK,GAAGI,KAAR;AACAD,YAAQ,CAACE,kCAAT,CAA4C7E,iBAA5C;AACH;;AANL;;AASAiB,MAAM,CAAC6D,cAAP,CAAsB,yBAAtB,EAAiD,IAAIL,qBAAJ,EAAjD,E;;;;;;;;;;;;;;;;;;;;;;;AC/JA,uB","file":"main.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"/\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 0);\n","import React from 'react';\n\nclass BathroomComponent extends React.Component\n{\n constructor(props)\n {\n super(props);\n\n this.hostTable = React.createRef();\n this.headerLeft = React.createRef();\n this.headerCenter = React.createRef();\n this.headerRight = React.createRef();\n this.state = {doors:{}};\n this.settings = {};\n }\n componentDidMount()\n {\n this.getSettings();\n this.resizeTable();\n }\n async getSettings()\n {\n try\n {\n\n var url = window.location.origin + \"/plugins/com.mattermost.bathroom/settings\";\n var res = await fetch(url);\n this.settings = await res.json();\n }\n catch (e)\n {\n console.log(e);\n setTimeout(this.getSettings.bind(this), 5000);\n return;\n }\n\n Registry.registerWebSocketEventHandler(\"custom_com.mattermost.bathroom_updated\", this.updateDoors.bind(this));\n this.updateDoors();\n this.interval = setInterval(this.updateDoors.bind(this), 90000);\n }\n componentWillUnmount()\n {\n if (this.interval)\n {\n clearInterval(this.interval);\n this.interval = null;\n }\n Registry.unregisterWebSocketEventHandler(\"custom_com.mattermost.bathroom_updated\");\n }\n async updateDoors(msg)\n {\n //var url = Store.getState().entities.general.config.SiteURL + \"/plugins/com.mattermost.bathroom/status\";\n try\n {\n var url = window.location.origin + \"/plugins/com.mattermost.bathroom/status\";\n var res = await fetch(url);\n var json = await res.json();\n this.setState({\"doors\":json});\n }\n catch (e)\n {\n console.log(e);\n setTimeout(this.updateDoors.bind(this), 3000);\n }\n }\n render()\n {\n if (!this.state.doors) return;\n\n var borderString = \"1px solid \" + this.props.theme.sidebarText;\n\n var Host = props =>\n
\n \n \n \n \n \n \n\n \n \n \n \n \n \n \n
{props.content}
\n
;\n\n var columns = 6;\n var keys = Object.keys(this.state.doors).sort();\n var width = Math.floor(100 / (columns /*+ 1*/)) + \"%\";\n var widthPx = \"23px\";\n var elems = [];\n var row = [];\n var rows = 0;\n var IconImg = props => ;\n var totalRows = Math.floor(keys.length / columns) + 1;\n for (var i = 0; i < keys.length /*(Math.floor(keys.length / 6) + 1) * 6*/; i++)\n {\n var img = null;\n if (i < keys.length)\n {\n var key = keys[i];\n var door = this.state.doors[key];\n var imgFile = this.settings[door + \"_icon\"];\n if (imgFile)\n {\n img = ;\n //img = \n }\n }\n row.push({img});\n if (i % columns == columns - 1 || i == keys.length - 1)\n {\n /*\n if (rows == 0)\n {\n row.unshift(\n //\n :\n );\n }\n */\n elems.push({[...row]});\n row.length = 0;\n rows++;\n }\n }\n var content =\n \n {elems}\n
\n return ;\n }\n componentDidUpdate()\n {\n this.resizeTable();\n }\n resizeTable()\n {\n this.headerLeft.current.width = this.headerRight.current.width = Math.max(50, (this.hostTable.current.clientWidth - this.headerCenter.current.clientWidth) / 2);\n }\n}\n\nvar Registry = null;\nvar Store = null;\n\nclass BathroomMonitorPlugin\n{\n initialize(registry, store)\n {\n Registry = registry;\n Store = store;\n registry.registerLeftSidebarHeaderComponent(BathroomComponent);\n }\n}\n\nwindow.registerPlugin('com.mattermost.bathroom', new BathroomMonitorPlugin());\n","module.exports = React;"],"sourceRoot":""} \ No newline at end of file diff --git a/mattermost/webapp/src/index.jsx b/mattermost/webapp/src/index.jsx index b87f43a..f2af10b 100644 --- a/mattermost/webapp/src/index.jsx +++ b/mattermost/webapp/src/index.jsx @@ -36,7 +36,7 @@ Registry.registerWebSocketEventHandler("custom_com.mattermost.bathroom_updated", this.updateDoors.bind(this)); this.updateDoors(); - this.interval = setInterval(this.updateDoors.bind(this), 30000); + this.interval = setInterval(this.updateDoors.bind(this), 90000); } componentWillUnmount() {