Skip to content

Commit

Permalink
feat: add search notifier field (#312)
Browse files Browse the repository at this point in the history
  • Loading branch information
xixas committed Sep 9, 2024
1 parent 10e9d4f commit 2e05661
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ <h2 class="p-col-12">Notifications</h2>
<p-toast key="tst"></p-toast>

<div class="p-grid">
<div class="p-col-12 p-md-3">
<div class="p-col-12 p-md-3 filter-row">
<p-dropdown
[options]="channelTypes"
[(ngModel)]="selectedChannelType"
Expand Down Expand Up @@ -56,6 +56,30 @@ <h2 class="p-col-12">Notifications</h2>
*ngIf="allApplicationsList.length !== 0"
></p-dropdown>
</div>
<div class="p-col-12 p-md-3 filter-row">
<input
type="email"
pInputText
[(ngModel)]="searchValue"
placeholder="Search Notifier Email"
class="grid-input"
pattern="^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$"
#searchInput="ngModel"
/>
<p-button
(onClick)="loadNotificationsLazy({ first: 0, rows: this.pageSize })"
label="Search"
class="grid-button"
[disabled]="searchInput.invalid || !searchInput.value"
/>
<p-button
(onClick)="onSearchClear(); loadNotificationsLazy({ first: 0, rows: this.pageSize })"
label="Clear"
class="grid-button"
severity="danger"
[disabled]="!searchValue"
/>
</div>
</div>

<div class="p-grid table-container">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,16 @@ h2 {
width: 100%;
}

.grid-dropdown {
.grid-dropdown,
.grid-input,
.grid-button {
margin-right: 1%;
}

.filter-row {
margin-bottom: 1%;
}

::ng-deep .p-calendar .p-calendar-clear-icon {
margin-right: 1.5rem;
margin-top: 0;
Expand Down
14 changes: 14 additions & 0 deletions apps/portal/src/app/views/notifications/notifications.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ export class NotificationsComponent implements OnInit {

selectedToDate = null;

searchValue = null;

mapApplicationAndKeys = null;

pageSizeOptions: number[] = [5, 10, 25, 50];
Expand Down Expand Up @@ -137,6 +139,10 @@ export class NotificationsComponent implements OnInit {
this.maxDateFrom = new Date();
}

onSearchClear() {
this.searchValue = null;
}

setTokenForSelectedApplication() {
if (this.allApplicationsList.length === 0) {
return JSON.parse(localStorage.getItem('osmoXUserData'))?.token;
Expand Down Expand Up @@ -206,6 +212,14 @@ export class NotificationsComponent implements OnInit {
});
}

if (this.searchValue) {
variables.filters.push({
field: 'data',
operator: 'contains',
value: this.searchValue,
});
}

// set the token based on selected application
const tokenForSelectedApplication = this.setTokenForSelectedApplication();

Expand Down

0 comments on commit 2e05661

Please sign in to comment.