From 14d6b03d947d2050bcd6d88ba713d6379d5d6465 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Mon, 27 Feb 2017 08:53:59 +0545 Subject: [PATCH 01/12] disable favourites on pixabay --- .../image-gallery.component.html | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/app/components/image-gallery/image-gallery.component.html b/src/app/components/image-gallery/image-gallery.component.html index 7d72f02..c95df17 100644 --- a/src/app/components/image-gallery/image-gallery.component.html +++ b/src/app/components/image-gallery/image-gallery.component.html @@ -14,16 +14,18 @@ - - - - - - - - - - + + + + + + + + + + + + From 8f2bfef63aac1cdcd9f03285e3d4ba7b3d2b842d Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Mon, 27 Feb 2017 09:22:03 +0545 Subject: [PATCH 02/12] add new albums --- .../components/sidebar/sidebar.component.html | 26 +++++++++++++++++-- .../components/sidebar/sidebar.component.ts | 11 ++++++++ 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/src/app/components/sidebar/sidebar.component.html b/src/app/components/sidebar/sidebar.component.html index d4972bc..380fda5 100644 --- a/src/app/components/sidebar/sidebar.component.html +++ b/src/app/components/sidebar/sidebar.component.html @@ -20,7 +20,14 @@ - + \ No newline at end of file From d25115c84371e8b396f9bae58c9081c183a52176 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Mon, 27 Feb 2017 09:49:01 +0545 Subject: [PATCH 05/12] styling add album modal --- .../components/sidebar/sidebar.component.html | 17 ++++++++++------- .../components/sidebar/sidebar.component.scss | 4 ++++ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/app/components/sidebar/sidebar.component.html b/src/app/components/sidebar/sidebar.component.html index e4c8626..c44166e 100644 --- a/src/app/components/sidebar/sidebar.component.html +++ b/src/app/components/sidebar/sidebar.component.html @@ -96,13 +96,16 @@ + + \ No newline at end of file diff --git a/src/app/components/image-gallery/image-gallery.component.scss b/src/app/components/image-gallery/image-gallery.component.scss index 2cf2e9d..504f63f 100644 --- a/src/app/components/image-gallery/image-gallery.component.scss +++ b/src/app/components/image-gallery/image-gallery.component.scss @@ -64,6 +64,19 @@ app-toolbar { margin-right: 20px; top: 20px; } +.modal{ + .menu{ + ul{ + list-style: none; + } + } + .media{ + img{ + max-width: 200px; + height: auto; + } + } +} @media(max-width: 1600px){ .pics{ diff --git a/src/app/components/image-gallery/image-gallery.component.ts b/src/app/components/image-gallery/image-gallery.component.ts index d012d70..c6c5e72 100644 --- a/src/app/components/image-gallery/image-gallery.component.ts +++ b/src/app/components/image-gallery/image-gallery.component.ts @@ -17,6 +17,8 @@ export class ImageGalleryComponent implements OnInit { scrollComplete:boolean = true; fullWidth=''; isActive=''; + showAddToAlbum=''; + collections:any; constructor(public api: ApiService, public electron:ElectronService, public picStore: PicStore, public store: LocalStore){ store.showSidebar.subscribe(show=>{ this.fullWidth = (show)?'':'full-width'; @@ -26,6 +28,7 @@ export class ImageGalleryComponent implements OnInit { console.log(this.pics); this.scrollComplete = true; }) + store.collections.subscribe(collections=>this.collections = collections.collections); } nextPage(){ this.api.nextPage(); @@ -58,10 +61,25 @@ export class ImageGalleryComponent implements OnInit { addToFavourite(pic){ this.store.addPicToCollection(pic,LocalStore.KEY_FAVOURITE) } + toggleAddToAlbum(pic){ + this.picStore.selectedPic = pic; + this.showAddToAlbum = (this.showAddToAlbum === '')?'is-active':''; + } + addToAlbum(pic,album){ + this.store.addPicToCollection(pic,album); + this.toggleAddToAlbum(pic); + } + removeFromAlbum(pic,album){ + this.store.removeFromCollection(pic,album); + this.toggleAddToAlbum(pic); + } removeFromFavourite(pic){ this.store.removeFromCollection(pic, LocalStore.KEY_FAVOURITE); } isFavourite(pic){ return this.store.isInCollection(pic,LocalStore.KEY_FAVOURITE); } + isInCollection(pic,album){ + return this.store.isInCollection(pic, album); + } } diff --git a/src/app/services/local-store.ts b/src/app/services/local-store.ts index 9223b23..6a8d225 100644 --- a/src/app/services/local-store.ts +++ b/src/app/services/local-store.ts @@ -60,10 +60,12 @@ export class LocalStore{ this._collections.next(collections); } isInCollection(pic, collection){ + collection = collection.toLowerCase(); let item = this._collections.getValue()[collection].find(item => item.foundAt == pic.foundAt); return (item !== undefined); } removeFromCollection(pic, collection){ + collection = collection.toLowerCase(); let pics = this._collections.getValue()[collection]; let item = pics.find(item => item.fullUrl === pic.fullUrl); pics.splice(pics.indexOf(item), 1); @@ -84,6 +86,7 @@ export class LocalStore{ this.updateCollections(collections); } addPicToCollection(pic, collection){ + collection = collection.toLowerCase(); var collections = this._collections.getValue(); collections[collection].push(pic); this.storeCollections(collections); From c1048da457c57f19efc9ac48a8a1860cfee0d37e Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Tue, 28 Feb 2017 08:40:02 +0545 Subject: [PATCH 07/12] remove collection function --- src/app/services/local-store.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/app/services/local-store.ts b/src/app/services/local-store.ts index 6a8d225..da37b5d 100644 --- a/src/app/services/local-store.ts +++ b/src/app/services/local-store.ts @@ -85,6 +85,14 @@ export class LocalStore{ this.storeCollections(collections); this.updateCollections(collections); } + removeCollection(collection:string){ + var key = collection.toLowerCase(); + var collections = this._collections.getValue(); + collections.collections.splice(collections.collections.indexOf(collection),1); + delete collections[key]; + this.storeCollections(collections); + this.updateCollections(collections); + } addPicToCollection(pic, collection){ collection = collection.toLowerCase(); var collections = this._collections.getValue(); From ae84ba2606366944e0a9189094c372ca6cc201c1 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Tue, 28 Feb 2017 08:40:20 +0545 Subject: [PATCH 08/12] gui for remove collection with confirmation dialog --- .../components/toolbar/toolbar.component.html | 20 +++++++++++++++++++ .../components/toolbar/toolbar.component.ts | 16 ++++++++++++++- 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/src/app/components/toolbar/toolbar.component.html b/src/app/components/toolbar/toolbar.component.html index e83846a..8305839 100644 --- a/src/app/components/toolbar/toolbar.component.html +++ b/src/app/components/toolbar/toolbar.component.html @@ -12,6 +12,9 @@ Previous + + Delete +
@@ -26,3 +29,20 @@

+ + diff --git a/src/app/components/toolbar/toolbar.component.ts b/src/app/components/toolbar/toolbar.component.ts index 3efc232..192e4d9 100644 --- a/src/app/components/toolbar/toolbar.component.ts +++ b/src/app/components/toolbar/toolbar.component.ts @@ -1,6 +1,7 @@ import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core'; import { LocalStore } from '../../services/local-store'; import { ApiService } from '../../services/api.service'; +import { PicStore } from '../../services/pic-store/pic-store'; @Component({ selector: 'app-toolbar', @@ -11,7 +12,8 @@ export class ToolbarComponent implements OnInit { @Output() search = new EventEmitter(); query: string; showSidebar:boolean; - constructor(public store: LocalStore, private api: ApiService) { + showDeleteConfirm: string = ''; + constructor(public store: LocalStore, private api: ApiService, private picStore: PicStore) { store.showSidebar.subscribe(show=>this.showSidebar = show); } @@ -33,4 +35,16 @@ export class ToolbarComponent implements OnInit { prevPage(){ this.api.prevPage(); } + showDeleteCollection(){ + return (this.picStore.selectedCollection != null) && this.picStore.selectedCollection != 'Favourite'; + } + deleteCollection(confirmed?:boolean){ + if(confirmed){ + this.store.removeCollection(this.picStore.selectedCollection); + this.showDeleteConfirm = ''; + this.picStore.initPics(); + }else{ + this.showDeleteConfirm = 'is-active' + } + } } From 1c559b3f85e53ba1fde8d9fc20fbe371dee6f33a Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Tue, 28 Feb 2017 08:42:44 +0545 Subject: [PATCH 09/12] edit button added edit album button and hide modal on clicking on background --- src/app/components/toolbar/toolbar.component.html | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/app/components/toolbar/toolbar.component.html b/src/app/components/toolbar/toolbar.component.html index 8305839..95582b9 100644 --- a/src/app/components/toolbar/toolbar.component.html +++ b/src/app/components/toolbar/toolbar.component.html @@ -13,10 +13,13 @@ Previous - Delete + Edit
+ + Delete + Next @@ -31,7 +34,7 @@
+ + diff --git a/src/app/components/toolbar/toolbar.component.ts b/src/app/components/toolbar/toolbar.component.ts index 5cc311d..c72a50d 100644 --- a/src/app/components/toolbar/toolbar.component.ts +++ b/src/app/components/toolbar/toolbar.component.ts @@ -13,6 +13,8 @@ export class ToolbarComponent implements OnInit { query: string; showSidebar:boolean; deleteConfirm: string = ''; + editDialog: string = ''; + collectionName: string = ''; constructor(public store: LocalStore, private api: ApiService, private picStore: PicStore) { store.showSidebar.subscribe(show=>this.showSidebar = show); } @@ -47,4 +49,13 @@ export class ToolbarComponent implements OnInit { this.deleteConfirm = 'is-active' } } + editCollection(confirmed?:boolean){ + if(confirmed){ + this.store.editCollection(this.picStore.selectedCollection, this.collectionName); + this.editDialog = ''; + }else{ + this.collectionName = this.picStore.selectedCollection; + this.editDialog = 'is-active'; + } + } }