Skip to content

Commit

Permalink
Merge pull request #602 from bcgov/oleks
Browse files Browse the repository at this point in the history
DSS-757, DSS-758, DSS-759: Aggregated Listings
  • Loading branch information
ychung-mot authored Sep 5, 2024
2 parents 2edde74 + ab65d4a commit f4c0756
Show file tree
Hide file tree
Showing 11 changed files with 1,294 additions and 2 deletions.
7 changes: 7 additions & 0 deletions frontend/src/app/app.routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { RoleDetailsComponent } from './features/components/roles-list/role-deta
import { UserDetailsComponent } from './features/components/user-management/user-details/user-details.component';
import { ExportListingsComponent } from './features/components/export-listings/export-listings.component';
import { UploadBusinessLicenseComponent } from './features/components/upload-business-license/upload-business-license.component';
import { AggregatedListingsTableComponent } from './features/components/listings-table/aggregated-listings-table/aggregated-listings-table.component';

export const routes: Routes = [
{
Expand Down Expand Up @@ -84,6 +85,12 @@ export const routes: Routes = [
canActivate: [approvedUserGuard, activeUserGuard, hasPermissionsGuard, areTermsAceptedGuard],
data: { permissions: [listing_read] },
},
{
path: 'aggregated-listings',
component: AggregatedListingsTableComponent,
canActivate: [approvedUserGuard, activeUserGuard, hasPermissionsGuard, areTermsAceptedGuard],
data: { permissions: [listing_read] },
},
{
path: 'listing/:id', component: ListingDetailsComponent,
canActivate: [approvedUserGuard, activeUserGuard, hasPermissionsGuard, areTermsAceptedGuard],
Expand Down
16 changes: 16 additions & 0 deletions frontend/src/app/common/models/listing-table-row.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,21 @@ export interface ListingTableRow {
bcRegistryNo?: string;

rentalListingContacts?: [];
selected?: boolean;

}

export interface AggregatedListingTableRow {
id?: string;
effectiveBusinessLicenceNo?: string;
effectiveHostNm?: string;
primaryHostNm: string;
matchAddressTxt: string;
nightsBookedYtdQty: number;
businessLicenceNo: string;
lastActionNm?: string;
lastActionDtm?: string;

listings: Array<ListingTableRow>;
selected?: boolean;
}
10 changes: 10 additions & 0 deletions frontend/src/app/common/services/dashboard.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,16 @@ export class DashboardService {

private initCards(): void {
this.cards = [
{
accessPermission: listing_read,
buttonIcon: '',
buttonText: 'View Aggregated Listing Data',
description: 'View aggregated platform listing data for your community',
route: 'aggregated-listings',
title: 'Aggregated Listing Data',
boxId: 'aggregated_listings_box',
buttonId: 'aggregated_listings_btn',
},
{
accessPermission: listing_read,
buttonIcon: '',
Expand Down
69 changes: 68 additions & 1 deletion frontend/src/app/common/services/listing-data.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Observable } from 'rxjs';
import { environment } from '../../../environments/environment';
import { PagingResponse } from '../models/paging-response';
import { ListingUploadHistoryRecord } from '../models/listing-upload-history-record';
import { ListingTableRow } from '../models/listing-table-row';
import { AggregatedListingTableRow, ListingTableRow } from '../models/listing-table-row';
import { ListingSearchRequest } from '../models/listing-search-request';
import { ListingAddressCandidate, ListingDetails } from '../models/listing-details';
import { ExportJurisdiction } from '../models/export-listing';
Expand Down Expand Up @@ -140,6 +140,73 @@ export class ListingDataService {
return this.httpClient.get<PagingResponse<ListingTableRow>>(endpointUrl);
}

getAggregatedListings(
pageNumber: number = 1,
pageSize: number = 10,
orderBy: string = '',
direction: 'asc' | 'desc' = 'asc',
searchReq: ListingSearchRequest = {},
filter?: ListingFilter
): Observable<PagingResponse<AggregatedListingTableRow>> {
let endpointUrl = `${environment.API_HOST}/rentallistings/grouped?pageSize=${pageSize}&pageNumber=${pageNumber}`;

if (orderBy) {
endpointUrl += `&orderBy=${orderBy}&direction=${direction}`;
}

if (searchReq.all) {
endpointUrl += `&all=${searchReq.all}`;
}
if (searchReq.address) {
endpointUrl += `&address=${searchReq.address}`;
}
if (searchReq.url) {
endpointUrl += `&url=${searchReq.url}`;
}
if (searchReq.listingId) {
endpointUrl += `&listingId=${searchReq.listingId}`;
}
if (searchReq.hostName) {
endpointUrl += `&hostName=${searchReq.hostName}`;
}
if (searchReq.businessLicence) {
endpointUrl += `&businessLicence=${searchReq.businessLicence}`;
}

if (filter) {
if (filter.byLocation) {
if (!!filter.byLocation?.isPrincipalResidenceRequired) {
endpointUrl += `&prRequirement=${filter.byLocation.isPrincipalResidenceRequired == 'Yes'}`;
}
if (!!filter.byLocation?.isBusinessLicenceRequired) {
endpointUrl += `&blRequirement=${filter.byLocation.isBusinessLicenceRequired == 'Yes'}`;
}
}
if (filter.byStatus) {
if (filter.byStatus.reassigned !== null && filter.byStatus.reassigned !== undefined) {
endpointUrl += `&reassigned=${!!filter.byStatus.reassigned}`;
}
if (filter.byStatus.takedownComplete !== null && filter.byStatus.takedownComplete !== undefined) {
endpointUrl += `&takedownComplete=${!!filter.byStatus.takedownComplete}`;
}

const statuses = new Array();
if (filter.byStatus.active) statuses.push('A')
if (filter.byStatus.inactive) statuses.push('I')
if (filter.byStatus.new) statuses.push('N')

if (statuses.length) {
endpointUrl += `&statuses=${statuses.join(',')}`;
}
}
if (!!filter.community) {
endpointUrl += `&lgId=${filter.community}`;
}
}

return this.httpClient.get<PagingResponse<AggregatedListingTableRow>>(endpointUrl);
}

getListingDetailsById(id: number): Observable<ListingDetails> {
return this.httpClient.get<ListingDetails>(`${environment.API_HOST}/rentallistings/${id}`);
}
Expand Down
7 changes: 7 additions & 0 deletions frontend/src/app/common/services/top-menu.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ export class TopMenuService {

private initMenuItems(): void {
this.menuItems = [
{
accessPermission: listing_read,
buttonId: 'aggregated_listings_mi_btn',
route: '/aggregated-listings',
title: 'Aggregated Listing Data',
folderName: 'Listings',
},
{
accessPermission: listing_read,
buttonId: 'listings_mi_btn',
Expand Down
Loading

0 comments on commit f4c0756

Please sign in to comment.