Skip to content

Commit

Permalink
- fix scroll issue
Browse files Browse the repository at this point in the history
  • Loading branch information
ubaid4j committed May 30, 2024
1 parent 075b0a5 commit 309a3e9
Show file tree
Hide file tree
Showing 9 changed files with 83 additions and 62 deletions.
1 change: 1 addition & 0 deletions api-gateway/src/main/webapp/app/posts/post.model.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export interface PostDetail {

export interface Post {
title: string;
createdBy: string
postDetail: PostDetail;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<p-card header="{{header}}" [style]="{width: '360px'}">
<p-card [header]="header" [subheader]="createdBy"
[style]="{width: '360px', marginTop: '1rem'}">
<p class="m-0">
{{content}}
</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ import {CardModule} from 'primeng/card';
})
export class PostComponent {
@Input() header = '';
@Input() createdBy = '';
@Input() content = '';
}
5 changes: 5 additions & 0 deletions api-gateway/src/main/webapp/app/posts/posts.component.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.search-results {
display: flex;
flex-direction: column;
align-items: center;
}
7 changes: 5 additions & 2 deletions api-gateway/src/main/webapp/app/posts/posts.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@
[infiniteScrollDistance]="1"
[infiniteScrollThrottle]="500"
(scrolled)="onScroll()"
[scrollWindow]="false"
>
<div class="data-card" *ngFor="let post of posts">
<app-post [header]="post.title" [content]="post.postDetail.content"/>
<app-post
[header]="post.title"
[content]="post.postDetail.content"
[createdBy]="post.createdBy"
/>
</div>

<div *ngIf="isLoading">Loading...</div>
Expand Down
8 changes: 4 additions & 4 deletions api-gateway/src/main/webapp/app/posts/posts.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export class PostsComponent implements OnInit {
toggleLoading = () => this.isLoading = !this.isLoading;

// it will be called when this component gets initialized.
loadData = () => {
loadData = () : void => {
this.toggleLoading();
this.postService.findAll(this.currentPage, this.itemsPerPage).subscribe({
next: postPage => {
Expand All @@ -41,18 +41,18 @@ export class PostsComponent implements OnInit {
})
}

appendData = () => {
appendData = () : void => {
this.toggleLoading();
this.postService.findAll(this.currentPage, this.itemsPerPage).subscribe({
next: postPage => {
this.posts.push(...this.posts, ...postPage.content);
this.posts.push(...postPage.content);
},
error: err => console.log(err),
complete: () => this.toggleLoading()
})
}

onScroll = () => {
onScroll = () : void => {
console.log('on scroll');
this.currentPage++;
this.appendData();
Expand Down
10 changes: 5 additions & 5 deletions post-service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@
<scope>test</scope>
<exclusions>
<exclusion>
<artifactId>commons-compress</artifactId>
<groupId>org.apache.commons</groupId>
<artifactId>commons-compress</artifactId>
</exclusion>
</exclusions>
</dependency>
Expand Down Expand Up @@ -216,14 +216,14 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.cyclonedx</groupId>
<artifactId>cyclonedx-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>

Expand Down
108 changes: 59 additions & 49 deletions post-service/pom.xml.bak
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
<description>Managing posts</description>
<properties>
<java.version>22</java.version>
<maven.version>4.0.0-alpha-13</maven.version>
<mapstruct.version>1.5.5.Final</mapstruct.version>
<maven.version>3.8.6</maven.version>
<sortpom-maven-plugin.version>3.4.0</sortpom-maven-plugin.version>
<spring-cloud.version>2023.0.1</spring-cloud.version>
<mapstruct.version>1.5.5.Final</mapstruct.version>
<springdoc-openapi-starter-webmvc-api.version>2.5.0</springdoc-openapi-starter-webmvc-api.version>
</properties>
<dependencyManagement>
Expand All @@ -32,15 +32,35 @@
</dependencyManagement>

<dependencies>
<dependency>
<groupId>jakarta.validation</groupId>
<artifactId>jakarta.validation-api</artifactId>
</dependency>
<dependency>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-core</artifactId>
</dependency>
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct</artifactId>
<version>${mapstruct.version}</version>
</dependency>
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<version>${mapstruct.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-starter-webmvc-api</artifactId>
<version>${springdoc-openapi-starter-webmvc-api.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
Expand All @@ -65,17 +85,6 @@
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct</artifactId>
<version>${mapstruct.version}</version>
</dependency>
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<version>${mapstruct.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
Expand All @@ -84,6 +93,16 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-testcontainers</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<artifactId>commons-compress</artifactId>
<groupId>org.apache.commons</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-consul-discovery</artifactId>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
Expand All @@ -95,19 +114,6 @@
<artifactId>postgresql</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>jakarta.validation</groupId>
<artifactId>jakarta.validation-api</artifactId>
</dependency>
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-starter-webmvc-api</artifactId>
<version>${springdoc-openapi-starter-webmvc-api.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-consul-discovery</artifactId>
</dependency>
</dependencies>

<build>
Expand All @@ -134,6 +140,27 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<parameters>true</parameters>
<annotationProcessorPaths>
<path>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
</path>
<path>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<version>${mapstruct.version}</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
Expand All @@ -159,27 +186,6 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<parameters>true</parameters>
<annotationProcessorPaths>
<path>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
</path>
<path>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<version>${mapstruct.version}</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
Expand All @@ -202,6 +208,10 @@
<groupId>com.github.ekryd.sortpom</groupId>
<artifactId>sortpom-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
Expand All @@ -211,8 +221,8 @@
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<groupId>org.cyclonedx</groupId>
<artifactId>cyclonedx-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package dev.ubaid.ps.service.dto;

public record PostDTO(String title, PostDetailDTO postDetail) {
public record PostDTO(String title, String createdBy, PostDetailDTO postDetail) {
}

0 comments on commit 309a3e9

Please sign in to comment.