Skip to content

Commit

Permalink
Match Announcer Page, UI Touchups & Permission Patch (#184)
Browse files Browse the repository at this point in the history
* Bug fix for match controller (can load match even when it's complete)

* dashboard ui update (badges & groupings)

* Cleaned up permission system & added match announcer page
  • Loading branch information
CJBuchel authored Nov 26, 2024
1 parent d45cb71 commit ab2d2bf
Show file tree
Hide file tree
Showing 67 changed files with 783 additions and 415 deletions.
2 changes: 1 addition & 1 deletion TMS.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"**/android": true,
},
"rust-analyzer.showUnlinkedFileNotification": false,
"svg.preview.background": "transparent",
"svg.preview.background": "dark-transparent",
"java.compile.nullAnalysis.mode": "automatic",
"java.configuration.updateBuildConfiguration": "automatic",
"cSpell.words": [
Expand Down
File renamed without changes
File renamed without changes
4 changes: 2 additions & 2 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ theme:
font:
text: 'Ubuntu'
code: 'Ubuntu Mono'
logo: assets/logo.svg
favicon: assets/logo_icon.svg
logo: assets/TMS_LOGO_WHITE.svg
favicon: assets/T_LOGO_WHITE.svg
features:
- navigation.footer
- navigation.tabs
Expand Down
2 changes: 1 addition & 1 deletion run_codegen
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ echo -e "${G}Running codegen for $TMS_INFRA"
# build wasm logic
echo -e "${G}Building wasm for $TMS_INFRA"
wasm-pack build $TMS_INFRA --target no-modules --out-dir $TMS_FLUTTER/web/pkg --no-typescript --out-name tms_infra --dev -- -Z build-std=std,panic_abort
(cd $TMS_FLUTTER && dart run flutter_rust_bridge build-web --dart-root $TMS_FLUTTER --rust-root $TMS_INFRA)
(cd $TMS_FLUTTER && flutter_rust_bridge_codegen build-web --dart-root $TMS_FLUTTER --rust-root $TMS_INFRA)

# run flutter code gen (freezed)
echo -e "${G}Running freezed for $TMS_FLUTTER"
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tms_client/android/app/src/main/res/mipmap-hdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tms_client/android/app/src/main/res/mipmap-mdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tms_client/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tms_client/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file removed tms_client/assets/logos/TMS_LOGO_ICON_SQUARE.png
Binary file not shown.
Binary file removed tms_client/assets/logos/TMS_LOGO_NO_TEXT_1024.png
Binary file not shown.
Binary file removed tms_client/assets/logos/TMS_LOGO_NO_TEXT_16.png
Binary file not shown.
Binary file removed tms_client/assets/logos/TMS_LOGO_NO_TEXT_192.png
Binary file not shown.
Binary file removed tms_client/assets/logos/TMS_LOGO_NO_TEXT_512.png
Binary file not shown.
Binary file removed tms_client/assets/logos/T_LOGO.png
Binary file not shown.
Binary file added tms_client/assets/logos/T_LOGO_PADDED.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 16 additions & 15 deletions tms_client/lib/generated/frb_generated.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1036,13 +1036,13 @@ abstract class TmsRustLibApi extends BaseApi {
{required User that});

bool crateInfraDatabaseSchemasUserUserHasPermissionAccess(
{required User that, required UserPermissions permissions});
{required User that, required UserPermissions requiredPermissions});

bool crateInfraDatabaseSchemasUserUserHasRole(
{required User that, required String role});

bool crateInfraDatabaseSchemasUserUserHasRoleAccess(
{required User that, required List<String> roles});
{required User that, required List<String> requiredRoles});

UserInsertRequest
crateInfraNetworkSchemasUserRequestsUserInsertRequestDefault();
Expand Down Expand Up @@ -1078,7 +1078,7 @@ abstract class TmsRustLibApi extends BaseApi {
{required UserPermissions that});

