Skip to content

Commit

Permalink
add directive to style
Browse files Browse the repository at this point in the history
  • Loading branch information
eranhd committed Jun 17, 2017
1 parent 5ea703e commit 4962a65
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 11 deletions.
8 changes: 7 additions & 1 deletion Web/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ import { SaveLocationBetaComponent } from "./mobile/pages/save-location-beta/sav
import { FlexLayoutModule } from "@angular/flex-layout";
import { PushNotificationsModule } from "angular2-notifications";

import { RowOver } from './directives/RowOver.directive';
import { Pointer } from './directives/Pointer.directive';


export const environment = {
production: false,
firebase: {
Expand Down Expand Up @@ -129,7 +133,9 @@ export const environment = {
ShowReportComponent,
ShowShiftComponent,
LocationName,
SaveLocationBetaComponent
SaveLocationBetaComponent,
RowOver,
Pointer
],
imports: [
BrowserModule,
Expand Down
20 changes: 20 additions & 0 deletions Web/src/app/directives/Pointer.directive.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { Directive, ElementRef, HostListener, Input } from '@angular/core';

@Directive({
selector: '[pointer]'
})
export class Pointer {
constructor(private el: ElementRef) { }

@HostListener('mouseenter') onMouseEnter() {
this.cursor('pointer');
}

@HostListener('mouseleave') onMouseLeave() {
this.cursor(null);
}

private cursor(style: string) {
this.el.nativeElement.style.cursor = style;
}
}
20 changes: 20 additions & 0 deletions Web/src/app/directives/RowOver.directive.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { Directive, ElementRef, HostListener, Input } from '@angular/core';

@Directive({
selector: '[row-over]'
})
export class RowOver {
constructor(private el: ElementRef) { }

@HostListener('mouseenter') onMouseEnter() {
this.highlight('whitesmoke');
}

@HostListener('mouseleave') onMouseLeave() {
this.highlight(null);
}

private highlight(color: string) {
this.el.nativeElement.style.backgroundColor = color;
}
}
2 changes: 1 addition & 1 deletion Web/src/app/pages/home/home.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ <h1>מפת אירועים</h1>
<h1>אירועים אחרונים</h1>
<div class='div_last_report'>
<div class='last_report' *ngFor='let report of reports'>
<app-last-report [report]='report'>
<app-last-report [report]='report' row-over>
</app-last-report>
</div>
</div>
Expand Down
15 changes: 11 additions & 4 deletions Web/src/app/pages/home/home.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,22 @@ export class HomeComponent implements OnInit {
console.log(this.shifts);
});


this.reports = [];
this.firebseService.reportObsarvable.subscribe(val => {
const r = [];

// const r = [];
for (const item of val)
if (this.firebseService.checkIfReportBelong(item["$key"]))
r.push(item);
this.reports = r.slice(0, 10);
this.reports.push(item);
this.reports = this.reports.slice(0, 10);

});
this.firebseService.hotObsarvable.subscribe(val=>{
for (const item of val)
if(this.firebseService.checkIfHotBelong(item['$key']))
this.reports.push(item);
this.reports = this.reports.slice(0, 10);
});
console.log(this.firebseService.getColdSpot('-Kldk9s0MYEfKwiYBr8E'));
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
*ngIf='report'
(click)='showPopup = true; setPopup()'
(mouseleave)='showPopup = flase'
class='report-row'>
class='report-row' pointer row-over>
<span *ngIf='report.date'>{{report.date | date:'shortDate'}}</span>
<span *ngIf='report.date'>{{report.date | date:'HH:mm'}}</span>
<span *ngIf='report.location'>{{report.location | locationName}}</span>
Expand Down
2 changes: 1 addition & 1 deletion Web/src/app/pages/shift/shift.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@
</th>
</tr>

<tr class='table_body' *ngFor='let shift of data' >
<tr class='table_body' *ngFor='let shift of data' row-over>
<td>
<button id='btn_delete' (click)='firebseService.removeData("shifts", shift.$key)'><md-icon>delete</md-icon></button>
<button id='btn_show' [routerLink]='["../show-shift", shift.$key]'><md-icon>zoom_in</md-icon></button>
Expand Down
6 changes: 3 additions & 3 deletions Web/src/app/pages/show-shift/show-shift.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,15 @@

<td>
<table>
<tr *ngFor='let item of coldSpotArr' (click)='choosen = item;'>
<tr *ngFor='let item of coldSpotArr' (click)='choosen = item;' row-over pointer>
<td>{{item | locationName}}</td>
</tr>
</table>
<!--{{show-shift.coldSpotArr[i].location| locationName}}-->
</td>
<td>
<table>
<tr *ngFor='let item of hotSpotArr' (click)='choosen = item; reportChoose = item;'>
<tr *ngFor='let item of hotSpotArr' (click)='choosen = item; reportChoose = item;' row-over pointer>
<td>
{{item.date | date:'HH:mm'}}
</td>
Expand All @@ -77,7 +77,7 @@
</td>
<td>
<table>
<tr *ngFor='let item of reportArr' (click)='choosen = item; reportChoose = item;'>
<tr *ngFor='let item of reportArr' (click)='choosen = item; reportChoose = item;' row-over pointer>
<td>
{{item.date | date:'HH:mm'}}
</td>
Expand Down

0 comments on commit 4962a65

Please sign in to comment.