From d0e01cb006981e8e1caea76e9553069db918f3b8 Mon Sep 17 00:00:00 2001 From: nbarrett Date: Fri, 11 Oct 2024 01:37:43 +0100 Subject: [PATCH] - support for querying group events from ramblers walks manager - first iteration is to display all event types on the walks page --- .../src/app/assets/styles/colours.sass | 10 +++ .../src/app/models/ramblers-walks-manager.ts | 24 ++++++- .../ngx-ramblers/src/app/models/walk.model.ts | 4 +- .../modules/common/card/image/card-image.sass | 2 +- .../modules/common/copy-icon/copy-icon.html | 2 +- .../committee/committee-display.service.ts | 19 +++++- .../walk-add-slots.component.ts | 16 +---- .../app/pages/walks/walk-display.service.ts | 17 ++++- .../walk-edit-full-page.component.ts | 13 ++-- .../walks/walk-edit/walk-edit.component.ts | 4 +- .../walks/walk-list/walk-list.component.html | 33 +++++----- .../walks/walk-list/walk-list.component.ts | 29 +++------ .../app/pages/walks/walk-view/walk-details.ts | 46 +++++++++----- .../app/pages/walks/walk-view/walk-images.ts | 5 +- .../pages/walks/walk-view/walk-leader.html | 2 +- .../app/pages/walks/walk-view/walk-view.ts | 63 +++++++++---------- .../committee/committee-query.service.ts | 2 +- .../ramblers-walks-and-events.service.ts | 57 ++++++++++------- .../{list-walks.ts => list-events.ts} | 26 ++++---- server/lib/ramblers/ramblers-routes.ts | 4 +- server/lib/shared/message-handlers.ts | 8 ++- 21 files changed, 229 insertions(+), 157 deletions(-) rename server/lib/ramblers/{list-walks.ts => list-events.ts} (90%) diff --git a/projects/ngx-ramblers/src/app/assets/styles/colours.sass b/projects/ngx-ramblers/src/app/assets/styles/colours.sass index a22fd91..ba69ced 100644 --- a/projects/ngx-ramblers/src/app/assets/styles/colours.sass +++ b/projects/ngx-ramblers/src/app/assets/styles/colours.sass @@ -91,6 +91,16 @@ $confirm-hover: #eb0c35 &:hover color: #ff3e43 +.group-walk + font-size: 1.5em + color: $admin-color + align-content: center + +.group-event + font-size: 1.5em + color: $ramblers-colour-rosycheeks + align-content: center + .ramblers color: $admin-color &:hover diff --git a/projects/ngx-ramblers/src/app/models/ramblers-walks-manager.ts b/projects/ngx-ramblers/src/app/models/ramblers-walks-manager.ts index f88182e..58d5a51 100644 --- a/projects/ngx-ramblers/src/app/models/ramblers-walks-manager.ts +++ b/projects/ngx-ramblers/src/app/models/ramblers-walks-manager.ts @@ -28,7 +28,7 @@ export interface RamblersWalksApiResponse extends ApiResponse { response?: RamblersWalkResponse[]; } -export enum WalkType { +export enum RamblersEventType { GROUP_WALK = "group-walk", GROUP_EVENT = "group-event", WELLBEING_WALK = "wellbeing-walk" @@ -84,7 +84,7 @@ export interface WalkLeader { } export interface GroupWalk { - item_type: WalkType; + item_type: RamblersEventType; id: string; title: string; group_code: string; @@ -95,6 +95,23 @@ export interface GroupWalk { start_date_time: string; end_date_time: string; meeting_date_time: string; + event_organiser?: { + name: string; + telephone: string; + has_email: boolean; + is_overridden: boolean; + email_form: string; + }, + location?: { + latitude: number; + longitude: number; + grid_reference_6: string; + grid_reference_8: string; + grid_reference_10: string; + postcode: string; + description: string; + w3w: string; + }; start_location: { latitude: number; longitude: number; @@ -156,7 +173,8 @@ export interface GroupListRequest { groups: string[]; } -export interface WalkListRequest { +export interface EventsListRequest { + types: RamblersEventType[]; ids?: string[]; rawData?: boolean; limit?: number; diff --git a/projects/ngx-ramblers/src/app/models/walk.model.ts b/projects/ngx-ramblers/src/app/models/walk.model.ts index 8ec1b31..118ce82 100644 --- a/projects/ngx-ramblers/src/app/models/walk.model.ts +++ b/projects/ngx-ramblers/src/app/models/walk.model.ts @@ -8,7 +8,7 @@ import { WalkAccessMode } from "./walk-edit-mode.model"; import { WalkEventType } from "./walk-event-type.model"; import { WalkEvent } from "./walk-event.model"; import { WalkVenue } from "./walk-venue.model"; -import { Media, Metadata, WalkLeader } from "./ramblers-walks-manager"; +import { Media, Metadata, RamblersEventType, WalkLeader } from "./ramblers-walks-manager"; export interface GoogleMapsConfig { apiKey: string; @@ -46,6 +46,7 @@ export interface WalkAscent { export interface Walk extends Identifiable { contactName?: string; walkType?: WalkType; + eventType: RamblersEventType; briefDescriptionAndStartPoint?: string; contactEmail?: string; contactId?: string; @@ -83,6 +84,7 @@ export interface Walk extends Identifiable { startLocation?: string; media?: Media[]; additionalDetails?: string; + organiser?: string; } export interface RiskAssessmentRecord { diff --git a/projects/ngx-ramblers/src/app/modules/common/card/image/card-image.sass b/projects/ngx-ramblers/src/app/modules/common/card/image/card-image.sass index 9bfcb72..6324cd1 100644 --- a/projects/ngx-ramblers/src/app/modules/common/card/image/card-image.sass +++ b/projects/ngx-ramblers/src/app/modules/common/card/image/card-image.sass @@ -6,6 +6,6 @@ margin-top: 25px .card-img-fixed-height - height: 300px + height: 350px object-fit: cover border-radius: 6px diff --git a/projects/ngx-ramblers/src/app/modules/common/copy-icon/copy-icon.html b/projects/ngx-ramblers/src/app/modules/common/copy-icon/copy-icon.html index a54c1ea..3afd07e 100644 --- a/projects/ngx-ramblers/src/app/modules/common/copy-icon/copy-icon.html +++ b/projects/ngx-ramblers/src/app/modules/common/copy-icon/copy-icon.html @@ -4,4 +4,4 @@ - + diff --git a/projects/ngx-ramblers/src/app/pages/committee/committee-display.service.ts b/projects/ngx-ramblers/src/app/pages/committee/committee-display.service.ts index d074525..1c3f2db 100644 --- a/projects/ngx-ramblers/src/app/pages/committee/committee-display.service.ts +++ b/projects/ngx-ramblers/src/app/pages/committee/committee-display.service.ts @@ -4,7 +4,7 @@ import last from "lodash-es/last"; import { ModalOptions } from "ngx-bootstrap/modal"; import { NgxLoggerLevel } from "ngx-logger"; import { Observable } from "rxjs"; -import { CommitteeFile } from "../../models/committee.model"; +import { CommitteeFile, GroupEventType, groupEventTypeFor } from "../../models/committee.model"; import { Confirm } from "../../models/ui-actions"; import { ValueOrDefaultPipe } from "../../pipes/value-or-default.pipe"; import { CommitteeConfigService } from "../../services/committee/commitee-config.service"; @@ -16,6 +16,8 @@ import { Logger, LoggerFactory } from "../../services/logger-factory.service"; import { MemberLoginService } from "../../services/member/member-login.service"; import { AlertInstance } from "../../services/notifier.service"; import { UrlService } from "../../services/url.service"; +import { Walk } from "../../models/walk.model"; +import { RamblersEventType } from "../../models/ramblers-walks-manager"; @Injectable({ providedIn: "root" @@ -120,4 +122,19 @@ export class CommitteeDisplayService { } } + ramblersEventType(walk: Walk): RamblersEventType { + return walk?.eventType || RamblersEventType.GROUP_WALK; + } + + groupEventType(walk: Walk): GroupEventType { + switch (this.ramblersEventType(walk)) { + case RamblersEventType.GROUP_WALK: + return groupEventTypeFor("walk"); + case RamblersEventType.GROUP_EVENT: + return groupEventTypeFor("socialEvent"); + case RamblersEventType.WELLBEING_WALK: + return groupEventTypeFor("walk"); + } + } + } diff --git a/projects/ngx-ramblers/src/app/pages/walks/walk-add-slots/walk-add-slots.component.ts b/projects/ngx-ramblers/src/app/pages/walks/walk-add-slots/walk-add-slots.component.ts index f37d86f..1108182 100644 --- a/projects/ngx-ramblers/src/app/pages/walks/walk-add-slots/walk-add-slots.component.ts +++ b/projects/ngx-ramblers/src/app/pages/walks/walk-add-slots/walk-add-slots.component.ts @@ -1,15 +1,11 @@ import { Component, OnInit } from "@angular/core"; -import { ActivatedRoute } from "@angular/router"; import difference from "lodash-es/difference"; import { NgxLoggerLevel } from "ngx-logger"; import { AlertMessage, AlertTarget } from "../../../models/alert-target.model"; import { NamedEvent, NamedEventType } from "../../../models/broadcast.model"; import { DateValue } from "../../../models/date.model"; import { Walk } from "../../../models/walk.model"; -import { DisplayDateAndTimePipe } from "../../../pipes/display-date-and-time.pipe"; import { DisplayDatePipe } from "../../../pipes/display-date.pipe"; -import { DisplayDayPipe } from "../../../pipes/display-day.pipe"; -import { SearchFilterPipe } from "../../../pipes/search-filter.pipe"; import { BroadcastService } from "../../../services/broadcast-service"; import { DateUtilsService } from "../../../services/date-utils.service"; import { Logger, LoggerFactory } from "../../../services/logger-factory.service"; @@ -17,15 +13,13 @@ import { MemberLoginService } from "../../../services/member/member-login.servic import { AlertInstance, NotifierService } from "../../../services/notifier.service"; import { UrlService } from "../../../services/url.service"; import { WalkEventService } from "../../../services/walks/walk-event.service"; -import { WalkNotificationService } from "../../../services/walks/walk-notification.service"; import { WalksQueryService } from "../../../services/walks/walks-query.service"; import { WalksReferenceService } from "../../../services/walks/walks-reference-data.service"; import { WalksService } from "../../../services/walks/walks.service"; -import { WalkDisplayService } from "../walk-display.service"; import { DisplayDatesAndTimesPipe } from "../../../pipes/display-dates-and-times.pipe"; -import { StringUtilsService } from "../../../services/string-utils.service"; import uniq from "lodash-es/uniq"; import { DisplayDatesPipe } from "../../../pipes/display-dates.pipe"; +import { RamblersEventType } from "../../../models/ramblers-walks-manager"; @Component({ selector: "app-walk-add-slots", @@ -48,16 +42,9 @@ export class WalkAddSlotsComponent implements OnInit { constructor( private walksService: WalksService, private memberLoginService: MemberLoginService, - private walksNotificationService: WalkNotificationService, - private display: WalkDisplayService, - private displayDay: DisplayDayPipe, private displayDate: DisplayDatePipe, - private stringUtilsService: StringUtilsService, private displayDates: DisplayDatesPipe, private displayDatesAndTimes: DisplayDatesAndTimesPipe, - private searchFilterPipe: SearchFilterPipe, - private displayDateAndTime: DisplayDateAndTimePipe, - private route: ActivatedRoute, private walksQueryService: WalksQueryService, private dateUtils: DateUtilsService, private notifierService: NotifierService, @@ -86,6 +73,7 @@ export class WalkAddSlotsComponent implements OnInit { createSlots(requiredSlots: number[], message: AlertMessage) { this.requiredWalkSlots = requiredSlots.map(date => { const walk: Walk = { + eventType: RamblersEventType.GROUP_WALK, walkDate: date, ramblersPublish: true, events: [] diff --git a/projects/ngx-ramblers/src/app/pages/walks/walk-display.service.ts b/projects/ngx-ramblers/src/app/pages/walks/walk-display.service.ts index 5839916..1e877c5 100644 --- a/projects/ngx-ramblers/src/app/pages/walks/walk-display.service.ts +++ b/projects/ngx-ramblers/src/app/pages/walks/walk-display.service.ts @@ -24,6 +24,8 @@ import { WalksReferenceService } from "../../services/walks/walks-reference-data import { CommitteeReferenceData } from "../../services/committee/committee-reference-data"; import { CommitteeConfigService } from "../../services/committee/commitee-config.service"; import { Observable, ReplaySubject } from "rxjs"; +import { StringUtilsService } from "../../services/string-utils.service"; +import { RamblersEventType } from "../../models/ramblers-walks-manager"; @Injectable({ providedIn: "root" @@ -49,6 +51,7 @@ export class WalkDisplayService { private memberLoginService: MemberLoginService, private router: Router, private urlService: UrlService, + protected stringUtils: StringUtilsService, private route: ActivatedRoute, private sanitiser: DomSanitizer, private walkEventService: WalkEventService, @@ -56,7 +59,7 @@ export class WalkDisplayService { private walksQueryService: WalksQueryService, private committeeConfig: CommitteeConfigService, loggerFactory: LoggerFactory) { - this.logger = loggerFactory.createLogger(WalkDisplayService, NgxLoggerLevel.OFF); + this.logger = loggerFactory.createLogger(WalkDisplayService, NgxLoggerLevel.ERROR); this.applyConfig(); this.refreshCachedData(); this.logger.debug("this.memberLoginService", this.memberLoginService.loggedInMember()); @@ -296,4 +299,16 @@ export class WalkDisplayService { allowAdminEdits() { return this.memberLoginService.allowWalkAdminEdits(); } + + eventType(walk: Walk): string { + return walk?.eventType || RamblersEventType.GROUP_WALK; + } + + eventTypeTitle(walk: Walk): string { + return this.stringUtils.asTitle(walk?.eventType) || "Walk"; + } + + isWalk(walk: Walk): boolean { + return !walk?.eventType || walk.eventType === RamblersEventType.GROUP_WALK; + } } diff --git a/projects/ngx-ramblers/src/app/pages/walks/walk-edit-fullpage/walk-edit-full-page.component.ts b/projects/ngx-ramblers/src/app/pages/walks/walk-edit-fullpage/walk-edit-full-page.component.ts index 85cdf74..84052da 100644 --- a/projects/ngx-ramblers/src/app/pages/walks/walk-edit-fullpage/walk-edit-full-page.component.ts +++ b/projects/ngx-ramblers/src/app/pages/walks/walk-edit-fullpage/walk-edit-full-page.component.ts @@ -4,13 +4,12 @@ import { NgxLoggerLevel } from "ngx-logger"; import { Subscription } from "rxjs"; import { AlertTarget } from "../../../models/alert-target.model"; import { DisplayedWalk, EventType, Walk } from "../../../models/walk.model"; -import { DisplayDatePipe } from "../../../pipes/display-date.pipe"; import { DateUtilsService } from "../../../services/date-utils.service"; import { Logger, LoggerFactory } from "../../../services/logger-factory.service"; -import { AlertInstance, NotifierService } from "../../../services/notifier.service"; import { WalksReferenceService } from "../../../services/walks/walks-reference-data.service"; import { WalksService } from "../../../services/walks/walks.service"; import { WalkDisplayService } from "../walk-display.service"; +import { RamblersEventType } from "../../../models/ramblers-walks-manager"; @Component({ selector: "app-walk-edit-full-page", @@ -21,7 +20,6 @@ export class WalkEditFullPageComponent implements OnInit, OnDestroy { private logger: Logger; public displayedWalk: DisplayedWalk; public notifyTarget: AlertTarget = {}; - private notify: AlertInstance; pageTitle: string; private subscriptions: Subscription[] = []; @@ -30,19 +28,18 @@ export class WalkEditFullPageComponent implements OnInit, OnDestroy { private walksReferenceService: WalksReferenceService, private dateUtils: DateUtilsService, private display: WalkDisplayService, - private notifierService: NotifierService, - displayDate: DisplayDatePipe, loggerFactory: LoggerFactory) { - this.logger = loggerFactory.createLogger(WalkEditFullPageComponent, NgxLoggerLevel.OFF); + loggerFactory: LoggerFactory) { + this.logger = loggerFactory.createLogger(WalkEditFullPageComponent, NgxLoggerLevel.ERROR); } ngOnInit() { this.logger.debug("ngOnInit"); - this.notify = this.notifierService.createAlertInstance(this.notifyTarget); this.subscriptions.push(this.route.paramMap.subscribe((paramMap: ParamMap) => { if (paramMap.has("add")) { this.displayedWalk = { walkAccessMode: WalksReferenceService.walkAccessModes.add, walk: { + eventType: RamblersEventType.GROUP_WALK, walkType: this.display.walkTypes[0], walkDate: this.dateUtils.momentNowNoTime().valueOf(), events: [] @@ -56,7 +53,7 @@ export class WalkEditFullPageComponent implements OnInit, OnDestroy { this.logger.debug("querying walk-id", walkId); this.walksService.getById(walkId) .then((walk: Walk) => { - this.logger.debug("found walk", walk); + this.logger.info("found walk", walk); this.displayedWalk = this.display.toDisplayedWalk(walk); if (this.displayedWalk.latestEventType) { this.setStatus(this.displayedWalk.latestEventType.eventType); diff --git a/projects/ngx-ramblers/src/app/pages/walks/walk-edit/walk-edit.component.ts b/projects/ngx-ramblers/src/app/pages/walks/walk-edit/walk-edit.component.ts index ce50443..e752c63 100644 --- a/projects/ngx-ramblers/src/app/pages/walks/walk-edit/walk-edit.component.ts +++ b/projects/ngx-ramblers/src/app/pages/walks/walk-edit/walk-edit.component.ts @@ -48,6 +48,7 @@ import { MailMessagingConfig } from "../../../models/mail.model"; import { MeetupService } from "../../../services/meetup.service"; import { WalkNotification } from "../../../models/walk-notification.model"; import { MeetupDescriptionComponent } from "../../../notifications/walks/templates/meetup/meetup-description.component"; +import { RamblersEventType } from "../../../models/ramblers-walks-manager"; @Component({ selector: "app-walk-edit", @@ -333,6 +334,7 @@ export class WalkEditComponent implements OnInit, OnDestroy { walkAccessMode: WalksReferenceService.walkAccessModes.add, latestEventType: null, walk: { + eventType: RamblersEventType.GROUP_WALK, walkType: this.display.walkTypes[0], walkDate: this.dateUtils.momentNowNoTime().valueOf(), events: [] @@ -642,7 +644,7 @@ export class WalkEditComponent implements OnInit, OnDestroy { switch (eventType.eventType) { case EventType.AWAITING_LEADER: { const walkDate = this.displayedWalk.walk.walkDate; - this.displayedWalk.walk = pick(this.displayedWalk.walk, ["id", "events", "walkDate"]); + this.displayedWalk.walk = pick(this.displayedWalk.walk, ["id", "events", "walkDate", "eventType"]); this.displayedWalk.walk.riskAssessment = []; return this.notify.success({ title: "Walk details reset for " + this.displayDate.transform(walkDate), diff --git a/projects/ngx-ramblers/src/app/pages/walks/walk-list/walk-list.component.html b/projects/ngx-ramblers/src/app/pages/walks/walk-list/walk-list.component.html index 309a7d2..13c4046 100644 --- a/projects/ngx-ramblers/src/app/pages/walks/walk-list/walk-list.component.html +++ b/projects/ngx-ramblers/src/app/pages/walks/walk-list/walk-list.component.html @@ -21,58 +21,63 @@ Action + Type Walk Date Start Time - Walk Title + Title Distance Postcode - Walk Leader + Leader Contact Phone + + + {{displayedWalk.walk.walkDate|displayDate}} - {{viewWalkField(displayedWalk, 'startTime')}} - {{viewWalkField(displayedWalk, 'briefDescriptionAndStartPoint')}} {{viewWalkField(displayedWalk, 'distance')}} + id="distance-{{index}}">{{viewWalkField(displayedWalk, 'distance')}} + {{viewWalkField(displayedWalk, 'postcode')}} - + {{displayedWalk.walk.displayName}} - {{displayedWalk.walk.displayName}} + {{ displayedWalk.walk.displayName }} - + diff --git a/projects/ngx-ramblers/src/app/pages/walks/walk-list/walk-list.component.ts b/projects/ngx-ramblers/src/app/pages/walks/walk-list/walk-list.component.ts index ecd3a26..761db87 100644 --- a/projects/ngx-ramblers/src/app/pages/walks/walk-list/walk-list.component.ts +++ b/projects/ngx-ramblers/src/app/pages/walks/walk-list/walk-list.component.ts @@ -1,4 +1,4 @@ -import { ChangeDetectionStrategy, ChangeDetectorRef, Component, OnDestroy, OnInit } from "@angular/core"; +import { ChangeDetectionStrategy, Component, OnDestroy, OnInit } from "@angular/core"; import { ActivatedRoute, ParamMap } from "@angular/router"; import range from "lodash-es/range"; import uniq from "lodash-es/uniq"; @@ -20,31 +20,24 @@ import { WalkDateAscending, WalkDateDescending } from "../../../models/walk.model"; -import { DisplayDateAndTimePipe } from "../../../pipes/display-date-and-time.pipe"; -import { DisplayDatePipe } from "../../../pipes/display-date.pipe"; -import { DisplayDayPipe } from "../../../pipes/display-day.pipe"; import { SearchFilterPipe } from "../../../pipes/search-filter.pipe"; import { BroadcastService } from "../../../services/broadcast-service"; import { DateUtilsService } from "../../../services/date-utils.service"; import { GoogleMapsService } from "../../../services/google-maps.service"; import { Logger, LoggerFactory } from "../../../services/logger-factory.service"; import { MemberLoginService } from "../../../services/member/member-login.service"; -import { MemberService } from "../../../services/member/member.service"; import { AlertInstance, NotifierService } from "../../../services/notifier.service"; -import { NumberUtilsService } from "../../../services/number-utils.service"; import { PageService } from "../../../services/page.service"; import { StringUtilsService } from "../../../services/string-utils.service"; -import { UrlService } from "../../../services/url.service"; import { RamblersWalksAndEventsService } from "../../../services/walks/ramblers-walks-and-events.service"; -import { WalkNotificationService } from "../../../services/walks/walk-notification.service"; import { WalksQueryService } from "../../../services/walks/walks-query.service"; -import { WalksReferenceService } from "../../../services/walks/walks-reference-data.service"; import { WalksService } from "../../../services/walks/walks.service"; -import { SiteEditService } from "../../../site-edit/site-edit.service"; import { LoginModalComponent } from "../../login/login-modal/login-modal.component"; import { WalkDisplayService } from "../walk-display.service"; import { SystemConfigService } from "../../../services/system/system-config.service"; import { sortBy } from "../../../functions/arrays"; +import { RamblersEventType } from "../../../models/ramblers-walks-manager"; +import { faPeopleGroup, faWalking } from "@fortawesome/free-solid-svg-icons"; @Component({ selector: "app-walk-list", @@ -53,6 +46,9 @@ import { sortBy } from "../../../functions/arrays"; changeDetection: ChangeDetectionStrategy.Default }) export class WalkListComponent implements OnInit, OnDestroy { + protected readonly RamblersEventType = RamblersEventType; + protected readonly faWalking = faWalking; + protected readonly faPeopleGroup = faPeopleGroup; public currentWalkId: string; private logger: Logger; private todayValue: number; @@ -79,27 +75,17 @@ export class WalkListComponent implements OnInit, OnDestroy { private pageService: PageService, public googleMapsService: GoogleMapsService, private walksService: WalksService, - private memberService: MemberService, - private numberUtils: NumberUtilsService, private authService: AuthService, public ramblersWalksAndEventsService: RamblersWalksAndEventsService, public memberLoginService: MemberLoginService, - private walksNotificationService: WalkNotificationService, public display: WalkDisplayService, - private stringUtils: StringUtilsService, - private displayDay: DisplayDayPipe, - private displayDate: DisplayDatePipe, + protected stringUtils: StringUtilsService, private searchFilterPipe: SearchFilterPipe, - private displayDateAndTime: DisplayDateAndTimePipe, private route: ActivatedRoute, private walksQueryService: WalksQueryService, private dateUtils: DateUtilsService, private notifierService: NotifierService, private broadcastService: BroadcastService, - private urlService: UrlService, - private walksReferenceService: WalksReferenceService, - private changeDetectorRef: ChangeDetectorRef, - private siteEditService: SiteEditService, loggerFactory: LoggerFactory) { this.logger = loggerFactory.createLogger(WalkListComponent, NgxLoggerLevel.OFF); } @@ -302,4 +288,5 @@ export class WalkListComponent implements OnInit, OnDestroy { this.logger.info("no groups to query:", groups); } } + } diff --git a/projects/ngx-ramblers/src/app/pages/walks/walk-view/walk-details.ts b/projects/ngx-ramblers/src/app/pages/walks/walk-view/walk-details.ts index c8bd9dd..d8aeaba 100644 --- a/projects/ngx-ramblers/src/app/pages/walks/walk-view/walk-details.ts +++ b/projects/ngx-ramblers/src/app/pages/walks/walk-view/walk-details.ts @@ -1,6 +1,7 @@ import { Component, Input, OnInit } from "@angular/core"; import { faListCheck, + faPeopleGroup, faPersonWalkingArrowLoopLeft, faPersonWalkingDashedLineArrowRight, faRulerHorizontal, @@ -13,15 +14,21 @@ import { Logger, LoggerFactory } from "../../../services/logger-factory.service" import { AscentValidationService } from "../../../services/walks/ascent-validation.service"; import { DistanceValidationService } from "../../../services/walks/distance-validation.service"; import { WalkDisplayService } from "../walk-display.service"; +import { StringUtilsService } from "../../../services/string-utils.service"; @Component({ selector: "app-walk-details", template: `

