Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | 3x 3x 3x 3x 3x | import { ChangeDetectionStrategy, Component, forwardRef } from '@angular/core';
import { ICellRendererAngularComp } from 'ag-grid-angular';
import { ICellRendererParams } from 'ag-grid-community';
import { Ref } from '../../../model/ref';
import { AdminService } from '../../../service/admin.service';
import { ProxyService } from '../../../service/api/proxy.service';
import { MdComponent } from '../../md/md.component';
import { NavComponent } from '../../nav/nav.component';
import { ViewerComponent } from '../../viewer/viewer.component';
@Component({
selector: 'app-grid-cell',
templateUrl: './grid-cell.component.html',
styleUrl: './grid-cell.component.scss',
changeDetection: ChangeDetectionStrategy.OnPush,
imports: [
forwardRef(() => MdComponent),
forwardRef(() => NavComponent),
forwardRef(() => ViewerComponent),
],
})
export class GridCellComponent implements ICellRendererAngularComp {
type = '';
value?: unknown;
private data?: Ref;
constructor(
private admin: AdminService,
private proxy: ProxyService,
) {}
agInit(params: ICellRendererParams): void {
this.value = params.value;
this.data = params.data;
const type = params.colDef?.type;
this.type = typeof type === 'string' ? type : '';
}
refresh(params: ICellRendererParams): boolean {
this.agInit(params);
return true;
}
get textValue() {
return typeof this.value === 'string' ? this.value : '';
}
get listValue() {
return Array.isArray(this.value) ? this.value.filter((value): value is string => typeof value === 'string' && !!value) : [];
}
get displayValue() {
if (Array.isArray(this.value)) {
return this.listValue.join(', ');
}
return this.textValue;
}
get imageUrl() {
const url = this.textValue;
if (!url) return '';
if (url.startsWith('cache:') || this.admin.getPlugin('plugin/image')?.config?.proxy) {
return this.proxy.getFetch(url, this.data?.origin || '', this.data?.title || $localize`Untitled Image`);
}
return url;
}
tagUrl(tag: string) {
return `tag:/${tag}`;
}
viewerRef(tag: string, url: string): Ref {
return {
url,
origin: '',
tags: [tag],
modifiedString: url,
};
}
}
|