appstore: more state information
This commit is contained in:
+11
-2
@@ -7,10 +7,12 @@ import dashboard from './dashboard.js';
|
||||
import debugModule from 'debug';
|
||||
import domains from './domains.js';
|
||||
import dockerRegistries from './dockerregistries.js';
|
||||
import directoryServer from './directoryserver.js';
|
||||
import externalLdap from './externalldap.js';
|
||||
import groups from './groups.js';
|
||||
import mail from './mail.js';
|
||||
import manifestFormat from '@cloudron/manifest-format';
|
||||
import oidcClients from './oidcclients.js';
|
||||
import paths from './paths.js';
|
||||
import promiseRetry from './promise-retry.js';
|
||||
import safe from 'safetydance';
|
||||
@@ -73,10 +75,15 @@ function getFeatures() {
|
||||
async function getState() {
|
||||
const mailDomains = await mail.listDomains();
|
||||
const mailStats = await Promise.all(mailDomains.map(d => mail.getStats(d.domain)));
|
||||
const allUsers = await users.list();
|
||||
const roleCounts = allUsers.reduce((acc, u) => {
|
||||
acc[u.role] = (acc[u.role] || 0) + 1;
|
||||
return acc;
|
||||
}, {});
|
||||
|
||||
const state = {
|
||||
provider: system.getProvider(),
|
||||
userCount: (await users.list()).length,
|
||||
users: { count: allUsers.length, roleCounts },
|
||||
groupCount: (await groups.list()).length,
|
||||
domains: (await domains.list()).map(d => d.provider),
|
||||
mail: {
|
||||
@@ -88,11 +95,13 @@ async function getState() {
|
||||
pop3Count: mailStats.reduce((acc, cur) => acc + cur.pop3Count, 0),
|
||||
aliasCount: mailStats.reduce((acc, cur) => acc + cur.aliasCount, 0)
|
||||
},
|
||||
apps: (await apps.list()).map(a => a.manifest.id), // array of appstore IDs
|
||||
apps: (await apps.list()).map(a => { return { id: a.manifest.id, community: !!a.versionsUrl }; }),
|
||||
dockerRegistries: (await dockerRegistries.list()).map(r => r.provider),
|
||||
backupSites: (await backupSites.list()).map(s => { return { provider: s.provider, format: s.format, encryption: !!s.encryption }; }),
|
||||
externalLdap: (await externalLdap.getConfig()).provider,
|
||||
volumes: (await volumes.list()).map(v => v.mountType),
|
||||
directoryServer: (await directoryServer.getConfig()).enabled,
|
||||
oidcClientCount: (await oidcClients.list()).length
|
||||
};
|
||||
|
||||
return state;
|
||||
|
||||
Reference in New Issue
Block a user