- - {{ displayedWalk.walk.walkType }} Walk Starting Point & Details + + + {{ display.isWalk(displayedWalk.walk) ? displayedWalk.walk.walkType : null }} + {{ display.eventTypeTitle(displayedWalk.walk) }} + {{ display.isWalk(displayedWalk.walk) ? 'Starting Point &' : '' }} Details

@@ -83,14 +90,14 @@ import { WalkDisplayService } from "../walk-display.service"; target="_blank">{{ displayedWalk.walk.gridReferenceFinish }}
-
+
Distance {{ distanceValidationService.walkDistances(displayedWalk.walk) }}
-
+
Grade @@ -104,15 +111,30 @@ import { WalkDisplayService } from "../walk-display.service"; {{ ascentValidationService.walkAscents(displayedWalk.walk) }}
-
{{displayedWalk?.walk?.startLocation}}
+
{{ displayedWalk?.walk?.startLocation }} +
+
+

**Organiser**: {{ displayedWalk.walk.organiser }}

+
-

additionalDetails:{{ displayedWalk.walk.additionalDetails }}

+

**Additional Details**: {{ displayedWalk.walk.additionalDetails }}

` }) export class WalkDetailsComponent implements OnInit { + + constructor( + public googleMapsService: GoogleMapsService, + public distanceValidationService: DistanceValidationService, + public ascentValidationService: AscentValidationService, + public display: WalkDisplayService, + protected stringUtils: StringUtilsService, + loggerFactory: LoggerFactory) { + this.logger = loggerFactory.createLogger("WalkDetailsComponent", NgxLoggerLevel.OFF); + } private logger: Logger; @Input() public displayedWalk: DisplayedWalk; @@ -123,14 +145,7 @@ export class WalkDetailsComponent implements OnInit { protected readonly faRulerVertical = faRulerVertical; protected readonly faListCheck = faListCheck; - constructor( - public googleMapsService: GoogleMapsService, - public distanceValidationService: DistanceValidationService, - public ascentValidationService: AscentValidationService, - public display: WalkDisplayService, - loggerFactory: LoggerFactory) { - this.logger = loggerFactory.createLogger("WalkDetailsComponent", NgxLoggerLevel.OFF); - } + protected readonly faPeopleGroup = faPeopleGroup; ngOnInit() { this.logger.info("ngOnInit", this.displayedWalk); @@ -143,5 +158,4 @@ export class WalkDetailsComponent implements OnInit { elementNameFinish(elementName: string) { return `${this.displayedWalk.showEndpoint ? "Finish " : ""}${elementName}`; } - } diff --git a/projects/ngx-ramblers/src/app/pages/walks/walk-view/walk-images.ts b/projects/ngx-ramblers/src/app/pages/walks/walk-view/walk-images.ts index 5adaf63..6526f2f 100644 --- a/projects/ngx-ramblers/src/app/pages/walks/walk-view/walk-images.ts +++ b/projects/ngx-ramblers/src/app/pages/walks/walk-view/walk-images.ts @@ -8,7 +8,7 @@ import { BasicMedia } from "../../../models/ramblers-walks-manager"; @Component({ selector: "app-walk-images", template: ` -
+
-

