Skip to content

Commit

Permalink
Add filter and tags
Browse files Browse the repository at this point in the history
  • Loading branch information
squix78 committed Jun 20, 2024
1 parent fcec211 commit 136d4b1
Show file tree
Hide file tree
Showing 10 changed files with 66 additions and 6 deletions.
4 changes: 3 additions & 1 deletion src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 11,7 @@ import { AppsComponent } from './apps/apps.component';
import { CacheInterceptor } from './services/cache.interceptor';
import { HTTP_INTERCEPTORS } from '@angular/common/http';
import { FlasherComponent } from './flasher/flasher.component';
import { FullTextFilterPipe } from './services/full-text-filter.pipe';

const routes: Routes = [
{ path: '', component: DevicesComponent },
Expand All @@ -25,7 26,8 @@ const routes: Routes = [
AppComponent,
DevicesComponent,
AppsComponent,
FlasherComponent
FlasherComponent,
FullTextFilterPipe
],
imports: [
BrowserModule,
Expand Down
10 changes: 9 additions & 1 deletion src/app/apps/apps.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 23,21 @@


<h1>Applications</h1>
<mat-card *ngFor="let app of apps">
<mat-form-field class="example-form-field">
<mat-label>Search Applications</mat-label>
<input matInput type="text" [(ngModel)]="searchText">
</mat-form-field>

<mat-card *ngFor="let app of apps | fullTextFilter: searchText">
<mat-card-header>
<img mat-card-avatar [src]="app.appIcon" alt="Device"/>
<mat-card-title>{{app.name}}</mat-card-title>
<mat-card-subtitle>{{app?.version}}</mat-card-subtitle>
</mat-card-header>
<mat-card-content>
<p>
<mat-chip *ngFor="let tag of app?.tags">{{tag}}</mat-chip>
</p>
<p>
{{app?.description}}
</p>
Expand Down
1 change: 1 addition & 0 deletions src/app/apps/apps.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 15,7 @@ export class AppsComponent implements OnInit{
deviceId: string;
device: Device | undefined;
apps: App[];
searchText: string;

constructor(private route: ActivatedRoute,
public deviceService: DevicesService,
Expand Down
14 changes: 13 additions & 1 deletion src/app/devices/devices.component.html
Original file line number Diff line number Diff line change
@@ -1,11 1,23 @@
<h1>Devices</h1>
<mat-card *ngFor="let device of devices">
<mat-form-field class="example-form-field">
<mat-label>Search Devices</mat-label>
<input matInput type="text" [(ngModel)]="searchText">
</mat-form-field>

<mat-card *ngFor="let device of devices | fullTextFilter: searchText">
<mat-card-header>
<img mat-card-avatar [src]="device.imageThumbnail" alt="Device"/>
<mat-card-title>{{device.name}}</mat-card-title>
<mat-card-subtitle>{{device.manufacturer}}</mat-card-subtitle>

</mat-card-header>
<mat-card-header>
<mat-card-title-group>
<img mat-card-sm-image [src]="device?.image" alt="Device"/>
<mat-card-title>{{device?.name}}</mat-card-title>
<mat-card-subtitle>{{device?.manufacturer}}</mat-card-subtitle>
</mat-card-title-group>
</mat-card-header>

<mat-card-content>
<p>
Expand Down
1 change: 1 addition & 0 deletions src/app/devices/devices.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 9,7 @@ import { Device } from '../models/device';
})
export class DevicesComponent implements OnInit {

searchText: string = '';
devices: Device[] = [];

constructor(public deviceService: DevicesService) { }
Expand Down
7 changes: 6 additions & 1 deletion src/app/flasher/flasher.component.css
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 13,12 @@
justify-content: space-between;
}

.mdc-card {
.mdc-card {
margin-bottom: 10px;
}

mat-chip {
padding: 0px 0px !important;
margin: 0px 2px !important;
font-size:smaller;
}
3 changes: 3 additions & 0 deletions src/app/flasher/flasher.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 9,9 @@
<mat-card-subtitle>{{app?.version}}</mat-card-subtitle>
</mat-card-header>
<mat-card-content>
<p>
<mat-chip *ngFor="let tag of app?.tags">{{tag}}</mat-chip>
</p>
<p>
{{app?.description}}
</p>
Expand Down
1 change: 1 addition & 0 deletions src/app/models/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 10,5 @@ export interface App {
instructions: string;
supportedDevices: string[];
partitions: Partition[];
tags: string[];
}
25 changes: 25 additions & 0 deletions src/app/services/full-text-filter.pipe.ts
Original file line number Diff line number Diff line change
@@ -0,0 1,25 @@
// full-text-filter.pipe.ts

import { Pipe, PipeTransform } from '@angular/core';

@Pipe({
name: 'fullTextFilter'
})
export class FullTextFilterPipe implements PipeTransform {
transform(items: any[], searchText: string): any[] {
if (!items) {
return [];
}
if (!searchText) {
return items;
}
searchText = searchText.toLowerCase();

return items.filter(item => {
// Check if the searchText exists in any attribute of the item
return Object.values(item).some(value =>
value && value.toString().toLowerCase().includes(searchText)
);
});
}
}
6 changes: 4 additions & 2 deletions src/assets/apps.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 14,8 @@
"data": [],
"offset": 0,
"url": "./assets/apps/super-wifi-duck/app-firmware.bin"
}]
}],
"tags": ["badusb", "keystroke-injection", "wifi-duck", "hid", "usb-rubber-ducky", "keyboard", "mouse"]
},
{
"id": "tp-pendrive-s3-circuit-python",
Expand All @@ -32,7 33,8 @@
"data": [],
"offset": 0,
"url": "./assets/apps/circuitpython/circuit-python-bootloader.bin"
}]
}],
"tags": ["circuit-python", "adafruit", "microcontroller", "embedded"]
},
{
"id": "other-device",
Expand Down

0 comments on commit 136d4b1

Please sign in to comment.