0 || actions.length > 0">
diff --git a/src/app/shared/card-item/card-item.component.ts b/src/app/shared/card-item/card-item.component.ts
index ff41443ee..e4a8b431e 100644
--- a/src/app/shared/card-item/card-item.component.ts
+++ b/src/app/shared/card-item/card-item.component.ts
@@ -19,6 +19,7 @@ export class CardItemComponent implements OnInit {
@Input() entity: any; // This is the entity we are representing. It will be returned if an action is executed.
@Output() clicked = new EventEmitter
();
+
placeholderImage = 'assets/images/image-placeholder.jpg';
constructor() { }
diff --git a/src/app/shared/library-card/library-card.component.html b/src/app/shared/library-card/library-card.component.html
new file mode 100644
index 000000000..fb6fa8b97
--- /dev/null
+++ b/src/app/shared/library-card/library-card.component.html
@@ -0,0 +1,3 @@
+
+
+
\ No newline at end of file
diff --git a/src/app/shared/library-card/library-card.component.scss b/src/app/shared/library-card/library-card.component.scss
new file mode 100644
index 000000000..e69de29bb
diff --git a/src/app/shared/library-card/library-card.component.ts b/src/app/shared/library-card/library-card.component.ts
new file mode 100644
index 000000000..773fa3d98
--- /dev/null
+++ b/src/app/shared/library-card/library-card.component.ts
@@ -0,0 +1,60 @@
+import { Component, EventEmitter, Input, OnChanges, OnInit, Output } from '@angular/core';
+import { Router } from '@angular/router';
+import { ToastrService } from 'ngx-toastr';
+import { take } from 'rxjs/operators';
+import { Library } from 'src/app/_models/library';
+import { User } from 'src/app/_models/user';
+import { AccountService } from 'src/app/_services/account.service';
+import { LibraryService } from 'src/app/_services/library.service';
+import { CardItemAction } from '../card-item/card-item.component';
+
+// Represents a library type card. Uses a app-card-item internally
+@Component({
+ selector: 'app-library-card',
+ templateUrl: './library-card.component.html',
+ styleUrls: ['./library-card.component.scss']
+})
+export class LibraryCardComponent implements OnInit, OnChanges {
+ @Input() data: Library | undefined;
+ @Output() clicked = new EventEmitter();
+
+ isAdmin = false;
+ actions: CardItemAction[] = [];
+
+ constructor(private accountService: AccountService, private router: Router,
+ private libraryService: LibraryService, private toastr: ToastrService) {
+ this.accountService.currentUser$.pipe(take(1)).subscribe(user => {
+ if (user) {
+ this.isAdmin = this.accountService.hasAdminRole(user);
+ }
+ });
+ }
+
+ ngOnInit(): void {
+ }
+
+ ngOnChanges(changes: any) {
+ if (this.data) {
+ this.generateActions();
+ }
+ }
+
+ generateActions() {
+ this.actions = [];
+
+ if (this.isAdmin) {
+ this.actions.push({title: 'Scan Library', callback: (data: Library) => {
+ console.log('You tried to scan library: ' + data.name);
+ this.libraryService.scan(data?.id).subscribe((res: any) => {
+ this.toastr.success('Scan started for ' + data.name);
+ });
+ }});
+ }
+ }
+
+ handleClick() {
+ this.clicked.emit(this.data);
+ this.router.navigate(['library', this.data?.id]);
+ }
+
+}
diff --git a/src/app/shared/shared.module.ts b/src/app/shared/shared.module.ts
index 01a2b702f..adcc30dc2 100644
--- a/src/app/shared/shared.module.ts
+++ b/src/app/shared/shared.module.ts
@@ -4,11 +4,12 @@ import { RegisterMemberComponent } from './register-member/register-member.compo
import { ReactiveFormsModule } from '@angular/forms';
import { CardItemComponent } from './card-item/card-item.component';
import { NgbDropdownModule } from '@ng-bootstrap/ng-bootstrap';
+import { LibraryCardComponent } from './library-card/library-card.component';
@NgModule({
- declarations: [RegisterMemberComponent, CardItemComponent],
+ declarations: [RegisterMemberComponent, CardItemComponent, LibraryCardComponent],
imports: [
CommonModule,
ReactiveFormsModule,
@@ -16,7 +17,8 @@ import { NgbDropdownModule } from '@ng-bootstrap/ng-bootstrap';
],
exports: [
RegisterMemberComponent,
- CardItemComponent
+ CardItemComponent,
+ LibraryCardComponent
]
})
export class SharedModule { }