Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(edit-content): drag and drop functionality #30135

Merged
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
fb7c358
feat(editor-content): working on preview component #29872
nicobytes Sep 23, 2024
52d1cf7
feat(editor-content): work on upload dotAsset #29872
nicobytes Sep 25, 2024
14866a2
feat(editor-content): apply format #29872
nicobytes Sep 25, 2024
15724e5
feat(editor-content): enable links #29872
nicobytes Sep 25, 2024
bd896c4
feat(editor-content): working on preview for text files #29872
nicobytes Sep 25, 2024
89f8239
feat(editor-content): remove contentlet #29872
nicobytes Sep 25, 2024
c0cb8bf
feat(editor-content): add jsdoc #29872
nicobytes Sep 26, 2024
3aad446
feat(editor-content): add unit tests to DotFileFieldUploadService #2…
nicobytes Sep 26, 2024
874b059
Merge branch 'master' into 29872-file-field-drag-and-drop-functionali…
nicobytes Sep 26, 2024
597b056
feat(editor-content): fix css error #29872
nicobytes Sep 26, 2024
3a4c065
Merge branch '29872-file-field-drag-and-drop-functionality-for-file-u…
nicobytes Sep 26, 2024
f272266
Merge branch 'master' into 29872-file-field-drag-and-drop-functionali…
nicobytes Sep 26, 2024
e6a12ab
feat(editor-content): fix error with sonar #29872
nicobytes Sep 26, 2024
99f5ac3
Merge branch '29872-file-field-drag-and-drop-functionality-for-file-u…
nicobytes Sep 26, 2024
5654d70
feat(editor-content): add unit tests to DotFileFieldPreviewComponent …
nicobytes Sep 26, 2024
d84ea81
feat(editor-content): add unit tests to DotFileFieldPreviewComponent …
nicobytes Sep 26, 2024
4cbbfbb
feat(editor-content): fix unit tests #29872
nicobytes Sep 26, 2024
b496933
feat(editor-content): apply format #29872
nicobytes Sep 26, 2024
710f81a
feat(editor-content): fix sonar issue #29872
nicobytes Sep 27, 2024
987928b
Merge branch 'master' into 29872-file-field-drag-and-drop-functionali…
nicobytes Sep 27, 2024
25869cf
feat(editor-content): add unit tests to DotUploadFileService #29872
nicobytes Sep 27, 2024
a89e9e2
feat(editor-content): add unit tests to DotFileFieldUiMessageComponen…
nicobytes Sep 27, 2024
38287eb
feat(editor-content): apply format #29872
nicobytes Sep 27, 2024
b531157
feat(editor-content): refactor upload asset #29872
nicobytes Sep 27, 2024
6ffdd79
feat(editor-content): refactor upload service #29872
nicobytes Sep 27, 2024
274c6af
feat(editor-content): apply format #29872
nicobytes Sep 27, 2024
991f7ab
feat(editor-content): fix error with preview #29872
nicobytes Sep 27, 2024
20a4311
Merge branch 'master' into 29872-file-field-drag-and-drop-functionali…
nicobytes Sep 27, 2024
fb22f8f
feat(editor-content): change id #29872
nicobytes Sep 27, 2024
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 @@ -89,4 +89,22 @@ export class DotUploadFileService {
})
);
}

uploadDotAsset(file: File): Observable<DotCMSContentlet> {
const formData = new FormData();
formData.append('file', file);
formData.append(
'json',
JSON.stringify({
contentlet: {
file: file.name,
contentType: 'dotAsset'
}
})
);

return this.http
.put<DotCMSContentlet>(`/api/v1/workflow/actions/default/fire/NEW`, formData)
nicobytes marked this conversation as resolved.
Show resolved Hide resolved
.pipe(pluck('entity'));
}
}
Original file line number Diff line number Diff line change
@@ -1 +1,133 @@
<p>Preview</p>
@let previewFile = $previewFile();
@let metadata = $metadata();
nicobytes marked this conversation as resolved.
Show resolved Hide resolved
@let downloadLink = $downloadLink();

