File

src/app/components/event-user/event-user.component.ts

Description

Event user view component

Implements

OnInit

Example

Metadata

selector app-event-user
styleUrls event-user.component.scss
templateUrl ./event-user.component.html

Index

Properties
Methods
Inputs

Constructor

constructor(afs: FirebaseFirestoreService)

Constructor

Parameters :
Name Type Optional Description
afs FirebaseFirestoreService

Angular Firestore Service

Inputs

event

Event Object

Type: Event

user

User Object

Type: User

Methods

deselectAllImages
deselectAllImages()

Deselect all images

Returns : void
getFollowingImage
getFollowingImage(imageIndex: number)
Parameters :
Name Type Optional Description
imageIndex number
Returns : any
ngOnInit
ngOnInit()

Initialize component

Returns : void
openImageModal
openImageModal(image: EventPicture, imageIndex: number)

Open image detail modal

Parameters :
Name Type Optional Description
image EventPicture

Image to open

imageIndex number
Returns : void
rateImage
rateImage(image: EventPicture)

Upvote image

Parameters :
Name Type Optional Description
image EventPicture

Image object

Returns : void
reportImage
reportImage(image: EventPicture)

Report image

Parameters :
Name Type Optional Description
image EventPicture

Image object

Returns : void
selectAllImages
selectAllImages()

Select all images

Returns : void

Properties

Public images
images: EventPicture[]
Type : EventPicture[]

Event images array

imgBigMarked
imgBigMarked: TemplateRef<any>
Type : TemplateRef<any>
Decorators : ViewChild

TemplateRef imgBigOverview

imgBigOverview
imgBigOverview: TemplateRef<any>
Type : TemplateRef<any>
Decorators : ViewChild

TemplateRef imgBigOverview

imgSmalMarked
imgSmalMarked: TemplateRef<any>
Type : TemplateRef<any>
Decorators : ViewChild

TemplateRef imgSmalOverview

imgSmalOverview
imgSmalOverview: TemplateRef<any>
Type : TemplateRef<any>
Decorators : ViewChild

TemplateRef imgSmalOverview

Private log
log:
Default value : Log.create('EventUserComponent')

Logger

Public photographer
photographer: PhotographerProfile
Type : PhotographerProfile

owner of event

pictureModal
pictureModal: any
Type : any
Decorators : ViewChild

TemplateRef pictureModal

Public priceList
priceList: PriceList
Type : PriceList

Printing house object

reportImageModal
reportImageModal: ModalDirective
Type : ModalDirective
Decorators : ViewChild

TemplateRef reportImageModal

Public templateMarked
templateMarked: TemplateRef<any>
Type : TemplateRef<any>

Template ref

Public templateOverview
templateOverview: TemplateRef<any>
Type : TemplateRef<any>

Template ref

import {
  Component,
  Input,
  OnInit,
  TemplateRef,
  ViewChild
} from '@angular/core';
import { ModalDirective } from 'ng-mdb-pro/free/modals/modal.directive';
import { Log } from 'ng2-logger';

import { Event } from '../../classes/event';
import { PriceList } from '../../classes/price-list';
import { User } from '../../classes/user';
import { EventPicture } from '../../interfaces/event-picture';
import { PhotographerProfile } from '../../interfaces/photographer-profile';
import { FirebaseFirestoreService } from '../../services/firebase/firestore/firebase-firestore.service';

/**
 * Event user view component
 * @author Daniel Sogl, Markus Kirschner, Tim Krießler
 */
@Component({
  selector: 'app-event-user',
  templateUrl: './event-user.component.html',
  styleUrls: ['./event-user.component.scss']
})
export class EventUserComponent implements OnInit {
  /** Logger */
  private log = Log.create('EventUserComponent');

  /** Event Object */
  @Input() public event: Event;
  /** User Object */
  @Input() public user: User;

  /** TemplateRef pictureModal */
  @ViewChild('pictureModal') pictureModal: any;
  /** TemplateRef reportImageModal */
  @ViewChild('reportImageModal') reportImageModal: ModalDirective;
  /** TemplateRef imgBigOverview */
  @ViewChild('imgBigOverview') imgBigOverview: TemplateRef<any>;
  /** TemplateRef imgSmalOverview */
  @ViewChild('imgSmalOverview') imgSmalOverview: TemplateRef<any>;
  /** TemplateRef imgBigOverview */
  @ViewChild('imgBigMarked') imgBigMarked: TemplateRef<any>;
  /** TemplateRef imgSmalOverview */
  @ViewChild('imgSmalMarked') imgSmalMarked: TemplateRef<any>;

  /** Template ref  */
  public templateOverview: TemplateRef<any>;
  /** Template ref */
  public templateMarked: TemplateRef<any>;

  /** Printing house object */
  public priceList: PriceList;
  /** Event images array */
  public images: EventPicture[];
  /** owner of event */
  public photographer: PhotographerProfile;

