Skip to content

Commit

Permalink
Merge branch 'frontend' into 596-fe-add-review-feature-to-workspace-page
Browse files Browse the repository at this point in the history
  • Loading branch information
Zulalm authored Dec 19, 2023
2 parents 3aec3c1 + f310758 commit a6a9aa7
Show file tree
Hide file tree
Showing 35 changed files with 1,951 additions and 623 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class PostQuestionError implements Exception {
String message;
PostQuestionError({this.message = "Post Question Error"});
}

class PostAnswerError implements Exception {
String message;
PostAnswerError({this.message = "Post Answer Error"});
}
35 changes: 6 additions & 29 deletions project/FrontEnd/collaborative_science_platform/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import 'package:collaborative_science_platform/providers/annotation_provider.dart';
import 'package:collaborative_science_platform/providers/auth.dart';
import 'package:collaborative_science_platform/providers/profile_data_provider.dart';
import 'package:collaborative_science_platform/providers/node_provider.dart';
import 'package:collaborative_science_platform/providers/question_provider.dart';
import 'package:collaborative_science_platform/providers/user_provider.dart';
import 'package:collaborative_science_platform/providers/workspace_provider.dart';
import 'package:collaborative_science_platform/services/screen_navigation.dart';
Expand Down Expand Up @@ -35,42 +37,17 @@ class MyApp extends StatelessWidget {
ChangeNotifierProvider<NodeProvider>(create: (context) => NodeProvider()),
ChangeNotifierProvider<UserProvider>(create: (context) => UserProvider()),
ChangeNotifierProvider<WorkspaceProvider>(create: (context) => WorkspaceProvider()),
ChangeNotifierProvider<QuestionAnswerProvider>(
create: (context) => QuestionAnswerProvider()),
ChangeNotifierProvider<AnnotationProvider>(create: (context) => AnnotationProvider()),
],
// child: MaterialApp(
// debugShowCheckedModeBanner: false,
// title: Constants.appName,
// routes: {
// '/': (context) => const HomePage(),
// LoginPage.routeName: (context) => const LoginPage(),
// SignUpPage.routeName: (context) => const SignUpPage(),
// WorkspacesPage.routeName: (context) => const WorkspacesPage(),
//
// ///ProfilePage.routeName: (context) => const ProfilePage(),
// GraphPage.routeName: (context) => const GraphPage(),
// NotificationPage.routeName: (context) => const NotificationPage(),
// AccountSettingsPage.routeName: (context) => const AccountSettingsPage(),
// PleaseLoginPage2.routeName: (context) => const PleaseLoginPage2(),
// NodeDetailsPage.routeName: (context) {
// final int nodeId = ModalRoute.of(context)!.settings.arguments as int;
// return NodeDetailsPage(nodeID: nodeId);
// },
// ProfilePage.routeName: (context) {
// final String email = ModalRoute.of(context)!.settings.arguments as String ?? "";
// return ProfilePage(email: email);
// },
// },
// navigatorKey: ScreenNavigation.navigatorKey,
// theme: ThemeData(
// colorScheme: ColorScheme.fromSeed(seedColor: AppColors.primaryColor),
// useMaterial3: true,
// ),
child: Portal(
child: MaterialApp.router(
routerConfig: router,
debugShowCheckedModeBanner: false,
title: Constants.appName,
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Color.fromARGB(255, 85, 234, 145)),
colorScheme: ColorScheme.fromSeed(seedColor: const Color.fromARGB(255, 85, 234, 145)),
useMaterial3: true,
),
),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,19 @@
import 'package:collaborative_science_platform/models/basic_user.dart';

