Build out the admin panel
- Overview: users, organizations, workspaces, spaces, pages, files and storage (org admins see their organization), plus pages open right now, the search index size, and version, uptime and database health. - Users: invite people by email (with resend, revoke and a copyable link when mail fails) and send a password-reset email. - Authentication: sign-up on or off, the email-domain allow-list, and sign-in links by email. - Branding: instance name, accent colour and logo. The web app shows them on the sign-in pages and applies the accent colour everywhere. - Email and Storage: SMTP and S3 settings with test buttons. - Maintenance: create, download and delete database backups, and a view of the background jobs with their last run, duration and errors. On the server, a small jobs registry records each search-indexing pass, and "search.rebuild" replaces the separate reindex endpoint. A new instance package serves the dashboard numbers, health and backups. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
92cd81fd96
commit
ffc6cc4fbc
31 files changed
+2326
-134
No files matched your search
@@ -1868,3 +1868,251 @@ class Comment {
|
||||
'canDelete': canDelete,
|
||||
};
|
||||
}
|
||||
|
||||
enum AdminStatsScope {
|
||||
instance('instance'),
|
||||
organization('organization');
|
||||
|
||||
const AdminStatsScope(this.value);
|
||||
final String value;
|
||||
|
||||
static AdminStatsScope fromJson(String value) => values.firstWhere(
|
||||
(e) => e.value == value,
|
||||
orElse: () => throw FormatException('unknown AdminStatsScope', value),
|
||||
);
|
||||
|
||||
String toJson() => value;
|
||||
}
|
||||
|
||||
class AdminStats {
|
||||
const AdminStats({
|
||||
required this.scope,
|
||||
required this.users,
|
||||
required this.organizations,
|
||||
required this.workspaces,
|
||||
required this.spaces,
|
||||
required this.pages,
|
||||
required this.attachments,
|
||||
required this.storageBytes,
|
||||
required this.rooms,
|
||||
required this.editors,
|
||||
required this.indexed,
|
||||
});
|
||||
|
||||
factory AdminStats.fromJson(Map<String, dynamic> json) => AdminStats(
|
||||
scope: AdminStatsScope.fromJson(json['scope'] as String),
|
||||
users: (json['users'] as num).toInt(),
|
||||
organizations: (json['organizations'] as num).toInt(),
|
||||
workspaces: (json['workspaces'] as num).toInt(),
|
||||
spaces: (json['spaces'] as num).toInt(),
|
||||
pages: (json['pages'] as num).toInt(),
|
||||
attachments: (json['attachments'] as num).toInt(),
|
||||
storageBytes: (json['storageBytes'] as num).toInt(),
|
||||
rooms: (json['rooms'] as num).toInt(),
|
||||
editors: (json['editors'] as num).toInt(),
|
||||
indexed: (json['indexed'] as num).toInt(),
|
||||
);
|
||||
|
||||
final AdminStatsScope scope;
|
||||
|
||||
final int users;
|
||||
|
||||
final int organizations;
|
||||
|
||||
final int workspaces;
|
||||
|
||||
final int spaces;
|
||||
|
||||
/// Pages outside the trash
|
||||
final int pages;
|
||||
|
||||
final int attachments;
|
||||
|
||||
/// Total size of attachments
|
||||
final int storageBytes;
|
||||
|
||||
/// Pages open for editing now (instance scope only)
|
||||
final int rooms;
|
||||
|
||||
/// People connected to those pages (instance scope only)
|
||||
final int editors;
|
||||
|
||||
/// Pages in the search index (instance scope only)
|
||||
final int indexed;
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'scope': scope.toJson(),
|
||||
'users': users,
|
||||
'organizations': organizations,
|
||||
'workspaces': workspaces,
|
||||
'spaces': spaces,
|
||||
'pages': pages,
|
||||
'attachments': attachments,
|
||||
'storageBytes': storageBytes,
|
||||
'rooms': rooms,
|
||||
'editors': editors,
|
||||
'indexed': indexed,
|
||||
};
|
||||
}
|
||||
|
||||
class AdminHealthDatabase {
|
||||
const AdminHealthDatabase({
|
||||
required this.ok,
|
||||
required this.latencyMs,
|
||||
this.error,
|
||||
});
|
||||
|
||||
factory AdminHealthDatabase.fromJson(Map<String, dynamic> json) =>
|
||||
AdminHealthDatabase(
|
||||
ok: json['ok'] as bool,
|
||||
latencyMs: (json['latencyMs'] as num).toInt(),
|
||||
error: json['error'] == null ? null : json['error'] as String,
|
||||
);
|
||||
|
||||
final bool ok;
|
||||
|
||||
final int latencyMs;
|
||||
|
||||
final String? error;
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'ok': ok,
|
||||
'latencyMs': latencyMs,
|
||||
'error': ?error,
|
||||
};
|
||||
}
|
||||
|
||||
class AdminHealth {
|
||||
const AdminHealth({
|
||||
required this.version,
|
||||
required this.goVersion,
|
||||
required this.started,
|
||||
required this.uptimeSeconds,
|
||||
required this.database,
|
||||
required this.goroutines,
|
||||
required this.memoryMb,
|
||||
});
|
||||
|
||||
factory AdminHealth.fromJson(Map<String, dynamic> json) => AdminHealth(
|
||||
version: json['version'] as String,
|
||||
goVersion: json['goVersion'] as String,
|
||||
started: json['started'] as String,
|
||||
uptimeSeconds: (json['uptimeSeconds'] as num).toInt(),
|
||||
database: AdminHealthDatabase.fromJson(
|
||||
json['database'] as Map<String, dynamic>,
|
||||
),
|
||||
goroutines: (json['goroutines'] as num).toInt(),
|
||||
memoryMb: (json['memoryMb'] as num).toInt(),
|
||||
);
|
||||
|
||||
final String version;
|
||||
|
||||
final String goVersion;
|
||||
|
||||
final String started;
|
||||
|
||||
final int uptimeSeconds;
|
||||
|
||||
final AdminHealthDatabase database;
|
||||
|
||||
final int goroutines;
|
||||
|
||||
final int memoryMb;
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'version': version,
|
||||
'goVersion': goVersion,
|
||||
'started': started,
|
||||
'uptimeSeconds': uptimeSeconds,
|
||||
'database': database.toJson(),
|
||||
'goroutines': goroutines,
|
||||
'memoryMb': memoryMb,
|
||||
};
|
||||
}
|
||||
|
||||
class Job {
|
||||
const Job({
|
||||
required this.name,
|
||||
required this.description,
|
||||
required this.every,
|
||||
required this.runnable,
|
||||
required this.running,
|
||||
required this.runs,
|
||||
required this.failures,
|
||||
required this.lastStarted,
|
||||
required this.lastDurationMs,
|
||||
required this.lastError,
|
||||
});
|
||||
|
||||
factory Job.fromJson(Map<String, dynamic> json) => Job(
|
||||
name: json['name'] as String,
|
||||
description: json['description'] as String,
|
||||
every: json['every'] as String,
|
||||
runnable: json['runnable'] as bool,
|
||||
running: json['running'] as bool,
|
||||
runs: (json['runs'] as num).toInt(),
|
||||
failures: (json['failures'] as num).toInt(),
|
||||
lastStarted: json['lastStarted'] as String,
|
||||
lastDurationMs: (json['lastDurationMs'] as num).toInt(),
|
||||
lastError: json['lastError'] as String,
|
||||
);
|
||||
|
||||
final String name;
|
||||
|
||||
final String description;
|
||||
|
||||
/// How often it runs on its own (Go duration); empty when only on demand
|
||||
final String every;
|
||||
|
||||
/// Can be started by hand
|
||||
final bool runnable;
|
||||
|
||||
final bool running;
|
||||
|
||||
/// Runs since the server started
|
||||
final int runs;
|
||||
|
||||
final int failures;
|
||||
|
||||
/// RFC 3339; empty before the first run
|
||||
final String lastStarted;
|
||||
|
||||
final int lastDurationMs;
|
||||
|
||||
final String lastError;
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'name': name,
|
||||
'description': description,
|
||||
'every': every,
|
||||
'runnable': runnable,
|
||||
'running': running,
|
||||
'runs': runs,
|
||||
'failures': failures,
|
||||
'lastStarted': lastStarted,
|
||||
'lastDurationMs': lastDurationMs,
|
||||
'lastError': lastError,
|
||||
};
|
||||
}
|
||||
|
||||
class Backup {
|
||||
const Backup({required this.key, required this.size, required this.modified});
|
||||
|
||||
factory Backup.fromJson(Map<String, dynamic> json) => Backup(
|
||||
key: json['key'] as String,
|
||||
size: (json['size'] as num).toInt(),
|
||||
modified: json['modified'] as String,
|
||||
);
|
||||
|
||||
final String key;
|
||||
|
||||
final int size;
|
||||
|
||||
final String modified;
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'key': key,
|
||||
'size': size,
|
||||
'modified': modified,
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user