Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/staging' into fixes/companySpeak…
Browse files Browse the repository at this point in the history
…erScreen
  • Loading branch information
bvlourenco committed Nov 19, 2022
2 parents 25becbf + 6dfeb31 commit f5bf206
Show file tree
Hide file tree
Showing 32 changed files with 2,771 additions and 372 deletions.
98 changes: 58 additions & 40 deletions backend/src/mongodb/member.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,48 +183,62 @@ func (m *MembersType) GetMembers(options GetMemberOptions) ([]*models.Member, er

var members []*models.Member = make([]*models.Member, 0)

query := mongo.Pipeline{

// filter by name first
{{
Key: "$match", Value: bson.M{
"name": bson.M{
"$regex": fmt.Sprintf(".*%s.*", nameFilter),
"$options": "i",
var query mongo.Pipeline
if len(nameFilter) > 0 {
query = mongo.Pipeline{
{{
"$match", bson.M{
"name": bson.M{
"$regex": fmt.Sprintf(".*%s.*", nameFilter),
"$options": "i",
},
},
},
}},

// get all the teams on which each member is participating,
// and add them to each member correspondingly
{{
Key: "$lookup", Value: bson.D{
{Key: "from", Value: Teams.Collection.Name()},
{Key: "localField", Value: "_id"},
{Key: "foreignField", Value: "members.member"},
{Key: "as", Value: "team"},
},
}},

// get an instance of each member for every team he/she belonged to
{{
Key: "$unwind", Value: "$team",
}},

// get the event associated with each team on each member
{{
Key: "$lookup", Value: bson.D{
{Key: "from", Value: Events.Collection.Name()},
{Key: "localField", Value: "team._id"},
{Key: "foreignField", Value: "teams"},
{Key: "as", Value: "event"},
},
}},
}},
}
} else {
query = mongo.Pipeline{

// filter by name first
{{
"$match", bson.M{
"name": bson.M{
"$regex": fmt.Sprintf(".*%s.*", nameFilter),
"$options": "i",
},
},
}},

// get all the teams on which each member is participating,
// and add them to each member correspondingly
{{
"$lookup", bson.D{
{"from", Teams.Collection.Name()},
{"localField", "_id"},
{"foreignField", "members.member"},
{"as", "team"},
},
}},

// get an instance of each member for every team he/she belonged to
{{
"$unwind", "$team",
}},

// get the event associated with each team on each member
{{
"$lookup", bson.D{
{"from", Events.Collection.Name()},
{"localField", "team._id"},
{"foreignField", "teams"},
{"as", "event"},
},
}},

// get an instance of each member for every event he/she belonged to
{{
Key: "$unwind", Value: "$event",
}},
// get an instance of each member for every event he/she belonged to
{{
"$unwind", "$event",
}},
}
}

if options.Event != nil {
Expand Down Expand Up @@ -330,6 +344,7 @@ func (m *MembersType) GetMembersParticipations(id primitive.ObjectID) ([]*models
options := GetEventsOptions{}
events, err := Events.GetEvents(options)
if err != nil {
print("ERROR #1", err)
return nil, err
}

Expand All @@ -339,6 +354,9 @@ func (m *MembersType) GetMembersParticipations(id primitive.ObjectID) ([]*models
for _, teamID := range event.Teams {
team, err := Teams.GetTeam(teamID)
if err != nil {
print("TEAM ID: ", teamID.Hex())
print("EVENT: ", event)
print("ERROR #2", err)
return nil, err
}
for _, teamMember := range team.Members {
Expand Down
5 changes: 5 additions & 0 deletions backend/src/mongodb/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ type CreateSessionData struct {
Description *string `json:"description"`
Place *string `json:"place"`
Kind *string `json:"kind"`
VideoURL *string `json:"videoURL"`
Company *primitive.ObjectID `json:"company"`
Speakers *[]primitive.ObjectID `json:"speaker"`
Tickets *models.SessionTickets `json:"tickets"`
Expand Down Expand Up @@ -199,6 +200,10 @@ func (s *SessionsType) CreateSession(data CreateSessionData) (*models.Session, e
c["speaker"] = data.Speakers
}

if data.VideoURL != nil {
c["videoURL"] = data.VideoURL
}

if data.Tickets != nil {
c["tickets"] = bson.M{
"start": data.Tickets.Start.UTC(),
Expand Down
2 changes: 1 addition & 1 deletion backend/src/mongodb/team.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ type UpdateTeamMemberData struct {

// CreateTeamMemberData contains data needed to create a team member
type CreateTeamMemberData struct {
Member primitive.ObjectID `json:"id"`
Member primitive.ObjectID `json:"member"`
Role models.TeamRole `json:"role"`
}

Expand Down
2 changes: 1 addition & 1 deletion frontend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ RUN git clone https://github.com/flutter/flutter.git /usr/local/flutter
ENV PATH="/usr/local/flutter/bin:/usr/local/flutter/bin/cache/dart-sdk/bin:${PATH}"

# Enable flutter web
RUN flutter channel master
RUN flutter channel stable
RUN flutter upgrade
RUN flutter config --enable-web

Expand Down
2 changes: 2 additions & 0 deletions frontend/lib/components/appbar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import 'package:flutter/material.dart';
import 'package:frontend/components/SearchResultWidget.dart';
import 'package:frontend/components/deckTheme.dart';
import 'package:frontend/components/eventNotifier.dart';
import 'package:frontend/components/SearchResultWidget.dart';
import 'package:frontend/main.dart';
import 'package:frontend/models/event.dart';
import 'package:frontend/routes/company/CompanyScreen.dart';
import 'package:frontend/routes/member/MemberScreen.dart';
Expand Down
50 changes: 28 additions & 22 deletions frontend/lib/components/filterBarTeam.dart
Original file line number Diff line number Diff line change
@@ -1,29 +1,34 @@
import 'package:flutter/material.dart';

class FilterBarTeam extends StatefulWidget {
String currentFilter;
final Function onSelected;
final List<String> teamFilters;

FilterBarTeam({Key? key, required this.onSelected}) : super(key: key);
FilterBarTeam(
{Key? key,
required this.currentFilter,
required this.teamFilters,
required this.onSelected})
: super(key: key);

@override
FilterBarTeamState createState() => FilterBarTeamState(onSelected: onSelected);
FilterBarTeamState createState() => FilterBarTeamState(
currentFilter: currentFilter,
teamFilters: teamFilters,
onSelected: onSelected);
}

class FilterBarTeamState extends State<FilterBarTeam> {
String currentFilter;
final List<String> teamFilters;
final Function onSelected;

FilterBarTeamState({Key? key, required this.onSelected});

int _currentIndex = 0;
List<String> _filters = [
"All",
"Coordination",
"DevTeam",
"Logistics",
"Multimedia",
"Partnerships",
"Social Network",
];
FilterBarTeamState(
{Key? key,
required this.currentFilter,
required this.teamFilters,
required this.onSelected});

@override
Widget build(BuildContext context) {
Expand All @@ -35,8 +40,8 @@ class FilterBarTeamState extends State<FilterBarTeam> {

rowChips() {
List<Widget> filters = [];
for (int i = 0; i < _filters.length; i++) {
filters.add(createChip(_filters[i], i));
for (int i = 0; i < teamFilters.length; i++) {
filters.add(createChip(teamFilters[i], i));
}
return Row(children: filters);
}
Expand All @@ -45,25 +50,26 @@ class FilterBarTeamState extends State<FilterBarTeam> {
return Container(
margin: EdgeInsets.all(7.0),
child: ChoiceChip(
selected: _currentIndex == index,
selected: label.toLowerCase() == currentFilter.toLowerCase(),
backgroundColor: Colors.indigo[100],
shape: RoundedRectangleBorder(
side: BorderSide(color: Colors.black12, width: 1),
borderRadius: BorderRadius.circular(15),
),
elevation: 2,
pressElevation: 1,
elevation: 1,
pressElevation: 3,
shadowColor: Colors.teal,
selectedColor: Colors.indigo[400],
onSelected: (bool selected) {
setState(() {
_currentIndex = selected ? index : _currentIndex;
onSelected(_filters[_currentIndex].toUpperCase());
onSelected(label.toUpperCase());
});
},
label: Text(label),
labelStyle: TextStyle(
color: _currentIndex != index ? Colors.indigo[400] : Colors.white,
color: label.toLowerCase() != currentFilter.toLowerCase()
? Colors.indigo[400]
: Colors.white,
),
padding: EdgeInsets.all(6.0),
),
Expand Down
10 changes: 0 additions & 10 deletions frontend/lib/components/filterbar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,6 @@ class FilterBarState extends State<FilterBar> {
FilterBarState({Key? key, required this.onSelected});

int _currentIndex = 0;
List<String> _filters = [
"All",
"Suggested",
"Contacted",
"Rejected",
"Give Up",
"Announced",
"In Conversations",
"In Negotiations"
];

@override
Widget build(BuildContext context) {
Expand Down
8 changes: 8 additions & 0 deletions frontend/lib/components/router.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import 'package:frontend/routes/member/MemberListWidget.dart';
import 'package:frontend/routes/speaker/AddFlightInfoForm.dart';
import 'package:frontend/routes/speaker/SpeakerListWidget.dart';
import 'package:frontend/routes/speaker/AddSpeakerForm.dart';
import 'package:frontend/routes/teams/AddTeamMemberForm.dart';
import 'package:frontend/routes/session/AddSessionForm.dart';

class Routes {
static const String BaseRoute = '/';
Expand All @@ -22,8 +24,10 @@ class Routes {
static const String AddSpeaker = '/add/speaker';
static const String ShowAllMembers = '/all/members';
static const String AddMember = '/add/member';
static const String AddTeamMember = '/add/teamMember';
static const String AddMeeting = '/add/meeting';
static const String AddFlightInfo = '/add/flightinfo';
static const String AddSession = '/add/session';
}

Route<dynamic> generateRoute(RouteSettings settings) {
Expand All @@ -44,12 +48,16 @@ Route<dynamic> generateRoute(RouteSettings settings) {
return SlideRoute(page: AddSpeakerForm());
case Routes.ShowAllMembers:
return MaterialPageRoute(builder: (context) => MemberListWidget());
case Routes.AddTeamMember:
return MaterialPageRoute(builder: (context) => AddTeamMemberForm());
case Routes.AddMember:
return SlideRoute(page: AddMemberForm());
case Routes.AddMeeting:
return SlideRoute(page: AddMeetingForm());
case Routes.AddFlightInfo:
return SlideRoute(page: AddFlightInfoForm());
case Routes.AddSession:
return SlideRoute(page: AddSessionForm());
default:
return MaterialPageRoute(builder: (context) => UnknownScreen());
}
Expand Down
8 changes: 8 additions & 0 deletions frontend/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ import 'package:frontend/components/eventNotifier.dart';
import 'package:frontend/routes/company/CompanyTableNotifier.dart';
import 'package:frontend/routes/member/MemberNotifier.dart';
import 'package:frontend/routes/meeting/MeetingsNotifier.dart';
import 'package:frontend/routes/session/SessionsNotifier.dart';
import 'package:frontend/routes/speaker/speakerNotifier.dart';
import 'package:frontend/models/event.dart';
import 'package:frontend/routes/teams/TeamsNotifier.dart';
import 'package:frontend/services/authService.dart';
import 'package:frontend/services/eventService.dart';
import 'package:provider/provider.dart';
Expand Down Expand Up @@ -39,12 +41,18 @@ Future main() async {
ChangeNotifierProvider<MeetingsNotifier>(
create: (_) => MeetingsNotifier(meetings: []),
),
ChangeNotifierProvider<SessionsNotifier>(
create: (_) => SessionsNotifier(sessions: []),
),
ChangeNotifierProvider<AuthService>(
create: (_) => AuthService(),
),
ChangeNotifierProvider<BottomNavigationBarProvider>(
create: (_) => BottomNavigationBarProvider(),
),
ChangeNotifierProvider<TeamsNotifier>(
create: (_) => TeamsNotifier(teams: []),
),
],
child: App(),
));
Expand Down
4 changes: 4 additions & 0 deletions frontend/lib/models/company.dart
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,10 @@ class Company {
(element) => element.event == this.lastParticipation)!;
}

String companyAsString() {
return '${this.name}';
}

bool operator ==(o) => o is Company && id == o.id;
int get hashCode => id.hashCode;
}
Expand Down
1 change: 1 addition & 0 deletions frontend/lib/models/member.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'dart:convert';

import 'package:frontend/models/contact.dart';
import 'package:frontend/models/team.dart';

class Member {
final String id;
Expand Down
Loading

0 comments on commit f5bf206

Please sign in to comment.