  /**
   * Constructor
   * @param  {FirebaseFirestoreService} afs Angular Firestore Service
   */
  constructor(private afs: FirebaseFirestoreService) {}

  /**
   * Initialize component
   */
  ngOnInit() {
    this.log.color = 'orange';
    this.log.d('Component initialized');

    this.log.d('Event', this.event);
    this.log.d('User', this.user);

    this.templateOverview = this.imgBigOverview;
    this.templateMarked = this.imgBigMarked;

    // Load images
    if (this.event) {
      this.afs
        .getPhotographerProfile(this.event.photographerUid)
        .valueChanges()
        .subscribe(photographer => {
          this.photographer = photographer;
        });

      this.afs
        .getEventPictures(this.event.id)
        .valueChanges()
        .map((images: EventPicture[]) => {
          for (let i = 0; i < images.length; i++) {
            images[i].selected = false;
          }
          return images;
        })
        .subscribe(images => {
          this.images = images;
          this.log.d('Event images', this.images);
        });

      this.afs
        .getPriceList(this.event.photographerUid)
        .valueChanges()
        .subscribe(priceList => {
          if (priceList) {
            this.priceList = priceList;
            this.log.d('Loaded priceList', this.priceList);
          }
        });
    }
  }

  /**
   * Open image detail modal
   * @param  {EventPicture} image Image to open
   */
  openImageModal(image: EventPicture, imageIndex: number) {
    this.pictureModal.showModal(
      image,
      imageIndex,
      this.images.length,
      this,
      this.priceList
    );
  }

  /**
   * Select all images
   */
  selectAllImages() {
    for (let i = 0; i < this.images.length; i++) {
      this.images[i].selected = true;
    }
  }

  /**
   * Deselect all images
   */
  deselectAllImages() {
    for (let i = 0; i < this.images.length; i++) {
      this.images[i].selected = false;
    }
  }

  /**
   * Upvote image
   * @param  {EventPicture} image Image object
   */
  rateImage(image: EventPicture) {
    if (this.user) {
      image.ratings++;
      this.afs
        .updateImage(image)
        .then(() => {
          this.log.d('Upvoted image');
        })
        .catch(err => {
          this.log.er('Error upvoting image', err);
        });
    } else {
      window.alert('Sign in to rate images');
    }
  }

  /**
   * Report image
   * @param  {EventPicture} image Image object
   */
  reportImage(image: EventPicture) {
    this.reportImageModal.show();
  }

  getFollowingImage(imageIndex: number) {
    return this.images[imageIndex];
  }
}
<div class="card">
  <h3 class="card-header indigo white-text">{{ event?.name }}</h3>
  <div class="card-body">
    <h4 class="card-title">{{ event?.date }} - {{event?.location }}</h4>
    <p class="card-text">{{ event?.description }}</p>
    <a routerLink="/photographer/{{photographer?.profileUrl}}">
      <p>{{ 'TEXTS.VISIT_PHOTOGRAPHERS_PAGE' | translate }}</p>
    </a>
  </div>
</div>

<br>
<br>

<mdb-tabset [buttonClass]="'nav-tabs indigo'" [contentClass]="''">
  <mdb-tab heading="{{ 'TEXTS.EVENT_ALL_PICTURES' | translate}}">
    <div class="row no-gutters justify-content-start" style="align-items: center">

      <div class="col-3">
        <a class="btn btn-pink darken-2 waves-light" id="button_select_all_pictures" (click)="selectAllImages()" mdbRippleRadius>{{ 'BUTTONS.SELECT_PICTURES' | translate }}</a>
      </div>

      <div class="col-1 offset-md-8">
        <a class="icon-button lessVertical" id="button_two_pictures_per_row" (click)="this.templateOverview = this.imgBigOverview"
          style="color: #e91e63 ">
          <i class="fa fa-th-large fa-2x" aria-hidden="true"></i>
        </a>
        &nbsp;&nbsp;
        <a class="icon-button lessVertical" id="button_three_pictures_per_row" (click)="this.templateOverview = this.imgSmalOverview"
          style="color: #e91e63">
          <i class="fa fa-th fa-2x" aria-hidden="true"></i>
        </a>
      </div>
    </div>
    <br>

    <!-- BILD -->
    <ng-container *ngTemplateOutlet="templateOverview"></ng-container>
    <!-- BILD -->

  </mdb-tab>

  <mdb-tab heading="{{ 'TEXTS.EVENT_SELECTED_PICTURES' | translate}}">
    <div class="row no-gutters justify-content-start" style="align-items: center">

      <div class="col-3">
        <a class="btn btn-pink darken-2 waves-light" id="button_deselect_all_pictures" (click)="deselectAllImages()" mdbRippleRadius>{{ 'BUTTONS.DESELECT_PICTURES' | translate }}</a>
      </div>
      <div class="col-1 offset-md-8">
        <a class="icon-button lessVertical" id="button_two_pictures_per_row" (click)="this.templateMarked = this.imgBigMarked" style="color: #e91e63 ">
          <i class="fa fa-th-large fa-2x" aria-hidden="true"></i>
        </a>
        &nbsp;&nbsp;
        <a class="icon-button lessVertical" id="button_three_pictures_per_row" (click)="this.templateMarked = this.imgSmalMarked"
          style="color: #e91e63 ">
          <i class="fa fa-th fa-2x" aria-hidden="true"></i>
        </a>
      </div>
    </div>
    <br>
    <!-- BILD -->
    <ng-container *ngTemplateOutlet="templateMarked"></ng-container>
    <!-- BILD -->
  </mdb-tab>
