forked from HyperIoT-Labs/HyperIoT-UI
-
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.
added project-card component + translations
- Loading branch information
Showing
14 changed files
with
240 additions
and
13 deletions.
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
36 changes: 36 additions & 0 deletions
36
src/app/pages/projects/project-card/project-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,36 @@ | ||
<mat-card class="md-padding" | ||
class="d-flex flex-row align-items-stretch" | ||
[class.mat-elevation-z2]="!isActive" | ||
[class.mat-elevation-z8]="isActive" | ||
(mouseover)="setActive(true)" | ||
(mouseout)="setActive(false)"> | ||
|
||
<!-- Cover --> | ||
<div *ngIf="!isActive" class="flex-fill d-flex align-items-end"> | ||
<h3>{{ project.name }}</h3> | ||
</div> | ||
|
||
<!-- Summary --> | ||
<div *ngIf="isActive" class="flex-fill d-flex flex-column"> | ||
<header> | ||
<h3>{{ project.name }}</h3> | ||
</header> | ||
<main class="flex-grow-1 d-flex flex-column"> | ||
<p class="multiline-ellipsis">{{ project.description }}</p> | ||
<div class="m-1 d-flex flex-row align-items-center"> | ||
<mat-icon>devices_other</mat-icon> | ||
<strong class="px-2">{{ deviceCount }}</strong> | ||
<span i18n="@@projectCard-string-device">HYT_string_device</span> | ||
</div> | ||
<div class="m-1 d-flex flex-row align-items-center"> | ||
<mat-icon>code</mat-icon> | ||
<strong class="px-2">{{ rulesCount }}</strong> | ||
<span i18n="@@projectCard-string-rule">HYT_string_rule</span> | ||
</div> | ||
</main> | ||
<footer class="mt-auto d-flex"> | ||
<button mat-stroked-button class="flex-grow-1" i18n="@@projectCard-button-view">HYT_button_view</button> | ||
</footer> | ||
</div> | ||
|
||
</mat-card> |
25 changes: 25 additions & 0 deletions
25
src/app/pages/projects/project-card/project-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,25 @@ | ||
mat-card { | ||
background: whitesmoke; | ||
width: 200px; | ||
height: 260px; | ||
margin: 8px; | ||
border-radius: 6px; | ||
} | ||
mat-card:hover { | ||
background: white; | ||
} | ||
h3 { | ||
margin: 0; | ||
} | ||
.multiline-ellipsis { | ||
font-size: 80%; | ||
max-width: 100%; | ||
height: 60px; | ||
margin: 8px auto; | ||
display: block; | ||
display: -webkit-box; | ||
-webkit-line-clamp: 3; | ||
-webkit-box-orient: vertical; | ||
overflow: hidden; | ||
text-overflow: ellipsis; | ||
} |
25 changes: 25 additions & 0 deletions
25
src/app/pages/projects/project-card/project-card.component.spec.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,25 @@ | ||
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { ProjectCardComponent } from './project-card.component'; | ||
|
||
describe('ProjectCardComponent', () => { | ||
let component: ProjectCardComponent; | ||
let fixture: ComponentFixture<ProjectCardComponent>; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [ ProjectCardComponent ] | ||
}) | ||
.compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(ProjectCardComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
41 changes: 41 additions & 0 deletions
41
src/app/pages/projects/project-card/project-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,41 @@ | ||
import { Component, OnInit, Input } from '@angular/core'; | ||
import { HProject, HDevice, HdevicesService, RulesService, Rule } from '@hyperiot/core'; | ||
|
||
@Component({ | ||
selector: 'hyt-project-card', | ||
templateUrl: './project-card.component.html', | ||
styleUrls: ['./project-card.component.scss'] | ||
}) | ||
export class ProjectCardComponent implements OnInit { | ||
@Input() project: HProject; | ||
isActive = false; | ||
deviceCount = 0; | ||
rulesCount = 0; | ||
activeTimeout; | ||
|
||
constructor( | ||
private hDeviceService: HdevicesService, | ||
private ruleService: RulesService | ||
) { } | ||
|
||
ngOnInit() { | ||
this.hDeviceService.findAllHDevice().subscribe((deviceList: HDevice[]) => { | ||
deviceList.forEach((d: HDevice) => { | ||
d.project && d.project.id === this.project.id && this.deviceCount++; | ||
}); | ||
}); | ||
this.ruleService.findAllRule().subscribe((ruleList: Rule[]) => { | ||
ruleList.forEach((r: Rule) => { | ||
r.project && r.project.id === this.project.id && this.rulesCount++; | ||
}); | ||
}); | ||
} | ||
|
||
setActive(active) { | ||
if (this.activeTimeout) { | ||
clearTimeout(this.activeTimeout); | ||
} | ||
this.activeTimeout = setTimeout(() => this.isActive = active, 10); | ||
} | ||
|
||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2"> | ||
<file source-language="en" datatype="plaintext" original="ng2.template"> | ||
<body> | ||
<trans-unit id="projectCard-string-device" datatype="html"> | ||
<source>HYT_string_device</source> | ||
<target>Device{{ deviceCount > 1 ? 's' : '' }}</target> | ||
<context-group purpose="location"> | ||
<context context-type="sourcefile">app/pages/projects/project-card/project-card.component.html</context> | ||
</context-group> | ||
</trans-unit> | ||
<trans-unit id="projectCard-string-rule" datatype="html"> | ||
<source>HYT_string_rule</source> | ||
<target>Rule{{ rulesCount > 1 ? 's' : '' }}</target> | ||
<context-group purpose="location"> | ||
<context context-type="sourcefile">app/pages/projects/project-card/project-card.component.html</context> | ||
</context-group> | ||
</trans-unit> | ||
<trans-unit id="projectCard-button-view" datatype="html"> | ||
<source>HYT_button_view</source> | ||
<target>View</target> | ||
<context-group purpose="location"> | ||
<context context-type="sourcefile">app/pages/projects/project-card/project-card.component.html</context> | ||
</context-group> | ||
</trans-unit> | ||
</body> | ||
</file> | ||
</xliff> |
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,28 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2"> | ||
<file source-language="en" datatype="plaintext" original="ng2.template"> | ||
<body> | ||
<trans-unit id="projectCard-string-device" datatype="html"> | ||
<source>HYT_string_device</source> | ||
<target>Dispositiv{{ deviceCount > 1 ? 'i' : 'o' }}</target> | ||
<context-group purpose="location"> | ||
<context context-type="sourcefile">app/pages/projects/project-card/project-card.component.html</context> | ||
</context-group> | ||
</trans-unit> | ||
<trans-unit id="projectCard-string-rule" datatype="html"> | ||
<source>HYT_string_rule</source> | ||
<target>Regol{{ rulesCount > 1 ? 'e' : 'a' }}</target> | ||
<context-group purpose="location"> | ||
<context context-type="sourcefile">app/pages/projects/project-card/project-card.component.html</context> | ||
</context-group> | ||
</trans-unit> | ||
<trans-unit id="projectCard-button-view" datatype="html"> | ||
<source>HYT_button_view</source> | ||
<target>Visualizza</target> | ||
<context-group purpose="location"> | ||
<context context-type="sourcefile">app/pages/projects/project-card/project-card.component.html</context> | ||
</context-group> | ||
</trans-unit> | ||
</body> | ||
</file> | ||
</xliff> |
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,25 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2"> | ||
<file source-language="en" datatype="plaintext" original="ng2.template"> | ||
<body> | ||
<trans-unit id="projectCard-string-device" datatype="html"> | ||
<source>HYT_string_device</source> | ||
<context-group purpose="location"> | ||
<context context-type="sourcefile">app/pages/projects/project-card/project-card.component.html</context> | ||
</context-group> | ||
</trans-unit> | ||
<trans-unit id="projectCard-string-rule" datatype="html"> | ||
<source>HYT_string_rule</source> | ||
<context-group purpose="location"> | ||
<context context-type="sourcefile">app/pages/projects/project-card/project-card.component.html</context> | ||
</context-group> | ||
</trans-unit> | ||
<trans-unit id="projectCard-button-view" datatype="html"> | ||
<source>HYT_button_view</source> | ||
<context-group purpose="location"> | ||
<context context-type="sourcefile">app/pages/projects/project-card/project-card.component.html</context> | ||
</context-group> | ||
</trans-unit> | ||
</body> | ||
</file> | ||
</xliff> |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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