-
Notifications
You must be signed in to change notification settings - Fork 22
chore(files): api #90
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/app/features/project/contributors/models/contributor-response.model.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
122 changes: 122 additions & 0 deletions
122
...roject/files/components/file-detail/components/file-metadata/file-metadata.component.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,122 @@ | ||
| <div class="metadata p-4 flex flex-column gap-3"> | ||
| <div class="flex justify-content-between"> | ||
| <h2>{{ 'project.files.detail.fileMetadata.title' | translate }}</h2> | ||
|
|
||
| <div class="flex gap-2"> | ||
| <p-button severity="secondary"><i class="osf-icon-download p-1"></i></p-button> | ||
| <p-button severity="secondary" (click)="editFileMetadataVisible = true">{{ | ||
| 'project.files.detail.fileMetadata.edit' | translate | ||
| }}</p-button> | ||
| </div> | ||
| </div> | ||
|
|
||
| <div class="flex flex-column gap-2"> | ||
| <h3>{{ 'project.files.detail.fileMetadata.fields.title' | translate }}</h3> | ||
|
|
||
| @if (fileMetadata().isLoading) { | ||
| <p-skeleton width="3rem" height="19px"></p-skeleton> | ||
| } @else { | ||
| <span>{{ fileMetadata().data?.title }}</span> | ||
| } | ||
| </div> | ||
|
|
||
| @if (fileMetadata().data?.description) { | ||
| <div class="flex flex-column gap-2"> | ||
| <h3>{{ 'project.files.detail.fileMetadata.fields.description' | translate }}</h3> | ||
|
|
||
| @if (fileMetadata().isLoading) { | ||
| <p-skeleton width="6rem" height="19px"></p-skeleton> | ||
| } @else { | ||
| <div> | ||
| {{ fileMetadata().data?.description }} | ||
| </div> | ||
| } | ||
| </div> | ||
| } | ||
|
|
||
| @if (fileMetadata().data?.resourceTypeGeneral) { | ||
| <div class="flex flex-column gap-2"> | ||
| <h3>{{ 'project.files.detail.fileMetadata.fields.resourceType' | translate }}</h3> | ||
|
|
||
| @if (fileMetadata().isLoading) { | ||
| <p-skeleton width="7.5rem" height="19px"></p-skeleton> | ||
| } @else { | ||
| <div> | ||
| <span>{{ fileMetadata().data?.resourceTypeGeneral }}</span> | ||
| </div> | ||
| } | ||
| </div> | ||
| } | ||
|
|
||
| @if (fileMetadata().data?.language) { | ||
| <div class="flex flex-column gap-2"> | ||
| <h3>{{ 'project.files.detail.fileMetadata.fields.resourceLanguage' | translate }}</h3> | ||
|
|
||
| @if (fileMetadata().isLoading) { | ||
| <p-skeleton width="10rem" height="19px"></p-skeleton> | ||
| } @else { | ||
| <div> | ||
| <span>{{ fileMetadata().data?.language }}</span> | ||
| </div> | ||
| } | ||
| </div> | ||
| } | ||
| </div> | ||
|
|
||
| <p-dialog | ||
| [header]="'project.files.detail.fileMetadata.edit' | translate" | ||
| [modal]="true" | ||
| [(visible)]="editFileMetadataVisible" | ||
| [style]="{ width: '25rem' }" | ||
| > | ||
| <form [formGroup]="fileMetadataForm" (ngSubmit)="setFileMetadata()" class="flex flex-column gap-3"> | ||
| <div class="flex flex-column gap-1"> | ||
| <p>{{ 'project.files.detail.fileMetadata.fields.title' | translate }}</p> | ||
| <input pInputText id="title" [formControl]="titleControl" /> | ||
| </div> | ||
| <div class="flex flex-column gap-1"> | ||
| <p>{{ 'project.files.detail.fileMetadata.fields.description' | translate }}</p> | ||
| <input pInputText id="description" [formControl]="descriptionControl" /> | ||
| </div> | ||
| <div class="flex flex-column gap-1"> | ||
| <p>{{ 'project.files.detail.fileMetadata.fields.resourceType' | translate }}</p> | ||
| <p-select | ||
| class="w-full" | ||
| [options]="resourceTypes" | ||
| optionValue="value" | ||
| optionLabel="value" | ||
| appendTo="body" | ||
| [formControl]="resourceTypeControl" | ||
| [showClear]="true" | ||
| ></p-select> | ||
| </div> | ||
| <div class="flex flex-column gap-1"> | ||
| <p>{{ 'project.files.detail.fileMetadata.fields.resourceLanguage' | translate }}</p> | ||
| <p-select | ||
| class="w-full" | ||
| [options]="languages" | ||
| optionValue="value" | ||
| optionLabel="label" | ||
| appendTo="body" | ||
| [formControl]="resourceLanguageControl" | ||
| [showClear]="true" | ||
| ></p-select> | ||
| </div> | ||
|
|
||
| <div class="flex btn-full-width gap-2"> | ||
| <p-button | ||
| [label]="'common.buttons.cancel' | translate" | ||
| severity="info" | ||
| class="w-full" | ||
| (click)="editFileMetadataVisible = false" | ||
| type="button" | ||
| /> | ||
| <p-button | ||
| [label]="'common.buttons.save' | translate" | ||
| class="w-full" | ||
| type="submit" | ||
| [disabled]="!fileMetadataForm.valid" | ||
| /> | ||
| </div> | ||
| </form> | ||
| </p-dialog> |
1 change: 1 addition & 0 deletions
1
...roject/files/components/file-detail/components/file-metadata/file-metadata.component.scss
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| @use "../../file-detail.component.scss"; |
94 changes: 94 additions & 0 deletions
94
.../project/files/components/file-detail/components/file-metadata/file-metadata.component.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,94 @@ | ||
| import { select, Store } from '@ngxs/store'; | ||
|
|
||
| import { TranslateModule } from '@ngx-translate/core'; | ||
|
|
||
| import { Button } from 'primeng/button'; | ||
| import { Dialog } from 'primeng/dialog'; | ||
| import { InputText } from 'primeng/inputtext'; | ||
| import { Select } from 'primeng/select'; | ||
| import { Skeleton } from 'primeng/skeleton'; | ||
|
|
||
| import { ChangeDetectionStrategy, Component, DestroyRef, inject } from '@angular/core'; | ||
| import { takeUntilDestroyed, toObservable } from '@angular/core/rxjs-interop'; | ||
| import { FormBuilder, FormControl, FormGroup, FormsModule, ReactiveFormsModule } from '@angular/forms'; | ||
|
|
||
| import { ProjectFilesSelectors, SetFileMetadata } from '@osf/features/project/files/store'; | ||
|
|
||
| import { LANGUAGES, RESOURCE_TYPES } from '../../constants/files-details.constants'; | ||
|
|
||
| @Component({ | ||
| selector: 'osf-file-metadata', | ||
| standalone: true, | ||
| imports: [Button, Dialog, InputText, Select, FormsModule, ReactiveFormsModule, Skeleton, TranslateModule], | ||
| templateUrl: './file-metadata.component.html', | ||
| styleUrl: './file-metadata.component.scss', | ||
| changeDetection: ChangeDetectionStrategy.OnPush, | ||
| }) | ||
| export class FileMetadataComponent { | ||
| readonly store = inject(Store); | ||
| readonly destroyRef = inject(DestroyRef); | ||
| readonly fb = inject(FormBuilder); | ||
|
|
||
| fileMetadata = select(ProjectFilesSelectors.getFileCustomMetadata); | ||
| isIframeLoading = true; | ||
| editFileMetadataVisible = false; | ||
|
|
||
| fileMetadataForm = new FormGroup({ | ||
| title: new FormControl<string | null>(null), | ||
| description: new FormControl<string | null>(null), | ||
| resourceType: new FormControl<string | null>(null), | ||
| resourceLanguage: new FormControl<string | null>(null), | ||
| }); | ||
|
|
||
| protected readonly resourceTypes = RESOURCE_TYPES; | ||
| protected readonly languages = LANGUAGES; | ||
|
|
||
| get titleControl(): FormControl<string | null> { | ||
| return this.fileMetadataForm.get('title') as FormControl<string | null>; | ||
| } | ||
|
|
||
| get descriptionControl(): FormControl<string | null> { | ||
| return this.fileMetadataForm.get('description') as FormControl<string | null>; | ||
| } | ||
|
|
||
| get resourceTypeControl(): FormControl<string | null> { | ||
| return this.fileMetadataForm.get('resourceType') as FormControl<string | null>; | ||
| } | ||
|
|
||
| get resourceLanguageControl(): FormControl<string | null> { | ||
| return this.fileMetadataForm.get('resourceLanguage') as FormControl<string | null>; | ||
| } | ||
|
|
||
| constructor() { | ||
| toObservable(this.fileMetadata) | ||
| .pipe(takeUntilDestroyed(this.destroyRef)) | ||
| .subscribe((metadata) => { | ||
| if (metadata.data) { | ||
| this.fileMetadataForm.patchValue({ | ||
| title: metadata.data.title, | ||
| description: metadata.data.description, | ||
| resourceType: metadata.data.resourceTypeGeneral, | ||
| resourceLanguage: metadata.data.language, | ||
| }); | ||
| } | ||
| }); | ||
| } | ||
|
|
||
| setFileMetadata() { | ||
| if (this.fileMetadataForm.valid) { | ||
| const formValues = { | ||
| title: this.fileMetadataForm.get('title')?.value ?? null, | ||
| description: this.fileMetadataForm.get('description')?.value ?? null, | ||
| resource_type_general: this.fileMetadataForm.get('resourceType')?.value ?? null, | ||
| language: this.fileMetadataForm.get('resourceLanguage')?.value ?? null, | ||
| }; | ||
|
|
||
| const fileId = this.fileMetadata().data?.id; | ||
| if (fileId) { | ||
| this.store.dispatch(new SetFileMetadata(formValues, fileId)); | ||
| } | ||
|
|
||
| this.editFileMetadataVisible = false; | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you change it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need file's guid on this page, not id, it's different file properties