Skip to content

Commit

Permalink
Added FlowStream stats.
Browse files Browse the repository at this point in the history
  • Loading branch information
petersirka committed Feb 10, 2024
1 parent 1e07c20 commit a299f42
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions definitions/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,14 @@ ROUTE('GET /flowstreams/', function($) {
var builder = [];
var editor = CONF.floweditor || 'https://flow.totaljs.com';

if ($.xhr) {
if ($.xhr || $.query.type === 'json') {

for (let key in Flow.instances) {
let db = Flow.db[key];
builder.push({ id: key, name: db.name, icon: db.icon, color: db.color, readme: db.readme, url: editor + '?socket=' + encodeURIComponent($.hostname('/flowstreams/{0}/?token={1}'.format(key, CONF.token))) });
let instance = Flow.instances[key];
let stats = instance.stats;
let newstats = stats ? { memory: stats.memory, messages: stats.messages, pending: stats.pending, minutes: stats.minutes, paused: stats.paused, mm: stats.mm, errors: stats.errors } : EMPTYOBJECT;
builder.push({ id: key, name: db.name, icon: db.icon, color: db.color, readme: db.readme, url: editor + '?socket=' + encodeURIComponent($.hostname('/flowstreams/{0}/?token={1}'.format(key, CONF.token))), stats: newstats });
}

$.json(builder);
Expand Down

0 comments on commit a299f42

Please sign in to comment.