Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Admin UI: Show devices of identity on identity details page #901

Merged
merged 20 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
fb6952e
feat: add Identity device table
stamenione Oct 4, 2024
27f193b
Merge branch 'main' into identities-devices-table
mergify[bot] Oct 7, 2024
89f28fe
Merge branch 'main' into identities-devices-table
mergify[bot] Oct 7, 2024
cf37fe8
Merge branch 'main' into identities-devices-table
mergify[bot] Oct 8, 2024
3b080ec
Merge branch 'main' into identities-devices-table
mergify[bot] Oct 8, 2024
e424b0d
Merge branch 'main' into identities-devices-table
mergify[bot] Oct 8, 2024
7f4c16c
Merge branch 'main' into identities-devices-table
mergify[bot] Oct 9, 2024
dcab442
Merge branch 'main' into identities-devices-table
mergify[bot] Oct 10, 2024
691d124
Merge branch 'main' into identities-devices-table
mergify[bot] Oct 11, 2024
efe24ed
Merge branch 'main' into identities-devices-table
mergify[bot] Oct 11, 2024
cd6fc30
Merge branch 'main' into identities-devices-table
stamenione Oct 14, 2024
031055f
Merge branch 'main' into identities-devices-table
mergify[bot] Oct 14, 2024
aad8093
Merge branch 'main' into identities-devices-table
mergify[bot] Oct 14, 2024
90ac1cd
fix: wrongly accessed time parameter from a map dynamic
stamenione Oct 14, 2024
c58164a
Merge branch 'identities-devices-table' of https://github.com/nmshd/b…
stamenione Oct 14, 2024
1f9561d
fix: remove unnecessary comparison
stamenione Oct 15, 2024
67a7471
Merge branch 'main' into identities-devices-table
mergify[bot] Oct 15, 2024
4045aa1
Merge branch 'main' into identities-devices-table
stamenione Oct 15, 2024
2796c83
Merge branch 'identities-devices-table' of https://github.com/nmshd/b…
stamenione Oct 15, 2024
594cad7
fix: move to object
jkoenig134 Oct 15, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import 'package:intl/intl.dart';

import '/core/core.dart';
import 'deletion_process_table/deletion_process_table.dart';
import 'identity_devices/identity_devices.dart';
import 'identity_messages/identity_messages.dart';
import 'identity_quotas/identity_quotas.dart';
import 'identity_relationships/identity_relationships.dart';
Expand Down Expand Up @@ -84,6 +85,8 @@ class _IdentityDetailsState extends State<IdentityDetails> {
Gaps.h16,
IdentityQuotas(identityDetails, _reloadIdentity),
Gaps.h16,
IdentityDevices(devices: identityDetails.devices),
Gaps.h16,
IdentityRelationships(address: identityDetails.address),
Gaps.h16,
IdentityMessages(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import 'package:admin_api_types/admin_api_types.dart';
import 'package:data_table_2/data_table_2.dart';
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';

import '/core/core.dart';

class IdentityDevices extends StatelessWidget {
final List<IdentityDevice> devices;

const IdentityDevices({required this.devices, super.key});

@override
Widget build(BuildContext context) {
return Theme(
data: Theme.of(context).copyWith(dividerColor: Colors.transparent),
child: ExpansionTile(
title: Text(context.l10n.identityDevices_title),
subtitle: Text(context.l10n.identityDevices_title_description),
children: [
Card(
child: Column(
children: [
SizedBox(
width: double.infinity,
height: 500,
child: DataTable2(
empty: Text(context.l10n.deletionProcessTable_noDeletionProcessFound),
columns: [
DataColumn2(label: Text(context.l10n.id)),
DataColumn2(label: Text(context.l10n.identityDevices_username)),
DataColumn2(label: Text(context.l10n.createdAt)),
DataColumn2(label: Text(context.l10n.lastLoginAt)),
DataColumn2(label: Text(context.l10n.identityDevices_communicationLanguage)),
],
rows: devices.map(
(device) {
final textColor = Theme.of(context).colorScheme.onSecondaryContainer;

return DataRow2(
cells: [
DataCell(Text(device.id, style: TextStyle(color: textColor))),
DataCell(Text(device.username, style: TextStyle(color: textColor))),
DataCell(
Text(
DateFormat.yMd(Localizations.localeOf(context).languageCode).format(device.createdAt),
style: TextStyle(color: textColor),
),
),
DataCell(
Text(
device.lastLogin != null
? DateFormat.yMd(Localizations.localeOf(context).languageCode).format(device.lastLogin!.time)
: '-',
style: TextStyle(color: textColor),
),
),
DataCell(Text(device.communicationLanguage, style: TextStyle(color: textColor))),
],
);
},
).toList(),
),
),
],
),
),
],
),
);
}
}
4 changes: 4 additions & 0 deletions Applications/AdminUi/apps/admin_ui/lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,10 @@
"identityDetails_sentMessages_title": "Sent Messages",
"identityDetails_sentMessages_subtitle": "View messages sent by this identity.",
"identityDetails_noSentMessagesFound": "No sent messages found.",
"identityDevices_title": "Devices",
"identityDevices_title_description": "View devices of this Identity",
"identityDevices_username": "Username",
"identityDevices_communicationLanguage": "Communication Language",
"identityRelationshipTable_peer": "Peer",
"identityRelationshipTable_requestedBy": "Requested By",
"identityRelationshipTable_templateId": "Template ID",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,28 @@ class IdentityDevice {
final String username;
final DateTime createdAt;
final String createdByDevice;
final Map<String, dynamic>? lastLogin;
final LastLoginInformation? lastLogin;
final String communicationLanguage;

IdentityDevice({
required this.id,
required this.username,
required this.createdAt,
required this.createdByDevice,
required this.communicationLanguage,
this.lastLogin,
});

factory IdentityDevice.fromJson(dynamic json) => _$IdentityDeviceFromJson(json as Map<String, dynamic>);
Map<String, dynamic> toJson() => _$IdentityDeviceToJson(this);
}

@JsonSerializable()
class LastLoginInformation {
final DateTime time;

LastLoginInformation({required this.time});

factory LastLoginInformation.fromJson(dynamic json) => _$LastLoginInformationFromJson(json as Map<String, dynamic>);
Map<String, dynamic> toJson() => _$LastLoginInformationToJson(this);
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.