Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,24 @@ <h3 class="dialog-title">{{ 'Embed this object' | translate }}</h3>
/>

<div class="end-dialog-buttons">
<button mat-flat-button color="primary" (click)="copy()">
<button mat-flat-button color="primary" (click)="copyEmbed()">
<mat-icon class="material-symbols-filled">content_copy</mat-icon>
<span>{{ 'Copy' | translate }}</span>
</button>
</div>

<app-outlined-input
class="embed-text-box"
type="textarea"
name="embedUrl"
[ngModel]="elementUrl()"
[disabled]="true"
/>

<div class="end-dialog-buttons">
<button mat-flat-button color="primary" (click)="copyUrl()">
<mat-icon class="material-symbols-filled">content_copy</mat-icon>
<span>{{ 'Copy model link' | translate }}</span>
</button>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
width: 100%;
justify-content: space-between;
align-items: center;

h3 {
font-weight: bold;
}
}

.end-dialog-buttons {
Expand All @@ -19,5 +23,5 @@
}

app-outlined-input {
padding-top: 0;
padding-top: 15px;
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, computed, Inject, inject } from '@angular/core';
import { Component, computed, inject } from '@angular/core';

import { MatButtonModule } from '@angular/material/button';
import { MAT_DIALOG_DATA, MatDialogModule } from '@angular/material/dialog';
Expand Down Expand Up @@ -31,9 +31,7 @@ export class EmbedObjectDialogComponent {

elementUrlText = computed(() => {
let embedHTML: string;
const iframe = document.querySelector('.iframe-container > iframe') as
| HTMLIFrameElement
| undefined;
const iframe = this.iFrameElement();

if (!iframe) return this.#snackbar.showMessage('Could not find viewer');

Expand Down Expand Up @@ -64,8 +62,21 @@ export class EmbedObjectDialogComponent {
return embedHTML;
});

public copy() {
elementUrl = computed(() => {
return this.iFrameElement()?.src;
});

iFrameElement = computed(() => {
return document.querySelector('.iframe-container > iframe') as HTMLIFrameElement | undefined;
});

public copyEmbed() {
const embedText = this.elementUrlText() as string;
this.#detailPageHelper.copyEmbed(embedText);
}

public copyUrl() {
const urlText = this.elementUrl() as string;
this.#detailPageHelper.copyUrl(urlText);
}
}
10 changes: 10 additions & 0 deletions src/app/services/detail-page-helper.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,16 @@ export class DetailPageHelperService {
}
}

public copyUrl(url: string) {
try {
this.copyToClipboard(url);
this.snackbar.showMessage('Model link copied to clipboard.', 3);
} catch (e) {
console.error(e);
this.snackbar.showMessage('Could not access your clipboard.', 3);
}
}

public copyEmbed(embed: string) {
try {
this.copyToClipboard(embed);
Expand Down
Loading