File

src/app/modules/certificate/services/upload-certificate/upload-certificate.service.ts

Index

Properties
Methods

Constructor

constructor(publicDataService: PublicDataService, http: HttpClient, configService: ConfigService, contentService: ContentService, userService: UserService)
Parameters :
Name Type Optional
publicDataService PublicDataService No
http HttpClient No
configService ConfigService No
contentService ContentService No
userService UserService No

Methods

createAsset
createAsset(reqObj, type?)

To create new asset images (State logos and Signs) and it create space

Parameters :
Name Optional
reqObj No
type Yes
Returns : any
createCertTemplate
createCertTemplate(data)
Parameters :
Name Optional
data No
Returns : any
getAssetData
getAssetData(query?, type?)

To get the asset images (State logos and Signs) to get the particular asset we need to pass asset naem as query

Parameters :
Name Optional
query Yes
type Yes
Returns : any
getCertificates
getCertificates(request)

To get the asset images (State logos and Signs) to get the particular asset we need to pass asset naem as query

Parameters :
Name Optional
request No
Returns : any
getSvg
getSvg(path)
Parameters :
Name Optional
path No
Returns : Promise<any>
storeAsset
storeAsset(file, identifier)

To upload new asset images (State logos and Signs) into the particular space

Parameters :
Name Optional
file No
identifier No
Returns : any
uploadTemplate
uploadTemplate(svgFile, identifier)
Parameters :
Name Optional
svgFile No
identifier No
Returns : any

Properties

certificate
Type : BehaviorSubject<any>
Public configService
Type : ConfigService
Public contentService
Type : ContentService
Public http
Type : HttpClient
Public publicDataService
Type : PublicDataService
Public userService
Type : UserService
import { Injectable } from '@angular/core';
import { ConfigService } from '@sunbird/shared';
import { PublicDataService } from '@sunbird/core';
import { HttpClient } from '@angular/common/http';
import { ContentService } from './../../../../modules/core/services/content/content.service';
import { UserService } from '@sunbird/core';
import { BehaviorSubject } from 'rxjs';

@Injectable({
  providedIn: 'root'
})
export class UploadCertificateService {

  certificate: BehaviorSubject<any>;

  constructor(
    public publicDataService: PublicDataService,
    public http: HttpClient,
    public configService: ConfigService,
    public contentService: ContentService,
    public userService: UserService
  ) {
    this.certificate = new BehaviorSubject(null);
  }

  /**
   * To get the asset images (State logos and Signs)
   * to get the particular asset we need to pass asset naem as query
   */
  getAssetData(query?, type?) {
    const body = {
      'request': {
        'filters': {
          'mediaType': ['image'],
          'contentType': ['Asset'],
          'compatibilityLevel': { 'min': 1, 'max': 2 },
          'status': ['Live'],
          'primaryCategory': 'Asset'
        },
        'sort_by': {
          'lastUpdatedOn': 'desc'
        },
        'limit': 50,
        'offset': 0
      }
    };
    if (!type) {
      body['request']['filters']['channel'] = this.userService.channel;
    }
    if (query) {
      body['request']['query'] = query;
    }
    const option = {
      url: this.configService.urlConFig.URLS.CONTENT.SEARCH,
      data: body
    };
    return this.publicDataService.post(option);
  }


    /**
   * To get the asset images (State logos and Signs)
   * to get the particular asset we need to pass asset naem as query
   */
  getCertificates(request) {
    const option = {
      url: this.configService.urlConFig.URLS.COMPOSITE.SEARCH,
      data: request
    };
    return this.contentService.post(option);
  }

  /**
  * To create new asset images (State logos and Signs) and it create space
  */
  createAsset(reqObj, type?) {
    const body = {
      'request':
      {
        'content': {
          'name': reqObj.assetCaption,
          'creator': reqObj.creator,
          'createdBy': reqObj.creatorId,
          'code': 'org.ekstep0.9002440445885993',
          'mimeType': 'image/png',
          'mediaType': 'image',
          'contentType': 'Asset',
          'primaryCategory': 'Asset',
          'osId': 'org.ekstep.quiz.app',
          'language': ['English'],
          'channel':  this.userService.channel
        }
      }
    };

    // if (type === 'SIGN') {
    //   body.request.content.primaryCategory = 'CertAsset';
    // }

    const option = {
      url: this.configService.urlConFig.URLS.CONTENT.CREATE,
      data: body
    };
    return this.contentService.post(option);
  }

  /**
   * To upload new asset images (State logos and Signs) into the particular space
   */
  storeAsset(file, identifier) {
    const formData = new FormData();
    formData.append('file', file);
    const option = {
      url: `${this.configService.urlConFig.URLS.CERTIFICATE.UPLOAD_CERT_TEMPLATE}/${identifier}`,
      data: formData
    };
    return this.contentService.post(option);
  }

  getSvg(path): Promise<any> {
    return this.http.get(path, { responseType: 'text' }).toPromise();
  }

  createCertTemplate(data) {
    const option = {
      url: this.configService.urlConFig.URLS.CERTIFICATE.CREATE_CERT_TEMPLATE,
      data: data
    };
    return this.contentService.post(option);
  }

  uploadTemplate(svgFile, identifier) {
    const formData = new FormData();
    formData.append('file', svgFile);
    const option = {
      url: `${this.configService.urlConFig.URLS.CERTIFICATE.UPLOAD_CERT_TEMPLATE}/${identifier}`,
      data: formData
    };
    return this.contentService.post(option);
  }
}

results matching ""

    No results matching ""