-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #37 from ThingooKNI/feature/device-list
Add device-list and device-details components
- Loading branch information
Showing
12 changed files
with
392 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
src/app/pages/device-details/device-details.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<div class="device-details-page-wrapper"> | ||
<mat-card class="device-details__section"> | ||
<div class="device-basic-info"> | ||
<div class="device-basic-info__first"> | ||
<div class="icon__wrapper"> | ||
<div class="icon"></div> | ||
</div> | ||
<div class="text__wrapper header-flex-column"> | ||
<h2>{{ device.displayName }}</h2> | ||
<p> | ||
{{ device.entities.length }} | ||
<span class="gray-color">ENTITIES</span> | ||
</p> | ||
</div> | ||
</div> | ||
<div class="device-basic-info__second header-flex-column"> | ||
<div> | ||
<span class="gray-color">KEY</span> | ||
{{ device.key }} | ||
</div> | ||
|
||
<div> | ||
<span class="gray-color">MAC</span> | ||
{{ device.macAddress }} | ||
</div> | ||
</div> | ||
</div> | ||
</mat-card> | ||
<mat-card class="device-entities device-details__section"> | ||
<h1 class="entities-title">Entities:</h1> | ||
<div class="entity-list"> | ||
<mat-card | ||
class="entity-item mat-elevation-z2" | ||
*ngFor="let entity of device.entities" | ||
> | ||
<div class="icon"></div> | ||
<h4> | ||
{{ entity.displayName }} | ||
</h4> | ||
<h3>92 dB</h3> | ||
<h5>13 minutes ago</h5> | ||
</mat-card> | ||
</div> | ||
</mat-card> | ||
</div> |
100 changes: 100 additions & 0 deletions
100
src/app/pages/device-details/device-details.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
.device-details-page-wrapper { | ||
width: 100vw; | ||
max-width: 1000px; | ||
|
||
mat-card.device-details__section { | ||
padding: calc(16px + 1.5vw) calc(16px + 1.5vw); | ||
} | ||
} | ||
|
||
.entity-list { | ||
display: flex; | ||
flex-direction: row; | ||
align-items: center; | ||
justify-content: flex-start; | ||
flex-wrap: wrap; | ||
gap: 20px; | ||
} | ||
|
||
.gray-color { | ||
color: lightgray; | ||
} | ||
|
||
.device-entities { | ||
margin-top: 12px; | ||
} | ||
|
||
.device-basic-info { | ||
display: flex; | ||
flex-direction: row; | ||
align-items: center; | ||
flex-wrap: wrap; | ||
|
||
.header-flex-column { | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: space-between; | ||
} | ||
|
||
p { | ||
margin: 0px; | ||
} | ||
|
||
&__first { | ||
display: grid; | ||
grid-template-columns: 65px calc(100% - 65px); | ||
margin-right: 4vw; | ||
|
||
.text__wrapper { | ||
margin-left: 5px; | ||
} | ||
|
||
h2 { | ||
margin-bottom: 0px; | ||
font-size: 28px; | ||
} | ||
} | ||
|
||
&__second { | ||
span { | ||
font-size: 18px; | ||
font-weight: 500; | ||
width: 45px; | ||
display: inline-block; | ||
} | ||
p { | ||
font-size: 18px; | ||
} | ||
} | ||
} | ||
|
||
.entity-item { | ||
display: flex; | ||
justify-content: center; | ||
flex-direction: column; | ||
align-items: center; | ||
width: 120px; | ||
|
||
&::before { | ||
content: " "; | ||
background-color: rgba($color: #fff, $alpha: 0.07); | ||
position: absolute; | ||
width: 100%; | ||
height: 100%; | ||
border-radius: 4px; | ||
} | ||
|
||
h4 { | ||
margin: 8px 0; | ||
} | ||
h3 { | ||
margin-bottom: 8px; | ||
} | ||
} | ||
|
||
.icon { | ||
width: 60px; | ||
height: 60px; | ||
border-radius: 50%; | ||
background-color: lightgray; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { Component, OnInit } from '@angular/core'; | ||
import { Device } from 'src/app/api/device.model'; | ||
import { Entity, EntityType, UnitType } from 'src/app/api/entity.model'; | ||
|
||
@Component({ | ||
selector: 'app-device-details', | ||
templateUrl: './device-details.component.html', | ||
styleUrls: ['./device-details.component.scss'], | ||
}) | ||
export class DeviceDetailsComponent implements OnInit { | ||
public device = new Device( | ||
1, | ||
'example key', | ||
'11:22:33:44:55:66:77', | ||
[ | ||
new Entity( | ||
1, | ||
'key1', | ||
EntityType.SENSOR, | ||
UnitType.DECIMAL, | ||
'C', | ||
'Entity 1' | ||
), | ||
new Entity( | ||
2, | ||
'key1', | ||
EntityType.SENSOR, | ||
UnitType.DECIMAL, | ||
'C', | ||
'Entity 2' | ||
), | ||
new Entity( | ||
3, | ||
'key1', | ||
EntityType.SENSOR, | ||
UnitType.DECIMAL, | ||
'C', | ||
'Entity 3' | ||
), | ||
], | ||
'Example device' | ||
); | ||
|
||
constructor() {} | ||
|
||
ngOnInit(): void {} | ||
} |
9 changes: 9 additions & 0 deletions
9
src/app/pages/device-list/device-card/device-card.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<mat-card class="device-card" [routerLink]="device.id.toString()" matRipple> | ||
<div> | ||
<div class="device-icon"></div> | ||
<h3 class="device-card__h3"> | ||
{{ device.displayName }} | ||
</h3> | ||
<p class="device-card__p">Entities: {{ device.entities.length }}</p> | ||
</div> | ||
</mat-card> |
44 changes: 44 additions & 0 deletions
44
src/app/pages/device-list/device-card/device-card.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
.device-icon { | ||
width: 60px; | ||
height: 60px; | ||
background-color: lightgray; | ||
border-radius: 50%; | ||
margin-bottom: 12px; | ||
} | ||
|
||
.device-card { | ||
width: 130px; | ||
height: 160px; | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
justify-content: center; | ||
margin: 0; | ||
user-select: none; | ||
cursor: pointer; | ||
border: 1px solid #303030; | ||
|
||
&:hover, | ||
&:focus { | ||
outline: none; | ||
|
||
&::before { | ||
/* this should be transformed into some kind of a mixin at a later date */ | ||
content: " "; | ||
background-color: rgba($color: #fff, $alpha: 0.03); | ||
position: absolute; | ||
width: 100%; | ||
height: 100%; | ||
border-radius: 4px; | ||
} | ||
} | ||
|
||
&__h3 { | ||
margin-bottom: 5px; | ||
} | ||
|
||
&__p { | ||
margin-top: 0; | ||
font-size: 13px; | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
src/app/pages/device-list/device-card/device-card.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { Component, OnInit, Input } from '@angular/core'; | ||
import { Device } from 'src/app/api/device.model'; | ||
|
||
@Component({ | ||
selector: 'app-device-card', | ||
templateUrl: './device-card.component.html', | ||
styleUrls: ['./device-card.component.scss'], | ||
}) | ||
export class DeviceCardComponent implements OnInit { | ||
@Input() device!: Device; | ||
|
||
constructor() {} | ||
|
||
ngOnInit(): void {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<div class="device-list-page-wrapper"> | ||
<mat-card class="no-devices" *ngIf="devicesList.length == 0"> | ||
<h1>You have no devices at this moment.</h1> | ||
</mat-card> | ||
<div class="device-list"> | ||
<app-device-card | ||
*ngFor="let device of devicesList" | ||
[device]="device" | ||
></app-device-card> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
.device-list { | ||
&-page-wrapper { | ||
width: 100vw; | ||
max-width: 1000px; | ||
} | ||
|
||
display: flex; | ||
flex-direction: row; | ||
align-items: center; | ||
justify-content: flex-start; | ||
flex-wrap: wrap; | ||
width: 100%; | ||
gap: 20px; | ||
} | ||
|
||
.no-devices { | ||
text-align: center; | ||
} |
Oops, something went wrong.