<div class="preview-container" [class.preview-container--fade]="metadata?.editableAsText">
@if (metadata?.editableAsText) {
<div class="preview-code_container" data-testId="code-preview">
<code>{{ $content() }}</code>
</div>
} @else {
<div class="preview-image__container">
@if (previewFile.source === 'temp') {
<dot-temp-file-thumbnail
[tempFile]="previewFile.file"
[iconSize]="'48px'"
data-testId="temp-file-thumbnail" />
} @else {
<dot-contentlet-thumbnail
fieldVariable="asset"
[iconSize]="'48px'"
[contentlet]="previewFile.file"
[playableVideo]="true"
data-testId="contentlet-thumbnail" />
}
</div>
<div class="preview-metadata__container">
@if (metadata) {
<span class="preview-metadata_header">{{ metadata.title }}</span>
@if (metadata.width && metadata.height) {
<div class="preview-metadata__info">
<i class="pi pi-arrows-alt"></i>
<span>{{ metadata.width }} x {{ metadata.height }}</span>
</div>
}
@if (metadata.fileSize) {
<div class="preview-metadata__info">
<i class="pi pi-file"></i>
<span>{{ metadata.fileSize | dotFileSizeFormat }}</span>
</div>
}
}
</div>
}

<!-- Actions -->
<div class="preview-resource-links__actions">
<p-button
(click)="toggleShowDialog()"
styleClass="p-button-rounded p-button-sm p-button-outlined"
data-testId="info-btn"
icon="pi pi-info" />

@if (downloadLink) {
<p-button
styleClass="p-button-rounded p-button-sm p-button-outlined"
data-testId="download-btn"
icon="pi pi-download"
(click)="downloadAsset(downloadLink)" />
}
</div>
<div class="preview-metadata__actions">
<p-button
(click)="removeFile.emit()"
[label]="'dot.common.remove' | dm"
styleClass="p-button-link p-button-sm"
data-testId="remove-button"
icon="pi pi-trash" />
</div>
<!-- Actions in small screens -->
<div class="preview-metadata__action--responsive">
<p-button
(click)="toggleShowDialog()"
styleClass="p-button-rounded"
data-testId="infor-button-responsive"
icon="pi pi-info" />
@if (downloadLink) {
<p-button
styleClass="p-button-rounded"
data-testId="download-btn-responsive"
icon="pi pi-download"
(click)="downloadAsset(downloadLink)" />
}
<p-button
(click)="removeFile.emit()"
styleClass="p-button-rounded "
data-testId="remove-button-responsive"
icon="pi pi-trash" />
</div>
</div>

<p-dialog
[(visible)]="$showDialog"
nicobytes marked this conversation as resolved.
Show resolved Hide resolved
[closeOnEscape]="true"
[dismissableMask]="true"
[modal]="true"
[header]="metadata.title"
[appendTo]="'body'"
[style]="{ maxWidth: '582px', width: '100%' }">
<div class="file-info__item">
<span class="file-info__title">{{ 'Size' | dm }}:</span>
<div class="file-info__link">
@if (metadata.width && metadata.height) {
<div class="file-info__size" data-testId="file-resolution">
<i class="pi pi-arrows-alt"></i>
<span>{{ metadata.width }}px, {{ metadata.height }}px</span>
</div>
}
<div class="file-info__size">
<i class="pi pi-file"></i>
<span>{{ metadata.fileSize | dotFileSizeFormat }}</span>
</div>
</div>
</div>
@for (sourceLink of $resourceLinks(); track $index) {
<div [attr.data-testId]="'resource-link-' + sourceLink.key" class="file-info__item">
<span class="file-info__title">{{ sourceLink.key | dm }}:</span>
<div class="file-info__link">
<a [href]="sourceLink.value" target="_blank">
{{ sourceLink.value || ('dot.file.field.no.link.found' | dm) }}
</a>
<dot-copy-button [copy]="sourceLink.value" />
</div>
</div>
}

