-
Notifications
You must be signed in to change notification settings - Fork 18
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
jlcrodrigues
wants to merge
74
commits into
develop
Choose a base branch
from
feature/cancel-reservations
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 66 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 3077511
feat: library reservations fetcher
jlcrodrigues c23cf3d
Display reserved library rooms
jlcrodrigues 5ed8089
Merge branch 'feature/library-occupation' into feature/library-rooms
jlcrodrigues cfec53e
Merge branch 'feature/library-rooms'
jlcrodrigues 83d9e1a
Merge branch feature/library-occupation
jlcrodrigues 057e001
Merge branch 'feature/library-occupation' of github.com:NIAEFEUP/proj…
jlcrodrigues 76cfe79
Added library reservations card to main page
jlcrodrigues 36980a7
Added tabs to library page
jlcrodrigues fc95928
Reworked library data flow
jlcrodrigues 6ce563e
Merge branch 'develop'
jlcrodrigues af78294
Fix merge conflicts
jlcrodrigues c2ecf16
Made changes to reserved rooms card
jlcrodrigues 7e4b925
Reworked library reservations' view
jlcrodrigues 53c2859
Added custom reservations route
jlcrodrigues 1aa923b
Small changes to library reservations
jlcrodrigues 9fa6414
Merge branch 'develop'
jlcrodrigues 7cfd371
Merge branch 'develop' into feature/library-rooms
jlcrodrigues fd285b4
Merge branch develop
jlcrodrigues a86709b
Fixed providers issues
jlcrodrigues c2d0834
Refactored helper functions
jlcrodrigues ea8af13
Made changes according to suggestions
jlcrodrigues aad69ab
Finished requested changes
jlcrodrigues 9723a9b
Fixed linter issues
jlcrodrigues 7456117
Finished reservations
jlcrodrigues 71f8d92
Merge branch 'feature/library-rooms' of github.com:NIAEFEUP/project-s…
jlcrodrigues 6893993
Fixed linter issues
jlcrodrigues 1a553fc
Removed nullable type from RoomList
jlcrodrigues 34aac72
Remove redundant reservation duration from db
jlcrodrigues e582cf7
Feature/library rooms (#658)
thePeras 30ef2c0
Merge branch 'develop'
jlcrodrigues c2aceee
Merge branch 'develop' of github.com:NIAEFEUP/project-schrodinger int…
jlcrodrigues 4c0f4b0
Merge branch 'develop'
jlcrodrigues c9c4a95
Merge branch feature/library-reservations
jlcrodrigues 37ab2c1
Made small adjustements to reservation cancelling
jlcrodrigues f64edb7
Worked on linter issues
jlcrodrigues 7f68904
Fixed linter issues
jlcrodrigues 47b39d6
Formatted files
jlcrodrigues bd16037
Worked on linter issues
jlcrodrigues b2a2ffb
Worked on linter issues
jlcrodrigues 9f417dd
Worked on linter issues
jlcrodrigues bc185b4
Merge branch develop
jlcrodrigues 3b10427
Merge branch 'develop' of github.com:NIAEFEUP/project-schrodinger int…
jlcrodrigues fc4980e
Merge branch 'feature/library-reservations'
jlcrodrigues 9af2713
Merge branch 'feature/library-reservations'
jlcrodrigues b50816f
Added missing translations
jlcrodrigues 01e259a
Fixed linter
jlcrodrigues 5ba9cfa
Made small changes according to suggestions
jlcrodrigues b51abd8
Merge branch 'develop'
jlcrodrigues ea9b0bc
Fixed context errors in reservation cancel button
jlcrodrigues da5c3fe
Merge branch 'develop'
jlcrodrigues 31624e4
Merge branch 'develop'
jlcrodrigues 4e6d45b
Merge branch 'feature/library-reservations' into feature/cancel-reser…
jlcrodrigues dc64cda
Merge branch 'develop'
jlcrodrigues 1768fb0
Merge branch 'feature/library-reservations'
jlcrodrigues 73f499e
Remove new line from version file
jlcrodrigues e6492a5
Linter fixes
jlcrodrigues 2e61e75
Merge branch 'develop'
jlcrodrigues 97c4c1b
Merge branch 'feature/library-reservations'
jlcrodrigues 1eff19f
Small lint fix
jlcrodrigues ca22148
Lint fixes
jlcrodrigues ee64b61
Merge branch 'develop' of github.com:NIAEFEUP/project-schrodinger int…
jlcrodrigues eabde47
Removed leftover ignore
jlcrodrigues 80df1bc
Generated translation files
jlcrodrigues f1e5c09
Merged branch 'feature/library-reservations'
jlcrodrigues 97507c7
Fixed library card page link
jlcrodrigues 85f81b4
Reset app version
jlcrodrigues a4e7a04
Merge branch 'develop' of github.com:NIAEFEUP/project-schrodinger int…
jlcrodrigues eb601cd
Reverted messages_all file, fixing tests
jlcrodrigues e3e5630
Merge branch 'feature/library-reservations' of github.com:NIAEFEUP/pr…
jlcrodrigues 0e8b516
Made changes according to suggestions
jlcrodrigues a4768ec
Format files
jlcrodrigues 65f3fe4
Fixed reservation weekday
jlcrodrigues 8ccb573
Merge branch feature/library-reservations
jlcrodrigues File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,4 +30,4 @@ subprojects { | |
|
||
tasks.register("clean", Delete) { | ||
delete rootProject.buildDir | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
uni/lib/controller/fetchers/library_reservation_fetcher.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,20 @@ import 'package:uni/model/entities/exam.dart'; | |
class AppExamsDatabase extends AppDatabase { | ||
AppExamsDatabase() | ||
: super('exams.db', [_createScript], onUpgrade: migrate, version: 5); | ||
Map<String, String> months = { | ||
'Janeiro': '01', | ||
'Fevereiro': '02', | ||
'Março': '03', | ||
'Abril': '04', | ||
'Maio': '05', | ||
'Junho': '06', | ||
'Julho': '07', | ||
'Agosto': '08', | ||
'Setembro': '09', | ||
'Outubro': '10', | ||
'Novembro': '11', | ||
'Dezembro': '12', | ||
}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Some git issues here |
||
|
||
static const _createScript = ''' | ||
CREATE TABLE exams(id TEXT, subject TEXT, begin TEXT, end TEXT, | ||
|
48 changes: 48 additions & 0 deletions
48
uni/lib/controller/local_storage/database/app_library_reservation.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
37
uni/lib/controller/parsers/parser_library_reservation.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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