From 5703782a0fe26929b827fafca66691e7dd41490b Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Tue, 23 Jan 2018 23:38:56 -0500 Subject: [PATCH] directives --- src/app/app.module.ts | 5 +++++ src/app/directives/fallback-src.directive.ts | 20 +++++++++++++++++++ src/app/directives/stop-click.directive.ts | 13 ++++++++++++ src/app/directives/stop-prop.directive.ts | 13 ++++++++++++ src/app/vault/ciphers.component.html | 2 +- src/app/vault/ciphers.component.ts | 4 ++++ src/app/vault/icon.component.html | 2 +- src/app/vault/icon.component.ts | 2 +- src/images/fa-globe.png | Bin 0 -> 344 bytes webpack.main.js | 1 + 10 files changed, 59 insertions(+), 3 deletions(-) create mode 100644 src/app/directives/fallback-src.directive.ts create mode 100644 src/app/directives/stop-click.directive.ts create mode 100644 src/app/directives/stop-prop.directive.ts create mode 100644 src/images/fa-globe.png diff --git a/src/app/app.module.ts b/src/app/app.module.ts index b026bd5aef..19a2c081c2 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -9,9 +9,12 @@ import { ServicesModule } from './services/services.module'; import { AppComponent } from './app.component'; import { CiphersComponent } from './vault/ciphers.component'; +import { FallbackSrcDirective } from './directives/fallback-src.directive'; import { GroupingsComponent } from './vault/groupings.component'; import { IconComponent } from './vault/icon.component'; import { LoginComponent } from './accounts/login.component'; +import { StopClickDirective } from './directives/stop-click.directive'; +import { StopPropDirective } from './directives/stop-prop.directive'; import { VaultComponent } from './vault/vault.component'; import { ViewComponent } from './vault/view.component'; @@ -25,9 +28,11 @@ import { ViewComponent } from './vault/view.component'; declarations: [ AppComponent, CiphersComponent, + FallbackSrcDirective, GroupingsComponent, IconComponent, LoginComponent, + StopClickDirective, VaultComponent, ViewComponent, ], diff --git a/src/app/directives/fallback-src.directive.ts b/src/app/directives/fallback-src.directive.ts new file mode 100644 index 0000000000..db716f53c5 --- /dev/null +++ b/src/app/directives/fallback-src.directive.ts @@ -0,0 +1,20 @@ +import { + Directive, + ElementRef, + HostListener, + Input, +} from '@angular/core'; + +@Directive({ + selector: '[appFallbackSrc]' +}) +export class FallbackSrcDirective { + @Input('appFallbackSrc') appFallbackSrc: string; + + constructor(private el: ElementRef) { + } + + @HostListener('error') OnError() { + this.el.nativeElement.src = this.appFallbackSrc; + } +} diff --git a/src/app/directives/stop-click.directive.ts b/src/app/directives/stop-click.directive.ts new file mode 100644 index 0000000000..f0c24f5c49 --- /dev/null +++ b/src/app/directives/stop-click.directive.ts @@ -0,0 +1,13 @@ +import { + Directive, + HostListener, +} from '@angular/core'; + +@Directive({ + selector: '[appStopClick]' +}) +export class StopClickDirective { + @HostListener('click', ['$event']) onClick($event: MouseEvent) { + $event.preventDefault(); + } +} diff --git a/src/app/directives/stop-prop.directive.ts b/src/app/directives/stop-prop.directive.ts new file mode 100644 index 0000000000..fba8737259 --- /dev/null +++ b/src/app/directives/stop-prop.directive.ts @@ -0,0 +1,13 @@ +import { + Directive, + HostListener, +} from '@angular/core'; + +@Directive({ + selector: '[appStopProp]' +}) +export class StopPropDirective { + @HostListener('click', ['$event']) onClick($event: MouseEvent) { + $event.stopPropagation(); + } +} diff --git a/src/app/vault/ciphers.component.html b/src/app/vault/ciphers.component.html index 4c3deeef85..eec16e883d 100644 --- a/src/app/vault/ciphers.component.html +++ b/src/app/vault/ciphers.component.html @@ -10,7 +10,7 @@
- diff --git a/src/app/vault/ciphers.component.ts b/src/app/vault/ciphers.component.ts index 3b21ee72ec..0a2bdfbda7 100644 --- a/src/app/vault/ciphers.component.ts +++ b/src/app/vault/ciphers.component.ts @@ -20,4 +20,8 @@ export class CiphersComponent implements OnChanges { ngOnChanges() { } + + viewCipher(cipher: any) { + console.log(cipher.id); + } } diff --git a/src/app/vault/icon.component.html b/src/app/vault/icon.component.html index 6a18b04293..fd42b99dde 100644 --- a/src/app/vault/icon.component.html +++ b/src/app/vault/icon.component.html @@ -1,4 +1,4 @@
- +
diff --git a/src/app/vault/icon.component.ts b/src/app/vault/icon.component.ts index 1a57b1f621..f565cc2790 100644 --- a/src/app/vault/icon.component.ts +++ b/src/app/vault/icon.component.ts @@ -78,7 +78,7 @@ export class IconComponent implements OnChanges { try { const url = new URL(hostnameUri); this.image = this.iconsUrl + '/' + url.hostname + '/icon.png'; - this.fallbackImage = '../images/fa-globe.png'; // TODO? + this.fallbackImage = 'images/fa-globe.png'; } catch (e) { } } } else { diff --git a/src/images/fa-globe.png b/src/images/fa-globe.png new file mode 100644 index 0000000000000000000000000000000000000000..7ba709fd1ae2a7f467f948e9c3a9d69c2da3afef GIT binary patch literal 344 zcmV-e0jK_nP)e( zze@u_5QX2JLgEilk#L|QLO>A_1jR~8Zy{(asnSHW{~8NRI}t2`h5taX3)l%_pGG7g zB4Tj}M+&hB62e$yx$MPP&CGuL_RUI8gzQqIMa%=IL>d;$B((XYj?uv|t{L%xLyR&r zjFV@TI}F2kAwO_1)?7V-(V;+{9>zUEKSRQa=Qzg=fy5TS7zdIlVZ5f6k_aWHsnW$r z2*fRhksFF%ae0hL#2Cgx1~^LrV_R;;52oC4K!I-$DT!xSHdv9kq)W{MjCFCIHa~>y zP|g6xq$qlAlYJr{y~$Jm^+x7aiz^mca*>ODBu|ooz9fk;VvYw(&hq9VRYFR%A^TOM qT%<@$k9RioU*y>2hzfhm`}03sXXm+tt9(EJ0000