Skip to content

Commit

Permalink
Merge branch 'main' into fix/semantic-release-dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
anninowak committed Mar 27, 2024
2 parents 9f5a950 + 8b19070 commit 4682df0
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
1 change: 1 addition & 0 deletions libs/angular-accelerator/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// directives
export * from './lib/directives/if-permission.directive'
export * from './lib/directives/if-breakpoint.directive'
export * from './lib/directives/src.directive'

// components
export * from './lib/components/column-group-selection/column-group-selection.component'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import { OcxTimeAgoPipe } from './pipes/ocxtimeago.pipe'
import { OcxTimeagoIntl } from './utils/ocxtimeagointl.utils'
import { createTranslateLoader } from './utils/create-translate-loader.utils'
import { TranslationCacheService } from './services/translation-cache.service'
import { SrcDirective } from './directives/src.directive'

export class AngularAcceleratorMissingTranslationHandler implements MissingTranslationHandler {
handle(params: MissingTranslationHandlerParams) {
Expand Down Expand Up @@ -86,6 +87,7 @@ export class AngularAcceleratorMissingTranslationHandler implements MissingTrans
GroupByCountDiagramComponent,
IfPermissionDirective,
IfBreakpointDirective,
SrcDirective,
OcxTimeAgoPipe,
],
providers: [
Expand Down Expand Up @@ -131,6 +133,7 @@ export class AngularAcceleratorMissingTranslationHandler implements MissingTrans
GroupByCountDiagramComponent,
IfPermissionDirective,
IfBreakpointDirective,
SrcDirective,
OcxTimeAgoPipe,
// DataListGridSortingComponent,
],
Expand Down
31 changes: 31 additions & 0 deletions libs/angular-accelerator/src/lib/directives/src.directive.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { HttpClient } from '@angular/common/http'
import { Directive, ElementRef, Input } from '@angular/core'

@Directive({ selector: '[ocxSrc]' })
export class SrcDirective {
private _src: string | undefined

@Input()
get ocxSrc(): string | undefined {
return this._src
}
set ocxSrc(value: string | undefined) {
if (value && this._src !== value) {
this.httpClient.get(value, { responseType: 'blob' }).subscribe({
next: (blob) => {
const url = URL.createObjectURL(blob)
this.el.nativeElement.onload = () => {
URL.revokeObjectURL(url)
}
this.el.nativeElement.src = url
},
error: () => {
this.el.nativeElement.src = 'error'
},
})
this._src = value
}
}

constructor(private el: ElementRef, private httpClient: HttpClient) {}
}

0 comments on commit 4682df0

Please sign in to comment.