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

Feature/cancel reservations #795

Open
wants to merge 74 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
6e3221e
Merge branch 'feature/library-occupation' into feature/library-rooms
jlcrodrigues Nov 13, 2022
3077511
feat: library reservations fetcher
jlcrodrigues Nov 14, 2022
c23cf3d
Display reserved library rooms
jlcrodrigues Dec 11, 2022
5ed8089
Merge branch 'feature/library-occupation' into feature/library-rooms
jlcrodrigues Dec 11, 2022
cfec53e
Merge branch 'feature/library-rooms'
jlcrodrigues Dec 11, 2022
83d9e1a
Merge branch feature/library-occupation
jlcrodrigues Jan 30, 2023
057e001
Merge branch 'feature/library-occupation' of github.com:NIAEFEUP/proj…
jlcrodrigues Jan 30, 2023
76cfe79
Added library reservations card to main page
jlcrodrigues Jan 30, 2023
36980a7
Added tabs to library page
jlcrodrigues Jan 30, 2023
fc95928
Reworked library data flow
jlcrodrigues Feb 12, 2023
6ce563e
Merge branch 'develop'
jlcrodrigues Feb 12, 2023
af78294
Fix merge conflicts
jlcrodrigues Feb 12, 2023
c2ecf16
Made changes to reserved rooms card
jlcrodrigues Feb 12, 2023
7e4b925
Reworked library reservations' view
jlcrodrigues Feb 12, 2023
53c2859
Added custom reservations route
jlcrodrigues Feb 12, 2023
1aa923b
Small changes to library reservations
jlcrodrigues Feb 12, 2023
9fa6414
Merge branch 'develop'
jlcrodrigues Feb 12, 2023
7cfd371
Merge branch 'develop' into feature/library-rooms
jlcrodrigues Feb 12, 2023
fd285b4
Merge branch develop
jlcrodrigues Mar 15, 2023
a86709b
Fixed providers issues
jlcrodrigues Mar 15, 2023
c2d0834
Refactored helper functions
jlcrodrigues Mar 15, 2023
ea8af13
Made changes according to suggestions
jlcrodrigues Apr 12, 2023
aad69ab
Finished requested changes
jlcrodrigues Apr 12, 2023
9723a9b
Fixed linter issues
jlcrodrigues Apr 12, 2023
7456117
Finished reservations
jlcrodrigues Apr 26, 2023
71f8d92
Merge branch 'feature/library-rooms' of github.com:NIAEFEUP/project-s…
jlcrodrigues Apr 26, 2023
6893993
Fixed linter issues
jlcrodrigues Apr 26, 2023
1a553fc
Removed nullable type from RoomList
jlcrodrigues May 9, 2023
34aac72
Remove redundant reservation duration from db
jlcrodrigues Jun 21, 2023
e582cf7
Feature/library rooms (#658)
thePeras Jun 21, 2023
30ef2c0
Merge branch 'develop'
jlcrodrigues Aug 24, 2023
c2aceee
Merge branch 'develop' of github.com:NIAEFEUP/project-schrodinger int…
jlcrodrigues Aug 24, 2023
4c0f4b0
Merge branch 'develop'
jlcrodrigues Aug 26, 2023
c9c4a95
Merge branch feature/library-reservations
jlcrodrigues Aug 26, 2023
37ab2c1
Made small adjustements to reservation cancelling
jlcrodrigues Aug 26, 2023
f64edb7
Worked on linter issues
jlcrodrigues Aug 26, 2023
7f68904
Fixed linter issues
jlcrodrigues Aug 27, 2023
47b39d6
Formatted files
jlcrodrigues Aug 27, 2023
bd16037
Worked on linter issues
jlcrodrigues Sep 20, 2023
b2a2ffb
Worked on linter issues
jlcrodrigues Sep 20, 2023
9f417dd
Worked on linter issues
jlcrodrigues Sep 20, 2023
bc185b4
Merge branch develop
jlcrodrigues Sep 26, 2023
3b10427
Merge branch 'develop' of github.com:NIAEFEUP/project-schrodinger int…
jlcrodrigues Sep 26, 2023
fc4980e
Merge branch 'feature/library-reservations'
jlcrodrigues Sep 26, 2023
9af2713
Merge branch 'feature/library-reservations'
jlcrodrigues Sep 26, 2023
b50816f
Added missing translations
jlcrodrigues Sep 26, 2023
01e259a
Fixed linter
jlcrodrigues Sep 26, 2023
5ba9cfa
Made small changes according to suggestions
jlcrodrigues Oct 11, 2023
b51abd8
Merge branch 'develop'
jlcrodrigues Oct 11, 2023
ea9b0bc
Fixed context errors in reservation cancel button
jlcrodrigues Nov 9, 2023
da5c3fe
Merge branch 'develop'
jlcrodrigues Nov 9, 2023
31624e4
Merge branch 'develop'
jlcrodrigues Nov 9, 2023
4e6d45b
Merge branch 'feature/library-reservations' into feature/cancel-reser…
jlcrodrigues Nov 9, 2023
dc64cda
Merge branch 'develop'
jlcrodrigues Dec 11, 2023
1768fb0
Merge branch 'feature/library-reservations'
jlcrodrigues Dec 11, 2023
73f499e
Remove new line from version file
jlcrodrigues Dec 11, 2023
e6492a5
Linter fixes
jlcrodrigues Dec 11, 2023
2e61e75
Merge branch 'develop'
jlcrodrigues Dec 28, 2023
97c4c1b
Merge branch 'feature/library-reservations'
jlcrodrigues Dec 28, 2023
1eff19f
Small lint fix
jlcrodrigues Dec 29, 2023
ca22148
Lint fixes
jlcrodrigues Dec 29, 2023
ee64b61
Merge branch 'develop' of github.com:NIAEFEUP/project-schrodinger int…
jlcrodrigues Jan 8, 2024
eabde47
Removed leftover ignore
jlcrodrigues Jan 8, 2024
80df1bc
Generated translation files
jlcrodrigues Jan 8, 2024
f1e5c09
Merged branch 'feature/library-reservations'
jlcrodrigues Jan 8, 2024
97507c7
Fixed library card page link
jlcrodrigues Jan 11, 2024
85f81b4
Reset app version
jlcrodrigues Jan 11, 2024
a4e7a04
Merge branch 'develop' of github.com:NIAEFEUP/project-schrodinger int…
jlcrodrigues Jan 24, 2024
eb601cd
Reverted messages_all file, fixing tests
jlcrodrigues Jan 24, 2024
e3e5630
Merge branch 'feature/library-reservations' of github.com:NIAEFEUP/pr…
jlcrodrigues Jan 24, 2024
0e8b516
Made changes according to suggestions
jlcrodrigues Jan 24, 2024
a4768ec
Format files
jlcrodrigues Jan 24, 2024
65f3fe4
Fixed reservation weekday
jlcrodrigues Jan 24, 2024
8ccb573
Merge branch feature/library-reservations
jlcrodrigues Jan 24, 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
2 changes: 1 addition & 1 deletion uni/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ subprojects {

tasks.register("clean", Delete) {
delete rootProject.buildDir
}
}
25 changes: 25 additions & 0 deletions uni/lib/controller/fetchers/library_reservation_fetcher.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import 'package:uni/controller/fetchers/session_dependant_fetcher.dart';
import 'package:uni/controller/networking/network_router.dart';
import 'package:uni/controller/parsers/parser_library_reservation.dart';
import 'package:uni/model/entities/library_reservation.dart';
import 'package:uni/model/entities/session.dart';

/// Get the library rooms' reservations from the website
class LibraryReservationsFetcherHtml implements SessionDependantFetcher {
@override
List<String> getEndpoints(Session session) {
// TO DO: Implement parsers for all faculties
// and dispatch for different fetchers
Comment on lines +11 to +12
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feature is specific to FEUP, it seems, so is there a need to implement parsers for all faculties?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, I removed the comment in #1073

final url = '${NetworkRouter.getBaseUrl('feup')}res_recursos_geral'
'.pedidos_list?pct_tipo_grupo_id=3';
return [url];
}

Future<List<LibraryReservation>> getReservations(Session session) async {
final baseUrl = getEndpoints(session)[0];
final response = NetworkRouter.getWithCookies(baseUrl, {}, session);
final reservations = await response.then(getReservationsFromHtml);

return reservations;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import 'package:uni/controller/local_storage/database/app_database.dart';
import 'package:uni/model/entities/library_reservation.dart';

class LibraryReservationDatabase extends AppDatabase {
LibraryReservationDatabase()
: super('reservations.db', [
'''
CREATE TABLE RESERVATION(
id INTEGER PRIMARY KEY AUTOINCREMENT,
room TEXT,
startDate TEXT,
duration INT
)
'''
]);

Future<void> saveReservations(List<LibraryReservation> reservations) async {
final db = await getDatabase();
await db.transaction((txn) async {
await txn.delete('RESERVATION');
for (final reservation in reservations) {
await txn.insert('RESERVATION', reservation.toMap());
}
});
}

Future<List<LibraryReservation>> reservations() async {
final db = await getDatabase();

final List<Map<String, dynamic>> items = await db.query('RESERVATION');

final reservations = <LibraryReservation>[];

for (var i = 0; i < items.length; i++) {
final minutes = items[i]['duration'] as int;
reservations.add(
LibraryReservation(
items[i]['id'].toString(),
items[i]['room'] as String,
DateTime.parse(items[i]['startDate'] as String),
Duration(hours: minutes ~/ 60, minutes: minutes % 60),
),
);
}

return reservations;
}
}
37 changes: 37 additions & 0 deletions uni/lib/controller/parsers/parser_library_reservation.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import 'package:html/parser.dart';
import 'package:http/http.dart';
import 'package:uni/model/entities/library_reservation.dart';

Future<List<LibraryReservation>> getReservationsFromHtml(
Response response,
) async {
final document = parse(response.body);

final reservationHtml = document.getElementsByClassName('d interior');

final idHtml = document
.querySelectorAll('tbody > tr')
.where(
(element) =>
element.children.length == 12 &&
element.children[11].firstChild!.text == 'Reservado',
)
.toList();

final result = <LibraryReservation>[];
for (var i = 0; i < reservationHtml.length && i < idHtml.length; i++) {
final room = reservationHtml[i].children[5].firstChild!.text;
final date = reservationHtml[i].children[0].firstChild!.text;
final hour = reservationHtml[i].children[2].firstChild!.text;
final idRef = idHtml[i].children[11].firstChild!.attributes['href'];
final id = idRef!.split('=')[1];
final startDate = DateTime.parse('$date $hour');
final durationHtml = reservationHtml[i].children[4].firstChild!.text;
final duration = Duration(
hours: int.parse(durationHtml!.substring(0, 2)),
minutes: int.parse(durationHtml.substring(3, 5)),
);
result.add(LibraryReservation(id, room!, startDate, duration));
}
return result;
}
33 changes: 24 additions & 9 deletions uni/lib/generated/intl/messages_en.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
// ignore_for_file:unnecessary_brace_in_string_interps, unnecessary_new
// ignore_for_file:prefer_single_quotes,comment_references, directives_ordering
// ignore_for_file:annotate_overrides,prefer_generic_function_type_aliases
// ignore_for_file:unused_import, file_names, avoid_escaping_inner_quotes
// ignore_for_file:unnecessary_string_interpolations, unnecessary_string_escapes
// ignore_for_file:unused_import, file_names

import 'package:intl/intl.dart';
import 'package:intl/message_lookup_by_library.dart';
Expand All @@ -20,12 +19,12 @@ typedef String MessageIfAbsent(String messageStr, List<dynamic> args);
class MessageLookup extends MessageLookupByLibrary {
String get localeName => 'en';

static String m0(time) => "last refresh at ${time}";
static m0(time) => "last refresh at ${time}";

static String m1(time) =>
static m1(time) =>
"${Intl.plural(time, zero: 'Refreshed ${time} minutes ago', one: 'Refreshed ${time} minute ago', other: 'Refreshed ${time} minutes ago')}";

static String m2(title) => "${Intl.select(title, {
static m2(title) => "${Intl.select(title, {
'horario': 'Schedule',
'exames': 'Exams',
'area': 'Personal Area',
Expand All @@ -40,7 +39,7 @@ class MessageLookup extends MessageLookupByLibrary {
})}";

final messages = _notInlinedMessages(_notInlinedMessages);
static Map<String, Function> _notInlinedMessages(_) => <String, Function>{
static _notInlinedMessages(_) => <String, Function>{
"about": MessageLookupByLibrary.simpleMessage("About us"),
"academic_services":
MessageLookupByLibrary.simpleMessage("Academic services"),
Expand Down Expand Up @@ -117,7 +116,6 @@ class MessageLookup extends MessageLookupByLibrary {
"edit_on": MessageLookupByLibrary.simpleMessage("Finish editing"),
"empty_text":
MessageLookupByLibrary.simpleMessage("Please fill in this field"),
"exam_of": MessageLookupByLibrary.simpleMessage("of"),
"exams_filter":
MessageLookupByLibrary.simpleMessage("Exams Filter Settings"),
"exit_confirm":
Expand All @@ -139,6 +137,7 @@ class MessageLookup extends MessageLookupByLibrary {
MessageLookupByLibrary.simpleMessage("Generate reference"),
"geral_registration":
MessageLookupByLibrary.simpleMessage("General Registration"),
"go_back": MessageLookupByLibrary.simpleMessage("Go back"),
"improvement_registration":
MessageLookupByLibrary.simpleMessage("Enrollment for Improvement"),
"increment": MessageLookupByLibrary.simpleMessage("Increment 1,00€"),
Expand All @@ -148,8 +147,23 @@ class MessageLookup extends MessageLookupByLibrary {
"language": MessageLookupByLibrary.simpleMessage("Language"),
"last_refresh_time": m0,
"last_timestamp": m1,
"library": MessageLookupByLibrary.simpleMessage("Library"),
"library_cancel_error": MessageLookupByLibrary.simpleMessage(
"An error occurred while canceling your reservation!"),
"library_cancel_reservation": MessageLookupByLibrary.simpleMessage(
"Do you want to cancel this reservation?"),
"library_cancel_success": MessageLookupByLibrary.simpleMessage(
"Your reservation was canceled!"),
"library_cancel_tooltip":
MessageLookupByLibrary.simpleMessage("Cancel reservation"),
"library_occupation":
MessageLookupByLibrary.simpleMessage("Library Occupation"),
"library_reservations":
MessageLookupByLibrary.simpleMessage("Library Reservations"),
"library_tab_occupation":
MessageLookupByLibrary.simpleMessage("Occupation"),
"library_tab_reservations":
MessageLookupByLibrary.simpleMessage("Reservations"),
"load_error": MessageLookupByLibrary.simpleMessage(
"Error loading the information"),
"loading_terms": MessageLookupByLibrary.simpleMessage(
Expand Down Expand Up @@ -187,10 +201,10 @@ class MessageLookup extends MessageLookupByLibrary {
MessageLookupByLibrary.simpleMessage("No favorite restaurants"),
"no_info": MessageLookupByLibrary.simpleMessage(
"There is no information to display"),
"no_link":
MessageLookupByLibrary.simpleMessage("We couldn\'t open the link"),
"no_library_info": MessageLookupByLibrary.simpleMessage(
"No library occupation information available"),
"no_link":
MessageLookupByLibrary.simpleMessage("We couldn\'t open the link"),
"no_menu_info": MessageLookupByLibrary.simpleMessage(
"There is no information available about meals"),
"no_menus": MessageLookupByLibrary.simpleMessage(
Expand All @@ -211,6 +225,7 @@ class MessageLookup extends MessageLookupByLibrary {
"notifications": MessageLookupByLibrary.simpleMessage("Notifications"),
"occurrence_type":
MessageLookupByLibrary.simpleMessage("Type of occurrence"),
"of_month": MessageLookupByLibrary.simpleMessage("of"),
"other_links": MessageLookupByLibrary.simpleMessage("Other links"),
"pass_change_request": MessageLookupByLibrary.simpleMessage(
"For security reasons, passwords must be changed periodically."),
Expand Down
33 changes: 24 additions & 9 deletions uni/lib/generated/intl/messages_pt_PT.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
// ignore_for_file:unnecessary_brace_in_string_interps, unnecessary_new
// ignore_for_file:prefer_single_quotes,comment_references, directives_ordering
// ignore_for_file:annotate_overrides,prefer_generic_function_type_aliases
// ignore_for_file:unused_import, file_names, avoid_escaping_inner_quotes
// ignore_for_file:unnecessary_string_interpolations, unnecessary_string_escapes
// ignore_for_file:unused_import, file_names

import 'package:intl/intl.dart';
import 'package:intl/message_lookup_by_library.dart';
Expand All @@ -20,12 +19,12 @@ typedef String MessageIfAbsent(String messageStr, List<dynamic> args);
class MessageLookup extends MessageLookupByLibrary {
String get localeName => 'pt_PT';

static String m0(time) => "última atualização às ${time}";
static m0(time) => "última atualização às ${time}";

static String m1(time) =>
static m1(time) =>
"${Intl.plural(time, zero: 'Atualizado há ${time} minutos', one: 'Atualizado há ${time} minuto', other: 'Atualizado há ${time} minutos')}";

static String m2(title) => "${Intl.select(title, {
static m2(title) => "${Intl.select(title, {
'horario': 'Horário',
'exames': 'Exames',
'area': 'Área Pessoal',
Expand All @@ -40,7 +39,7 @@ class MessageLookup extends MessageLookupByLibrary {
})}";

final messages = _notInlinedMessages(_notInlinedMessages);
static Map<String, Function> _notInlinedMessages(_) => <String, Function>{
static _notInlinedMessages(_) => <String, Function>{
"about": MessageLookupByLibrary.simpleMessage("Sobre nós"),
"academic_services":
MessageLookupByLibrary.simpleMessage("Serviços académicos"),
Expand Down Expand Up @@ -116,7 +115,6 @@ class MessageLookup extends MessageLookupByLibrary {
"edit_on": MessageLookupByLibrary.simpleMessage("Concluir edição"),
"empty_text": MessageLookupByLibrary.simpleMessage(
"Por favor preenche este campo"),
"of_month": MessageLookupByLibrary.simpleMessage("de"),
"exams_filter":
MessageLookupByLibrary.simpleMessage("Definições Filtro de Exames"),
"exit_confirm": MessageLookupByLibrary.simpleMessage(
Expand All @@ -138,6 +136,7 @@ class MessageLookup extends MessageLookupByLibrary {
MessageLookupByLibrary.simpleMessage("Gerar referência"),
"geral_registration":
MessageLookupByLibrary.simpleMessage("Inscrição Geral"),
"go_back": MessageLookupByLibrary.simpleMessage("Voltar"),
"improvement_registration":
MessageLookupByLibrary.simpleMessage("Inscrição para Melhoria"),
"increment": MessageLookupByLibrary.simpleMessage("Incrementar 1,00€"),
Expand All @@ -148,8 +147,23 @@ class MessageLookup extends MessageLookupByLibrary {
"language": MessageLookupByLibrary.simpleMessage("Idioma"),
"last_refresh_time": m0,
"last_timestamp": m1,
"library": MessageLookupByLibrary.simpleMessage("Biblioteca"),
"library_cancel_error": MessageLookupByLibrary.simpleMessage(
"Ocorreu um erro ao cancelar a reserva!"),
"library_cancel_reservation": MessageLookupByLibrary.simpleMessage(
"Queres cancelar este pedido?"),
"library_cancel_success":
MessageLookupByLibrary.simpleMessage("A reserva foi cancelada!"),
"library_cancel_tooltip":
MessageLookupByLibrary.simpleMessage("Cancelar reserva"),
"library_occupation":
MessageLookupByLibrary.simpleMessage("Ocupação da Biblioteca"),
"library_reservations":
MessageLookupByLibrary.simpleMessage("Gabinetes Reservados"),
"library_tab_occupation":
MessageLookupByLibrary.simpleMessage("Ocupação"),
"library_tab_reservations":
MessageLookupByLibrary.simpleMessage("Gabinetes"),
"load_error": MessageLookupByLibrary.simpleMessage(
"Aconteceu um erro ao carregar os dados"),
"loading_terms": MessageLookupByLibrary.simpleMessage(
Expand Down Expand Up @@ -188,10 +202,10 @@ class MessageLookup extends MessageLookupByLibrary {
MessageLookupByLibrary.simpleMessage("Sem restaurantes favoritos"),
"no_info": MessageLookupByLibrary.simpleMessage(
"Não existem informações para apresentar"),
"no_link": MessageLookupByLibrary.simpleMessage(
"Não conseguimos abrir o link"),
"no_library_info":
MessageLookupByLibrary.simpleMessage("Sem informação de ocupação"),
"no_link": MessageLookupByLibrary.simpleMessage(
"Não conseguimos abrir o link"),
"no_menu_info": MessageLookupByLibrary.simpleMessage(
"Não há informação disponível sobre refeições"),
"no_menus": MessageLookupByLibrary.simpleMessage(
Expand All @@ -212,6 +226,7 @@ class MessageLookup extends MessageLookupByLibrary {
"notifications": MessageLookupByLibrary.simpleMessage("Notificações"),
"occurrence_type":
MessageLookupByLibrary.simpleMessage("Tipo de ocorrência"),
"of_month": MessageLookupByLibrary.simpleMessage("de"),
"other_links": MessageLookupByLibrary.simpleMessage("Outros links"),
"pass_change_request": MessageLookupByLibrary.simpleMessage(
"Por razões de segurança, as palavras-passe têm de ser alteradas periodicamente."),
Expand Down
Loading
Loading