<ng-template pTemplate="footer">
<p-button
(click)="$showDialog.set(false)"
[label]="'Cancel' | dm"
styleClass="p-button-outlined"
data-testId="dialog-cancel" />
</ng-template>
</p-dialog>
Original file line number Diff line number Diff line change
@@ -0,0 +1,208 @@
@use "variables" as *;

:host {
display: block;
width: 100%;
height: 100%;
}

dot-contentlet-thumbnail::ng-deep {
.background-image:not(.svg-thumbnail) {
img {
object-fit: cover;
}
}

img {
object-fit: contain;
}
}

.preview-container {
display: flex;
gap: $spacing-1;
align-items: flex-start;
justify-content: center;
height: 100%;
width: 100%;
position: relative;
container-type: inline-size;
container-name: preview;

&:only-child {
gap: 0;
}
}

.preview-image__container {
height: 100%;
width: 100%;
display: flex;
justify-content: center;
align-items: center;
background: $color-palette-gray-200;
overflow: hidden;
}

.preview-metadata__info {
display: flex;
justify-content: flex-start;
align-items: center;
gap: $spacing-0;
}

.preview-metadata__container {
flex-grow: 1;
padding: $spacing-1;
padding-right: $spacing-6;
flex-direction: column;
overflow: hidden;
gap: $spacing-2;
min-width: 150px;
display: none;

span {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}

.preview-metadata_header {
font-size: $font-size-md;
font-weight: $font-weight-semi-bold;
margin: 0;
color: $black;
}
}

.preview-code_container {
display: flex;
align-items: center;
justify-content: center;
height: 100%;
width: 100%;
user-select: none;

code {
background: #ffffff;
color: $color-palette-primary-500;
height: 100%;
width: 100%;
white-space: pre-wrap;
overflow: hidden;
line-height: normal;
}
}

.preview-metadata__action--responsive {
position: absolute;
bottom: $spacing-1;
right: $spacing-1;
display: flex;
flex-direction: column;
gap: $spacing-1;
z-index: 100;
}

.preview-resource-links__actions {
position: absolute;
top: 0;
right: 0;
display: flex;
flex-direction: column;
gap: $spacing-0;
padding-top: $spacing-1;
display: none;
}

.preview-metadata__actions {
position: absolute;
bottom: $spacing-1;
right: 0;
display: none;
justify-content: flex-end;
align-items: center;
gap: $spacing-1;
z-index: 100;
}

.file-info__item {
display: flex;
padding: $spacing-0 0;
flex-direction: column;
justify-content: center;
align-items: flex-start;
gap: $spacing-0;

&:not(:last-child)::after {
content: "";
display: block;
width: 100%;
height: 1px;
background: $color-palette-gray-200;
margin: $spacing-1 0;
}
}

.file-info__link {
display: flex;
align-items: center;
gap: $spacing-1;
min-height: 32px;
font-size: $font-size-sm;
width: 100%;

a {
color: $black;
text-decoration: none;
flex: 1 0 0;
}
}

.file-info__title {
font-size: $font-size-sm;
font-style: normal;
font-weight: 600;
}

.file-info__size {
display: flex;
align-items: center;
gap: $spacing-0;
}

.preview-container--fade::after {
content: "";
background: linear-gradient(0deg, rgba(255, 255, 255, 1) 0%, rgba(255, 255, 255, 0) 100%);
position: absolute;
width: 100%;
height: 50%;
bottom: 0;
left: 0;
border-radius: $border-radius-md;
pointer-events: none;
}

@container preview (min-width: 500px) {
.preview-metadata__container,
.preview-metadata__actions {
display: flex;
}

.preview-metadata__action--responsive {
display: none;
}

.preview-image__container {
height: 100%;
max-width: 17.5rem;
}

.preview-resource-links__actions {
display: flex;
}

.preview-overlay__container {
display: none;
}
}
Loading
Loading