Skip to content

Commit

Permalink
feat(module-details): statistics card in page
Browse files Browse the repository at this point in the history
  • Loading branch information
Polyterative committed Nov 10, 2024
1 parent 39635b8 commit 8e5ae8b
Show file tree
Hide file tree
Showing 7 changed files with 87 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,27 +57,6 @@
>
Abstract module, used for educational patches.
</p>

<div appCopyable *ngIf="data">
<span class="hot">{{ data?.name }}</span>
is a <span class="hot">{{ data?.hp }}</span>HP
<span class="hot">{{ data?.standard?.name }}</span> module made by
<span class="hot">{{ data?.manufacturer?.name }}</span>

<br>
Module has <span class="hot"> {{ data?.isComplete ? 'been' : 'not been' }} completed</span>
and <span class="hot">{{ data?.isApproved ? 'has' : 'has not' }} </span> been approved.
<br>

Module has <span class="hot">{{ data?.panels?.length }}</span> panel(s).
<br>
Provides <span class="hot">{{ data?.ins?.length }}</span> in(s)
and <span class="hot">{{ data?.outs?.length }}</span> out(s).

</div>

<div *ngIf="data">
First seen on <span class="hot">{{ data?.created | date: 'mediumDate' }}</span>
and last updated on <span class="hot">{{ data?.updated | date: 'mediumDate' }}</span>.
</div>


</div>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div class="rowwrap gap1">
<app-label-value-showcase *ngFor="let item of data"
<div class="rowwrap gap1 grow">
<app-label-value-showcase *ngFor="let item of data$ | async"
class="label-value-showcase"
[style]="{ flex: '1 1 auto', 'min-width': minSize }"
[style]="{ flex: '1 1 '+item.size, }"
[label]="item.label"
[icon]="item.icon"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ import {
Component,
Input
} from '@angular/core';
import { BehaviorSubject } from 'rxjs';
import { LabelValueShowcaseModule } from "src/app/shared-interproject/components/@visual/label-value-showcase/label-value-showcase.module";
import {
AsyncPipe,
NgForOf,
NgIf
} from "@angular/common";
Expand All @@ -15,6 +17,8 @@ interface LabelValueData {
label: string;
value: string;
icon?: string;
hidden?: boolean;
size?: string;
}

@Component({
Expand All @@ -24,15 +28,18 @@ interface LabelValueData {
LabelValueShowcaseModule,
NgForOf,
MatIcon,
NgIf
NgIf,
AsyncPipe
],
templateUrl: './lib-showcase-grid.component.html',
styleUrl: './lib-showcase-grid.component.scss',
changeDetection: ChangeDetectionStrategy.OnPush
})
export class LibShowcaseGridComponent {
public data$ = new BehaviorSubject<LabelValueData[]>([]);

@Input() data: LabelValueData[] = [];
@Input() minSize: string = '6rem'; // Default size is 12rem
@Input() set data(values: LabelValueData[]) {
this.data$.next(values.filter(v => !v.hidden));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,15 @@
This rack private. It won't be listed in search but will be accessible to anyone who has
the URLm
</app-advice-tooltip>
<lib-clean-card>
<lib-clean-card [@enter]>
<app-lib-showcase-grid [data]="[
{ label: 'Rack name', value: data.name, icon: 'label' },
{ label: 'Rack rows', value: data.rows.toString(), icon: 'view_comfy' },
{ label: 'Modules', value: (bag.rowedRackedModules | totalModulesOfRack).toString(), icon: 'widgets' },
{ label: 'HP', value: data.hp.toString(), icon: 'straighten' },
{ label: 'HP used', value: (bag.rowedRackedModules | totalHpOfRack).toString(), icon: 'crop_5_4' },
{ label: 'HP available', value: (data.hp * data.rows - (bag.rowedRackedModules | totalHpOfRack)).toString(), icon: 'crop_free' },
{ label: 'Rack Utilization', value: calculateRackUtilization(data.hp, data.rows, bag.rowedRackedModules | totalHpOfRack), icon: 'bar_chart' },
{ label: 'Rack name', value: data.name, icon: 'label', size: 'auto' },
{ label: 'Rack rows', value: data.rows.toString(), icon: 'view_comfy', size: 'auto' },
{ label: 'Modules', value: (bag.rowedRackedModules | totalModulesOfRack).toString(), icon: 'widgets', size: 'auto' },
{ label: 'HP', value: data.hp.toString(), icon: 'straighten', size: 'auto' },
{ label: 'HP used', value: (bag.rowedRackedModules | totalHpOfRack).toString(), icon: 'crop_5_4', size: 'auto' },
{ label: 'HP available', value: (data.hp * data.rows - (bag.rowedRackedModules | totalHpOfRack)).toString(), icon: 'crop_free', size: 'auto' },
{ label: 'Rack Utilization', value: calculateRackUtilization(data.hp, data.rows, bag.rowedRackedModules | totalHpOfRack), icon: 'bar_chart', size: 'auto' }
]">
</app-lib-showcase-grid>

Expand Down
4 changes: 2 additions & 2 deletions src/app/components/rack-parts/rack.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ import { MatBadge } from "@angular/material/badge";
import { CalculateRowInformationPipe } from "src/app/components/rack-parts/rack-editor/calculate-row-information.pipe";
import { RackImageComponent } from "src/app/components/rack-parts/rack-image/rack-image.component";
import { LabelValueShowcaseModule } from "src/app/shared-interproject/components/@visual/label-value-showcase/label-value-showcase.module";
import { LibShowcaseGridComponent } from "src/app/components/rack-parts/rack-editor/lib-showcase-grid/lib-showcase-grid.component";
import { LibShowcaseGridComponent, } from "src/app/components/rack-parts/rack-editor/lib-showcase-grid/lib-showcase-grid.component";


@NgModule({
Expand Down Expand Up @@ -109,7 +109,7 @@ import { LibShowcaseGridComponent } from "src/app/components/rack-parts/rack-edi
CalculateRowInformationPipe,
RackImageComponent,
LabelValueShowcaseModule,
LibShowcaseGridComponent
LibShowcaseGridComponent,
]
})
export class RackModule {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,64 @@
</ng-template>

</lib-clean-card>
<div class="col"
<div class="col gap1"
>

<!-- <div appCopyable *ngIf="data">-->
<!-- <span class="hot">{{ data?.name }}</span>-->
<!-- is a <span class="hot">{{ data?.hp }}</span>HP-->
<!-- <span class="hot">{{ data?.standard?.name }}</span> module made by-->
<!-- <span class="hot">{{ data?.manufacturer?.name }}</span>-->
<!-- -->
<!-- <br>-->
<!-- Module has <span class="hot"> {{ data?.isComplete ? 'been' : 'not been' }} completed</span>-->
<!-- and <span class="hot">{{ data?.isApproved ? 'has' : 'has not' }} </span> been approved.-->
<!-- <br>-->
<!-- -->
<!-- Module has <span class="hot">{{ data?.panels?.length }}</span> panel(s).-->
<!-- <br>-->
<!-- Provides <span class="hot">{{ data?.ins?.length }}</span> in(s)-->
<!-- and <span class="hot">{{ data?.outs?.length }}</span> out(s).-->
<!-- -->
<!-- </div>-->
<!-- -->
<!-- <div *ngIf="data">-->
<!-- First seen on <span class="hot">{{ data?.created | date: 'mediumDate' }}</span>-->
<!-- and last updated on <span class="hot">{{ data?.updated | date: 'mediumDate' }}</span>.-->
<!-- </div>-->


<lib-clean-card [@enter]>
<div class="col gap1">
<app-lib-showcase-grid [data]="[
{ label: 'Manufacturer', value: bag.data.manufacturer.name, icon: 'business',size:'auto' },
{ label: 'HP', value: bag.data.hp.toString(), icon: 'straighten' },
{ label: 'Standard', value: bag.data.standard.name, icon: 'verified' },
{ label: 'Panels', value: bag.data.panels.length.toString(), icon: 'view_module' },
]">
</app-lib-showcase-grid>

