Skip to content

Commit

Permalink
Improve caption edition
Browse files Browse the repository at this point in the history
  • Loading branch information
Chocobozzz committed Sep 19, 2024
1 parent 25639d0 commit d594ee6
Show file tree
Hide file tree
Showing 33 changed files with 739 additions and 281 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
@use '_variables' as *;
@use '_mixins' as *;

my-timestamp-input {
display: block;
width: 85px;
}

.grid-container {
display: grid;
grid-template-columns: auto 1fr;
Expand Down Expand Up @@ -88,10 +93,6 @@ h2 {
}
}

my-timestamp-input {
display: block;
}

my-embed {
display: block;
max-width: 500px;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import { FormReactive } from '@app/shared/shared-forms/form-reactive'
import { FormReactiveService } from '@app/shared/shared-forms/form-reactive.service'
import { NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap'
import { HTMLServerConfig, VideoConstant } from '@peertube/peertube-models'
import { ReactiveFileComponent } from '../../../shared/shared-forms/reactive-file.component'
import { ReactiveFileComponent } from '../../../../shared/shared-forms/reactive-file.component'
import { NgIf } from '@angular/common'
import { NgSelectModule } from '@ng-select/ng-select'
import { GlobalIconComponent } from '../../../shared/shared-icons/global-icon.component'
import { GlobalIconComponent } from '../../../../shared/shared-icons/global-icon.component'
import { FormsModule, ReactiveFormsModule } from '@angular/forms'
import { VideoCaptionEdit } from '@app/shared/shared-main/video-caption/video-caption-edit.model'

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
<div class="modal-header">
<h4 i18n class="modal-title">Edit caption "{{ videoCaption.language.label }}"</h4>

<button class="border-0 p-0" title="Close this modal" i18n-title (click)="hide()">
<my-global-icon iconName="cross"></my-global-icon>
</button>
</div>

<div class="modal-body">

<div class="row">

<my-embed *ngIf="publishedVideo" #embed class="col-md-12 col-xl-6 mb-3" [video]="publishedVideo" enableAPI="true"></my-embed>

<div [ngClass]="publishedVideo ? 'col-xl-6 col-md-12' : ''">

<div class="d-flex justify-content-between align-items-center mb-3 ms-2">
<my-peertube-checkbox
inputName="raw-edition"
[(ngModel)]="rawEdition" (ngModelChange)="onRawEditionSwitch()"
i18n-labelText labelText="Raw edition"
></my-peertube-checkbox>

<my-button *ngIf="!rawEdition && !segmentToUpdate" i18n-label label="Add a new segment" (click)="addSegmentToEdit()">
</my-button>
</div>

<div [hidden]="!rawEdition" [formGroup]="form">
<textarea
id="captionFileContent"
formControlName="captionFileContent"
i18n-label aria-label="Caption raw content"
class="form-control caption-raw-textarea fs-7"
[ngClass]="{ 'input-error': formErrors['captionFileContent'] }"
#textarea
>
</textarea>

<div *ngIf="formErrors.captionFileContent" class="form-error" role="alert">
{{ formErrors.captionFileContent }}
</div>
</div>

<div class="text-start segments pe-2 ps-2" [hidden]="rawEdition">
<div class="pt-1 pb-1 mb-3" *ngFor="let segment of segments">
@if (segmentToUpdate === segment) {
<div role="form">
<div class="d-flex flex-wrap ">
<div>
<label class="visually-hidden" i18n for="segmentStart">Segment start timestamp</label>

<my-timestamp-input
class="me-1"
inputName="segmentStart" [disableBorder]="false" [maxTimestamp]="publishedVideo.duration * 1000" mask="99:99:99.999"
[(ngModel)]="segment.startMs" [parser]="timestampParser" [formatter]="timestampFormatter"
></my-timestamp-input>

<my-button *ngIf="publishedVideo" icon="clock-arrow-down" i18n-title title="Use video current time as start time" (click)="videoTimeForSegmentStart(segment)">
</my-button>
</div>

<my-global-icon class="d-inline-block ms-2 me-2" iconName="move-right"></my-global-icon>

<div>
<label class="visually-hidden" i18n for="segmentEnd">Segment end timestamp</label>

<my-timestamp-input
class="me-1"
inputName="segmentEnd" [disableBorder]="false" [maxTimestamp]="publishedVideo.duration * 1000" mask="99:99:99.999"
[(ngModel)]="segment.endMs" [parser]="timestampParser" [formatter]="timestampFormatter"
></my-timestamp-input>

<my-button *ngIf="publishedVideo" icon="clock-arrow-down" i18n-title title="Use video current time as end time" (click)="videoTimeForSegmentEnd(segment)">
</my-button>
</div>
</div>

<div class="d-flex mt-2">
<div class="form-group w-100">
<label class="visually-hidden" i18n for="segment-edition">Segment end timestamp</label>

<textarea id="segment-edition" name="segment-edition" class="form-control fs-7" [(ngModel)]="segment.text"></textarea>

<div *ngIf="segmentEditionError" class="form-error" role="alert">{{ segmentEditionError }}</div>
</div>

<div class="d-flex flex-column ms-3">
<my-button i18n-title title="Save" icon="tick" (click)="onEditionSaved(segment)"></my-button>
<my-button class="mt-3" i18n-title title="Revert" icon="undo" (click)="onEditionCanceled(segment)"></my-button>
</div>
</div>
</div>
} @else {
<div class="d-flex">
<div
class="flex-grow-1 segment-text ps-1 pe-1" role="button" tabindex="0" i18n-title title="Jump to this segment"
(keyup.enter)="onSegmentClick($event, segment)" (click)="onSegmentClick($event, segment)"
[ngClass]="getSegmentClasses(segment)"
>
<strong class="segment-start me-2 d-block">{{ segment.startFormatted }} -> {{ segment.endFormatted }}</strong>
<span class="segment-text fs-7" [innerHTML]="segment.text | nl2br"></span>
</div>

<div class="d-flex flex-column ms-3" [ngClass]="{ 'opacity-0': !!segmentToUpdate }">
<my-edit-button i18n-title title="Edit this segment" (click)="updateSegment(segment)"></my-edit-button>
<my-delete-button class="mt-1" i18n-title title="Delete this segment" (click)="deleteSegment(segment)"></my-delete-button>
</div>
</div>
}
</div>
</div>
</div>
</div>
</div>

<div class="modal-footer inputs">
<input
type="button" role="button" i18n-value value="Cancel" class="peertube-button grey-button"
(click)="hide()" (key.enter)="hide()"
>

<input
type="button" i18n-value value="Edit this caption" class="peertube-button orange-button"
[disabled]="rawEdition && !form.valid" (click)="updateCaption()"
>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
@use '_variables' as *;
@use '_mixins' as *;

.caption-raw-textarea,
.segments {
min-height: 50vh;
max-height: 50vh;

overflow: auto;
}

.segments textarea {
min-height: 100px;
}

.segment-text {
&.active,
&:hover {
background: pvar(--mainBackgroundHoverColor);
}
}

my-timestamp-input {
width: 100px;
display: inline-block;
}
Loading

0 comments on commit d594ee6

Please sign in to comment.