mirror of
https://git.selfprivacy.org/kherel/selfprivacy.org.app.git
synced 2025-01-08 17:11:14 +00:00
feat: added translations to some of console page elements, empty view when there are 0 logs in console yet.
This commit is contained in:
parent
8919a50bf3
commit
47f3d5f53c
|
@ -47,7 +47,23 @@
|
||||||
"console_page": {
|
"console_page": {
|
||||||
"title": "Console",
|
"title": "Console",
|
||||||
"waiting": "Waiting for initialization…",
|
"waiting": "Waiting for initialization…",
|
||||||
"copy": "Copy"
|
"copy": "Copy",
|
||||||
|
"historyEmpty": "No data yet",
|
||||||
|
"error":"Error",
|
||||||
|
"log":"Log",
|
||||||
|
"rest_api_request":"Rest API Request",
|
||||||
|
"rest_api_response":"Rest API Response",
|
||||||
|
"graphql_request":"GraphQL Request",
|
||||||
|
"graphql_response":"GraphQL Response",
|
||||||
|
"logged_at": "logged at: ",
|
||||||
|
"data": "Data",
|
||||||
|
"erros":"Errors",
|
||||||
|
"request_data": "Request data",
|
||||||
|
"headers": "Headers",
|
||||||
|
"response_data": "Response data",
|
||||||
|
"context": "Context",
|
||||||
|
"operation": "Operation",
|
||||||
|
"variables": "Variables"
|
||||||
},
|
},
|
||||||
"about_application_page": {
|
"about_application_page": {
|
||||||
"title": "About & support",
|
"title": "About & support",
|
||||||
|
|
|
@ -10,36 +10,35 @@ extension on ConsoleLog {
|
||||||
if (log.uri != null) _KeyValueRow('uri', log.uri.toString()),
|
if (log.uri != null) _KeyValueRow('uri', log.uri.toString()),
|
||||||
|
|
||||||
// headers bloc
|
// headers bloc
|
||||||
if (log.headers?.isNotEmpty ?? false) const _SectionRow('Headers'),
|
if (log.headers?.isNotEmpty ?? false)
|
||||||
|
const _SectionRow('console_page.headers'),
|
||||||
...?log.headers?.entries
|
...?log.headers?.entries
|
||||||
.map((final entry) => _KeyValueRow(entry.key, entry.value)),
|
.map((final entry) => _KeyValueRow(entry.key, entry.value)),
|
||||||
|
|
||||||
// data bloc
|
// data bloc
|
||||||
const _SectionRow('Request data'),
|
const _SectionRow('console_page.data'),
|
||||||
_DataRow(log.data?.toString()),
|
_DataRow(log.data?.toString()),
|
||||||
],
|
],
|
||||||
(final RestApiResponseConsoleLog log) => [
|
(final RestApiResponseConsoleLog log) => [
|
||||||
if (log.method != null) _KeyValueRow('method', log.method),
|
if (log.method != null) _KeyValueRow('method', log.method),
|
||||||
if (log.uri != null) _KeyValueRow('uri', log.uri.toString()),
|
if (log.uri != null) _KeyValueRow('uri', log.uri.toString()),
|
||||||
if (log.statusCode != null)
|
if (log.statusCode != null)
|
||||||
_KeyValueRow(
|
_KeyValueRow('statusCode', log.statusCode.toString()),
|
||||||
'statusCode',
|
|
||||||
log.statusCode.toString(),
|
|
||||||
),
|
|
||||||
|
|
||||||
// data bloc
|
// data bloc
|
||||||
const _SectionRow('Response data'),
|
const _SectionRow('console_page.response_data'),
|
||||||
_DataRow(log.data?.toString()),
|
_DataRow(log.data?.toString()),
|
||||||
],
|
],
|
||||||
(final GraphQlRequestConsoleLog log) => [
|
(final GraphQlRequestConsoleLog log) => [
|
||||||
// context
|
// context
|
||||||
const _SectionRow('Context'),
|
const _SectionRow('console_page.context'),
|
||||||
_DataRow(log.context?.toString()),
|
_DataRow(log.context?.toString()),
|
||||||
// data
|
// data
|
||||||
if (log.operation != null) const _SectionRow('Operation'),
|
if (log.operation != null)
|
||||||
|
const _SectionRow('console_page.operation'),
|
||||||
_DataRow(log.stringifiedOperation), // errors
|
_DataRow(log.stringifiedOperation), // errors
|
||||||
if (log.variables?.isNotEmpty ?? false)
|
if (log.variables?.isNotEmpty ?? false)
|
||||||
const _SectionRow('Variables'),
|
const _SectionRow('console_page.variables'),
|
||||||
...?log.variables?.entries.map(
|
...?log.variables?.entries.map(
|
||||||
(final entry) => _KeyValueRow(
|
(final entry) => _KeyValueRow(
|
||||||
entry.key,
|
entry.key,
|
||||||
|
@ -49,10 +48,10 @@ extension on ConsoleLog {
|
||||||
],
|
],
|
||||||
(final GraphQlResponseConsoleLog log) => [
|
(final GraphQlResponseConsoleLog log) => [
|
||||||
// context
|
// context
|
||||||
const _SectionRow('Context'),
|
const _SectionRow('console_page.context'),
|
||||||
_DataRow(log.context?.toString()),
|
_DataRow(log.context?.toString()),
|
||||||
// data
|
// data
|
||||||
if (log.data != null) const _SectionRow('Data'),
|
if (log.data != null) const _SectionRow('console_page.data'),
|
||||||
...?log.data?.entries.map(
|
...?log.data?.entries.map(
|
||||||
(final entry) => _KeyValueRow(
|
(final entry) => _KeyValueRow(
|
||||||
entry.key,
|
entry.key,
|
||||||
|
@ -60,7 +59,8 @@ extension on ConsoleLog {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
// errors
|
// errors
|
||||||
if (log.errors?.isNotEmpty ?? false) const _SectionRow('Errors'),
|
if (log.errors?.isNotEmpty ?? false)
|
||||||
|
const _SectionRow('console_page.errors'),
|
||||||
...?log.errors?.map(
|
...?log.errors?.map(
|
||||||
(final entry) => _KeyValueRow(
|
(final entry) => _KeyValueRow(
|
||||||
entry.message,
|
entry.message,
|
||||||
|
@ -94,8 +94,7 @@ class ConsoleItemDialog extends StatelessWidget {
|
||||||
children: [
|
children: [
|
||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
/// TODO(misterfourtytwo): maybe should add translations later
|
Text('logged_at'.tr()),
|
||||||
const Text('logged at: '),
|
|
||||||
SelectableText(
|
SelectableText(
|
||||||
log.timeString,
|
log.timeString,
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
|
@ -160,6 +159,7 @@ class _DataRow extends StatelessWidget {
|
||||||
|
|
||||||
class _SectionRow extends StatelessWidget {
|
class _SectionRow extends StatelessWidget {
|
||||||
const _SectionRow(this.title);
|
const _SectionRow(this.title);
|
||||||
|
|
||||||
final String title;
|
final String title;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -175,7 +175,7 @@ class _SectionRow extends StatelessWidget {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
child: SelectableText(
|
child: SelectableText(
|
||||||
title,
|
title.tr(),
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
fontWeight: FontWeight.w800,
|
fontWeight: FontWeight.w800,
|
||||||
fontSize: 20,
|
fontSize: 20,
|
||||||
|
|
|
@ -78,12 +78,14 @@ class _ConsolePageState extends State<ConsolePage> {
|
||||||
final AsyncSnapshot<void> snapshot,
|
final AsyncSnapshot<void> snapshot,
|
||||||
) {
|
) {
|
||||||
if (snapshot.hasData) {
|
if (snapshot.hasData) {
|
||||||
final List<ConsoleLog> messages =
|
final List<ConsoleLog> logs =
|
||||||
getIt.get<ConsoleModel>().logs;
|
getIt.get<ConsoleModel>().logs;
|
||||||
|
|
||||||
return _ConsoleViewLoaded(
|
return logs.isEmpty
|
||||||
logs: messages,
|
? const _ConsoleViewEmpty()
|
||||||
);
|
: _ConsoleViewLoaded(
|
||||||
|
logs: logs,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return const _ConsoleViewLoading();
|
return const _ConsoleViewLoading();
|
||||||
|
@ -115,6 +117,16 @@ class _ConsoleViewLoading extends StatelessWidget {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class _ConsoleViewEmpty extends StatelessWidget {
|
||||||
|
const _ConsoleViewEmpty();
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(final BuildContext context) => Align(
|
||||||
|
alignment: Alignment.topCenter,
|
||||||
|
child: Text('console_page.historyEmpty'.tr()),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
class _ConsoleViewLoaded extends StatelessWidget {
|
class _ConsoleViewLoaded extends StatelessWidget {
|
||||||
const _ConsoleViewLoaded({required this.logs});
|
const _ConsoleViewLoaded({required this.logs});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue