Skip to content

Commit

Permalink
component find advertisement created
Browse files Browse the repository at this point in the history
PropertyController json and csv added
  • Loading branch information
RudyVane committed May 29, 2023
1 parent 5d9b99b commit e5af657
Show file tree
Hide file tree
Showing 19 changed files with 216 additions and 32 deletions.
2 changes: 2 additions & 0 deletions angular/src/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
<button (click)="showRegisterComponent()">New user</button>
<button (click)="showListComponent()">Properties</button>
<button (click)="showUserAddComponent()">Write Advertisement</button>
<button (click)="showUserAdvertisement()">Find Advertisements</button>

</div>
<router-outlet></router-outlet>

Expand Down
4 changes: 3 additions & 1 deletion angular/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { SearchComponent } from './search/search.component';
import { CommonModule } from '@angular/common';
import { ContactformComponent } from './contactform/contactform.component';
import { FormsModule } from '@angular/forms';
import { FindAdvertisementComponent } from './find-advertisement/find-advertisement.component';



Expand All @@ -24,7 +25,8 @@ import { FormsModule } from '@angular/forms';
PropertyListComponent,
UserAdvertisementComponent,
SearchComponent,
ContactformComponent
ContactformComponent,
FindAdvertisementComponent
// PropertyDetailsComponent

],
Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<p>find-advertisement works!</p>
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { FindAdvertisementComponent } from './find-advertisement.component';

describe('FindAdvertisementComponent', () => {
let component: FindAdvertisementComponent;
let fixture: ComponentFixture<FindAdvertisementComponent>;

beforeEach(() => {
TestBed.configureTestingModule({
declarations: [FindAdvertisementComponent]
});
fixture = TestBed.createComponent(FindAdvertisementComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
10 changes: 10 additions & 0 deletions angular/src/app/find-advertisement/find-advertisement.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Component } from '@angular/core';

@Component({
selector: 'app-find-advertisement',
templateUrl: './find-advertisement.component.html',
styleUrls: ['./find-advertisement.component.css']
})
export class FindAdvertisementComponent {

}
4 changes: 4 additions & 0 deletions angular/src/app/form/form.component.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
.container {
padding-left: 10px;
padding-right: 10px;
}
.form-container {
display: flex;
flex-direction: column;
Expand Down
2 changes: 2 additions & 0 deletions angular/src/app/form/form.component.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<div class = 'container'>
<div class="content">
<h1>Add new property</h1>

Expand All @@ -9,3 +10,4 @@ <h1>Add new property</h1>
<button type="submit">Submit</button>
</form>
</div>
</div>
4 changes: 4 additions & 0 deletions angular/src/app/home/home.component.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.container {
padding-left: 10px;
padding-right: 10px;
}
4 changes: 4 additions & 0 deletions angular/src/app/login/login.component.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.container {
padding-left: 10px;
padding-right: 10px;
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<div class = 'container'>
<h1>Details</h1>
<div *ngIf="property$ | async as property">
<h2>{{ property.title }}</h2>
Expand Down Expand Up @@ -45,6 +46,6 @@ <h2>{{ property.title }}</h2>
<p><strong>Toilet:</strong> {{ property.toilet }}</p>
</div>


</div>


3 changes: 2 additions & 1 deletion angular/src/app/property-list/property-list.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ <h1>Properties</h1>
<option value="All Cities">All Cities</option>
<option *ngFor="let city of distinctCities" [value]="city">{{ city }}</option>
</select>

<label for="minRent">Min Rent:</label>
<input type="number" id="minRent" name="minRent" [(ngModel)]="minRent">
<label for="maxRent">Max Rent:</label>
<input type="number" id="maxRent" name="maxRent" [(ngModel)]="maxRent">

Expand Down
100 changes: 82 additions & 18 deletions angular/src/app/property-list/property-list.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,15 @@ export class PropertyListComponent implements OnInit {
selectedProperty: Property | null = null;
showContactForm: boolean = false; // Define the showContactForm property
selectedCity: string = '';
maxRent: number = 1500;
maxRent: number = 0;
selectedGender: string = '';
id: number = 2;
distinctCities: string[] = [];
showFilterButtons: boolean = false;
topN: number = 10;

currentPage = 1;
minRent: number = 0;
constructor(
private http: HttpClient,
private router: Router,
Expand Down Expand Up @@ -111,7 +112,7 @@ export class PropertyListComponent implements OnInit {
(data: Page<Property>) => {
console.log(data); // Log the API response
this.properties = data;
this.properties.content = this.properties.content.slice(0, 100);
this.properties.content = this.properties.content.slice(0, 1000);
},
(error) => {
console.error('Error retrieving properties:', error);
Expand All @@ -131,7 +132,9 @@ export class PropertyListComponent implements OnInit {
if (this.maxRent) {
params.maxRent = this.maxRent;
}

if (this.minRent) {
params.minRent = this.minRent;
}
if (this.selectedGender) {
params.gender = this.selectedGender;
}
Expand All @@ -149,7 +152,9 @@ export class PropertyListComponent implements OnInit {
if (this.selectedCity && this.selectedCity !== 'All Cities' && property.city !== this.selectedCity) {
meetsCriteria = false;
}

if (this.minRent && property.rent < this.minRent) {
meetsCriteria = false;
}
if (this.maxRent && property.rent > this.maxRent) {
meetsCriteria = false;
}
Expand All @@ -161,7 +166,7 @@ export class PropertyListComponent implements OnInit {
return meetsCriteria;
});

this.properties.content = this.properties.content.slice(0, 100);
this.properties.content = this.properties.content.slice(0, 1000);

// Set the flag to show the filter buttons only after the "Apply Filters" button is clicked
this.showFilterButtons = true;
Expand All @@ -176,13 +181,30 @@ export class PropertyListComponent implements OnInit {
filterRentDown(): void {
if (this.selectedCity && this.selectedCity !== 'All Cities') {
const apiUrl = 'http://localhost:8080/property';
const params: any = {
city: this.selectedCity
};
const params: any = {};

if (this.selectedCity && this.selectedCity !== 'All Cities') {
params.city = this.selectedCity;
}

if (this.maxRent) {
params.maxRent = this.maxRent;
}
if (this.minRent) {
params.minRent = this.minRent;
}
if (this.selectedGender) {
params.gender = this.selectedGender;
}

// Make the API call with the updated URL and query parameters
this.http.get<Page<Property>>(apiUrl, { params }).pipe(
map((data: Page<Property>) => {
// Filter the properties based on rent within the specified range
data.content = data.content.filter(property => property.rent >= this.minRent && property.rent <= this.maxRent);
return data;
}),
tap((data: Page<Property>) => {
// Sort the properties based on rent in descending order
data.content.sort((a, b) => b.rent - a.rent);
return data;
Expand All @@ -199,16 +221,34 @@ export class PropertyListComponent implements OnInit {
}
}


filterRentUp(): void {
if (this.selectedCity && this.selectedCity !== 'All Cities') {
const apiUrl = 'http://localhost:8080/property';
const params: any = {
city: this.selectedCity
};
const params: any = {};

if (this.selectedCity && this.selectedCity !== 'All Cities') {
params.city = this.selectedCity;
}

if (this.maxRent) {
params.maxRent = this.maxRent;
}
if (this.minRent) {
params.minRent = this.minRent;
}
if (this.selectedGender) {
params.gender = this.selectedGender;
}

// Make the API call with the updated URL and query parameters
this.http.get<Page<Property>>(apiUrl, { params }).pipe(
map((data: Page<Property>) => {
// Filter the properties based on rent within the specified range
data.content = data.content.filter(property => property.rent >= this.minRent && property.rent <= this.maxRent);
return data;
}),
tap((data: Page<Property>) => {
// Sort the properties based on rent in ascending order
data.content.sort((a, b) => a.rent - b.rent);
return data;
Expand All @@ -224,12 +264,25 @@ export class PropertyListComponent implements OnInit {
).subscribe();
}
}

filterSqmUp(): void {
if (this.selectedCity && this.selectedCity !== 'All Cities') {
const apiUrl = 'http://localhost:8080/property';
const params: any = {
city: this.selectedCity
};
const params: any = {};

if (this.selectedCity && this.selectedCity !== 'All Cities') {
params.city = this.selectedCity;
}

if (this.maxRent) {
params.maxRent = this.maxRent;
}
if (this.minRent) {
params.minRent = this.minRent;
}
if (this.selectedGender) {
params.gender = this.selectedGender;
}

// Make the API call with the updated URL and query parameters
this.http.get<Page<Property>>(apiUrl, { params }).pipe(
Expand Down Expand Up @@ -259,9 +312,21 @@ export class PropertyListComponent implements OnInit {
filterSqmDown(): void {
if (this.selectedCity && this.selectedCity !== 'All Cities') {
const apiUrl = 'http://localhost:8080/property';
const params: any = {
city: this.selectedCity
};
const params: any = {};

if (this.selectedCity && this.selectedCity !== 'All Cities') {
params.city = this.selectedCity;
}

if (this.maxRent) {
params.maxRent = this.maxRent;
}
if (this.minRent) {
params.minRent = this.minRent;
}
if (this.selectedGender) {
params.gender = this.selectedGender;
}

// Make the API call with the updated URL and query parameters
this.http.get<Page<Property>>(apiUrl, { params }).pipe(
Expand All @@ -287,5 +352,4 @@ export class PropertyListComponent implements OnInit {
).subscribe();
}
}

}
4 changes: 4 additions & 0 deletions angular/src/app/register/register.component.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
.container {
padding-left: 10px;
padding-right: 10px;
}
.form-container {
display: flex;
flex-direction: column;
Expand Down
3 changes: 3 additions & 0 deletions angular/src/app/register/register.component.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<div class = 'container'>
<div class="content">
<h1>Register</h1>

Expand All @@ -8,3 +9,5 @@ <h1>Register</h1>
</div>
<button type="submit">Register</button>
</form>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
.container {
padding-left: 10px;
padding-right: 10px;
}
.form-container {
display: flex;
flex-direction: column;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<div class = 'container'>
<div class="content">
<h2>Advertisement</h2>

Expand All @@ -9,3 +10,4 @@ <h2>Advertisement</h2>
<button type="submit">Register</button>
</form>
</div>
</div>
Loading

0 comments on commit e5af657

Please sign in to comment.