juhamust / mozaik-ext-slack Goto Github PK
View Code? Open in Web Editor NEWSlack widgets to Mozaik dashboard
Slack widgets to Mozaik dashboard
Currently bot_message is not handled,
there is a warning 'User and/or channel not found. Message from private channel?'
bot_message has no property user, only bot_id
With a stock mozaik dashboard of mozaik-demo getting a crash as soon as the page is loaded.
$ node app.js
info: registered API 'mozaik' (mode: poll)
info: registered API 'slack' (mode: poll)
info: serving static contents from /Users/stephenthoma/code/mozaik-demo/build
info: Mozaïk server listening at http://0.0.0.0:5000
info: Loaded slack 32 channels
info: Loaded 146 slack users
info: Started listening Slack events
info: Client #1 connected
info: Added subscription 'slack.message'
info: Calling 'slack.message'
/Users/stephenthoma/code/mozaik-demo/node_modules/mozaik/src/Bus.js:132
callFn(params).then(function (data) {
^
TypeError: Cannot read property 'then' of undefined
at processApiCall (Bus.js:118:9)
at Object.clientSubscription (Bus.js:189:17)
at WebSocket.<anonymous> (server.js:53:24)
at emitTwo (events.js:106:13)
at WebSocket.emit (events.js:191:7)
at Receiver.ontext (/Users/stephenthoma/code/mozaik-demo/node_modules/mozaik/node_modules/ws/lib/WebSocket.js:841:10)
at /Users/stephenthoma/code/mozaik-demo/node_modules/mozaik/node_modules/ws/lib/Receiver.js:536:18
at /Users/stephenthoma/code/mozaik-demo/node_modules/mozaik/node_modules/ws/lib/Receiver.js:368:7
at /Users/stephenthoma/code/mozaik-demo/node_modules/mozaik/node_modules/ws/lib/PerMessageDeflate.js:249:5
at afterWrite (_stream_writable.js:361:3)
at onwrite (_stream_writable.js:352:7)
at WritableState.onwrite (_stream_writable.js:89:5)
at afterTransform (_stream_transform.js:79:3)
at TransformState.afterTransform (_stream_transform.js:54:12)
at Zlib.callback (zlib.js:639:5)
Config:
slack: {
token: process.env.SLACK_TOKEN,
showImages: true,
publicDir: './build',
maxImageAge: '8 hours'
},
.......
dashboards: [
{
columns: 4,
rows: 3,
widgets: [
{
type: 'slack.pulse',
channel: 'general',
columns: 1, rows: 1,
x: 1, y: 0
}
]
}
]
src/App.jsx
import React from 'react';
import Mozaik from 'mozaik/browser';
import slack from 'mozaik-ext-slack';
const MozaikComponent = Mozaik.Component.Mozaik;
const ConfigActions = Mozaik.Actions.Config;
Mozaik.Registry.addExtensions({
slack
});
React.render(<MozaikComponent/>, document.getElementById('mozaik'));
ConfigActions.loadConfig();
src/server.js:
import Mozaik from 'mozaik';
import config from '../config';
import slack from 'mozaik-ext-slack/client';
const mozaik = new Mozaik(config);
mozaik.bus.registerApi('slack', slack);
mozaik.startServer();
Calculate appropriate font size for the message - so that the whole message can be shown.
Sometimes it is wanted to show only certain messages. Allow to define a trigger word in widget config - and only those messages will be shown.
Restore the latest Slack message from localstorage - to have some content after reload.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.