-
+
+
+
+
+
+
+
+
+
+ {{filterOption['value']['label']}}
+
+
+
+
+
+
+
+
+
+
+
Videos
+
+
+
+
+ search
+
+
+
+
diff --git a/src/app/subscription/subscription/subscription.component.scss b/src/app/subscription/subscription/subscription.component.scss
index 10557a0c..a9c26bb6 100644
--- a/src/app/subscription/subscription/subscription.component.scss
+++ b/src/app/subscription/subscription/subscription.component.scss
@@ -8,6 +8,13 @@
left: 15px;
}
+.filter-select-parent {
+ position: absolute;
+ top: 0px;
+ left: 20px;
+ display: block;
+}
+
.search-bar {
transition: all .5s ease;
position: relative;
@@ -29,6 +36,7 @@
.flex-grid {
width: 100%;
display: block;
+ position: relative;
}
.col {
width: 33%;
diff --git a/src/app/subscription/subscription/subscription.component.ts b/src/app/subscription/subscription/subscription.component.ts
index 0bcf0089..f9ff060f 100644
--- a/src/app/subscription/subscription/subscription.component.ts
+++ b/src/app/subscription/subscription/subscription.component.ts
@@ -17,6 +17,30 @@ export class SubscriptionComponent implements OnInit {
search_mode = false;
search_text = '';
searchIsFocused = false;
+ descendingMode = true;
+ filterProperties = {
+ 'upload_date': {
+ 'key': 'upload_date',
+ 'label': 'Upload Date',
+ 'property': 'upload_date'
+ },
+ 'name': {
+ 'key': 'name',
+ 'label': 'Name',
+ 'property': 'title'
+ },
+ 'file_size': {
+ 'key': 'file_size',
+ 'label': 'File Size',
+ 'property': 'size'
+ },
+ 'duration': {
+ 'key': 'duration',
+ 'label': 'Duration',
+ 'property': 'duration'
+ }
+ };
+ filterProperty = this.filterProperties['upload_date'];
constructor(private postsService: PostsService, private route: ActivatedRoute, private router: Router) { }
@@ -27,6 +51,12 @@ export class SubscriptionComponent implements OnInit {
this.getSubscription();
this.getConfig();
}
+
+ // set filter property to cached
+ const cached_filter_property = localStorage.getItem('filter_property');
+ if (cached_filter_property && this.filterProperties[cached_filter_property]) {
+ this.filterProperty = this.filterProperties[cached_filter_property];
+ }
}
goBack() {
@@ -42,6 +72,7 @@ export class SubscriptionComponent implements OnInit {
} else {
this.filtered_files = this.files;
}
+ this.filterByProperty(this.filterProperty['property']);
});
}
@@ -72,4 +103,23 @@ export class SubscriptionComponent implements OnInit {
this.filtered_files = this.files.filter(option => option.id.toLowerCase().includes(filterValue));
}
+ filterByProperty(prop) {
+ if (this.descendingMode) {
+ this.filtered_files = this.filtered_files.sort((a, b) => (a[prop] > b[prop] ? -1 : 1));
+ } else {
+ this.filtered_files = this.filtered_files.sort((a, b) => (a[prop] > b[prop] ? 1 : -1));
+ }
+ }
+
+ filterOptionChanged(value) {
+ // this.filterProperty = value;
+ this.filterByProperty(value['property']);
+ localStorage.setItem('filter_property', value['key']);
+ }
+
+ toggleModeChange() {
+ this.descendingMode = !this.descendingMode;
+ this.filterByProperty(this.filterProperty['property']);
+ }
+
}