bool crateInfraDatabaseSchemasUserUserPermissionsHasRoleAccess(
{required UserPermissions that, required List<String> roles});
{required UserPermissions that, required List<String> requiredRoles});

UserPermissions crateInfraDatabaseSchemasUserUserPermissionsNew(
{bool? admin,
Expand Down Expand Up @@ -8948,20 +8948,21 @@ class TmsRustLibApiImpl extends TmsRustLibApiImplPlatform

@override
bool crateInfraDatabaseSchemasUserUserHasPermissionAccess(
{required User that, required UserPermissions permissions}) {
{required User that, required UserPermissions requiredPermissions}) {
return handler.executeSync(SyncTask(
callFfi: () {
final serializer = SseSerializer(generalizedFrbRustBinding);
sse_encode_box_autoadd_user(that, serializer);
sse_encode_box_autoadd_user_permissions(permissions, serializer);
sse_encode_box_autoadd_user_permissions(
requiredPermissions, serializer);
return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 305)!;
},
codec: SseCodec(
decodeSuccessData: sse_decode_bool,
decodeErrorData: null,
),
constMeta: kCrateInfraDatabaseSchemasUserUserHasPermissionAccessConstMeta,
argValues: [that, permissions],
argValues: [that, requiredPermissions],
apiImpl: this,
));
}
Expand All @@ -8970,7 +8971,7 @@ class TmsRustLibApiImpl extends TmsRustLibApiImplPlatform
get kCrateInfraDatabaseSchemasUserUserHasPermissionAccessConstMeta =>
const TaskConstMeta(
debugName: "user_has_permission_access",
argNames: ["that", "permissions"],
argNames: ["that", "requiredPermissions"],
);

@override
Expand Down Expand Up @@ -9001,28 +9002,28 @@ class TmsRustLibApiImpl extends TmsRustLibApiImplPlatform

@override
bool crateInfraDatabaseSchemasUserUserHasRoleAccess(
{required User that, required List<String> roles}) {
{required User that, required List<String> requiredRoles}) {
return handler.executeSync(SyncTask(
callFfi: () {
final serializer = SseSerializer(generalizedFrbRustBinding);
sse_encode_box_autoadd_user(that, serializer);
sse_encode_list_String(roles, serializer);
sse_encode_list_String(requiredRoles, serializer);
return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 307)!;
},
codec: SseCodec(
decodeSuccessData: sse_decode_bool,
decodeErrorData: null,
),
constMeta: kCrateInfraDatabaseSchemasUserUserHasRoleAccessConstMeta,
argValues: [that, roles],
argValues: [that, requiredRoles],
apiImpl: this,
));
}

TaskConstMeta get kCrateInfraDatabaseSchemasUserUserHasRoleAccessConstMeta =>
const TaskConstMeta(
debugName: "user_has_role_access",
argNames: ["that", "roles"],
argNames: ["that", "requiredRoles"],
);

@override
Expand Down Expand Up @@ -9296,12 +9297,12 @@ class TmsRustLibApiImpl extends TmsRustLibApiImplPlatform

@override
bool crateInfraDatabaseSchemasUserUserPermissionsHasRoleAccess(
{required UserPermissions that, required List<String> roles}) {
{required UserPermissions that, required List<String> requiredRoles}) {
return handler.executeSync(SyncTask(
callFfi: () {
final serializer = SseSerializer(generalizedFrbRustBinding);
sse_encode_box_autoadd_user_permissions(that, serializer);
sse_encode_list_String(roles, serializer);
sse_encode_list_String(requiredRoles, serializer);
return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 318)!;
},
codec: SseCodec(
Expand All @@ -9310,7 +9311,7 @@ class TmsRustLibApiImpl extends TmsRustLibApiImplPlatform
),
constMeta:
kCrateInfraDatabaseSchemasUserUserPermissionsHasRoleAccessConstMeta,
argValues: [that, roles],
argValues: [that, requiredRoles],
apiImpl: this,
));
}
Expand All @@ -9319,7 +9320,7 @@ class TmsRustLibApiImpl extends TmsRustLibApiImplPlatform
get kCrateInfraDatabaseSchemasUserUserPermissionsHasRoleAccessConstMeta =>
const TaskConstMeta(
debugName: "user_permissions_has_role_access",
argNames: ["that", "roles"],
argNames: ["that", "requiredRoles"],
);