class Annotation {
int annotationID;
String annotationType;
String annotationVisibilityType;
BasicUser owner;
Object annotationLocation;
int? annotationID;
// String annotationType;
// String annotationVisibilityType;
// BasicUser owner;
// Object annotationLocation;
String annotationContent;
String annotationAuthor;
int startOffset;
int endOffset;
DateTime createdAt;
DateTime updatedAt;

Annotation({
required this.annotationID,
required this.annotationType,
required this.annotationVisibilityType,
required this.owner,
required this.annotationLocation,
this.annotationID,
required this.startOffset,
required this.endOffset,
required this.createdAt,
required this.updatedAt,
required this.annotationContent,
required this.annotationAuthor,
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,22 @@ class BasicUser {
String bio;
bool emailNotificationPreference;
bool showActivity;
String userType;

BasicUser({
required this.basicUserId,
required this.bio,
required this.emailNotificationPreference,
required this.showActivity,
this.basicUserId = 0,
this.bio = "",
this.emailNotificationPreference = true,
this.showActivity = true,
this.userType = "",
});
factory BasicUser.fromJson(Map<String, dynamic> jsonString) {
return BasicUser(
basicUserId: jsonString["basic_user_id"],
bio: jsonString["bio"],
emailNotificationPreference: jsonString["email_notification_preference"],
showActivity: jsonString["show_activity_preference"],
userType: jsonString["user_type"],
);
}

}
Original file line number Diff line number Diff line change
@@ -1,31 +1,64 @@
import 'package:collaborative_science_platform/models/user.dart';

class Question {
int id;
String content;
String createdAt;
User? asker;
String answer;
User asker;
String? answer;
User? answerer;
String answeredAt;
Question({
required this.content,
required this.createdAt,
required this.answer,
required this.answeredAt,
required this.answerer,
required this.asker,
});
String? answeredAt;
int? nodeId;
bool isAnswered;
Question(
{required this.id,
required this.content,
required this.createdAt,
required this.asker,
required this.answer,
required this.answerer,
required this.answeredAt,
required this.nodeId,
required this.isAnswered});
factory Question.fromJson(Map<String, dynamic> jsonString) {
return Question(
id: jsonString['id'] ?? -1,
content: jsonString['question_content'] ?? "",
createdAt: jsonString['created_at'] ?? "",
answer: jsonString['answer_content'] ?? "",
answeredAt: jsonString['answered_at'] ?? "",
answerer: jsonString['answerer'] == null
? null
: User.fromJsonforNodeDetailPage(jsonString['answerer']),
asker:
jsonString['asker'] == null ? null : User.fromJsonforNodeDetailPage(jsonString['asker']),
asker: User.fromJsonforNodeDetailPage(jsonString['asker']),
nodeId: jsonString['node_id'] ?? -1,
isAnswered: jsonString['answer_content'] != null,
);
}

factory Question.fromJsonforProfilePage(Map<String, dynamic> jsonString) {
return Question(
id: jsonString['id'] ?? -1,
content: jsonString['question_content'] ?? "",
createdAt: jsonString['ask_date'] ?? "",
asker: User(
id: jsonString['asker_id'],
email: jsonString['asker_mail'],
firstName: jsonString['asker_name'],
lastName: jsonString['asker_surname'],
),
answer: jsonString.containsKey("answer_content") ? jsonString["answer_content"] : "",
answerer: jsonString.containsKey("answerer")
? User(
id: jsonString['answerer_id'],
email: jsonString['answerer_mail'],
firstName: jsonString['answerer_name'],
lastName: jsonString['answerer_surname'],
)
: null,
answeredAt: jsonString.containsKey("answer_date") ? jsonString["answer_date"] as String : "",
nodeId: jsonString['node_id'] ?? -1,
isAnswered: jsonString['is_answered'] == 1,
);
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:collaborative_science_platform/models/node_details_page/question.dart';
import 'package:collaborative_science_platform/models/user.dart';

class Node {
Expand Down Expand Up @@ -29,25 +30,34 @@ class ProfileData {
String email;
String aboutMe;
List<Node> nodes;
List<int> askedQuestionIDs;
List<int> answeredQuestionIDs;
List<Question> askedQuestions;
List<Question> answeredQuestions;
ProfileData(
{this.id = 0,
this.aboutMe = "",
this.email = "",
this.name = "",
this.surname = "",
this.nodes = const [],
this.askedQuestionIDs = const [],
this.answeredQuestionIDs = const []});
this.askedQuestions = const [],
this.answeredQuestions = const []});

factory ProfileData.fromJson(Map<String, dynamic> jsonString) {
var list = jsonString['nodes'] as List;
List<Node> nodes = list.map((e) => Node.fromJson(e)).toList();
var nodeList = jsonString['nodes'] as List;
var askedList = jsonString['asked_questions'] as List;
var answeredList = jsonString['answered_questions'] as List;

List<Node> nodes = nodeList.map((e) => Node.fromJson(e)).toList();
List<Question> asked = askedList.map((e) => Question.fromJsonforProfilePage(e)).toList();
List<Question> answered = answeredList.map((e) => Question.fromJsonforProfilePage(e)).toList();

return ProfileData(
nodes: nodes,
name: jsonString['name'],
surname: jsonString['surname'],
aboutMe: jsonString['bio'],
askedQuestions: asked,
answeredQuestions: answered,
);
}

Expand All @@ -72,8 +82,6 @@ class ProfileData {
],
),
],
askedQuestionIDs: [1, 2, 3, 4, 5],
answeredQuestionIDs: [1, 2, 3, 4, 5],
);
}
}

This file was deleted.

Loading

0 comments on commit a6a9aa7

Please sign in to comment.