File

src/app/modules/program-dashboard/shared/sb-bignumber/sb-bignumber.component.ts

Implements

OnInit OnChanges

Metadata

Index

Properties
Methods
Inputs

Constructor

constructor(resourceService: ResourceService, dialog: MatDialog, filterService: PdServiceService)
Parameters :
Name Type Optional
resourceService ResourceService No
dialog MatDialog No
filterService PdServiceService No

Inputs

appliedFilters
Type : any
chart
Type : any
hideElements
Type : boolean
Default value : false

Methods

checkForChanges
checkForChanges()
Returns : void
ngOnChanges
ngOnChanges(_changes: SimpleChanges)
Parameters :
Name Type Optional
_changes SimpleChanges No
Returns : void
ngOnInit
ngOnInit()
Returns : void

Properties

chartConfig
chartData
contentRef
Type : TemplateRef<any>
Decorators :
@ViewChild('content', {read: TemplateRef})
Public dialog
Type : MatDialog
Public filterService
Type : PdServiceService
globalChange
Type : boolean
globalData
lastUpdatedOn
outletRef
Type : ViewContainerRef
Decorators :
@ViewChild('outlet', {read: ViewContainerRef})
Public resourceService
Type : ResourceService
showLastUpdatedOn
Type : boolean
Default value : false
updatedData
import { Component, Input, OnChanges, OnInit, SimpleChanges, TemplateRef, ViewChild, ViewContainerRef} from '@angular/core';
import { MatDialog } from '@angular/material/dialog';
import { ResourceService } from '@sunbird/shared';
import * as _ from "lodash-es";
import { PdServiceService } from '../services/pd-service/pd-service.service';
import dayjs from 'dayjs';
@Component({
  selector: 'app-sb-bignumber',
  templateUrl: './sb-bignumber.component.html',
  styleUrls: ['./sb-bignumber.component.scss']
})
export class SbBignumberComponent implements OnInit, OnChanges {
  @Input() chart;
  lastUpdatedOn;
  @Input() hideElements = false;
  @Input() appliedFilters;
  chartData;
  chartConfig;
  updatedData;
  globalChange:boolean;
  globalData;
  @ViewChild('outlet', { read: ViewContainerRef }) outletRef: ViewContainerRef;
  @ViewChild('content', { read: TemplateRef }) contentRef: TemplateRef<any>;
  showLastUpdatedOn: boolean = false;
  constructor(
    public resourceService: ResourceService,
    public dialog: MatDialog,
    public filterService:PdServiceService
  ) { }

  ngOnInit(){
    this.updatedData = this.chartData = _.compact(this.chart.chartData);
    this.chartConfig = this.chart.chartConfig;
    if(_.get(this.chart,'lastUpdatedOn')){
      this.lastUpdatedOn = dayjs(this.chart.lastUpdatedOn).format('DD-MMMM-YYYY');
      if (_.get(this.chartConfig, 'options.showLastUpdatedOn') || this.lastUpdatedOn) {
        this.showLastUpdatedOn = true;
      }
    }
  }

  ngOnChanges(_changes: SimpleChanges): void {
   this.checkForChanges();
  }

  checkForChanges(){
    if(Object.keys(this.appliedFilters).length){
      this.globalData = this.filterService.getFilteredData(this.chartData,this.appliedFilters)
      this.globalChange = true;
      this.updatedData = this.globalData;
      this.outletRef.clear();
      this.outletRef.createEmbeddedView(this.contentRef);
    }else{
      this.globalData = this.chartData;
      this.globalChange = false;

    }
  }
}
<div
  *ngIf="showLastUpdatedOn && lastUpdatedOn"
  class="sb-last-update-status mb-8"
>
  <span>{{ resourceService?.frmelmnts?.lbl?.lastUpdatedOn }}&nbsp;: </span>
  &nbsp; {{ lastUpdatedOn }}
</div>
<div class="d-flex flex-dr bigNumberCard py-24">
    <ng-container #outlet [ngTemplateOutlet]="content">
    </ng-container>
    <ng-template #content>
        <ng-container *ngIf="globalChange else default">
            <ng-container *ngFor="let bigNum of chart?.chartConfig?.bigNumbers">
              <sb-dashlet
                [type]="'bigNumber'"
                [data]="globalData | bigData: bigNum"
                [config]="bigNum | bigData"
                class="mt-8"
                #lib
              ></sb-dashlet>
            </ng-container>
          </ng-container>
    </ng-template>

  <ng-template #default>
    <ng-container *ngFor="let bigNum of chart?.chartConfig?.bigNumbers">
      <sb-dashlet
        [type]="'bigNumber'"
        [data]="updatedData | bigData: bigNum"
        [config]="bigNum | bigData"
        class="mt-8"
        #lib
      >
      </sb-dashlet>
    </ng-container>
  </ng-template>
</div>

./sb-bignumber.component.scss

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

.sb-last-update-status {
    font-size: calculateRem(12px);
    font-weight: bold;
  }
  
  ::ng-deep {
  
    .bigNumberCard {
      border-bottom: 0.0625rem solid var(--rc-dddddd) !important;
      display: grid !important;
      grid-template-columns: 1fr 1fr 1fr !important;
      gap: 1.5rem !important;
  
      sb-dashlet {
        border-right: 0.0625rem solid var(--rc-dddddd) !important;
  
        &:nth-child(3n + 3) {
          border-right: 0rem solid var(--gray-100) !important;
        }
      }
  
      .card {
        flex: 1 !important;
        background-color: var(--gray-hs) !important;
        box-shadow: none !important;
        margin-top: 1.5rem !important;
  
        .header {
          font-size: 1.125rem !important;
          font-weight: unset !important;
        }
  
        .content {
          padding: 0% !important;
        }
  
        .description {
          color: var(--gray) !important;
          font-size: 2.5rem !important;
          font-weight: 700 !important;
          margin-top: 0% !important;
        }
  
        .meta {
          color: var(--gray-200);
          font-size: calculateRem(18px) !important;
        }
  
      }
  
  
    }
  }
Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""