Chocobozzz/PeerTube

View on GitHub
client/src/app/+videos/+video-edit/video-add-components/video-import-url.component.html

Summary

Maintainability
Test Coverage
<div *ngIf="!hasImportedVideo" class="upload-video-container">
  <div class="first-step-block">
    <my-global-icon class="upload-icon" iconName="upload" aria-hidden="true"></my-global-icon>

    <div class="form-group">
      <label i18n for="targetUrl">URL</label>

      <my-help>
        <ng-template ptTemplate="customHtml">
          <ng-container i18n>
            You can import any URL <a href='https://rg3.github.io/youtube-dl/supportedsites.html' target='_blank' rel='noopener noreferrer'>supported by youtube-dl</a>
            or URL that points to a media file.
            You should make sure you have diffusion rights over the content it points to, otherwise it could cause legal trouble to yourself and your instance.
          </ng-container>
        </ng-template>
      </my-help>

      <input type="text" id="targetUrl" [(ngModel)]="targetUrl" class="form-control" />

      <div *ngIf="isChannelSyncEnabled()" class="form-group-description" i18n>
        You can also synchronize a remote channel in <a class="text-decoration-underline" routerLink="/my-library/video-channel-syncs">your library</a>
      </div>
    </div>

    <div class="form-group">
      <label i18n for="first-step-channel">Channel</label>
      <my-select-channel inputId="first-step-channel" [items]="userVideoChannels" [(ngModel)]="firstStepChannelId"></my-select-channel>
    </div>

    <div class="form-group">
      <label i18n for="first-step-privacy">Privacy</label>
      <my-select-options inputId="first-step-privacy" [items]="videoPrivacies" [(ngModel)]="firstStepPrivacyId"></my-select-options>
    </div>

    <input
      type="button" i18n-value value="Import"
      [disabled]="!isTargetUrlValid() || isImportingVideo" (click)="importVideo()"
    />
  </div>
</div>


<my-alert *ngIf="error" type="danger">
  <div i18n>Sorry, but something went wrong</div>

  {{ error }}
</my-alert>

<my-alert type="primary" *ngIf="!error && hasImportedVideo" i18n>
  Congratulations, the video behind {{ targetUrl }} will be imported! You can already add information about this video.
</my-alert>

<!-- Hidden because we want to load the component -->
<form [hidden]="!hasImportedVideo" novalidate [formGroup]="form">
  <my-video-edit
    #videoEdit
    [form]="form" [formErrors]="formErrors" [videoCaptions]="videoCaptions"
    [validationMessages]="validationMessages" [userVideoChannels]="userVideoChannels"
    forbidScheduledPublication="true"
    type="import-url"
  ></my-video-edit>

  <div class="submit-container">
    <my-button
      theme="orange" i18n-label label="Update" icon="circle-tick" (click)="updateSecondStep()"
      [disabled]="!form.valid || isUpdatingVideo === true"
    ></my-button>
  </div>
</form>