Skip to content

Commit

Permalink
Event deliveries search apps filter (#382)
Browse files Browse the repository at this point in the history
* WIP

* undo push

* update dashboard component with external parameters for cloud support

* remove app portal
update convoy-dashboard

* implement search for apps filter in event deliveries tab
  • Loading branch information
horlah authored Jan 21, 2022
1 parent 6869290 commit 9fa4c94
Show file tree
Hide file tree
Showing 10 changed files with 101 additions and 25 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "convoy-dashboard",
"version": "0.0.4",
"version": "0.3.1",
"description": "Convoy Dashboard UI",
"repository": {
"type": "git",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,13 +254,27 @@ <h2>Configuration</h2>
</div>
</div>

<div class="select">
<select [ngClass]="{ active: !!eventDeliveriesApp }" aria-label="frequency" [(ngModel)]="eventDeliveriesApp" (change)="getEventDeliveries({ addToURL: true })">
<option value="">All Apps</option>
<option [value]="app.uid" *ngFor="let app of apps?.content">
{{ app.name }}
</option>
</select>
<div class="dropdown large">
<button
class="filter--button dropdown--button"
[ngClass]="{ active: !!eventDeliveriesApp }"
(click)="showOverlay = true; showEventDeliveriesAppsDropdown = !showEventDeliveriesAppsDropdown"
>
<img src="/assets/img/apps-icon-grey.svg" alt="apps filter icon" />
<span>All Apps</span>
<img src="/assets/img/angle-arrow-down.svg" alt="arrow down icon" />
</button>
<div class="dropdown--list" [ngClass]="{ show: showEventDeliveriesAppsDropdown }">
<div class="search">
<img src="/assets/img/search-icon.svg" alt="search icon" />
<input type="search" placeholder="Search apps here" (input)="searchApps($event)" />
</div>
<div class="dropdown--list--item" *ngFor="let app of filteredApps">
<input type="radio" name="app" [value]="app.uid" [id]="app.uid" [checked]="app.uid === eventDeliveriesApp" (change)="updateEventDevliveryAppFilter(app.uid, $event)" />
<label [for]="app.uid">{{ app.name }}</label>
</div>
<p *ngIf="filteredApps.length === 0">No app to display</p>
</div>
</div>

<div class="filter--button event-button active" *ngIf="eventDeliveryFilteredByEventId !== ''">
Expand Down Expand Up @@ -542,4 +556,4 @@ <h5>{{ endpoint.description }}</h5>
</div>
</div>

<div class="overlay" *ngIf="showOverlay" (click)="showOverlay = false; showEventDeliveriesStatusDropdown = false"></div>
<div class="overlay" *ngIf="showOverlay" (click)="showOverlay = false; showEventDeliveriesStatusDropdown = false; showEventDeliveriesAppsDropdown = false"></div>
Original file line number Diff line number Diff line change
Expand Up @@ -322,3 +322,37 @@
font-size: 12px;
margin-top: 10px;
}

.dropdown {
&.large {
.dropdown--list {
width: 249px;
}

p {
text-align: center;
font-style: italic;
}
}
}

.search {
display: flex;
background: #ffffff;
border: 1px solid #edeff5;
box-sizing: border-box;
border-radius: 10px;
padding: 10px 15px;
align-items: center;
margin-bottom: 20px;

img {
margin-right: 10px;
}

input {
font-size: 14px;
border: none;
padding: 0;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export class ConvoyDashboardComponent implements OnInit {
}[] = [];
events!: { pagination: PAGINATION; content: EVENT[] };
apps!: { pagination: PAGINATION; content: APP[] };
filteredApps!: APP[];
eventDetailsTabs = [
{ id: 'data', label: 'Event' },
{ id: 'response', label: 'Response' },
Expand Down Expand Up @@ -82,6 +83,7 @@ export class ConvoyDashboardComponent implements OnInit {
eventDeliveryFilteredByStatus: string[] = [];
showOverlay = false;
showEventDeliveriesStatusDropdown = false;
showEventDeliveriesAppsDropdown = false;
@Input('apiURL') apiURL: string = '';
@Input('isCloud') isCloud: boolean = false;
@Input('groupId') groupId: string = '';
Expand Down Expand Up @@ -326,6 +328,11 @@ export class ConvoyDashboardComponent implements OnInit {
}
}

updateEventDevliveryAppFilter(appId: string, isChecked: any) {
if (isChecked.target.checked) this.eventDeliveriesApp = appId;
this.getEventDeliveries({ addToURL: true });
}

async getEventDeliveries(requestDetails?: { addToURL?: boolean }) {
if (requestDetails?.addToURL) this.addFilterToURL({ section: 'eventDels' });
const { startDate, endDate } = this.setDateForFilter(this.eventDeliveriesFilterDateRange.value);
Expand Down Expand Up @@ -379,20 +386,22 @@ export class ConvoyDashboardComponent implements OnInit {
}
}

async getApps() {
async getApps(search?: string) {
try {
const appsResponse = await this.convyDashboardService.request({
url: this.getAPIURL(`/apps?groupID=${this.activeGroup || ''}&sort=AESC&page=${this.appsPage || 1}&perPage=10`),
url: this.getAPIURL(`/apps?groupID=${this.activeGroup || ''}&sort=AESC&page=${this.appsPage || 1}&perPage=10${search ? `&q=${search}` : ''}`),
method: 'get'
});

if (this.apps?.pagination?.next === this.appsPage) {
if (!search && this.apps?.pagination?.next === this.appsPage) {
const content = [...this.apps.content, ...appsResponse.data.content];
const pagination = appsResponse.data.pagination;
this.apps = { content, pagination };
return;
}
this.apps = appsResponse.data;

if (!search) this.apps = appsResponse.data;
this.filteredApps = appsResponse.data.content;
if (this.activeTab === 'apps') this.detailsItem = this.apps?.content[0];
return;
} catch (error) {
Expand Down Expand Up @@ -556,4 +565,13 @@ export class ConvoyDashboardComponent implements OnInit {
checkIfEventDeliveryStatusFilterOptionIsSelected(status: string): boolean {
return this.eventDeliveryFilteredByStatus?.length > 0 ? this.eventDeliveryFilteredByStatus.includes(status) : false;
}

checkIfEventDeliveryAppFilterOptionIsSelected(appId: string): boolean {
return appId === this.eventDeliveriesApp;
}

searchApps(searchInput: any) {
const searchString = searchInput.target.value;
searchString ? this.getApps(searchString) : (this.filteredApps = this.apps.content);
}
}
13 changes: 3 additions & 10 deletions web/ui/dashboard/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion web/ui/dashboard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"@angular/router": "~13.0.0",
"angular-prism": "^0.1.20",
"chart.js": "^3.6.0",
"convoy-dashboard": "0.0.4",
"convoy-dashboard": "0.3.1",
"date-fns": "^2.27.0",
"moment": "^2.29.1",
"ng2-prism": "^2.3.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@

<!-- <convoy-app-portal></convoy-app-portal> -->
<!-- <app-portal></app-portal> -->
<convoy-app></convoy-app>
<!-- <convoy-app></convoy-app> -->
</div>
3 changes: 3 additions & 0 deletions web/ui/dashboard/src/assets/img/apps-icon-grey.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions web/ui/dashboard/src/assets/img/search-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions web/ui/dashboard/src/scss/_table.scss
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
.dropdown {
position: relative;

&.large {
min-width: 145px;
}

.dropdown--list {
position: absolute;
top: 110%;
Expand Down

0 comments on commit 9fa4c94

Please sign in to comment.