Commit a41bbe7d3a90bbd6e1d656bf814833fafdc55b30
Add status page
Sometimes during indexing the server becomes unresponsive to outside queries, which makes tracking indexing progress difficult. This page simply shows a `JSON.stringify()` of the index status.Daan Wynen committed on 3/12/2021, 10:15:04 AM
Parent: 0685882d708b3c0e16500ae619da942dfb9167d0
Files changed
index.js | changed |
lib/depject/index.js | changed |
lib/depject/page/html/render/status.js | added |
lib/depject/progress/obs.js | changed |
lib/main-window.js | changed |
lib/plugins/progress.js | changed |
locales/en.json | changed |
index.js | ||
---|---|---|
@@ -103,8 +103,15 @@ | ||
103 | 103 … | accelerator: 'CmdOrCtrl+,', |
104 | 104 … | click: () => { |
105 | 105 … | browserWindow.webContents.send('goToSettings') |
106 | 106 … | } |
107 … | + }, | |
108 … | + { | |
109 … | + label: 'Status', | |
110 … | + accelerator: 'CmdOrCtrl+.', | |
111 … | + click: () => { | |
112 … | + browserWindow.webContents.send('goToStatus') | |
113 … | + } | |
107 | 114 … | } |
108 | 115 … | ] |
109 | 116 … | }) |
110 | 117 … |
lib/depject/index.js | ||
---|---|---|
@@ -137,8 +137,9 @@ | ||
137 | 137 … | profile: require('./page/html/render/profile.js'), |
138 | 138 … | public: require('./page/html/render/public.js'), |
139 | 139 … | search: require('./page/html/render/search.js'), |
140 | 140 … | settings: require('./page/html/render/settings.js'), |
141 … | + status: require('./page/html/render/status.js'), | |
141 | 142 … | tag: require('./page/html/render/tag.js'), |
142 | 143 … | 'your-posts': require('./page/html/render/your-posts.js'), |
143 | 144 … | 'attending-gatherings': require('./page/html/render/attending-gatherings.js') |
144 | 145 … | } |
lib/depject/page/html/render/status.js | ||
---|---|---|
@@ -1,0 +1,47 @@ | ||
1 … | +const { computed, h } = require('mutant') | |
2 … | +const nest = require('depnest') | |
3 … | +const renderProgress = require('../../../../progress/html/render') | |
4 … | + | |
5 … | +exports.needs = nest({ | |
6 … | + 'sbot.pull.stream': 'first', | |
7 … | + 'progress.obs': { | |
8 … | + indexes: 'first', | |
9 … | + plugins: 'first', | |
10 … | + replicate: 'first', | |
11 … | + migration: 'first' | |
12 … | + }, | |
13 … | + 'intl.sync.i18n': 'first' | |
14 … | +}) | |
15 … | + | |
16 … | +exports.gives = nest('page.html.render') | |
17 … | + | |
18 … | +exports.create = function (api) { | |
19 … | + return nest('page.html.render', function channel (path) { | |
20 … | + const indexes = api.progress.obs.indexes() | |
21 … | + const pluginIndexes = api.progress.obs.plugins() | |
22 … | + const indexesJson = computed([indexes, pluginIndexes], (indexes, plugins) => { | |
23 … | + return JSON.stringify({indexes, plugins}, null, 4) | |
24 … | + }) | |
25 … | + | |
26 … | + if (path !== '/status') return | |
27 … | + const i18n = api.intl.sync.i18n | |
28 … | + | |
29 … | + const prepend = [ | |
30 … | + h('PageHeading', [ | |
31 … | + h('h1', [ | |
32 … | + h('strong', i18n('Status')) | |
33 … | + ]) | |
34 … | + ]) | |
35 … | + ] | |
36 … | + | |
37 … | + return h('Scroller', { style: { overflow: 'auto' } }, [ | |
38 … | + h('div.wrapper', [ | |
39 … | + h('section.prepend', prepend), | |
40 … | + h('section.content', [ | |
41 … | + h('h2', i18n('Indexes')), | |
42 … | + h('pre', [indexesJson]) | |
43 … | + ]), | |
44 … | + ]) | |
45 … | + ]) | |
46 … | + }) | |
47 … | +} |
lib/depject/progress/obs.js | ||
---|---|---|
@@ -5,8 +5,9 @@ | ||
5 | 5 … | exports.gives = nest({ |
6 | 6 … | 'progress.obs': [ |
7 | 7 … | 'global', |
8 | 8 … | 'indexes', |
9 … | + 'plugins', | |
9 | 10 … | 'replicate', |
10 | 11 … | 'migration', |
11 | 12 … | 'peer' |
12 | 13 … | ] |
@@ -18,8 +19,9 @@ | ||
18 | 19 … | |
19 | 20 … | exports.create = function (api) { |
20 | 21 … | let syncStatus = null |
21 | 22 … | let progress = null |
23 … | + let pluginProgress = null | |
22 | 24 … | |
23 | 25 … | return nest({ |
24 | 26 … | 'progress.obs': { |
25 | 27 … | replicate () { |
@@ -36,8 +38,12 @@ | ||
36 | 38 … | indexes () { |
37 | 39 … | load() |
38 | 40 … | return progress.indexes |
39 | 41 … | }, |
42 … | + plugins () { | |
43 … | + load() | |
44 … | + return pluginProgress.plugins | |
45 … | + }, | |
40 | 46 … | migration () { |
41 | 47 … | load() |
42 | 48 … | return progress.migration |
43 | 49 … | }, |
@@ -62,8 +68,13 @@ | ||
62 | 68 … | indexes: Status(), |
63 | 69 … | migration: Status() |
64 | 70 … | }) |
65 | 71 … | } |
72 … | + if (!pluginProgress) { | |
73 … | + pluginProgress = ProgressStatus(x => x.patchwork.progress(), { | |
74 … | + plugins: Struct({}), | |
75 … | + }) | |
76 … | + } | |
66 | 77 … | } |
67 | 78 … | |
68 | 79 … | function ProgressStatus (keyFn, attrs) { |
69 | 80 … | const progress = Struct(attrs || { |
lib/main-window.js | ||
---|---|---|
@@ -117,9 +117,9 @@ | ||
117 | 117 … | }) |
118 | 118 … | |
119 | 119 … | const defaultViews = computed(includeParticipating, (includeParticipating) => { |
120 | 120 … | const result = [ |
121 | - '/public', '/private', '/mentions' | |
121 … | + '/public', '/private', '/mentions', '/status' | |
122 | 122 … | ] |
123 | 123 … | |
124 | 124 … | // allow user to choose in settings whether to show participating tab |
125 | 125 … | if (includeParticipating) { |
@@ -140,8 +140,9 @@ | ||
140 | 140 … | electron.ipcRenderer.on('goForward', views.goForward) |
141 | 141 … | electron.ipcRenderer.on('goBack', views.goBack) |
142 | 142 … | |
143 | 143 … | electron.ipcRenderer.on('goToSettings', () => api.app.navigate('/settings')) |
144 … | + electron.ipcRenderer.on('goTostatus', () => api.app.navigate('/status')) | |
144 | 145 … | |
145 | 146 … | electron.ipcRenderer.on("navigate-to", (ev, target) => { |
146 | 147 … | navigate(target); |
147 | 148 … | }); |
@@ -367,8 +368,13 @@ | ||
367 | 368 … | type: "normal", |
368 | 369 … | label: i18n("Settings"), |
369 | 370 … | target: "/settings", |
370 | 371 … | }, |
372 … | + { | |
373 … | + type: "normal", | |
374 … | + label: i18n("Status"), | |
375 … | + target: "/status", | |
376 … | + }, | |
371 | 377 … | ]; |
372 | 378 … | return dropTabItems |
373 | 379 … | } |
374 | 380 … |
lib/plugins/progress.js | ||
---|---|---|
@@ -3,14 +3,22 @@ | ||
3 | 3 … | |
4 | 4 … | module.exports = function (ssb) { |
5 | 5 … | return { |
6 | 6 … | stream: function () { |
7 | - let lastValue = deepClone(ssb.progress()) | |
7 … | + let lastValue = deepClone(ssb.status()) | |
8 … | + lastValue = { | |
9 … | + ...lastValue.progress, | |
10 … | + plugins: lastValue.sync.plugins, | |
11 … | + } | |
8 | 12 … | |
9 | 13 … | const timer = setInterval(() => { |
10 | - const newValue = ssb.progress() | |
14 … | + let newValue = deepClone(ssb.status()) | |
15 … | + newValue = { | |
16 … | + ...newValue.progress, | |
17 … | + plugins: newValue.sync.plugins, | |
18 … | + } | |
11 | 19 … | if (!deepEqual(newValue, lastValue)) { |
12 | - lastValue = deepClone(newValue) | |
20 … | + lastValue = newValue | |
13 | 21 … | pushable.push(lastValue) |
14 | 22 … | } |
15 | 23 … | }, 200) |
16 | 24 … |
locales/en.json | ||
---|---|---|
@@ -303,6 +303,8 @@ | ||
303 | 303 … | "Connections": "Connections", |
304 | 304 … | "Connect": "Connect", |
305 | 305 … | "In order to share with users on the internet, you need to be invited to a pub server or a room server.": "In order to share with users on the internet, you need to be invited to a pub server or a room server.", |
306 | 306 … | "nl": "nl", |
307 | - "Last activity": "Last activity" | |
307 … | + "Last activity": "Last activity", | |
308 … | + "Status": "Status", | |
309 … | + "Indexes": "Indexes" | |
308 | 310 … | } |
Built with git-ssb-web