<!--
BSD LICENSE

Copyright(c) 2023 Intel Corporation. All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
  * Redistributions of source code must retain the above copyright
    notice, this list of conditions and the following disclaimer.
  * Redistributions in binary form must reproduce the above copyright
    notice, this list of conditions and the following disclaimer in
    the documentation and/or other materials provided with the
    distribution.
  * Neither the name of Intel Corporation nor the names of its
    contributors may be used to endorse or promote products derived
    from this software without specific prior written permission.
    
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-->
<mat-card class="container">
  <div class="header">
    <mat-card-title>
      Speed Select Technology - Core Power (SST-CP)
    </mat-card-title>
    <button mat-mini-fab [disabled]="!available" color="primary" (click)="pwrProfileAddDialog()">
      <mat-icon>add</mat-icon>
    </button>
  </div>

  <mat-card-content>
    <div class="info-text">
      Speed Select Technology Core Power (SST-CP) allows users to distribute
      excess power among cores according to core priority. There are four levels
      of priority known as Energy Performance Preference (EPP)...
      <a href="https://www.intel.com/content/www/us/en/architecture-and-technology/speed-select-technology-article.html"
        target="_blank" rel="noopener noreferrer"> See More.
      </a>
    </div>
    <ng-container *ngIf="available">
      <br />
      <span *ngIf="!pwrProfiles?.length">No profiles currently configured</span>
      <table mat-table [dataSource]="tableData" *ngIf="pwrProfiles?.length">
        <ng-container matColumnDef="id">
          <th mat-header-cell *matHeaderCellDef>ID</th>
          <td mat-cell *matCellDef="let profile">{{ profile.id }}</td>
        </ng-container>

        <ng-container matColumnDef="name">
          <th mat-header-cell *matHeaderCellDef>Name</th>
          <td mat-cell *matCellDef="let profile">{{ profile.name }}</td>
        </ng-container>

        <ng-container matColumnDef="minFreq">
          <th mat-header-cell *matHeaderCellDef>Min. Frequency</th>
          <td mat-cell *matCellDef="let profile">{{ profile.min_freq }}Mhz</td>
        </ng-container>

        <ng-container matColumnDef="maxFreq">
          <th mat-header-cell *matHeaderCellDef>Max. Frequency</th>
          <td mat-cell *matCellDef="let profile">{{ profile.max_freq }}Mhz</td>
        </ng-container>

        <ng-container matColumnDef="epp" class="cell-header">
          <th mat-header-cell *matHeaderCellDef>Energy Power Preference</th>
          <td mat-cell *matCellDef="let profile">{{ profile.epp }}</td>
        </ng-container>

        <ng-container matColumnDef="action">
          <th mat-header-cell *matHeaderCellDef></th>
          <td mat-cell *matCellDef="let profile">
            <button mat-icon-button [matMenuTriggerFor]="menu">
              <mat-icon>more_horiz</mat-icon>
            </button>
            <mat-menu #menu="matMenu">
              <button mat-menu-item class="edit-button" (click)="pwrProfileEditDialog(profile)">
                Edit
              </button>
              <button mat-menu-item class="delete-button" (click)="deletePwrProfile(profile.id)">
                Delete
              </button>
            </mat-menu>
          </td>
        </ng-container>

        <tr mat-header-row *matHeaderRowDef="tableHeaders"></tr>
        <tr mat-row *matRowDef="let row; columns: tableHeaders"></tr>
      </table>
    </ng-container>
  </mat-card-content>
  <h2 *ngIf="!available">Not currently available or supported...</h2>
</mat-card>
