git ssb

1+

Daan Patchwork / patchwork



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.jschanged
lib/depject/index.jschanged
lib/depject/page/html/render/status.jsadded
lib/depject/progress/obs.jschanged
lib/main-window.jschanged
lib/plugins/progress.jschanged
locales/en.jsonchanged
index.jsView
@@ -103,8 +103,15 @@
103103 accelerator: 'CmdOrCtrl+,',
104104 click: () => {
105105 browserWindow.webContents.send('goToSettings')
106106 }
107 + },
108 + {
109 + label: 'Status',
110 + accelerator: 'CmdOrCtrl+.',
111 + click: () => {
112 + browserWindow.webContents.send('goToStatus')
113 + }
107114 }
108115 ]
109116 })
110117
lib/depject/index.jsView
@@ -137,8 +137,9 @@
137137 profile: require('./page/html/render/profile.js'),
138138 public: require('./page/html/render/public.js'),
139139 search: require('./page/html/render/search.js'),
140140 settings: require('./page/html/render/settings.js'),
141 + status: require('./page/html/render/status.js'),
141142 tag: require('./page/html/render/tag.js'),
142143 'your-posts': require('./page/html/render/your-posts.js'),
143144 'attending-gatherings': require('./page/html/render/attending-gatherings.js')
144145 }
lib/depject/page/html/render/status.jsView
@@ -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.jsView
@@ -5,8 +5,9 @@
55 exports.gives = nest({
66 'progress.obs': [
77 'global',
88 'indexes',
9 + 'plugins',
910 'replicate',
1011 'migration',
1112 'peer'
1213 ]
@@ -18,8 +19,9 @@
1819
1920 exports.create = function (api) {
2021 let syncStatus = null
2122 let progress = null
23 + let pluginProgress = null
2224
2325 return nest({
2426 'progress.obs': {
2527 replicate () {
@@ -36,8 +38,12 @@
3638 indexes () {
3739 load()
3840 return progress.indexes
3941 },
42 + plugins () {
43 + load()
44 + return pluginProgress.plugins
45 + },
4046 migration () {
4147 load()
4248 return progress.migration
4349 },
@@ -62,8 +68,13 @@
6268 indexes: Status(),
6369 migration: Status()
6470 })
6571 }
72 + if (!pluginProgress) {
73 + pluginProgress = ProgressStatus(x => x.patchwork.progress(), {
74 + plugins: Struct({}),
75 + })
76 + }
6677 }
6778
6879 function ProgressStatus (keyFn, attrs) {
6980 const progress = Struct(attrs || {
lib/main-window.jsView
@@ -117,9 +117,9 @@
117117 })
118118
119119 const defaultViews = computed(includeParticipating, (includeParticipating) => {
120120 const result = [
121- '/public', '/private', '/mentions'
121 + '/public', '/private', '/mentions', '/status'
122122 ]
123123
124124 // allow user to choose in settings whether to show participating tab
125125 if (includeParticipating) {
@@ -140,8 +140,9 @@
140140 electron.ipcRenderer.on('goForward', views.goForward)
141141 electron.ipcRenderer.on('goBack', views.goBack)
142142
143143 electron.ipcRenderer.on('goToSettings', () => api.app.navigate('/settings'))
144 + electron.ipcRenderer.on('goTostatus', () => api.app.navigate('/status'))
144145
145146 electron.ipcRenderer.on("navigate-to", (ev, target) => {
146147 navigate(target);
147148 });
@@ -367,8 +368,13 @@
367368 type: "normal",
368369 label: i18n("Settings"),
369370 target: "/settings",
370371 },
372 + {
373 + type: "normal",
374 + label: i18n("Status"),
375 + target: "/status",
376 + },
371377 ];
372378 return dropTabItems
373379 }
374380
lib/plugins/progress.jsView
@@ -3,14 +3,22 @@
33
44 module.exports = function (ssb) {
55 return {
66 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 + }
812
913 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 + }
1119 if (!deepEqual(newValue, lastValue)) {
12- lastValue = deepClone(newValue)
20 + lastValue = newValue
1321 pushable.push(lastValue)
1422 }
1523 }, 200)
1624
locales/en.jsonView
@@ -303,6 +303,8 @@
303303 "Connections": "Connections",
304304 "Connect": "Connect",
305305 "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.",
306306 "nl": "nl",
307- "Last activity": "Last activity"
307 + "Last activity": "Last activity",
308 + "Status": "Status",
309 + "Indexes": "Indexes"
308310 }

Built with git-ssb-web