diff options
| author | bozo.kopic <bozo@kopic.xyz> | 2022-03-22 01:31:27 +0100 |
|---|---|---|
| committer | bozo.kopic <bozo@kopic.xyz> | 2022-03-22 01:31:27 +0100 |
| commit | cc4ba3b063f14943579ffbfe416828590f70ae0a (patch) | |
| tree | af2127920fb57603206ca670beb63b5d58650fb8 /src_js/hatter/common.js | |
| parent | c594b1fca854a7b9fb73d854a9830143cd1032fc (diff) | |
WIP major rewrite
Diffstat (limited to 'src_js/hatter/common.js')
| -rw-r--r-- | src_js/hatter/common.js | 66 |
1 files changed, 0 insertions, 66 deletions
diff --git a/src_js/hatter/common.js b/src_js/hatter/common.js deleted file mode 100644 index c6dcfcc..0000000 --- a/src_js/hatter/common.js +++ /dev/null @@ -1,66 +0,0 @@ - -import r from 'hatter/renderer'; -import * as util from 'hatter/util'; - - -export const defaultState = { - conn: null, - log: { - offset: 0, - offsetText: '0', - limit: 0, - limitText: '0', - entries: [] - }, - job: { - active: null, - queue: [] - }, - repositories: [] -}; - - -export function processMsg(msg) { - if (msg.type == 'repositories') { - r.set('repositories', msg.repositories); - } else if (msg.type == 'active_job') { - r.set(['job', 'active'], msg.job); - } else if (msg.type == 'job_queue') { - r.set(['job', 'queue'], msg.jobs); - } else if (msg.type == 'log_entries') { - r.set(['log', 'entires'], msg.entries); - } -} - - -export function addJob(repository) { - r.get('conn').send(JSON.stringify({ - type: 'add_job', - repository: repository, - commit: 'HEAD' - })); -} - - -bean.on(r, 'change', state => { - let newOffset = parseInt(state.log.offsetText); - let newLimit = parseInt(state.log.limitText); - if (util.isInteger(newOffset) && newOffset != state.log.offset) { - r.set(['log', 'offset'], newOffset).then(sendSetLog); - } - if (util.isInteger(newLimit) && newLimit != state.log.limit) { - r.set(['log', 'limit'], newLimit).then(sendSetLog); - } -}); - - -function sendSetLog() { - let conn = r.get('conn'); - if (!conn) - return; - conn.send(JSON.stringify({ - type: 'set_log', - offset: r.get('offset'), - limit: r.get('limit') - })); -} |