</mdb-tabset>

<!-- Detail picture modal -->
<app-picture-detail #pictureModal></app-picture-detail>

<ng-template #imgBigOverview>
  <div class="row">
    <div *ngFor="let image of images; let i = index" class="col-4">
      <div class="card card-outline-primary z-depth-1">
        <img class="img-fluid" [defaultImage]="'https://www.scandichotels.de/Static/img/placeholders/image-placeholder_3x2.svg'"
          [lazyLoad]="image.thumbnail" width="328" height="250" [alt]="image.name" div class="box1" (click)="openImageModal(image, i)">
        <div class="card-body">
          <p>{{image.name}}</p>
          <table>
            <tr>
              <td>
                <a class="icon-button" id="button_picture{{i}}_mark" [ngStyle]="image.selected && { 'color': '#3f51b5' }" (click)="images[i].selected = !images[i].selected">
                  <i class="fa fa-check fa-2x" aria-hidden="true">&nbsp;</i>
                </a>
              </td>

              <td>
                <a class="icon-button" id="button_picture{{i}}_like" style="color: #3f51b5" (click)="rateImage(image)">
                  &nbsp;
                  <i class="fa fa-heart fa-2x" aria-hidden="true">&nbsp;{{ image.ratings }}</i>
                </a>
              </td>

              <td>
                <a class="icon-button" id="button_picture{{i}}_report" style="color: #ff4848" (click)="reportImage(image)">
                  &nbsp;
                  <i class="fa fa-exclamation-triangle fa-2x" aria-hidden="true">&nbsp;</i>
                </a>
              </td>
            </tr>
          </table>
        </div>
      </div>
    </div>
  </div>

</ng-template>

<ng-template #imgSmalOverview>
  <img *ngFor="let image of images; let i = index" class="img-fluid" [defaultImage]="'https://www.scandichotels.de/Static/img/placeholders/image-placeholder_3x2.svg'"
    [lazyLoad]="image.thumbnail" width="250" height="150" [alt]="image.name" div class="box1" (click)="openImageModal(image, i)">
</ng-template>

<ng-template #imgBigMarked>
  <div class="card-columns">
    <div *ngFor="let image of images; let i = index">
      <div class="card card-outline-primary z-depth-1" *ngIf="image.selected">
        <img class="img-fluid" [defaultImage]="'https://www.scandichotels.de/Static/img/placeholders/image-placeholder_3x2.svg'"
          [lazyLoad]="image.thumbnail" width="328" height="250" [alt]="image.name" div class="box1" (click)="openImageModal(image, i)">
      </div>
    </div>
  </div>
</ng-template>
<ng-template #imgSmalMarked>
  <div *ngFor="let image of images; let i = index">
    <img class="img-fluid" *ngIf="image.selected" [defaultImage]="'https://www.scandichotels.de/Static/img/placeholders/image-placeholder_3x2.svg'"
      [lazyLoad]="image.thumbnail" width="250" height="150" [alt]="image.name" div class="box1" (click)="openImageModal(image, i)">
  </div>
</ng-template>


<div mdbModal #reportImageModal="mdb-modal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
  aria-hidden="true">
  <div class="modal-dialog modal-notify modal-danger" role="document">
    <div class="modal-content">
      <div class="modal-header text-center">
        <p class="heading lead">{{ 'LABELS.REPORT_IMAGE' | translate}}</p>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close" (click)="reportImageModal.hide()">
          <span aria-hidden="true" class="white-text">×</span>
        </button>
      </div>
      <div class="modal-body">
        <div class="text-center">
          <p>{{ 'TEXTS.DESCRIBE_REPORT' | translate}}</p>
          <br>
          <div class="md-form">
            <textarea class="md-textarea" type="text" length="250" mdbCharCounter mdbActive></textarea>
            <label for="input_text">{{ 'LABELS.TYPE_HERE' | translate}}</label>
          </div>
        </div>
      </div>
      <div class="modal-footer justify-content-center">
        <button type="button" class="btn btn-danger waves-light" (click)="reportImageModal.hide()" mdbRippleRadius>{{ 'BUTTONS.SEND_REPORT' | translate}}</button>
      </div>
    </div>
  </div>
</div>
Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""