diff --git a/api-gateway/src/main/java/com/petclinic/bffapigateway/domainclientlayer/VisitsServiceClient.java b/api-gateway/src/main/java/com/petclinic/bffapigateway/domainclientlayer/VisitsServiceClient.java index f9f89e1007..9cb799d9ba 100755 --- a/api-gateway/src/main/java/com/petclinic/bffapigateway/domainclientlayer/VisitsServiceClient.java +++ b/api-gateway/src/main/java/com/petclinic/bffapigateway/domainclientlayer/VisitsServiceClient.java @@ -139,7 +139,7 @@ public Mono deleteVisitByVisitId(String visitId){ public Mono deleteAllCancelledVisits(){ return webClient .delete() - .uri("/visits/cancelled") + .uri("/cancelled") .retrieve() .bodyToMono(Void.class); } diff --git a/api-gateway/src/main/resources/static/scripts/visit-list/visit-list.controller.js b/api-gateway/src/main/resources/static/scripts/visit-list/visit-list.controller.js index 7b5bfa81ee..475c15c37c 100644 --- a/api-gateway/src/main/resources/static/scripts/visit-list/visit-list.controller.js +++ b/api-gateway/src/main/resources/static/scripts/visit-list/visit-list.controller.js @@ -4,7 +4,10 @@ angular.module('visitList') let self = this; // Lists holding visits for the tables to display self.upcomingVisits = [] - self.previousVisits = [] + self.confirmedVisits = [] + self.cancelledVisits = [] + self.completedVisits = [] + let url //sorted by order or most to least permissions if ($window.localStorage.getItem("roles").includes("ADMIN")){ @@ -19,9 +22,25 @@ angular.module('visitList') eventSource.addEventListener('message', function (event){ $scope.$apply(function(){ console.log(event.data) - self.upcomingVisits.push(JSON.parse(event.data)) - }) - }) + const visitData = JSON.parse(event.data); + switch (visitData.status) { + case "UPCOMING": + self.upcomingVisits.push(visitData); + break; + case "CONFIRMED": + self.confirmedVisits.push(visitData); + break; + case "CANCELLED": + self.cancelledVisits.push(visitData); + break; + case "COMPLETED": + self.completedVisits.push(visitData); + break; + default: + break; + } + }); + }); eventSource.onerror = (error) =>{ if(eventSource.readyState === 0){ eventSource.close() @@ -109,7 +128,7 @@ angular.module('visitList') loadingIndicator.style.display = 'block' setTimeout(function() { location.reload() - }, 1000) //delay by 1 second + }, 150) //delay reload to be more graceful } function errorCallback(error) { alert(error.errors) diff --git a/api-gateway/src/main/resources/static/scripts/visit-list/visit-list.template.html b/api-gateway/src/main/resources/static/scripts/visit-list/visit-list.template.html index 2c1aac1a49..592eaab3d5 100644 --- a/api-gateway/src/main/resources/static/scripts/visit-list/visit-list.template.html +++ b/api-gateway/src/main/resources/static/scripts/visit-list/visit-list.template.html @@ -1,24 +1,31 @@ + +
- -
- -
+ +
-

Visits

- - +

Upcoming Visits

+
@@ -62,11 +66,11 @@

Visits

- + @@ -81,7 +85,6 @@

Visits

- @@ -90,15 +93,181 @@

Visits

- + + + + + + + + + + + +
- - + +
{{v.visitId}} {{v.visitDate | date:'yyyy-MM-ddTHH:mm:ss'}} {{v.description}} {{v.practitionerId}} {{v.petId}}{{v.status}} + + {{ v.status === 'UPCOMING' ? 'Confirm Visit' : v.status === 'CONFIRMED' ? 'Complete Visit' : v.status === 'CANCELLED' ? 'Cannot Confirm Cancelled Visit' : 'Visit Completed!' }} + + + {{ v.status === 'UPCOMING' ? 'Cancel Visit' : v.status === 'CONFIRMED' ? 'Cannot Cancel Confirmed Visit' : v.status === 'COMPLETED' ? 'Cannot Cancel Completed Visit' : 'Visit Cancelled!' }} + Delete Visit
+ +
+

Confirmed Visits

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
{{v.visitId}}{{v.visitDate | date:'yyyy-MM-ddTHH:mm:ss'}}{{v.description}}{{v.practitionerId}}{{v.petId}}{{v.status}} + + {{ v.status === 'UPCOMING' ? 'Confirm Visit' : v.status === 'CONFIRMED' ? 'Complete Visit' : v.status === 'CANCELLED' ? 'Cannot Confirm Cancelled Visit' : 'Visit Completed!' }} + + + {{ v.status === 'UPCOMING' ? 'Cancel Visit' : v.status === 'CONFIRMED' ? 'Cannot Cancel Confirmed Visit' : v.status === 'COMPLETED' ? 'Cannot Cancel Completed Visit' : 'Visit Cancelled!' }} + Delete Visit
+ + +
+

Cancelled Visits

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
{{v.visitId}}{{v.visitDate | date:'yyyy-MM-ddTHH:mm:ss'}}{{v.description}}{{v.practitionerId}}{{v.petId}} {{v.status}} + + {{ v.status === 'UPCOMING' ? 'Confirm Visit' : v.status === 'CONFIRMED' ? 'Complete Visit' : v.status === 'CANCELLED' ? 'Cannot Confirm Cancelled Visit' : 'Visit Completed!' }} + + + {{ v.status === 'UPCOMING' ? 'Cancel Visit' : v.status === 'CONFIRMED' ? 'Cannot Cancel Confirmed Visit' : v.status === 'COMPLETED' ? 'Cannot Cancel Completed Visit' : 'Visit Cancelled!' }} + Delete Visit
+ +
+

Completed Visits

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + - -
+ + +
{{v.visitId}}{{v.visitDate | date:'yyyy-MM-ddTHH:mm:ss'}}{{v.description}}{{v.practitionerId}}{{v.petId}} {{v.status}} Visits {{ v.status === 'UPCOMING' ? 'Confirm Visit' : v.status === 'CONFIRMED' ? 'Complete Visit' : v.status === 'CANCELLED' ? 'Cannot Confirm Cancelled Visit' : 'Visit Completed!' }} Visits {{ v.status === 'UPCOMING' ? 'Cancel Visit' : v.status === 'CONFIRMED' ? 'Cannot Cancel Confirmed Visit' : v.status === 'COMPLETED' ? 'Cannot Cancel Completed Visit' : 'Visit Cancelled!' }} Delete Visit
\ No newline at end of file + + diff --git a/api-gateway/src/main/resources/static/scripts/visits/visits.controller.js b/api-gateway/src/main/resources/static/scripts/visits/visits.controller.js index 3bc6463a23..154d960829 100755 --- a/api-gateway/src/main/resources/static/scripts/visits/visits.controller.js +++ b/api-gateway/src/main/resources/static/scripts/visits/visits.controller.js @@ -75,8 +75,6 @@ angular.module('visits') // Lists holding visits for the table to display self.upcomingVisits = [] - self.previousVisits = [] - self.sortFetchedVisits = function() { let currentDate = getCurrentDate() @@ -85,8 +83,6 @@ angular.module('visits') if(selectedVisitDate >= currentDate) { self.upcomingVisits.push(visit) - } else { - self.previousVisits.push(visit) } }) }