File

src/app/manage-learn/all-evidence-list/all-evidence-list/all-evidence-list.component.ts

Implements

OnInit

Metadata

Index

Properties
Methods

Constructor

constructor(routerParam: ActivatedRoute, httpClient: HttpClient, dhiti: DhitiApiService, utils: UtilsService, loader: LoaderService, toast: ToastService)
Parameters :
Name Type Optional
routerParam ActivatedRoute No
httpClient HttpClient No
dhiti DhitiApiService No
utils UtilsService No
loader LoaderService No
toast ToastService No

Methods

Async getAllEvidence
getAllEvidence()
Returns : any
Async getSurveyEvidence
getSurveyEvidence()
Returns : any
ionViewDidLoad
ionViewDidLoad()
Returns : void
ngOnInit
ngOnInit()
Returns : void
onTabChange
onTabChange(tabName)
Parameters :
Name Optional
tabName No
Returns : void
setAllEvidence
setAllEvidence()
Returns : void

Properties

audios
Type : any
data
Type : any
documents
Type : any
images
Type : any
payload
Type : any
remarks
Type : any
selectedTab
videos
Type : any
import { HttpClient } from '@angular/common/http';
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { LoaderService, ToastService, UtilsService } from '../../core';
import { urlConstants } from '../../core/constants/urlConstants';
import { DhitiApiService } from '../../core/services/dhiti-api.service';

@Component({
  selector: 'app-all-evidence-list',
  templateUrl: './all-evidence-list.component.html',
  styleUrls: ['./all-evidence-list.component.scss'],
})
export class AllEvidenceListComponent implements OnInit {
  selectedTab;
  payload: any;
  remarks: any;
  images: any;
  videos: any;
  documents: any;
  audios: any;
  data: any;

  constructor(
    private routerParam: ActivatedRoute,
    private httpClient: HttpClient,
    private dhiti: DhitiApiService,
    private utils: UtilsService,
    private loader: LoaderService,
    private toast: ToastService
  ) {}

  ngOnInit() {
    this.selectedTab = 'evidence';

    this.routerParam.queryParams.subscribe((params) => {
      const submissionId = params.submissionId;
      const observationId = params.observationId;
      const entityId = params.entityId;
      const questionExternalId = params.questionExternalId;
      const entityType = params.entityType;
      const surveyEvidence = params.surveyEvidence;
      const solutionId = params.solutionId;
      this.data = params.data;
      this.payload = {
        submissionId: submissionId,
        questionId: questionExternalId,
        observationId: observationId,
        entityId: entityId,
        entityType: entityType,
        solutionId: solutionId,
      };
      if (this.data) {
        this.setAllEvidence();
      } else {
        surveyEvidence ? this.getSurveyEvidence() : this.getAllEvidence();
      }
    });
  }

  ionViewDidLoad() {
    this.selectedTab = 'evidence';
  }

  onTabChange(tabName) {
    this.selectedTab = tabName;
  }

  setAllEvidence() {
    console.log(this.data);
    this.images = this.data.images;
    this.videos = this.data.videos;
    this.documents = this.data.documents;
    this.remarks = this.data.remarks;
    this.audios = this.data.audios;
  }
  async getAllEvidence() {
    let url = urlConstants.API_URLS.ALL_EVIDENCE;
    this.loader.startLoader();
    let payload = await this.utils.getProfileInfo();
    payload = { ...this.payload, ...payload };
    const config = {
      url: url,
      payload: payload,
    };
    this.dhiti.post(config).subscribe(
      (success) => {
        this.loader.stopLoader();
        if (success.result === true && success.data) {
          this.images = success.data.images;
          this.videos = success.data.videos;
          this.documents = success.data.documents;
          this.remarks = success.data.remarks;
          this.audios = success.data.audios;
        } else {
          this.toast.openToast(success.data);
        }
      },
      (error) => {
        this.toast.openToast(error.message);
        this.loader.stopLoader();
      }
    );

    // this.apiService.httpPost(
    //   url,
    //   this.payload,
    //   (success) => {
    //     this.utils.stopLoader();
    //     console.log(JSON.stringify(success));

    //    if (success.result === true && success.data) {
    //       this.images = success.data.images;
    //       this.videos = success.data.videos;
    //       this.documents = success.data.documents;
    //       this.remarks = success.data.remarks;
    //       this.audios = success.data.audios;
    //     } else {
    //       this.utils.openToast(success.data);
    //     }
    //   },
    //   (error) => {
    //     this.utils.openToast(error.message);

    //     this.utils.stopLoader();
    //   },
    //   { baseUrl: 'dhiti', version: 'v1' }
    // );
  }