@override
Expand Down
16 changes: 9 additions & 7 deletions tms_client/lib/generated/infra/database_schemas/user.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,17 @@ class User {
that: this,
);

bool hasPermissionAccess({required UserPermissions permissions}) =>
bool hasPermissionAccess({required UserPermissions requiredPermissions}) =>
TmsRustLib.instance.api
.crateInfraDatabaseSchemasUserUserHasPermissionAccess(
that: this, permissions: permissions);
that: this, requiredPermissions: requiredPermissions);

bool hasRole({required String role}) => TmsRustLib.instance.api
.crateInfraDatabaseSchemasUserUserHasRole(that: this, role: role);

bool hasRoleAccess({required List<String> roles}) => TmsRustLib.instance.api
.crateInfraDatabaseSchemasUserUserHasRoleAccess(that: this, roles: roles);
bool hasRoleAccess({required List<String> requiredRoles}) =>
TmsRustLib.instance.api.crateInfraDatabaseSchemasUserUserHasRoleAccess(
that: this, requiredRoles: requiredRoles);

factory User(
{required String username,
Expand Down Expand Up @@ -112,9 +113,10 @@ class UserPermissions {
that: this,
);

bool hasRoleAccess({required List<String> roles}) => TmsRustLib.instance.api
.crateInfraDatabaseSchemasUserUserPermissionsHasRoleAccess(
that: this, roles: roles);
bool hasRoleAccess({required List<String> requiredRoles}) =>
TmsRustLib.instance.api
.crateInfraDatabaseSchemasUserUserPermissionsHasRoleAccess(
that: this, requiredRoles: requiredRoles);

factory UserPermissions(
{bool? admin,
Expand Down
7 changes: 4 additions & 3 deletions tms_client/lib/providers/auth_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,10 @@ class AuthProvider extends EchoTreeProvider<String, User> {
return status;
}

bool hasPermissionAccess(UserPermissions permissions) {
var r = roles.map((e) => e.roleId).toList();
return permissions.hasRoleAccess(roles: r);
bool hasPermissionAccess(UserPermissions requiredPermissions) {
final currentUserRoles = roles.map((e) => e.roleId).toList();
final currentUserPerms = UserPermissions.fromRoles(roles: currentUserRoles);
return currentUserPerms.hasRoleAccess(requiredRoles: requiredPermissions.getRoles());
}

List<User> get usersByName {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,18 +121,22 @@ class _LoadedGameMatchStatusProvider extends _StagedGameMatchStatusProvider {
}

bool canLoad(List<GameMatch> matches) {
// check if all staged matches have submitted prior score sheets
// check if all staged match tables have submitted prior score sheets
bool tablesReady = _stagedMatchNumbers.every((matchNumber) {
GameMatch? match = matches.firstWhereOrNull((match) => match.matchNumber == matchNumber);
if (match == null) {
return false;
}

if (match == null) return false;
return match.gameMatchTables.every((table) {
return hasTableSubmittedPriorScoreSheets(table.table, matches);
});
});
return _stagedMatchNumbers.isNotEmpty && _loadedMatchNumbers.isEmpty && tablesReady;

// check to make sure that the staged matches are incomplete
bool matchesIncomplete = _stagedMatchNumbers.every((matchNumber) {
GameMatch? match = matches.firstWhereOrNull((match) => match.matchNumber == matchNumber);
if (match == null) return false;
return !match.completed;
});
return _stagedMatchNumbers.isNotEmpty && _loadedMatchNumbers.isEmpty && tablesReady && matchesIncomplete;
}

bool get canUnload {
Expand Down
2 changes: 1 addition & 1 deletion tms_client/lib/views/dashboard/dashboard.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'package:echo_tree_flutter/widgets/echo_tree_lifetime_widget.dart';
import 'package:flutter/material.dart';
import 'package:tms/views/dashboard/dashboard_info_banner.dart';
import 'package:tms/views/dashboard/integrity_overview.dart';
import 'package:tms/views/dashboard/integrity_overview/integrity_overview.dart';
import 'package:tms/views/dashboard/scoring_overview/scoring_overview.dart';
import 'package:tms/views/dashboard/timers_overview.dart';

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
import 'package:flutter/material.dart';
import 'package:tms/generated/infra/database_schemas/tournament_integrity_message.dart';
import 'package:tms/widgets/expandable/expandable_tile.dart';
import 'package:tms/widgets/integrity_checks/icon_tooltip_integrity_check.dart';

class IntegrityMessageTile extends StatelessWidget {
final List<TournamentIntegrityMessage> messages;
final ExpansionController _expansionController = ExpansionController(isExpanded: false);

IntegrityMessageTile({
Key? key,
required this.messages,
}) : super(key: key);

Widget _tile(BuildContext context, TournamentIntegrityMessage m) {
return ListTile(
leading: IconTooltipIntegrityCheck(messages: [m]),
title: Text(
m.integrityCode.getMessage(),
overflow: TextOverflow.ellipsis,
),
subtitle: Row(
children: [
// code
Text(
m.integrityCode.getStringifiedCode(),
style: TextStyle(
fontWeight: FontWeight.bold,
color: m.integrityCode.when(
error: (_) => Colors.red,
warning: (_) => Colors.orange,
),
),
),
// team (if applicable)
if (m.teamNumber != null) ...[
const SizedBox(width: 10),
Text(
"Team ${m.teamNumber}",
style: const TextStyle(
fontStyle: FontStyle.italic,
fontWeight: FontWeight.bold,
),
),
],
// match (if applicable)
if (m.matchNumber != null) ...[
const SizedBox(width: 10),
Text(
"Match ${m.matchNumber}",
style: const TextStyle(
fontStyle: FontStyle.italic,
fontWeight: FontWeight.bold,
),
),
],
// session (if applicable)
if (m.sessionNumber != null) ...[
const SizedBox(width: 10),
Text(
"Session ${m.sessionNumber}",
style: const TextStyle(
fontStyle: FontStyle.italic,
fontWeight: FontWeight.bold,
),
),
],
],
),
);
}

@override
Widget build(BuildContext context) {
if (messages.length > 1) {
return Badge.count(
count: messages.length,
backgroundColor: Colors.red,
child: ExpandableTile(
controller: _expansionController,
header: Padding(
padding: const EdgeInsets.all(15),
child: Row(
children: [
IconTooltipIntegrityCheck(messages: messages),
const SizedBox(width: 10),
// code
Text(
messages.first.integrityCode.getStringifiedCode(),
style: TextStyle(
fontWeight: FontWeight.bold,
color: messages.first.integrityCode.when(
error: (_) => Colors.red,
warning: (_) => Colors.orange,
),
),
),
const SizedBox(width: 10),
Text(
messages.first.integrityCode.getMessage(),
style: const TextStyle(fontSize: 16),
),
const Spacer(),
ValueListenableBuilder(
valueListenable: _expansionController,
builder: (context, isExpanded, _) {
return Icon(
isExpanded ? Icons.keyboard_arrow_up : Icons.keyboard_arrow_down,
);
},
),
],
),
),
body: Column(
children: messages.map((m) => _tile(context, m)).toList(),
),
),
);
} else if (messages.isNotEmpty) {
return _tile(context, messages.first);
} else {
return const SizedBox();
}
}
}
Loading

0 comments on commit ab2d2bf

Please sign in to comment.