You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
frontend/src/app/components/editor/database/renderers/link-renderer.component.ts

56 lines
1.5 KiB

import {ICellRendererAngularComp} from 'ag-grid-angular';
import {Component, HostListener} from '@angular/core';
import {ICellRendererParams} from 'ag-grid-community';
import {NavigationService} from '../../../../service/navigation.service';
import {NodeTypeIcons} from '../../../../structures/node-types';
@Component({
selector: 'editor-link-renderer',
template: `
<div (click)="onClick($event)" *ngIf="href" style="display: flex">
<div class="text">{{ href }}</div>
<div class="btn" [title]="href" (click)="onClick($event, true)">
<i class="fa fa-external-link-alt" style="margin-right: 2px;"></i> Open
</div>
</div>`,
styles: [`
.text {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
padding-right: 5px;
flex: 1;
}
.btn:hover {
cursor: pointer;
font-weight: bold;
}
`]
})
export class LinkRendererComponent implements ICellRendererAngularComp {
public params: ICellRendererParams;
public href?: string;
constructor(
protected readonly nav: NavigationService,
) { }
agInit(params: ICellRendererParams): void {
this.params = params;
this.href = params.value;
}
onClick(event, force = false) {
if ( event.ctrlKey || force ) {
event.stopPropagation();
event.preventDefault();
window.open(this.href, '_blank');
}
}
refresh(params: any): boolean {
return false;
}
}