]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.html
Instance homepage support (#4007)
[github/Chocobozzz/PeerTube.git] / client / src / app / +admin / config / edit-custom-config / edit-custom-config.component.html
index fe9d856d050161c5756419129ccd54f06ec9d281..3ceea02ca7a0f825e9458d111253e641db4e4cd1 100644 (file)
+<h1 class="sr-only" i18n>Configuration</h1>
 <form role="form" [formGroup]="form">
 
-  <ngb-tabset class="root-tabset bootstrap">
+  <div ngbNav #nav="ngbNav" [activeId]="activeNav" (activeIdChange)="onNavChange($event)" class="nav-tabs">
 
-    <ngb-tab i18n-title title="Basic configuration">
-      <ng-template ngbTabContent>
-
-        <div i18n class="inner-form-title">Instance</div>
-
-        <ng-container formGroupName="instance">
-          <div class="form-group">
-            <label i18n for="instanceName">Name</label>
-            <input
-              type="text" id="instanceName"
-              formControlName="name" [ngClass]="{ 'input-error': formErrors.instance.name }"
-            >
-            <div *ngIf="formErrors.instance.name" class="form-error">{{ formErrors.instance.name }}</div>
-          </div>
-
-          <div class="form-group">
-            <label i18n for="instanceShortDescription">Short description</label>
-            <textarea
-              id="instanceShortDescription" formControlName="shortDescription"
-              [ngClass]="{ 'input-error': formErrors['instance.shortDescription'] }"
-            ></textarea>
-            <div *ngIf="formErrors.instance.shortDescription" class="form-error">{{ formErrors.instance.shortDescription }}</div>
-          </div>
-
-          <div class="form-group">
-            <label i18n for="instanceDescription">Description</label><my-help helpType="markdownText"></my-help>
-            <my-markdown-textarea
-              id="instanceDescription" formControlName="description" textareaWidth="500px" [previewColumn]="true"
-              [classes]="{ 'input-error': formErrors['instance.description'] }"
-            ></my-markdown-textarea>
-            <div *ngIf="formErrors.instance.description" class="form-error">{{ formErrors.instance.description }}</div>
-          </div>
-
-          <div class="form-group">
-            <label i18n for="instanceTerms">Terms</label><my-help helpType="markdownText"></my-help>
-            <my-markdown-textarea
-              id="instanceTerms" formControlName="terms" textareaWidth="500px" [previewColumn]="true"
-              [ngClass]="{ 'input-error': formErrors['instance.terms'] }"
-            ></my-markdown-textarea>
-            <div *ngIf="formErrors.instance.terms" class="form-error">{{ formErrors.instance.terms }}</div>
-          </div>
-
-          <div class="form-group">
-            <my-peertube-checkbox
-              inputName="instanceIsNSFW" formControlName="isNSFW"
-              i18n-labelText labelText="Dedicated to sensitive or NSFW content"
-              i18n-helpHtml helpHtml="Enabling it will allow other administrators to know that you are mainly federating sensitive content.<br /><br />
-              Moreover, the NSFW checkbox on video upload will be automatically checked by default."
-            ></my-peertube-checkbox>
-          </div>
-
-          <div class="form-group">
-            <label i18n for="instanceDefaultClientRoute">Default client route</label>
-            <div class="peertube-select-container">
-              <select id="instanceDefaultClientRoute" formControlName="defaultClientRoute">
-                <option i18n value="/videos/overview">Videos Overview</option>
-                <option i18n value="/videos/trending">Videos Trending</option>
-                <option i18n value="/videos/recently-added">Videos Recently Added</option>
-                <option i18n value="/videos/local">Local videos</option>
-              </select>
-            </div>
-            <div *ngIf="formErrors.instance.defaultClientRoute" class="form-error">{{ formErrors.instance.defaultClientRoute }}</div>
-          </div>
-
-          <div class="form-group">
-            <label i18n for="instanceDefaultNSFWPolicy">Policy on videos containing sensitive content</label>
-            <my-help
-              helpType="custom" i18n-customHtml
-              customHtml="With <strong>Do not list</strong> or <strong>Blur thumbnails</strong>, a confirmation will be requested to watch the video."
-            ></my-help>
-
-            <div class="peertube-select-container">
-              <select id="instanceDefaultNSFWPolicy" formControlName="defaultNSFWPolicy">
-                <option i18n value="do_not_list">Do not list</option>
-                <option i18n value="blur">Blur thumbnails</option>
-                <option i18n value="display">Display</option>
-              </select>
-            </div>
-            <div *ngIf="formErrors.instance.defaultNSFWPolicy" class="form-error">{{ formErrors.instance.defaultNSFWPolicy }}</div>
-          </div>
-        </ng-container>
-
-
-        <div i18n class="inner-form-title">Theme</div>
-
-        <ng-container formGroupName="theme">
-          <div class="form-group">
-            <label i18n for="themeDefault">Global theme</label>
-
-            <div class="peertube-select-container">
-              <select formControlName="default" id="themeDefault">
-                <option i18n value="default">default</option>
-
-                <option *ngFor="let theme of availableThemes" [value]="theme">{{ theme }}</option>
-              </select>
-            </div>
-          </div>
-        </ng-container>
-
-
-        <div i18n class="inner-form-title">Signup</div>
-
-        <ng-container formGroupName="signup">
-          <div class="form-group">
-            <my-peertube-checkbox
-              inputName="signupEnabled" formControlName="enabled"
-              i18n-labelText labelText="Signup enabled"
-            ></my-peertube-checkbox>
-          </div>
-
-          <div class="form-group">
-            <my-peertube-checkbox *ngIf="isSignupEnabled()"
-              inputName="signupRequiresEmailVerification" formControlName="requiresEmailVerification"
-              i18n-labelText labelText="Signup requires email verification"
-            ></my-peertube-checkbox>
-          </div>
-
-          <div *ngIf="isSignupEnabled()" class="form-group">
-            <label i18n for="signupLimit">Signup limit</label>
-            <input
-              type="text" id="signupLimit"
-              formControlName="limit" [ngClass]="{ 'input-error': formErrors['signup.limit'] }"
-            >
-            <div *ngIf="formErrors.signup.limit" class="form-error">{{ formErrors.signup.limit }}</div>
-          </div>
-        </ng-container>
-
-
-        <div i18n class="inner-form-title">Users</div>
-
-        <ng-container formGroupName="user">
-          <div class="form-group">
-            <label i18n for="userVideoQuota">User default video quota</label>
-            <div class="peertube-select-container">
-              <select id="userVideoQuota" formControlName="videoQuota">
-                <option *ngFor="let videoQuotaOption of videoQuotaOptions" [value]="videoQuotaOption.value">
-                  {{ videoQuotaOption.label }}
-                </option>
-              </select>
-            </div>
-            <div *ngIf="formErrors.user.videoQuota" class="form-error">{{ formErrors.user.videoQuota }}</div>
-          </div>
-
-          <div class="form-group">
-            <label i18n for="userVideoQuotaDaily">User default daily upload limit</label>
-            <div class="peertube-select-container">
-              <select id="userVideoQuotaDaily" formControlName="videoQuotaDaily">
-                <option *ngFor="let videoQuotaDailyOption of videoQuotaDailyOptions" [value]="videoQuotaDailyOption.value">
-                  {{ videoQuotaDailyOption.label }}
-                </option>
-              </select>
-            </div>
-            <div *ngIf="formErrors.user.videoQuotaDaily" class="form-error">{{ formErrors.user.videoQuotaDaily }}</div>
-          </div>
-        </ng-container>
-
-
-        <div i18n class="inner-form-title">Import</div>
-
-        <ng-container formGroupName="import">
-          <ng-container formGroupName="videos">
-
-            <div class="form-group" formGroupName="http">
-              <my-peertube-checkbox
-                inputName="importVideosHttpEnabled" formControlName="enabled"
-                i18n-labelText labelText="Video import with HTTP URL (i.e. YouTube) enabled"
-              ></my-peertube-checkbox>
-            </div>
-
-            <div class="form-group" formGroupName="torrent">
-              <my-peertube-checkbox
-                inputName="importVideosTorrentEnabled" formControlName="enabled"
-                i18n-labelText labelText="Video import with a torrent file or a magnet URI enabled"
-              ></my-peertube-checkbox>
-            </div>
-
-          </ng-container>
-        </ng-container>
-
-
-        <div i18n class="inner-form-title">Auto-blacklist</div>
-
-        <ng-container formGroupName="autoBlacklist">
-          <ng-container formGroupName="videos">
-            <ng-container formGroupName="ofUsers">
-
-              <div class="form-group">
-                <my-peertube-checkbox
-                  inputName="autoBlacklistVideosOfUsersEnabled" formControlName="enabled"
-                  i18n-labelText labelText="New videos of users automatically blacklisted enabled"
-                ></my-peertube-checkbox>
-              </div>
-
-            </ng-container>
-          </ng-container>
-        </ng-container>
-
-
-        <div i18n class="inner-form-title">Instance followers</div>
-
-        <ng-container formGroupName="followers">
-          <ng-container formGroupName="instance">
-
-            <div class="form-group">
-              <my-peertube-checkbox
-                inputName="followersInstanceEnabled" formControlName="enabled"
-                i18n-labelText labelText="Other instances can follow your instance"
-              ></my-peertube-checkbox>
-            </div>
-
-            <div class="form-group">
-              <my-peertube-checkbox
-                inputName="followersInstanceManualApproval" formControlName="manualApproval"
-                i18n-labelText labelText="Manually approve new instance follower"
-              ></my-peertube-checkbox>
-            </div>
-          </ng-container>
-        </ng-container>
-
-
-        <div i18n class="inner-form-title">Administrator</div>
-
-        <div class="form-group" formGroupName="admin">
-          <label i18n for="adminEmail">Admin email</label>
-          <input
-            type="text" id="adminEmail"
-            formControlName="email" [ngClass]="{ 'input-error': formErrors['admin.email'] }"
-          >
-          <div *ngIf="formErrors.admin.email" class="form-error">{{ formErrors.admin.email }}</div>
-        </div>
-
-        <div class="form-group" formGroupName="contactForm">
-          <my-peertube-checkbox
-            inputName="enableContactForm" formControlName="enabled"
-            i18n-labelText labelText="Enable contact form"
-          ></my-peertube-checkbox>
-        </div>
+    <ng-container ngbNavItem="instance-homepage">
+      <a ngbNavLink i18n>Homepage</a>
 
+      <ng-template ngbNavContent>
+        <my-edit-homepage [form]="form" [formErrors]="formErrors"></my-edit-homepage>
       </ng-template>
-    </ngb-tab>
-
-    <ngb-tab i18n-title title="Services">
-      <ng-template ngbTabContent>
-        <div i18n class="inner-form-title">Twitter</div>
+    </ng-container>
 
-        <ng-container formGroupName="services">
-          <ng-container formGroupName="twitter">
+    <ng-container ngbNavItem="instance-information">
+      <a ngbNavLink i18n>Information</a>
 
-            <div class="form-group">
-              <label i18n for="signupLimit">Your Twitter username</label>
-              <my-help
-                helpType="custom" i18n-customHtml
-                customHtml="Indicates the Twitter account for the website or platform on which the content was published."
-              ></my-help>
-              <input
-                type="text" id="servicesTwitterUsername"
-                formControlName="username" [ngClass]="{ 'input-error': formErrors['services.twitter.username'] }"
-              >
-              <div *ngIf="formErrors.services.twitter.username" class="form-error">{{ formErrors.services.twitter.username }}</div>
-            </div>
-
-            <div class="form-group">
-              <my-peertube-checkbox
-                inputName="servicesTwitterWhitelisted" formControlName="whitelisted"
-                i18n-labelText labelText="Instance whitelisted by Twitter"
-                i18n-helpHtml helpHtml="If your instance is whitelisted by Twitter, a video player will be embedded in the Twitter feed on PeerTube video share.<br />
-        If the instance is not whitelisted, we use an image link card that will redirect on your PeerTube instance.<br /><br />
-        Check this checkbox, save the configuration and test with a video URL of your instance (https://example.com/videos/watch/blabla) on <a target='_blank' rel='noopener noreferrer' href='https://cards-dev.twitter.com/validator'>https://cards-dev.twitter.com/validator</a> to see if you instance is whitelisted."
-              ></my-peertube-checkbox>
-            </div>
-
-          </ng-container>
-        </ng-container>
-
-    </ng-template>
-    </ngb-tab>
-
-    <ngb-tab i18n-title title="Advanced configuration">
-      <ng-template ngbTabContent>
-
-        <div i18n class="inner-form-title">Transcoding</div>
-
-        <ng-container formGroupName="transcoding">
-          <div class="form-group">
-            <my-peertube-checkbox
-              inputName="transcodingEnabled" formControlName="enabled"
-              i18n-labelText labelText="Transcoding enabled"
-              i18n-helpHtml helpHtml="If you disable transcoding, many videos from your users will not work!"
-            ></my-peertube-checkbox>
-          </div>
-
-          <ng-container *ngIf="isTranscodingEnabled()">
-
-            <div class="form-group">
-              <my-peertube-checkbox
-                inputName="transcodingAllowAdditionalExtensions" formControlName="allowAdditionalExtensions"
-                i18n-labelText labelText="Allow additional extensions"
-                i18n-helpHtml helpHtml="Allow your users to upload .mkv, .mov, .avi, .flv videos"
-              ></my-peertube-checkbox>
-            </div>
+      <ng-template ngbNavContent>
+        <my-edit-instance-information [form]="form" [formErrors]="formErrors" [languageItems]="languageItems" [categoryItems]="categoryItems">
+        </my-edit-instance-information>
+      </ng-template>
+    </ng-container>
 
-            <div class="form-group">
-              <my-peertube-checkbox
-                inputName="transcodingAllowAudioFiles" formControlName="allowAudioFiles"
-                i18n-labelText labelText="Allow audio files upload"
-                i18n-helpHtml helpHtml="Allow your users to upload audio files that will be merged with the preview file on upload"
-              ></my-peertube-checkbox>
-            </div>
+    <ng-container ngbNavItem="basic-configuration">
+      <a ngbNavLink i18n>Basic</a>
 
-            <div class="form-group">
-              <label i18n for="transcodingThreads">Transcoding threads</label>
-              <div class="peertube-select-container">
-                <select id="transcodingThreads" formControlName="threads">
-                  <option *ngFor="let transcodingThreadOption of transcodingThreadOptions" [value]="transcodingThreadOption.value">
-                    {{ transcodingThreadOption.label }}
-                  </option>
-                </select>
-              </div>
-              <div *ngIf="formErrors.transcoding.threads" class="form-error">{{ formErrors.transcoding.threads }}</div>
-            </div>
+      <ng-template ngbNavContent>
+        <my-edit-basic-configuration [form]="form" [formErrors]="formErrors" [serverConfig]="serverConfig">
+        </my-edit-basic-configuration>
+      </ng-template>
+    </ng-container>
 
-            <ng-container formGroupName="resolutions">
-              <div class="form-group" *ngFor="let resolution of resolutions">
-                <my-peertube-checkbox
-                  [inputName]="getResolutionKey(resolution.id)" [formControlName]="resolution.id"
-                  i18n-labelText labelText="Resolution {{resolution.label}} enabled"
-                ></my-peertube-checkbox>
-              </div>
-            </ng-container>
+    <ng-container ngbNavItem="transcoding">
+      <a ngbNavLink i18n>VOD Transcoding</a>
 
-          </ng-container>
-        </ng-container>
+      <ng-template ngbNavContent>
+        <my-edit-vod-transcoding [form]="form" [formErrors]="formErrors" [serverConfig]="serverConfig">
+        </my-edit-vod-transcoding>
+      </ng-template>
+    </ng-container>
 
-        <div i18n class="inner-form-title">
-          Cache
+    <ng-container ngbNavItem="live">
+      <a ngbNavLink i18n>Live streaming</a>
 
-          <my-help
-            helpType="custom" i18n-customHtml
-            customHtml="Some files are not federated (previews, captions). We fetch them directly from the origin instance and cache them."
-          ></my-help>
-        </div>
+      <ng-template ngbNavContent>
+        <my-edit-live-configuration [form]="form" [formErrors]="formErrors" [serverConfig]="serverConfig">
+        </my-edit-live-configuration>
+      </ng-template>
+    </ng-container>
 
-        <ng-container formGroupName="cache">
-          <div class="form-group" formGroupName="previews">
-            <label i18n for="cachePreviewsSize">Previews cache size</label>
-            <input
-              type="text" id="cachePreviewsSize"
-              formControlName="size" [ngClass]="{ 'input-error': formErrors['cache.previews.size'] }"
-            >
-            <div *ngIf="formErrors.cache.previews.size" class="form-error">{{ formErrors.cache.previews.size }}</div>
-          </div>
+    <ng-container ngbNavItem="advanced-configuration">
+      <a ngbNavLink i18n>Advanced</a>
 
-          <div class="form-group" formGroupName="captions">
-            <label i18n for="cacheCaptionsSize">Video captions cache size</label>
-            <input
-              type="text" id="cacheCaptionsSize"
-              formControlName="size" [ngClass]="{ 'input-error': formErrors['cache.captions.size'] }"
-            >
-            <div *ngIf="formErrors.cache.captions.size" class="form-error">{{ formErrors.cache.captions.size }}</div>
-          </div>
-        </ng-container>
+      <ng-template ngbNavContent>
+        <my-edit-advanced-configuration [form]="form" [formErrors]="formErrors">
+        </my-edit-advanced-configuration>
+      </ng-template>
+    </ng-container>
+  </div>
 
-        <div i18n class="inner-form-title">Customizations</div>
+  <div [ngbNavOutlet]="nav"></div>
 
-        <ng-container formGroupName="instance">
-          <ng-container formGroupName="customizations">
-            <div class="form-group">
-              <label i18n for="customizationJavascript">JavaScript</label>
-              <my-help
-                helpType="custom" i18n-customHtml
-                customHtml="Write directly JavaScript code.<br />Example: <pre>console.log('my instance is amazing');</pre>"
-              ></my-help>
-              <textarea
-                id="customizationJavascript" formControlName="javascript"
-                [ngClass]="{ 'input-error': formErrors['instance.customizations.javascript'] }"
-              ></textarea>
-              <div *ngIf="formErrors.instance.customizations.javascript" class="form-error">{{ formErrors.instance.customizations.javascript }}</div>
-            </div>
+  <div class="form-row mt-4"> <!-- submit placement block -->
+    <div class="col-md-7 col-xl-5"></div>
+    <div class="col-md-5 col-xl-5">
 
-            <div class="form-group">
-              <label for="customizationCSS">CSS</label>
-              <my-help
-                  helpType="custom"
-                  i18n-customHtml
-                  customHtml="
-                    Write directly CSS code. Example:<br /><br />
-                    <pre>
-  #custom-css {{ '{' }}
-    color: red;
-  {{ '}' }}
-                    </pre>
+      <div class="form-error submit-error" i18n *ngIf="!form.valid">
+        There are errors in the form:
 
-                    Prepend with <em>#custom-css</em> to override styles. Example:<br /><br />
-                    <pre>
-  #custom-css .logged-in-email {{ '{' }}
-    color: red;
-  {{ '}' }}
-                    </pre>
-                  "
-              ></my-help>
-              <textarea
-                id="customizationCSS" formControlName="css"
-                [ngClass]="{ 'input-error': formErrors['instance.customizations.css'] }"
-              ></textarea>
-              <div *ngIf="formErrors.instance.customizations.css" class="form-error">{{ formErrors.instance.customizations.css }}</div>
-            </div>
-          </ng-container>
-        </ng-container>
+        <ul>
+          <li *ngFor="let error of grabAllErrors()">
+            {{ error }}
+          </li>
+        </ul>
+      </div>
 
-      </ng-template>
-    </ngb-tab>
-  </ngb-tabset>
+      <span class="form-error submit-error" i18n *ngIf="!hasLiveAllowReplayConsistentOptions()">
+        You cannot allow live replay if you don't enable transcoding.
+      </span>
 
-  <input (click)="formValidated()" type="submit" i18n-value value="Update configuration" [disabled]="!form.valid">
-  <span class="form-error" i18n *ngIf="!form.valid">It seems the configuration is invalid. Please search potential errors in the different tabs.</span>
+      <input (click)="formValidated()" type="submit" i18n-value value="Update configuration" [disabled]="!form.valid || !hasConsistentOptions()">
+    </div>
+  </div>
 </form>