File

src/app/modules/shared/components/desktop-app-update/desktop-app-update.component.ts

Implements

OnInit OnDestroy

Metadata

Index

Properties
Methods

Constructor

constructor(appUpdateService: AppUpdateService, resourceService: ResourceService)
Parameters :
Name Type Optional
appUpdateService AppUpdateService No
resourceService ResourceService No

Methods

checkForAppUpdate
checkForAppUpdate()
Returns : void
ngOnDestroy
ngOnDestroy()
Returns : void
ngOnInit
ngOnInit()
Returns : void
setTelemetry
setTelemetry()
Returns : void

Properties

Public appUpdateService
Type : AppUpdateService
downloadUrl
Type : string
isUpdateAvailable
newVersion
Public resourceService
Type : ResourceService
telemetryInteractEdata
Type : IInteractEventEdata
Public telemetryInteractObject
Type : IInteractEventObject
Public unsubscribe$
Default value : new Subject<void>()
import { ServerResponse } from '@sunbird/shared';
import { IInteractEventEdata, IInteractEventObject } from '@sunbird/telemetry';
import { takeUntil } from 'rxjs/operators';
import { Subject } from 'rxjs';
import { Component, OnInit, OnDestroy } from '@angular/core';
import * as _ from 'lodash-es';
import { AppUpdateService } from '../../../core/services/app-update/app-update.service';
import { ResourceService } from '../../services/resource/resource.service';

@Component({
  selector: 'app-desktop-app-update',
  templateUrl: './desktop-app-update.component.html',
  styleUrls: ['./desktop-app-update.component.scss']
})
export class DesktopAppUpdateComponent implements OnInit, OnDestroy {

  isUpdateAvailable;
  downloadUrl: string;
  public unsubscribe$ = new Subject<void>();
  telemetryInteractEdata: IInteractEventEdata;
  public telemetryInteractObject: IInteractEventObject;
  newVersion;

  constructor(public appUpdateService: AppUpdateService, public resourceService: ResourceService) { }

  ngOnInit() {
    this.checkForAppUpdate();
  }

  checkForAppUpdate() {
    this.appUpdateService.checkForAppUpdate().pipe(takeUntil(this.unsubscribe$)).subscribe((response: ServerResponse) => {
      this.isUpdateAvailable = _.get(response, 'result.updateAvailable');
      this.downloadUrl = _.get(response, 'result.url');
      this.newVersion = _.get(response, 'result.version');
      this.setTelemetry();
    }, (error) => {
        console.log(`Received Error while checking app update Error: ${JSON.stringify(error.error)}`);
    });
  }

  ngOnDestroy() {
    this.unsubscribe$.next();
    this.unsubscribe$.complete();
  }

  setTelemetry() {
  this.telemetryInteractObject = {
      id: 'update-app-link',
      type: 'click',
      ver: <HTMLInputElement>document.getElementById('buildNumber') ?
           (<HTMLInputElement>document.getElementById('buildNumber')).value : '1.0.0'
    };

    this.telemetryInteractEdata =  {
      id: 'update-app-link',
      type: 'click',
      pageid: 'library',
      extra: {
        newVersion: this.newVersion
      }
    };
  }
}
<app-modal-wrapper *ngIf="isUpdateAvailable" [config]="{disableClose: true, size: 'normal'}" (dismiss)="modal.deny()"
  #modal>
  <ng-template sbModalContent>
    <div class="sb-modal">
      <div class="transition ui dimmer page modals active visible">
        <div class="ui modal transition active visible normal">
          <button aria-label="close dialog" mat-dialog-close class="close updatePopupClose"></button>
          <div class="sb-modal-header"></div>

          <div class="sb-modal-content pt-0">
            <div class="sb-offline-updates pb-32">
              <div class="sb-offline-updates-content text-center">
                <div class="sb-offline-updates-content-logo">
                  <img src="assets/images/Group16.svg" class="logo" alt="DEV Logo" />
                </div>
                <div class="sb-offline-updates-content-desc mb-32">
                  <h3 class="sb-offline-updates-content-title mt-16 mb-8 font-weight-bold">
                    {{resourceService.frmelmnts?.lbl?.appUpdateAvailable}}</h3>
                  <p class="sb-offline-updates-content-para">
                    {{resourceService.frmelmnts?.lbl?.appUpdateDescription}}
                  </p>
                </div>
                <div class="sb-offline-label">
                  <div class="d-inline-flex">
                    <span class="sb-label-name mr-8">{{resourceService.frmelmnts?.lbl?.useThis}}</span>
                    <span>
                      <a href="{{downloadUrl}}" target="_blank" class="sb-color-success" appTelemetryInteract
                        [telemetryInteractObject]="telemetryInteractObject"
                        [telemetryInteractEdata]="telemetryInteractEdata">{{ downloadUrl }}</a>
                    </span>
                  </div>
                </div>
                <!-- <p class="sb-offline-updates-content-para mt-4">*Requires Windows 64 bit operating system</p> -->
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </ng-template>
</app-modal-wrapper>

./desktop-app-update.component.scss

@use "@project-sunbird/sb-styles/assets/mixins/mixins" as *;

.sb-offline-updates {
  background: var(--white);
}
.sb-offline-updates-content {
}
.sb-offline-updates-content-logo {
  .logo {
    height: calculateRem(100px);
  }
}
.sb-offline-updates-content-title {
  font-size: calculateRem(18px);
}
.sb-offline-updates-content-para {
  font-size: calculateRem(12px);
  color: var(--gray-400);
  line-height: calculateRem(18px);
}
.sb-offline-label {
  font-size: calculateRem(16px);
}
.sb-offline-updates-modal {
  .sb-modal-header {
    background-color: var(--white) !important;
  }
}
.updatePopupClose {
  border: none;
  border-radius: 50% !important;
}
Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""