Walk Leader{{!display.shouldShowFullDetails(displayedWalk) && displayedWalk.walk.displayName ? " is " + displayedWalk.walk.displayName : ""}}

+

{{ display.isWalk(displayedWalk.walk) ? 'Walk Leader' : (display.eventTypeTitle(displayedWalk.walk) + " Organiser") }}{{ !display.shouldShowFullDetails(displayedWalk) && displayedWalk.walk.displayName ? " is " + displayedWalk.walk.displayName : "" }}

{{displayedWalk?.latestEventType?.description || 'no description'}}

diff --git a/projects/ngx-ramblers/src/app/pages/walks/walk-view/walk-view.ts b/projects/ngx-ramblers/src/app/pages/walks/walk-view/walk-view.ts index 26d80e6..3e46bcf 100644 --- a/projects/ngx-ramblers/src/app/pages/walks/walk-view/walk-view.ts +++ b/projects/ngx-ramblers/src/app/pages/walks/walk-view/walk-view.ts @@ -1,4 +1,4 @@ -import { ChangeDetectionStrategy, Component, Input, OnDestroy, OnInit } from "@angular/core"; +import { Component, inject, Input, OnDestroy, OnInit } from "@angular/core"; import { SafeResourceUrl } from "@angular/platform-browser"; import { NgxLoggerLevel } from "ngx-logger"; import { Subscription } from "rxjs"; @@ -8,7 +8,7 @@ import { LoginResponse } from "../../../models/member.model"; import { DisplayedWalk, MapDisplay, Walk } from "../../../models/walk.model"; import { DateUtilsService } from "../../../services/date-utils.service"; import { GoogleMapsService } from "../../../services/google-maps.service"; -import { Logger, LoggerFactory } from "../../../services/logger-factory.service"; +import { LoggerFactory } from "../../../services/logger-factory.service"; import { MeetupService } from "../../../services/meetup.service"; import { MemberLoginService } from "../../../services/member/member-login.service"; import { AlertInstance, NotifierService } from "../../../services/notifier.service"; @@ -18,6 +18,7 @@ import { WalkDisplayService } from "../walk-display.service"; import { SystemConfigService } from "../../../services/system/system-config.service"; import { SystemConfig } from "../../../models/system.model"; import { WalksQueryService } from "../../../services/walks/walks-query.service"; +import { StringUtilsService } from "../../../services/string-utils.service"; @Component({ selector: "app-walk-view", @@ -113,9 +114,10 @@ import { WalksQueryService } from "../../../services/walks/walks-query.service";
+ elementName="This {{display.eventTypeTitle(displayedWalk.walk)}}">
@@ -200,49 +202,41 @@ import { WalksQueryService } from "../../../services/walks/walks-query.service";
`, styleUrls: ["./walk-view.sass"], - changeDetection: ChangeDetectionStrategy.Default }) export class WalkViewComponent implements OnInit, OnDestroy { - - @Input("displayedWalk") set init(displayedWalk: DisplayedWalk) { - this.applyWalk(displayedWalk); - } - - constructor( - public walksQueryService: WalksQueryService, - private walksService: WalksService, - public googleMapsService: GoogleMapsService, - private authService: AuthService, - private memberLoginService: MemberLoginService, - public display: WalkDisplayService, - private dateUtils: DateUtilsService, - public meetupService: MeetupService, - private urlService: UrlService, - private systemConfigService: SystemConfigService, - private notifierService: NotifierService, - loggerFactory: LoggerFactory) { - this.logger = loggerFactory.createLogger("WalkViewComponent", NgxLoggerLevel.OFF); - } - public walkIdOrPath: string; public pathContainsWalkId: boolean; public displayedWalk: DisplayedWalk; public displayLinks: boolean; public fromPostcode = ""; public mapDisplay: MapDisplay = MapDisplay.SHOW_START_POINT; - private logger: Logger; public allowWalkAdminEdits: boolean; public googleMapsUrl: SafeResourceUrl; public loggedIn: boolean; private subscriptions: Subscription[] = []; - private notify: AlertInstance; public notifyTarget: AlertTarget = {}; - protected readonly ALERT_WARNING = ALERT_WARNING; + public walksQueryService = inject(WalksQueryService); + private walksService = inject(WalksService); + public googleMapsService = inject(GoogleMapsService); + private authService = inject(AuthService); + private memberLoginService = inject(MemberLoginService); + public display = inject(WalkDisplayService); + private dateUtils = inject(DateUtilsService); + public meetupService = inject(MeetupService); + private urlService = inject(UrlService); + protected stringUtils = inject(StringUtilsService); + private systemConfigService = inject(SystemConfigService); + private notifierService = inject(NotifierService); + private logger = inject(LoggerFactory).createLogger("WalkViewComponent", NgxLoggerLevel.OFF); + private notify: AlertInstance = this.notifierService.createAlertInstance(this.notifyTarget); + + @Input("displayedWalk") set init(displayedWalk: DisplayedWalk) { + this.applyWalk(displayedWalk); + } ngOnInit() { - this.notify = this.notifierService.createAlertInstance(this.notifyTarget); this.loggedIn = this.memberLoginService.memberLoggedIn(); this.allowWalkAdminEdits = this.memberLoginService.allowWalkAdminEdits(); this.refreshHomePostcode(); @@ -270,10 +264,6 @@ export class WalkViewComponent implements OnInit, OnDestroy { this.logger.info("event received:", config); this.updateGoogleMap(); }); - this.notify.success({ - title: "Single walk showing", - message: " - " - }); } ngOnDestroy(): void { @@ -285,6 +275,7 @@ export class WalkViewComponent implements OnInit, OnDestroy { this.walksService.getByIdIfPossible(this.walkIdOrPath) .then((walk: Walk) => { if (walk) { + this.logger.info("Walk found:", walk); this.applyWalk(this.display.toDisplayedWalk(walk)); } else { this.logger.warn("Walk not found:", this.walkIdOrPath) @@ -303,6 +294,10 @@ export class WalkViewComponent implements OnInit, OnDestroy { this.displayLinks = !!(this.displayedWalk.walk.meetupEventUrl || this.displayedWalk.walk.osMapsRoute || this.displayedWalk.walk.osMapsRoute || this.displayedWalk.walk.ramblersWalkId || this.displayedWalk.walkLink); this.updateGoogleMap(); } + this.notify.success({ + title: `Single ${this.display.eventTypeTitle(this.displayedWalk?.walk)} showing`, + message: " - " + }); } updateGoogleMap() { diff --git a/projects/ngx-ramblers/src/app/services/committee/committee-query.service.ts b/projects/ngx-ramblers/src/app/services/committee/committee-query.service.ts index 9da03e4..6f343dc 100644 --- a/projects/ngx-ramblers/src/app/services/committee/committee-query.service.ts +++ b/projects/ngx-ramblers/src/app/services/committee/committee-query.service.ts @@ -92,7 +92,7 @@ export class CommitteeQueryService { .then(walks => walks?.forEach(walk => events.push({ id: walk.id, selected: true, - eventType: GroupEventTypes.WALK, + eventType: this.display.groupEventType(walk), eventDate: walk.walkDate, eventTime: walk.startTime, distance: walk.distance, diff --git a/projects/ngx-ramblers/src/app/services/walks/ramblers-walks-and-events.service.ts b/projects/ngx-ramblers/src/app/services/walks/ramblers-walks-and-events.service.ts index 86aa4d4..9457be7 100644 --- a/projects/ngx-ramblers/src/app/services/walks/ramblers-walks-and-events.service.ts +++ b/projects/ngx-ramblers/src/app/services/walks/ramblers-walks-and-events.service.ts @@ -9,9 +9,11 @@ import { ApiResponse } from "../../models/api-response.model"; import { Member } from "../../models/member.model"; import { RamblersUploadAuditApiResponse } from "../../models/ramblers-upload-audit.model"; import { + EventsListRequest, GroupListRequest, GroupWalk, Metadata, + RamblersEventType, RamblersGroupsApiResponse, RamblersGroupsApiResponseApiResponse, RamblersWalkResponse, @@ -20,7 +22,6 @@ import { RamblersWalksRawApiResponseApiResponse, RamblersWalksUploadRequest, WalkLeader, - WalkListRequest, WALKS_MANAGER_API_DATE_FORMAT, WALKS_MANAGER_CSV_DATE_FORMAT, WALKS_MANAGER_GO_LIVE_DATE, @@ -68,16 +69,6 @@ import { sortBy } from "../../functions/arrays"; providedIn: "root" }) export class RamblersWalksAndEventsService { - private readonly logger: Logger; - private auditSubject = new ReplaySubject(); - private walkLeadersSubject = new ReplaySubject(); - private walksSubject = new ReplaySubject(); - private rawWalksSubject = new ReplaySubject(); - private groupsSubject = new ReplaySubject(); - private committeeReferenceData: CommitteeReferenceData; - private ramblers: Ramblers; - private BASE_URL = "/api/ramblers/walks-manager"; - private NEAREST_TOWN_PREFIX = "Nearest Town is "; constructor(private http: HttpClient, private riskAssessmentService: RiskAssessmentService, @@ -103,6 +94,18 @@ export class RamblersWalksAndEventsService { } + private readonly logger: Logger; + private auditSubject = new ReplaySubject(); + private walkLeadersSubject = new ReplaySubject(); + private walksSubject = new ReplaySubject(); + private rawWalksSubject = new ReplaySubject(); + private groupsSubject = new ReplaySubject(); + private committeeReferenceData: CommitteeReferenceData; + private ramblers: Ramblers; + private BASE_URL = "/api/ramblers/walks-manager"; + private NEAREST_TOWN_PREFIX = "Nearest Town is "; + + static areMongoIdsSupplied(response: any): response is MongoIdsSupplied { return (response as MongoIdsSupplied)?._id?.$in !== undefined; } @@ -131,7 +134,7 @@ export class RamblersWalksAndEventsService { this.logger.debug("queryWalkLeaders:"); const date = WALKS_MANAGER_GO_LIVE_DATE; const dateEnd = this.dateUtils.asMoment().add(2, "month").format(WALKS_MANAGER_API_DATE_FORMAT); - const body: WalkListRequest = {date, dateEnd, limit: 2000}; + const body: EventsListRequest = {types: [RamblersEventType.GROUP_WALK], date, dateEnd, limit: 2000}; this.logger.off("queryWalkLeaders:body:", body); const apiResponse = await this.commonDataService.responseFrom(this.logger, this.http.post(`${this.BASE_URL}/walk-leaders`, body), this.walkLeadersSubject); return apiResponse.response; @@ -155,7 +158,7 @@ export class RamblersWalksAndEventsService { } async listRamblersWalks(): Promise { - const apiResponse = await this.commonDataService.responseFrom(this.logger, this.http.post(`${this.BASE_URL}/list-walks`, {}), this.walksSubject); + const apiResponse = await this.commonDataService.responseFrom(this.logger, this.http.post(`${this.BASE_URL}/list-events`, {}), this.walksSubject); this.logger.off("received", apiResponse); return apiResponse.response; } @@ -167,9 +170,18 @@ export class RamblersWalksAndEventsService { const sort = isEqual(dataQueryOptions?.sort, WalkDateDescending) || isEqual(dataQueryOptions?.sort, WalkDateAscending) ? "date" : "date"; const date = usedIds.length > 0 ? null : this.createStartDate(dataQueryOptions?.criteria); const dateEnd = usedIds.length > 0 ? null : this.createEndDate(dataQueryOptions?.criteria); - const body: WalkListRequest = {date, dateEnd, order, sort, rawData: true, limit: 200, ids: usedIds}; + const body: EventsListRequest = { + types: [RamblersEventType.GROUP_WALK, RamblersEventType.GROUP_EVENT, RamblersEventType.WELLBEING_WALK], + date, + dateEnd, + order, + sort, + rawData: true, + limit: 300, + ids: usedIds + }; this.logger.off("listRamblersWalksRawData:dataQueryOptions:", dataQueryOptions, "ids:", ids, "usedIds:", usedIds, "body:", body); - const rawData = await this.commonDataService.responseFrom(this.logger, this.http.post(`${this.BASE_URL}/list-walks`, body), this.rawWalksSubject); + const rawData = await this.commonDataService.responseFrom(this.logger, this.http.post(`${this.BASE_URL}/list-events`, body), this.rawWalksSubject); return rawData.response; } @@ -492,25 +504,25 @@ export class RamblersWalksAndEventsService { return this.listRamblersWalksRawData(dataQueryOptions) .then((ramblersWalksRawApiResponse: RamblersWalksRawApiResponse) => ramblersWalksRawApiResponse.data.map(remoteWalk => this.toWalk(remoteWalk))); } - toWalk(groupWalk: GroupWalk): Walk { const startMoment = this.dateUtils.asMoment(groupWalk.start_date_time); const contactName = groupWalk?.walk_leader?.name; const displayName = this.memberNamingService.createDisplayNameFromContactName(contactName); const walk: Walk = { + eventType: groupWalk.item_type, media: groupWalk.media, ascent: groupWalk.ascent_feet?.toString(), briefDescriptionAndStartPoint: groupWalk.title, config: {meetup: null}, - contactEmail: groupWalk?.walk_leader?.email_form, + contactEmail: groupWalk?.walk_leader?.email_form || groupWalk?.event_organiser?.email_form, contactId: "n/a", contactName, - contactPhone: groupWalk?.walk_leader?.telephone, + contactPhone: groupWalk?.walk_leader?.telephone || groupWalk?.event_organiser?.telephone, displayName, - distance: `${groupWalk?.distance_miles} miles`, + distance: groupWalk?.distance_miles ? `${groupWalk?.distance_miles} miles` : "", events: [], grade: groupWalk.difficulty?.description, - gridReference: groupWalk.start_location?.grid_reference_8, + gridReference: groupWalk.start_location?.grid_reference_8 || groupWalk.location.grid_reference_8, gridReferenceFinish: groupWalk.end_location?.grid_reference_8, id: groupWalk.id, location: null, @@ -522,7 +534,7 @@ export class RamblersWalksAndEventsService { nearestTown: groupWalk.start_location?.description?.replace(this.NEAREST_TOWN_PREFIX, ""), osMapsRoute: null, osMapsTitle: null, - postcode: groupWalk.start_location?.postcode, + postcode: groupWalk.start_location?.postcode || groupWalk.location.postcode, postcodeFinish: groupWalk.end_location?.postcode, ramblersPublish: false, ramblersWalkId: groupWalk.id, @@ -540,7 +552,8 @@ export class RamblersWalksAndEventsService { }, features: (groupWalk.facilities || []).concat(groupWalk.transport || []).concat(groupWalk.accessibility || []).sort(sortBy("description")), startLocation: groupWalk.start_location?.description, - additionalDetails: groupWalk.additional_details + additionalDetails: groupWalk.additional_details, + organiser:groupWalk?.event_organiser?.name }; this.logger.info("groupWalk:", groupWalk, "walk:", walk, "contactName:", contactName, "displayName:", displayName); return walk; diff --git a/server/lib/ramblers/list-walks.ts b/server/lib/ramblers/list-events.ts similarity index 90% rename from server/lib/ramblers/list-walks.ts rename to server/lib/ramblers/list-events.ts index 4052b68..22e8995 100644 --- a/server/lib/ramblers/list-walks.ts +++ b/server/lib/ramblers/list-events.ts @@ -8,7 +8,7 @@ import { RamblersWalksRawApiResponse, RamblersWalksRawApiResponseApiResponse, WalkLeader, - WalkListRequest, + EventsListRequest, WALKS_MANAGER_API_DATE_FORMAT, WALKS_MANAGER_GO_LIVE_DATE } from "../../../projects/ngx-ramblers/src/app/models/ramblers-walks-manager"; @@ -30,17 +30,18 @@ noopDebugLog.enabled = false; debugLog.enabled = false; export function walkLeaders(req: Request, res: Response): void { - const body: WalkListRequest = req.body; - debugLog("listWalks:body:", body); + const body: EventsListRequest = req.body; + debugLog("listEvents:body:", body); systemConfig() .then((systemConfig: SystemConfig) => { const limit = body.limit; const date = dateParameter(body); const dateEnd = dateEndParameter(body); const defaultOptions = requestDefaults.createApiRequestOptions(systemConfig); - debugLog("listWalks:defaultOptions:", defaultOptions); + debugLog("listEvents:defaultOptions:", defaultOptions); const optionalParameters = [ optionalParameter("groups", systemConfig?.group?.groupCode), + optionalParameter("types", body.types), optionalParameter("limit", limit), optionalParameter("date", date), optionalParameter("date_end", dateEnd)] @@ -53,7 +54,7 @@ export function walkLeaders(req: Request, res: Response): void { protocol: defaultOptions.protocol, headers: defaultOptions.headers, method: "get", - path: `/api/volunteers/walksevents?api-key=${systemConfig?.national?.walksManager?.apiKey}&types=group-walk&${optionalParameters}` + path: `/api/volunteers/walksevents?api-key=${systemConfig?.national?.walksManager?.apiKey}&${optionalParameters}` }, debug: noopDebugLog, res, @@ -75,10 +76,10 @@ export function walkLeaders(req: Request, res: Response): void { .catch(error => res.json(error)); } -export function listWalks(req: Request, res: Response): void { - const body: WalkListRequest = req.body; +export function listEvents(req: Request, res: Response): void { + const body: EventsListRequest = req.body; const rawData: boolean = body.rawData; - debugLog("listWalks:body:", body); + debugLog("listEvents:body:", body); systemConfig() .then((systemConfig: SystemConfig) => { const limit = body.limit; @@ -88,9 +89,10 @@ export function listWalks(req: Request, res: Response): void { const date = dateParameter(body); const dateEnd = dateEndParameter(body); const defaultOptions = requestDefaults.createApiRequestOptions(systemConfig); - debugLog("listWalks:defaultOptions:", defaultOptions); + debugLog("listEvents:defaultOptions:", defaultOptions); const optionalParameters = [ optionalParameter("groups", systemConfig?.group?.groupCode), + optionalParameter("types", body.types), optionalParameter("ids", ids), optionalParameter("limit", limit), optionalParameter("sort", sort), @@ -106,7 +108,7 @@ export function listWalks(req: Request, res: Response): void { protocol: defaultOptions.protocol, headers: defaultOptions.headers, method: "get", - path: `/api/volunteers/walksevents?api-key=${systemConfig?.national?.walksManager?.apiKey}&types=group-walk&${optionalParameters}` + path: `/api/volunteers/walksevents?api-key=${systemConfig?.national?.walksManager?.apiKey}&${optionalParameters}` }, debug: noopDebugLog, res, @@ -128,7 +130,7 @@ export function listWalks(req: Request, res: Response): void { .catch(error => res.json(error)); } -function dateParameter(body: WalkListRequest): string { +function dateParameter(body: EventsListRequest): string { if (body?.ids?.length > 0) { const dateParameter = moment(WALKS_MANAGER_GO_LIVE_DATE).tz("Europe/London").startOf("day").format(WALKS_MANAGER_API_DATE_FORMAT); debugLog("returning dateParameter:", dateParameter, "given id request:", body.ids, "and dateEnd:", body.date); @@ -139,7 +141,7 @@ function dateParameter(body: WalkListRequest): string { } } -function dateEndParameter(body: WalkListRequest): string { +function dateEndParameter(body: EventsListRequest): string { if (body?.ids?.length > 0) { const dateEndParameter = moment().tz("Europe/London").add(2, "month").format(WALKS_MANAGER_API_DATE_FORMAT); debugLog("returning dateEndParameter:", dateEndParameter, "given id request:", body.ids, "and dateEnd:", body.dateEnd); diff --git a/server/lib/ramblers/ramblers-routes.ts b/server/lib/ramblers/ramblers-routes.ts index f857237..e2923b2 100644 --- a/server/lib/ramblers/ramblers-routes.ts +++ b/server/lib/ramblers/ramblers-routes.ts @@ -5,11 +5,11 @@ import { envConfig } from "../env-config/env-config"; import * as groups from "./list-groups"; import * as memberBulkLoad from "./member-bulk-load"; import * as ramblersWalkUpload from "./ramblers-walk-upload"; -import * as walksAndEvents from "./list-walks"; +import * as walksAndEvents from "./list-events"; const router = express.Router(); -router.post("/walks-manager/list-walks", walksAndEvents.listWalks); +router.post("/walks-manager/list-events", walksAndEvents.listEvents); router.post("/walks-manager/list-groups", groups.listGroups); router.post("/walks-manager/upload-walks", authConfig.authenticate(), ramblersWalkUpload.uploadWalks); router.post("/walks-manager/walk-leaders", authConfig.authenticate(), walksAndEvents.walkLeaders); diff --git a/server/lib/shared/message-handlers.ts b/server/lib/shared/message-handlers.ts index 820609f..e35223e 100644 --- a/server/lib/shared/message-handlers.ts +++ b/server/lib/shared/message-handlers.ts @@ -4,9 +4,15 @@ import isEmpty = require("lodash/isEmpty"); import querystring = require("querystring"); import { envConfig } from "../env-config/env-config"; import { MessageHandlerOptions } from "../../../projects/ngx-ramblers/src/app/models/server-models"; +import { isArray } from "lodash"; export function optionalParameter(key: string, value: any): string { - return key && value ? `${key}=${value}` : ""; + if (key && value) { + const appliedValue = isArray(value) ? value.join(",") : value; + return `${key}=${appliedValue}`; + } else { + return ""; + } } function createRequestAudit(options: MessageHandlerOptions) {