<app-lib-showcase-grid
*ngIf="(bag.data.outs.length + bag.data.ins.length)>0"
[data]="[
{ label: 'Inputs', value: bag.data.ins.length.toString(), icon: 'input', hidden: bag.data.ins.length === 0 ,size:'auto' },
{ label: 'Outputs', value: bag.data.outs.length.toString(), icon: 'output', hidden: bag.data.outs.length === 0 ,size:'auto'},
{ label: 'Total Jacks', value: (bag.data.outs.length + bag.data.ins.length).toString(), icon: 'settings_input_composite', hidden: (bag.data.outs.length + bag.data.ins.length) === 0 ,size:'auto'},
{ label: 'Density (in+out/hp)', value: ((bag.data.outs.length + bag.data.ins.length)/bag.data.hp).toPrecision(3), icon: 'bar_chart' ,size:'auto'},
]">
</app-lib-showcase-grid>
<app-lib-showcase-grid [data]="[
{ label: 'Data Complete', value: bag.data.isComplete ? 'Yes' : 'No', icon: 'done',size:'auto' },
{ label: 'Approved', value: bag.data.isApproved ? 'Yes' : 'No', icon: 'thumb_up',size:'auto' },
]">
</app-lib-showcase-grid>
</div>

<!-- { label: '+12V mA', value: '12000', icon: 'bolt' },-->
<!-- { label: '-12V mA', value: '12000', icon: 'bolt' },-->
<!-- { label: '+5V mA', value: '12000', icon: 'bolt' }-->
</lib-clean-card>

<div class="col gap1"
*ngIf="bag.data"
>
Expand Down Expand Up @@ -84,14 +140,6 @@


</div>
<p fxLayoutAlign="end"
style="font-size: 1rem; font-family: 'Roboto', sans-serif"
*ngIf="bag.data&&!bag.data.isComplete&&!viewConfig.hideLabels&&(bag.data.manufacturer.id!==10000)"
>
Do you know about this module?
Please help the community by adding the module's ins and outs.
Contributors' patches DO sound better!
</p>
</div>

<lib-hero-content-card titleNormal="Search on" *ngIf="bag.data">
Expand Down Expand Up @@ -184,6 +232,9 @@
>
<lib-hero-content-card *ngIf="bag.data&&dataService.moduleEditingPanelOpenState$|async"
titleNormal="Module Editor"
description="Do you know about this module?
Please help the community by adding the module's ins and outs.
Contributors' patches DO sound better!"
>
<app-module-editor [data]="(bag.data)"
></app-module-editor>
Expand Down
2 changes: 2 additions & 0 deletions src/app/features/module-browser/module-browser.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ import {
} from "@angular/material/menu";
import { CommentsModule } from "src/app/components/shared-atoms/comments/comments.module";
import { CopyableDirective } from "src/app/shared-interproject/app-copy-on-click.directive";
import { LibShowcaseGridComponent, } from "src/app/components/rack-parts/rack-editor/lib-showcase-grid/lib-showcase-grid.component";


const parentPrefix = 'modules';
Expand Down Expand Up @@ -135,6 +136,7 @@ const parentPrefix = 'modules';
MatMenuTrigger,
CommentsModule,
CopyableDirective,
LibShowcaseGridComponent,
],
exports: [
ModuleListComponent,
Expand Down

0 comments on commit 8e5ae8b

Please sign in to comment.