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

feat: Designer Dashboard Improvements #457

Merged
merged 52 commits into from
Aug 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
f91cce3
feat(#432): dashboard search and filter
johannesvedder Jun 13, 2023
362a4fe
fix: remove Designer V2 version number from page title
johannesvedder Jun 22, 2023
01510b4
feat(#432): dashboard pin and unpin studies
johannesvedder Jun 22, 2023
0c3d225
refactor: rename .env.selfhost to .env.hpi
johannesvedder Jun 22, 2023
9f0e8ac
feat(#432): add pins to study table and refactor code
johannesvedder Jun 23, 2023
eda8ccf
refactor: fix dashboard pin null value
johannesvedder Jun 27, 2023
615d5b6
feat: initial study tags
johannesvedder Jun 27, 2023
2aa65e2
use custom multiselect
johannesvedder Jun 27, 2023
515785b
fix: update copyright
johannesvedder Jun 27, 2023
66ba324
style: typo
johannesvedder Jun 27, 2023
cf39195
fix: tag type
johannesvedder Jun 27, 2023
b96dcf8
feat: display and update tags correctly
johannesvedder Jun 27, 2023
d7cb5f3
refactor: make tags more reactive
johannesvedder Jun 29, 2023
ef7532a
fix: make color nullable and int, add tags to dashboard
johannesvedder Jun 29, 2023
c1bf13d
refactor: rename
johannesvedder Jun 30, 2023
8d4eaa9
feat: working tags with foreign key study_tag
johannesvedder Jun 30, 2023
db57e09
fix: study_tags was null for new studies
johannesvedder Jun 30, 2023
354313c
style: dashboard study rows pin and tags improvement
johannesvedder Jun 30, 2023
59882b7
fix: tag related sql
johannesvedder Jun 30, 2023
73c207f
docs: update database documentation
Jun 30, 2023
0cbb4a6
fix: user related policies
johannesvedder Jun 30, 2023
052f977
fix: add user policy
johannesvedder Jun 30, 2023
9baddd1
fix: tag color
johannesvedder Jun 30, 2023
5729a09
fix: non-working pin
johannesvedder Jun 30, 2023
0bd0b30
docs: update database documentation
Jun 30, 2023
18158bb
chore: format
johannesvedder Jun 30, 2023
95f3306
feat: refactor Search to widget and make tags clickable
johannesvedder Jul 1, 2023
d0a96ea
fix: make Repo urls optional
johannesvedder Jul 1, 2023
324e2ce
fix: study was not returned completely
johannesvedder Jul 1, 2023
2d5076a
Merge branch 'dev' into issue/2-432-feature-designer-dashboard-improv…
johannesvedder Jul 17, 2023
e586369
chore: lock files
johannesvedder Jul 12, 2023
b4a987e
refactor: cleanup
johannesvedder Jul 14, 2023
611541f
fix(#482): docker networks
johannesvedder Jul 17, 2023
f2f8eca
feat: make study tags reactive
johannesvedder Jul 17, 2023
5df6619
remove tag color and parent from schema
johannesvedder Jul 17, 2023
e6579c8
refactor: pin changes to user_repository.dart
johannesvedder Jul 17, 2023
d820e77
chore: format
johannesvedder Jul 17, 2023
e66c8b3
Merge branch 'issue/482-supabase-test-framework' into issue/432-featu…
johannesvedder Jul 27, 2023
a47d7fc
feat(#432): partially reactive tags with validation
johannesvedder Jul 27, 2023
1b57070
docs: update database documentation
Jul 27, 2023
c59debb
fix(#432): Move tags to different branch
johannesvedder Jul 30, 2023
052517f
docs: update database documentation
Jul 30, 2023
c5757ce
Merge branch 'dev' into issue/432-feature-designer-dashboard-improvem…
johannesvedder Aug 8, 2023
db3a074
fix supabase tests
johannesvedder Aug 8, 2023
4be269e
Merge branch 'dev' into issue/432-feature-designer-dashboard-improvem…
johannesvedder Aug 8, 2023
76865d5
refactor: move migrate-user_preferences.sql
johannesvedder Aug 8, 2023
6a6fce9
fix(#432): remove search shadow and set correct color
johannesvedder Aug 15, 2023
691415c
refactor(#432): remove default case
johannesvedder Aug 15, 2023
cf811b0
refactor(#432): remove comment
johannesvedder Aug 15, 2023
152e66d
fix(#432): fallback to id sorting if predicates provide equal result
johannesvedder Aug 15, 2023
595a717
refactor: format
johannesvedder Aug 15, 2023
35f74ea
docs: update UML documentation
Aug 16, 2023
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 @@ -186,10 +186,13 @@ class AverageSectionWidget extends ReportSectionWidget {
showTitles: true,
getTitlesWidget: getTitles,
)),
// ignore: prefer_const_constructors
topTitles: AxisTitles(
// ignore: prefer_const_constructors
sideTitles: SideTitles(
showTitles: false,
))),
// ignore: prefer_const_constructors
gridData: charts.FlGridData(
drawHorizontalLine: false,
drawVerticalLine: false,
Expand Down
8 changes: 0 additions & 8 deletions app/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -373,14 +373,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.10.2"
freezed_annotation:
dependency: transitive
description:
name: freezed_annotation
sha256: "70776c4541e5cacfe45bcaf00fe79137b8c61aa34fb5765a05ce6c57fd72c6e9"
url: "https://pub.dev"
source: hosted
version: "0.14.3"
functions_client:
dependency: transitive
description:
Expand Down
1 change: 1 addition & 0 deletions core/lib/src/models/models.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ export 'tables/study.dart';
export 'tables/study_invite.dart';
export 'tables/study_subject.dart';
export 'tables/subject_progress.dart';
export 'tables/user.dart';
export 'tasks/tasks.dart';
4 changes: 2 additions & 2 deletions core/lib/src/models/tables/repo.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ class Repo extends SupabaseObjectFunctions<Repo> {
String studyId;
GitProvider provider;
@JsonKey(name: 'web_url')
String webUrl;
String? webUrl;
@JsonKey(name: 'git_url')
String gitUrl;
String? gitUrl;

Repo(this.projectId, this.userId, this.studyId, this.provider, this.webUrl, this.gitUrl);

Expand Down
30 changes: 20 additions & 10 deletions core/lib/src/models/tables/repo.g.dart

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

17 changes: 16 additions & 1 deletion core/lib/src/models/tables/study.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ enum ResultSharing {
}

@JsonSerializable()
class Study extends SupabaseObjectFunctions<Study> {
class Study extends SupabaseObjectFunctions<Study> implements Comparable<Study> {
static const String tableName = 'study';

@override
Expand Down Expand Up @@ -99,45 +99,55 @@ class Study extends SupabaseObjectFunctions<Study> {

factory Study.fromJson(Map<String, dynamic> json) {
final study = _$StudyFromJson(json);

final List? repo = json['repo'] as List?;
if (repo != null && repo.isNotEmpty) {
study.repo = Repo.fromJson((json['repo'] as List)[0] as Map<String, dynamic>);
}

final List? invites = json['study_invite'] as List?;
if (invites != null) {
study.invites = invites.map((json) => StudyInvite.fromJson(json as Map<String, dynamic>)).toList();
}

final List? participants = json['study_subject'] as List?;
if (participants != null) {
study.participants = participants.map((json) => StudySubject.fromJson(json as Map<String, dynamic>)).toList();
}

List? participantsProgress = json['study_progress'] as List?;
participantsProgress = json['study_progress_export'] as List?;
participantsProgress ??= json['subject_progress'] as List?;
if (participantsProgress != null) {
study.participantsProgress =
participantsProgress.map((json) => SubjectProgress.fromJson(json as Map<String, dynamic>)).toList();
}

final int? participantCount = json['study_participant_count'] as int?;
if (participantCount != null) {
study.participantCount = participantCount;
}

final int? endedCount = json['study_ended_count'] as int?;
if (endedCount != null) {
study.endedCount = endedCount;
}

final int? activeSubjectCount = json['active_subject_count'] as int?;
if (activeSubjectCount != null) {
study.activeSubjectCount = activeSubjectCount;
}

final List? missedDays = json['study_missed_days'] as List?;
if (missedDays != null) {
study.missedDays = List<int>.from(json['study_missed_days'] as List);
}

final String? createdAt = json['created_at'] as String?;
if (createdAt != null && createdAt.isNotEmpty) {
study.createdAt = DateTime.parse(createdAt);
}

return study;
}

Expand Down Expand Up @@ -236,4 +246,9 @@ class Study extends SupabaseObjectFunctions<Study> {
String toString() {
return 'Study{id: $id, title: $title, description: $description, userId: $userId, participation: $participation, resultSharing: $resultSharing, contact: $contact, iconName: $iconName, published: $published, questionnaire: $questionnaire, eligibilityCriteria: $eligibilityCriteria, consent: $consent, interventions: $interventions, observations: $observations, schedule: $schedule, reportSpecification: $reportSpecification, results: $results, collaboratorEmails: $collaboratorEmails, registryPublished: $registryPublished, participantCount: $participantCount, endedCount: $endedCount, activeSubjectCount: $activeSubjectCount, missedDays: $missedDays, repo: $repo, invites: $invites, participants: $participants, participantsProgress: $participantsProgress, createdAt: $createdAt}';
}

@override
int compareTo(Study other) {
return id.compareTo(other.id);
}
}
51 changes: 51 additions & 0 deletions core/lib/src/models/tables/user.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import 'package:json_annotation/json_annotation.dart';

import 'package:studyu_core/core.dart';

part 'user.g.dart';

@JsonSerializable()
class StudyUUser extends SupabaseObjectFunctions<StudyUUser> {
static const String tableName = 'user';

@override
Map<String, dynamic> get primaryKeys => {'id': id};

@JsonKey(name: 'id')
String id;
@JsonKey(name: 'email')
String email;
@JsonKey(name: 'preferences')
Preferences preferences;

StudyUUser({required this.id, required this.email, Preferences? preferences})
: preferences = preferences ?? Preferences();

factory StudyUUser.fromJson(Map<String, dynamic> json) => _$StudyUUserFromJson(json);

@override
Map<String, dynamic> toJson() => _$StudyUUserToJson(this);
}

@JsonSerializable()
class Preferences {
// todo store preferred user language in database
@JsonKey(name: 'lang')
String language;

@JsonKey(name: 'pinned_studies')
Set<String> pinnedStudies;

Preferences({this.language = '', this.pinnedStudies = const {}});

factory Preferences.fromJson(Map<String, dynamic> json) => _$PreferencesFromJson(json);

Map<String, dynamic> toJson() {
final Map<String, dynamic> json = _$PreferencesToJson(this);
// Remove empty fields from the JSON map
json.removeWhere(
(key, value) => value == null || value is String && value.isEmpty || value is Set && value.isEmpty,
);
return json;
}
}
36 changes: 36 additions & 0 deletions core/lib/src/models/tables/user.g.dart

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

12 changes: 5 additions & 7 deletions core/lib/src/util/supabase_object.dart
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
import 'dart:io';

import 'package:studyu_core/core.dart';
import 'package:studyu_core/src/env/env.dart' as env;
import 'package:studyu_core/src/models/tables/app_config.dart';
import 'package:studyu_core/src/models/tables/repo.dart';
import 'package:studyu_core/src/models/tables/study.dart';
import 'package:studyu_core/src/models/tables/study_invite.dart';
import 'package:studyu_core/src/models/tables/study_subject.dart';
import 'package:studyu_core/src/models/tables/subject_progress.dart';
import 'package:studyu_core/src/util/analytics.dart';
import 'package:supabase/supabase.dart';

abstract class SupabaseObject {
Expand All @@ -30,6 +24,8 @@ String tableName(Type cls) {
return Repo.tableName;
case StudyInvite:
return StudyInvite.tableName;
case StudyUUser:
return StudyUUser.tableName;
default:
print('$cls is not a supported Supabase type');
throw TypeError();
Expand All @@ -51,6 +47,8 @@ abstract class SupabaseObjectFunctions<T extends SupabaseObject> implements Supa
return Repo.fromJson(json) as T;
case StudyInvite:
return StudyInvite.fromJson(json) as T;
case StudyUUser:
return StudyUUser.fromJson(json) as T;
default:
print('$T is not a supported Supabase type');
throw TypeError();
Expand Down
12 changes: 12 additions & 0 deletions database/migration/migrate-user_preferences.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
ALTER TABLE public."user" ADD COLUMN preferences jsonb;


--
-- Name: Allow users to manage their own user; Type: POLICY; Schema: public; Owner: supabase_admin
--

CREATE POLICY "Allow users to manage their own user"
ON public."user" FOR ALL
USING (
auth.uid() = id
);
15 changes: 13 additions & 2 deletions database/studyu-schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ SET default_table_access_method = heap;
--

CREATE TABLE public.study (
id uuid DEFAULT gen_random_uuid() NOT NULL,
id uuid DEFAULT gen_random_uuid() NOT NULL UNIQUE,
contact jsonb NOT NULL,
title text NOT NULL,
description text NOT NULL,
Expand Down Expand Up @@ -580,7 +580,8 @@ ALTER TABLE public.study_progress_export OWNER TO postgres;

CREATE TABLE public."user" (
id uuid NOT NULL,
email text
email text,
preferences jsonb
);


Expand Down Expand Up @@ -831,6 +832,16 @@ CREATE POLICY "Users can do everything with their progress" ON public.subject_pr
WHERE (study_subject.id = subject_progress.subject_id))));


--
-- Name: Allow users to manage their own user; Type: POLICY; Schema: public; Owner:
--

CREATE POLICY "Allow users to manage their own user"
ON public."user" FOR ALL
USING (
auth.uid() = id
);

--
-- Name: app_config; Type: ROW SECURITY; Schema: public; Owner: postgres
--
Expand Down
Loading