From 74cda25c637b27851e3667c943d058fd7200121f Mon Sep 17 00:00:00 2001 From: Isaac Grynsztein Date: Mon, 9 Mar 2020 00:22:03 -0400 Subject: [PATCH] added search functionality made subscription file cards more responsive on mobile layouts removed unused shell code --- docker_wrapper.sh | 39 ------------------- .../subscription/subscription.component.html | 15 ++++++- .../subscription/subscription.component.scss | 27 +++++++++++++ .../subscription/subscription.component.ts | 23 +++++++++++ 4 files changed, 63 insertions(+), 41 deletions(-) delete mode 100644 docker_wrapper.sh diff --git a/docker_wrapper.sh b/docker_wrapper.sh deleted file mode 100644 index ed24447..0000000 --- a/docker_wrapper.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/bash - -cd backend - -# Start the first process -node app.js & -status=$? -if [ $status -ne 0 ]; then - echo "Failed to start my_first_process: $status" - exit $status -fi - -# Start the second process -apachectl -DFOREGROUND -status=$? -if [ $status -ne 0 ]; then - echo "Failed to start my_second_process: $status" - exit $status -fi - -# Naive check runs checks once a minute to see if either of the processes exited. -# This illustrates part of the heavy lifting you need to do if you want to run -# more than one service in a container. The container will exit with an error -# if it detects that either of the processes has exited. -# Otherwise it will loop forever, waking up every 60 seconds - -while /bin/true; do - ps aux |grep node\ app.js # |grep -q -v grep - PROCESS_1_STATUS=$? - ps aux |grep apache2 # |grep -q -v grep - PROCESS_2_STATUS=$? - # If the greps above find anything, they will exit with 0 status - # If they are not both 0, then something is wrong - if [ $PROCESS_1_STATUS -ne 0 -o $PROCESS_2_STATUS -ne 0 ]; then - echo "One of the processes has already exited." - exit -1 - fi - sleep 60 -done \ No newline at end of file diff --git a/src/app/subscription/subscription/subscription.component.html b/src/app/subscription/subscription/subscription.component.html index 2d7e25d..d9ee614 100644 --- a/src/app/subscription/subscription/subscription.component.html +++ b/src/app/subscription/subscription/subscription.component.html @@ -9,10 +9,21 @@
-

Videos

+
+
+
+

Videos

+
+
+ + + search + +
+
-
+
diff --git a/src/app/subscription/subscription/subscription.component.scss b/src/app/subscription/subscription/subscription.component.scss index 0f2927c..10557a0 100644 --- a/src/app/subscription/subscription/subscription.component.scss +++ b/src/app/subscription/subscription/subscription.component.scss @@ -6,4 +6,31 @@ float: left; position: absolute; left: 15px; +} + +.search-bar { + transition: all .5s ease; + position: relative; + float: right; +} + +.search-bar-unfocused { + width: 100px; +} + +.search-input { + transition: all .5s ease; +} + +.search-bar-focused { + width: 100%; +} + +.flex-grid { + width: 100%; + display: block; +} +.col { + width: 33%; + display: inline-block; } \ No newline at end of file diff --git a/src/app/subscription/subscription/subscription.component.ts b/src/app/subscription/subscription/subscription.component.ts index 745eeea..0bcf008 100644 --- a/src/app/subscription/subscription/subscription.component.ts +++ b/src/app/subscription/subscription/subscription.component.ts @@ -12,7 +12,11 @@ export class SubscriptionComponent implements OnInit { id = null; subscription = null; files: any[] = null; + filtered_files: any[] = null; use_youtubedl_archive = false; + search_mode = false; + search_text = ''; + searchIsFocused = false; constructor(private postsService: PostsService, private route: ActivatedRoute, private router: Router) { } @@ -33,6 +37,11 @@ export class SubscriptionComponent implements OnInit { this.postsService.getSubscription(this.id).subscribe(res => { this.subscription = res['subscription']; this.files = res['files']; + if (this.search_mode) { + this.filterFiles(this.search_text); + } else { + this.filtered_files = this.files; + } }); } @@ -49,4 +58,18 @@ export class SubscriptionComponent implements OnInit { subPlaylist: this.subscription.isPlaylist}]); } + onSearchInputChanged(newvalue) { + if (newvalue.length > 0) { + this.search_mode = true; + this.filterFiles(newvalue); + } else { + this.search_mode = false; + } + } + + private filterFiles(value: string) { + const filterValue = value.toLowerCase(); + this.filtered_files = this.files.filter(option => option.id.toLowerCase().includes(filterValue)); + } + }