File

src/app/pages/dashboard/electricity/electricity.component.ts

Implements

OnDestroy

Metadata

selector ngx-electricity
styleUrls electricity.component.scss
templateUrl ./electricity.component.html

Index

Properties
Methods

Constructor

constructor(eService: ElectricityService, themeService: NbThemeService)
Parameters :
Name Type Optional
eService ElectricityService no
themeService NbThemeService no

Methods

ngOnDestroy
ngOnDestroy()
Returns : void

Properties

currentTheme
currentTheme: string
Type : string
data
data: Array<any>
Type : Array<any>
themeSubscription
themeSubscription: any
Type : any
type
type: string
Type : string
Default value : 'week'
types
types: []
Type : []
Default value : ['week', 'month', 'year']
import { Component, OnDestroy } from '@angular/core';
import { NbThemeService } from '@nebular/theme';

import { ElectricityService } from '../../../@core/data/electricity.service';

@Component({
  selector: 'ngx-electricity',
  styleUrls: ['./electricity.component.scss'],
  templateUrl: './electricity.component.html',
})
export class ElectricityComponent implements OnDestroy {

  data: Array<any>;

  type = 'week';
  types = ['week', 'month', 'year'];

  currentTheme: string;
  themeSubscription: any;

  constructor(private eService: ElectricityService, private themeService: NbThemeService) {
    this.data = this.eService.getData();

    this.themeSubscription = this.themeService.getJsTheme().subscribe(theme => {
      this.currentTheme = theme.name;
    });
  }

  ngOnDestroy() {
    this.themeSubscription.unsubscribe();
  }
}
<nb-card size="large">
  <div class="consumption-table">
    <div class="table-header">
      <div>Electricity</div>
      <div class="subtitle">Consumption</div>
    </div>

    <nb-tabset fullWidth>
      <nb-tab *ngFor="let year of data" [tabTitle]="year.title" [active]="year.active">
        <div class="stats-month" *ngFor="let month of year.months">
          <div>
            <span class="month">{{ month.month }}</span>
            <span class="delta" [ngClass]="{ 'down': month.down }">{{ month.delta }}</span>
          </div>
          <div class="results">
            <b>{{ month.kWatts }}</b> kWh / <b>{{ month.cost }}</b> USD
          </div>
        </div>
      </nb-tab>
    </nb-tabset>
  </div>

  <div class="chart-container">
    <div class="chart-header">
      <div class="header-stats">
        <div class="stats-block">
          <div class="subtitle">Consumed</div>
          <div>
            <span class="value">816</span>
            <span class="unit">kWh</span>
          </div>
        </div>

        <div class="stats-block">
          <div class="subtitle">Spent</div>
          <div>
            <span class="value">291</span>
            <span class="unit">USD</span>
          </div>
        </div>
      </div>

      <div class="dropdown" ngbDropdown>
        <button type="button" ngbDropdownToggle class="btn"
                [ngClass]="{ 'btn-outline-success': currentTheme == 'default', 'btn-primary': currentTheme != 'default'}">
          {{ type }}
        </button>
        <ul class="dropdown-menu" ngbDropdownMenu>
          <li class="dropdown-item" *ngFor="let t of types" (click)="type = t">{{ t }}</li>
        </ul>
      </div>

    </div>
    <ngx-electricity-chart></ngx-electricity-chart>
  </div>
</nb-card>
Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""