  //for surveyEvidence
  async getSurveyEvidence() {
    let url = urlConstants.API_URLS.SURVEY_FEEDBACK.LIST_ALL_EVIDENCES;
    this.loader.startLoader();
    let payload = await this.utils.getProfileInfo();
    payload = { ...this.payload, ...payload };
    const config = {
      url: url,
      payload: payload,
    };
    this.dhiti.post(config).subscribe(
      (success) => {
        this.loader.stopLoader();
        console.log(JSON.stringify(success));
        if (success.result === true && success.data) {
          this.images = success.data.images;
          this.videos = success.data.videos;
          this.documents = success.data.documents;
          this.remarks = success.data.remarks;
          this.audios = success.data.audios;
        } else {
          this.toast.openToast(success.data);
        }
      },
      (error) => {
        this.toast.openToast(error.message);
        this.loader.stopLoader();
      }
    );

  }
}
<ion-content>
  <div padding>
    <ion-segment [(ngModel)]="selectedTab">
      <ion-segment-button value="evidence" (click)="onTabChange('evidence')">
        {{ 'FRMELEMNTS_LBL_EVIDENCES' | translate }}
      </ion-segment-button>
      <ion-segment-button value="remarks" (click)="onTabChange('remarks')">
        {{ 'FRMELEMNTS_LBL_REMARKS' | translate }}
      </ion-segment-button>
    </ion-segment>
  </div>

  <div [ngSwitch]="selectedTab">
    <div *ngSwitchCase="'evidence'">
      <!-- //for images -->
      <div *ngIf="images?.length">
        <ion-grid>
          <ion-row>
            <ion-col size="12">
              <h5>{{ 'FRMELEMNTS_LBL_IMAGES' | translate }}</h5>
            </ion-col>
            <ion-col size="4" *ngFor="let i of images">
              <attachments [url]="i.url" [extension]="i.extension"></attachments>
            </ion-col>
          </ion-row>
        </ion-grid>
      </div>

      <!-- //for VIDEOS-->
      <div *ngIf="videos?.length">
        <ion-grid>
          <ion-row>
            <ion-col>
              <h5>{{ 'FRMELEMNTS_LBL_VIDEOS' | translate }}</h5>
            </ion-col>
            <ion-col size="4" *ngFor="let v of videos">
              <attachments [url]="v.url" [extension]="v.extension"></attachments>
            </ion-col>
          </ion-row>
        </ion-grid>
      </div>

      <!-- //for DOCUMENT -->
      <div *ngIf="documents?.length">
        <ion-grid>
          <ion-row>
            <ion-col size="12">
              <h5>{{ 'FRMELEMNTS_LBL_DOCUMENTS' | translate }}</h5>
            </ion-col>
            <ion-col size="4" *ngFor="let d of documents">
              <attachments [url]="d.url" [extension]="d.extension"></attachments>
            </ion-col>
          </ion-row>
        </ion-grid>
      </div>
      <!-- //for Audio -->
      <div *ngIf="audios?.length">
        <ion-grid>
          <ion-row>
            <ion-col size="12">
              <h5>{{ 'FRMELEMNTS_LBL_AUDIOS' | translate }}</h5>
            </ion-col>
            <ion-col size="4" *ngFor="let a of audios">
              <attachments [url]="a.url" [extension]="a.extension"></attachments>
            </ion-col>
          </ion-row>
        </ion-grid>
      </div>
    </div>

    <div *ngSwitchCase="'remarks'">
      <div *ngIf="remarks?.length">
        <ion-item text-wrap text-justify *ngFor="let r of remarks">
          {{ r }}
        </ion-item>
      </div>
    </div>
  </div>
</ion-content>

./all-evidence-list.component.scss

Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""