Add ability to set a custom quota
This commit is contained in:
parent
ead64cdf8d
commit
21e493d4d8
|
@ -402,25 +402,29 @@
|
||||||
<ng-container formGroupName="user">
|
<ng-container formGroupName="user">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label i18n for="userVideoQuota">Default video quota per user</label>
|
<label i18n for="userVideoQuota">Default video quota per user</label>
|
||||||
<div class="peertube-select-container">
|
|
||||||
<select id="userVideoQuota" formControlName="videoQuota" class="form-control">
|
<my-select-custom-value
|
||||||
<option *ngFor="let videoQuotaOption of videoQuotaOptions" [value]="videoQuotaOption.value" [disabled]="videoQuotaOption.disabled">
|
id="userVideoQuota"
|
||||||
{{ videoQuotaOption.label }}
|
[items]="videoQuotaOptions"
|
||||||
</option>
|
formControlName="videoQuota"
|
||||||
</select>
|
i18n-inputSuffix inputSuffix="bytes" inputType="number"
|
||||||
</div>
|
[clearable]="false"
|
||||||
|
></my-select-custom-value>
|
||||||
|
|
||||||
<div *ngIf="formErrors.user.videoQuota" class="form-error">{{ formErrors.user.videoQuota }}</div>
|
<div *ngIf="formErrors.user.videoQuota" class="form-error">{{ formErrors.user.videoQuota }}</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label i18n for="userVideoQuotaDaily">Default daily upload limit per user</label>
|
<label i18n for="userVideoQuotaDaily">Default daily upload limit per user</label>
|
||||||
<div class="peertube-select-container">
|
|
||||||
<select id="userVideoQuotaDaily" formControlName="videoQuotaDaily" class="form-control">
|
<my-select-custom-value
|
||||||
<option *ngFor="let videoQuotaDailyOption of videoQuotaDailyOptions" [value]="videoQuotaDailyOption.value" [disabled]="videoQuotaDailyOption.disabled">
|
id="userVideoQuotaDaily"
|
||||||
{{ videoQuotaDailyOption.label }}
|
[items]="videoQuotaDailyOptions"
|
||||||
</option>
|
formControlName="videoQuotaDaily"
|
||||||
</select>
|
i18n-inputSuffix inputSuffix="bytes" inputType="number"
|
||||||
</div>
|
[clearable]="false"
|
||||||
|
></my-select-custom-value>
|
||||||
|
|
||||||
<div *ngIf="formErrors.user.videoQuotaDaily" class="form-error">{{ formErrors.user.videoQuotaDaily }}</div>
|
<div *ngIf="formErrors.user.videoQuotaDaily" class="form-error">{{ formErrors.user.videoQuotaDaily }}</div>
|
||||||
</div>
|
</div>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
|
@ -19,9 +19,10 @@ import {
|
||||||
TRANSCODING_THREADS_VALIDATOR
|
TRANSCODING_THREADS_VALIDATOR
|
||||||
} from '@app/shared/form-validators/custom-config-validators'
|
} from '@app/shared/form-validators/custom-config-validators'
|
||||||
import { USER_VIDEO_QUOTA_DAILY_VALIDATOR, USER_VIDEO_QUOTA_VALIDATOR } from '@app/shared/form-validators/user-validators'
|
import { USER_VIDEO_QUOTA_DAILY_VALIDATOR, USER_VIDEO_QUOTA_VALIDATOR } from '@app/shared/form-validators/user-validators'
|
||||||
import { FormReactive, FormValidatorService, SelectOptionsItem } from '@app/shared/shared-forms'
|
import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
|
||||||
import { NgbNav } from '@ng-bootstrap/ng-bootstrap'
|
import { NgbNav } from '@ng-bootstrap/ng-bootstrap'
|
||||||
import { CustomConfig, ServerConfig } from '@shared/models'
|
import { CustomConfig, ServerConfig } from '@shared/models'
|
||||||
|
import { SelectOptionsItem } from 'src/types/select-options-item.model'
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'my-edit-custom-config',
|
selector: 'my-edit-custom-config',
|
||||||
|
|
|
@ -3,43 +3,46 @@ import { HttpClient } from '@angular/common/http'
|
||||||
import { Injectable } from '@angular/core'
|
import { Injectable } from '@angular/core'
|
||||||
import { RestExtractor } from '@app/core'
|
import { RestExtractor } from '@app/core'
|
||||||
import { CustomConfig } from '@shared/models'
|
import { CustomConfig } from '@shared/models'
|
||||||
|
import { SelectOptionsItem } from '../../../../types/select-options-item.model'
|
||||||
import { environment } from '../../../../environments/environment'
|
import { environment } from '../../../../environments/environment'
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class ConfigService {
|
export class ConfigService {
|
||||||
private static BASE_APPLICATION_URL = environment.apiUrl + '/api/v1/config'
|
private static BASE_APPLICATION_URL = environment.apiUrl + '/api/v1/config'
|
||||||
|
|
||||||
videoQuotaOptions: { value: number, label: string, disabled?: boolean }[] = []
|
videoQuotaOptions: SelectOptionsItem[] = []
|
||||||
videoQuotaDailyOptions: { value: number, label: string, disabled?: boolean }[] = []
|
videoQuotaDailyOptions: SelectOptionsItem[] = []
|
||||||
|
|
||||||
constructor (
|
constructor (
|
||||||
private authHttp: HttpClient,
|
private authHttp: HttpClient,
|
||||||
private restExtractor: RestExtractor
|
private restExtractor: RestExtractor
|
||||||
) {
|
) {
|
||||||
this.videoQuotaOptions = [
|
this.videoQuotaOptions = [
|
||||||
{ value: undefined, label: 'Default quota', disabled: true },
|
{ id: -1, label: $localize`Unlimited` },
|
||||||
{ value: -1, label: $localize`Unlimited` },
|
{ id: 0, label: $localize`None - no upload possible` },
|
||||||
{ value: undefined, label: '─────', disabled: true },
|
{ id: 100 * 1024 * 1024, label: $localize`100MB` },
|
||||||
{ value: 0, label: $localize`None - no upload possible` },
|
{ id: 500 * 1024 * 1024, label: $localize`500MB` },
|
||||||
{ value: 100 * 1024 * 1024, label: $localize`100MB` },
|
{ id: 1024 * 1024 * 1024, label: $localize`1GB` },
|
||||||
{ value: 500 * 1024 * 1024, label: $localize`500MB` },
|
{ id: 5 * 1024 * 1024 * 1024, label: $localize`5GB` },
|
||||||
{ value: 1024 * 1024 * 1024, label: $localize`1GB` },
|
{ id: 20 * 1024 * 1024 * 1024, label: $localize`20GB` },
|
||||||
{ value: 5 * 1024 * 1024 * 1024, label: $localize`5GB` },
|
{ id: 50 * 1024 * 1024 * 1024, label: $localize`50GB` },
|
||||||
{ value: 20 * 1024 * 1024 * 1024, label: $localize`20GB` },
|
{ id: 100 * 1024 * 1024 * 1024, label: $localize`100GB` },
|
||||||
{ value: 50 * 1024 * 1024 * 1024, label: $localize`50GB` }
|
{ id: 200 * 1024 * 1024 * 1024, label: $localize`200GB` },
|
||||||
|
{ id: 500 * 1024 * 1024 * 1024, label: $localize`500GB` }
|
||||||
]
|
]
|
||||||
|
|
||||||
this.videoQuotaDailyOptions = [
|
this.videoQuotaDailyOptions = [
|
||||||
{ value: undefined, label: 'Default daily upload limit', disabled: true },
|
{ id: -1, label: $localize`Unlimited` },
|
||||||
{ value: -1, label: $localize`Unlimited` },
|
{ id: 0, label: $localize`None - no upload possible` },
|
||||||
{ value: undefined, label: '─────', disabled: true },
|
{ id: 10 * 1024 * 1024, label: $localize`10MB` },
|
||||||
{ value: 0, label: $localize`None - no upload possible` },
|
{ id: 50 * 1024 * 1024, label: $localize`50MB` },
|
||||||
{ value: 10 * 1024 * 1024, label: $localize`10MB` },
|
{ id: 100 * 1024 * 1024, label: $localize`100MB` },
|
||||||
{ value: 50 * 1024 * 1024, label: $localize`50MB` },
|
{ id: 500 * 1024 * 1024, label: $localize`500MB` },
|
||||||
{ value: 100 * 1024 * 1024, label: $localize`100MB` },
|
{ id: 2 * 1024 * 1024 * 1024, label: $localize`2GB` },
|
||||||
{ value: 500 * 1024 * 1024, label: $localize`500MB` },
|
{ id: 5 * 1024 * 1024 * 1024, label: $localize`5GB` },
|
||||||
{ value: 2 * 1024 * 1024 * 1024, label: $localize`2GB` },
|
{ id: 10 * 1024 * 1024 * 1024, label: $localize`10GB` },
|
||||||
{ value: 5 * 1024 * 1024 * 1024, label: $localize`5GB` }
|
{ id: 20 * 1024 * 1024 * 1024, label: $localize`20GB` },
|
||||||
|
{ id: 50 * 1024 * 1024 * 1024, label: $localize`50GB` }
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,8 +45,8 @@ export class UserCreateComponent extends UserEdit implements OnInit {
|
||||||
|
|
||||||
const defaultValues = {
|
const defaultValues = {
|
||||||
role: UserRole.USER.toString(),
|
role: UserRole.USER.toString(),
|
||||||
videoQuota: '-1',
|
videoQuota: -1,
|
||||||
videoQuotaDaily: '-1'
|
videoQuotaDaily: -1
|
||||||
}
|
}
|
||||||
|
|
||||||
this.buildForm({
|
this.buildForm({
|
||||||
|
|
|
@ -149,28 +149,38 @@
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label i18n for="videoQuota">Video quota</label>
|
<label i18n for="videoQuota">Video quota</label>
|
||||||
<div class="peertube-select-container">
|
|
||||||
<select id="videoQuota" formControlName="videoQuota" class="form-control">
|
<my-select-custom-value
|
||||||
<option *ngFor="let videoQuotaOption of videoQuotaOptions" [value]="videoQuotaOption.value" [disabled]="videoQuotaOption.disabled">
|
id="videoQuota"
|
||||||
{{ videoQuotaOption.label }}
|
[items]="videoQuotaOptions"
|
||||||
</option>
|
formControlName="videoQuota"
|
||||||
</select>
|
i18n-inputSuffix inputSuffix="bytes" inputType="number"
|
||||||
</div>
|
[clearable]="false"
|
||||||
|
></my-select-custom-value>
|
||||||
|
|
||||||
<div i18n class="transcoding-information" *ngIf="isTranscodingInformationDisplayed()">
|
<div i18n class="transcoding-information" *ngIf="isTranscodingInformationDisplayed()">
|
||||||
Transcoding is enabled. The video quota only takes into account <strong>original</strong> video size. <br />
|
Transcoding is enabled. The video quota only takes into account <strong>original</strong> video size. <br />
|
||||||
At most, this user could upload ~ {{ computeQuotaWithTranscoding() | bytes: 0 }}.
|
At most, this user could upload ~ {{ computeQuotaWithTranscoding() | bytes: 0 }}.
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div *ngIf="formErrors.videoQuota" class="form-error">
|
||||||
|
{{ formErrors.videoQuota }}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label i18n for="videoQuotaDaily">Daily video quota</label>
|
<label i18n for="videoQuotaDaily">Daily video quota</label>
|
||||||
<div class="peertube-select-container">
|
|
||||||
<select id="videoQuotaDaily" formControlName="videoQuotaDaily" class="form-control">
|
<my-select-custom-value
|
||||||
<option *ngFor="let videoQuotaDailyOption of videoQuotaDailyOptions" [value]="videoQuotaDailyOption.value" [disabled]="videoQuotaDailyOption.disabled">
|
id="videoQuotaDaily"
|
||||||
{{ videoQuotaDailyOption.label }}
|
[items]="videoQuotaDailyOptions"
|
||||||
</option>
|
formControlName="videoQuotaDaily"
|
||||||
</select>
|
i18n-inputSuffix inputSuffix="bytes" inputType="number"
|
||||||
|
[clearable]="false"
|
||||||
|
></my-select-custom-value>
|
||||||
|
|
||||||
|
<div *ngIf="formErrors.videoQuotaDaily" class="form-error">
|
||||||
|
{{ formErrors.videoQuotaDaily }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
@import '_variables';
|
@import '_variables';
|
||||||
@import '_mixins';
|
@import '_mixins';
|
||||||
|
|
||||||
|
$form-base-input-width: 340px;
|
||||||
|
|
||||||
label {
|
label {
|
||||||
font-weight: $font-regular;
|
font-weight: $font-regular;
|
||||||
font-size: 100%;
|
font-size: 100%;
|
||||||
|
@ -15,18 +17,24 @@ label {
|
||||||
}
|
}
|
||||||
|
|
||||||
input:not([type=submit]) {
|
input:not([type=submit]) {
|
||||||
@include peertube-input-text(340px);
|
@include peertube-input-text($form-base-input-width);
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
|
|
||||||
my-input-toggle-hidden {
|
my-input-toggle-hidden {
|
||||||
@include responsive-width(340px);
|
@include responsive-width($form-base-input-width);
|
||||||
|
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
|
|
||||||
.peertube-select-container {
|
.peertube-select-container {
|
||||||
@include peertube-select-container(340px);
|
@include peertube-select-container($form-base-input-width);
|
||||||
|
}
|
||||||
|
|
||||||
|
my-select-custom-value {
|
||||||
|
@include responsive-width($form-base-input-width);
|
||||||
|
|
||||||
|
display: block;
|
||||||
}
|
}
|
||||||
|
|
||||||
input[type=submit], button {
|
input[type=submit], button {
|
||||||
|
|
|
@ -4,12 +4,13 @@ import { AuthService, ScreenService, ServerService, User } from '@app/core'
|
||||||
import { FormReactive } from '@app/shared/shared-forms'
|
import { FormReactive } from '@app/shared/shared-forms'
|
||||||
import { USER_ROLE_LABELS } from '@shared/core-utils/users'
|
import { USER_ROLE_LABELS } from '@shared/core-utils/users'
|
||||||
import { ServerConfig, UserAdminFlag, UserRole, VideoResolution } from '@shared/models'
|
import { ServerConfig, UserAdminFlag, UserRole, VideoResolution } from '@shared/models'
|
||||||
|
import { SelectOptionsItem } from '../../../../types/select-options-item.model'
|
||||||
|
|
||||||
@Directive()
|
@Directive()
|
||||||
// tslint:disable-next-line: directive-class-suffix
|
// tslint:disable-next-line: directive-class-suffix
|
||||||
export abstract class UserEdit extends FormReactive implements OnInit {
|
export abstract class UserEdit extends FormReactive implements OnInit {
|
||||||
videoQuotaOptions: { value: string, label: string, disabled?: boolean }[] = []
|
videoQuotaOptions: SelectOptionsItem[] = []
|
||||||
videoQuotaDailyOptions: { value: string, label: string, disabled?: boolean }[] = []
|
videoQuotaDailyOptions: SelectOptionsItem[] = []
|
||||||
username: string
|
username: string
|
||||||
user: User
|
user: User
|
||||||
|
|
||||||
|
@ -97,19 +98,7 @@ export abstract class UserEdit extends FormReactive implements OnInit {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected buildQuotaOptions () {
|
protected buildQuotaOptions () {
|
||||||
// These are used by a HTML select, so convert key into strings
|
this.videoQuotaOptions = this.configService.videoQuotaOptions
|
||||||
this.videoQuotaOptions = this.configService
|
this.videoQuotaDailyOptions = this.configService.videoQuotaDailyOptions
|
||||||
.videoQuotaOptions.map(q => ({
|
|
||||||
value: q.value?.toString(),
|
|
||||||
label: q.label,
|
|
||||||
disabled: q.disabled
|
|
||||||
}))
|
|
||||||
|
|
||||||
this.videoQuotaDailyOptions = this.configService
|
|
||||||
.videoQuotaDailyOptions.map(q => ({
|
|
||||||
value: q.value?.toString(),
|
|
||||||
label: q.label,
|
|
||||||
disabled: q.disabled
|
|
||||||
}))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import { FormReactive, SelectChannelItem } from '@app/shared/shared-forms'
|
import { FormReactive } from '@app/shared/shared-forms'
|
||||||
import { VideoConstant, VideoPlaylistPrivacy } from '@shared/models'
|
import { VideoConstant, VideoPlaylistPrivacy } from '@shared/models'
|
||||||
import { VideoPlaylist } from '@shared/models/videos/playlist/video-playlist.model'
|
import { VideoPlaylist } from '@shared/models/videos/playlist/video-playlist.model'
|
||||||
|
import { SelectChannelItem } from '../../../types/select-options-item.model'
|
||||||
|
|
||||||
export abstract class MyVideoPlaylistEdit extends FormReactive {
|
export abstract class MyVideoPlaylistEdit extends FormReactive {
|
||||||
// Declare it here to avoid errors in create template
|
// Declare it here to avoid errors in create template
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import { forkJoin } from 'rxjs'
|
import { forkJoin } from 'rxjs'
|
||||||
import { map } from 'rxjs/operators'
|
import { map } from 'rxjs/operators'
|
||||||
|
import { SelectChannelItem } from 'src/types/select-options-item.model'
|
||||||
import { Component, EventEmitter, Input, NgZone, OnDestroy, OnInit, Output, ViewChild } from '@angular/core'
|
import { Component, EventEmitter, Input, NgZone, OnDestroy, OnInit, Output, ViewChild } from '@angular/core'
|
||||||
import { FormArray, FormControl, FormGroup, ValidatorFn, Validators } from '@angular/forms'
|
import { FormArray, FormControl, FormGroup, ValidatorFn, Validators } from '@angular/forms'
|
||||||
import { HooksService, PluginService, ServerService } from '@app/core'
|
import { HooksService, PluginService, ServerService } from '@app/core'
|
||||||
|
@ -17,10 +18,10 @@ import {
|
||||||
VIDEO_SUPPORT_VALIDATOR,
|
VIDEO_SUPPORT_VALIDATOR,
|
||||||
VIDEO_TAGS_ARRAY_VALIDATOR
|
VIDEO_TAGS_ARRAY_VALIDATOR
|
||||||
} from '@app/shared/form-validators/video-validators'
|
} from '@app/shared/form-validators/video-validators'
|
||||||
import { FormReactiveValidationMessages, FormValidatorService, SelectChannelItem } from '@app/shared/shared-forms'
|
import { FormReactiveValidationMessages, FormValidatorService } from '@app/shared/shared-forms'
|
||||||
import { InstanceService } from '@app/shared/shared-instance'
|
import { InstanceService } from '@app/shared/shared-instance'
|
||||||
import { VideoCaptionEdit, VideoEdit, VideoService } from '@app/shared/shared-main'
|
import { VideoCaptionEdit, VideoEdit, VideoService } from '@app/shared/shared-main'
|
||||||
import { ServerConfig, VideoConstant, LiveVideo, VideoPrivacy } from '@shared/models'
|
import { LiveVideo, ServerConfig, VideoConstant, VideoPrivacy } from '@shared/models'
|
||||||
import { RegisterClientFormFieldOptions, RegisterClientVideoFieldOptions } from '@shared/models/plugins/register-client-form-field.model'
|
import { RegisterClientFormFieldOptions, RegisterClientVideoFieldOptions } from '@shared/models/plugins/register-client-form-field.model'
|
||||||
import { I18nPrimengCalendarService } from './i18n-primeng-calendar.service'
|
import { I18nPrimengCalendarService } from './i18n-primeng-calendar.service'
|
||||||
import { VideoCaptionAddModalComponent } from './video-caption-add-modal.component'
|
import { VideoCaptionAddModalComponent } from './video-caption-add-modal.component'
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
import { catchError, switchMap, tap } from 'rxjs/operators'
|
import { catchError, switchMap, tap } from 'rxjs/operators'
|
||||||
|
import { SelectChannelItem } from 'src/types/select-options-item.model'
|
||||||
import { Directive, EventEmitter, OnInit } from '@angular/core'
|
import { Directive, EventEmitter, OnInit } from '@angular/core'
|
||||||
import { AuthService, CanComponentDeactivateResult, Notifier, ServerService } from '@app/core'
|
import { AuthService, CanComponentDeactivateResult, Notifier, ServerService } from '@app/core'
|
||||||
import { populateAsyncUserVideoChannels } from '@app/helpers'
|
import { populateAsyncUserVideoChannels } from '@app/helpers'
|
||||||
import { FormReactive, SelectChannelItem } from '@app/shared/shared-forms'
|
import { FormReactive } from '@app/shared/shared-forms'
|
||||||
import { VideoCaptionEdit, VideoCaptionService, VideoEdit, VideoService } from '@app/shared/shared-main'
|
import { VideoCaptionEdit, VideoCaptionService, VideoEdit, VideoService } from '@app/shared/shared-main'
|
||||||
import { LoadingBarService } from '@ngx-loading-bar/core'
|
import { LoadingBarService } from '@ngx-loading-bar/core'
|
||||||
import { ServerConfig, VideoConstant, VideoPrivacy } from '@shared/models'
|
import { ServerConfig, VideoConstant, VideoPrivacy } from '@shared/models'
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
import { of } from 'rxjs'
|
import { of } from 'rxjs'
|
||||||
import { map, switchMap } from 'rxjs/operators'
|
import { map, switchMap } from 'rxjs/operators'
|
||||||
|
import { SelectChannelItem } from 'src/types/select-options-item.model'
|
||||||
import { Component, HostListener, OnInit } from '@angular/core'
|
import { Component, HostListener, OnInit } from '@angular/core'
|
||||||
import { ActivatedRoute, Router } from '@angular/router'
|
import { ActivatedRoute, Router } from '@angular/router'
|
||||||
import { Notifier } from '@app/core'
|
import { Notifier } from '@app/core'
|
||||||
import { FormReactive, FormValidatorService, SelectChannelItem } from '@app/shared/shared-forms'
|
import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
|
||||||
import { VideoCaptionEdit, VideoCaptionService, VideoDetails, VideoEdit, VideoService } from '@app/shared/shared-main'
|
import { VideoCaptionEdit, VideoCaptionService, VideoDetails, VideoEdit, VideoService } from '@app/shared/shared-main'
|
||||||
import { LiveVideoService } from '@app/shared/shared-video-live'
|
import { LiveVideoService } from '@app/shared/shared-video-live'
|
||||||
import { LoadingBarService } from '@ngx-loading-bar/core'
|
import { LoadingBarService } from '@ngx-loading-bar/core'
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
|
import { SelectChannelItem } from 'src/types/select-options-item.model'
|
||||||
import { DatePipe } from '@angular/common'
|
import { DatePipe } from '@angular/common'
|
||||||
import { HttpErrorResponse } from '@angular/common/http'
|
import { HttpErrorResponse } from '@angular/common/http'
|
||||||
import { Notifier } from '@app/core'
|
import { Notifier } from '@app/core'
|
||||||
import { SelectChannelItem } from '@app/shared/shared-forms'
|
import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes'
|
||||||
import { environment } from '../../environments/environment'
|
import { environment } from '../../environments/environment'
|
||||||
import { AuthService } from '../core/auth'
|
import { AuthService } from '../core/auth'
|
||||||
import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes'
|
|
||||||
|
|
||||||
// Thanks: https://stackoverflow.com/questions/901115/how-can-i-get-query-string-values-in-javascript
|
// Thanks: https://stackoverflow.com/questions/901115/how-can-i-get-query-string-values-in-javascript
|
||||||
function getParameterByName (name: string, url: string) {
|
function getParameterByName (name: string, url: string) {
|
||||||
|
|
|
@ -10,5 +10,5 @@ export type BuildFormArgument = {
|
||||||
}
|
}
|
||||||
|
|
||||||
export type BuildFormDefaultValues = {
|
export type BuildFormDefaultValues = {
|
||||||
[ name: string ]: string | string[] | BuildFormDefaultValues
|
[ name: string ]: number | string | string[] | BuildFormDefaultValues
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,7 @@
|
||||||
import { Component, forwardRef, Input } from '@angular/core'
|
import { Component, forwardRef, Input, OnChanges } from '@angular/core'
|
||||||
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms'
|
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms'
|
||||||
import { VideoChannel } from '@app/shared/shared-main'
|
import { VideoChannel } from '@app/shared/shared-main'
|
||||||
|
import { SelectChannelItem } from '../../../../types/select-options-item.model'
|
||||||
export type SelectChannelItem = {
|
|
||||||
id: number
|
|
||||||
label: string
|
|
||||||
support: string
|
|
||||||
avatarPath?: string
|
|
||||||
}
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'my-select-channel',
|
selector: 'my-select-channel',
|
||||||
|
@ -21,9 +15,10 @@ export type SelectChannelItem = {
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
export class SelectChannelComponent implements ControlValueAccessor {
|
export class SelectChannelComponent implements ControlValueAccessor, OnChanges {
|
||||||
@Input() items: SelectChannelItem[] = []
|
@Input() items: SelectChannelItem[] = []
|
||||||
|
|
||||||
|
channels: SelectChannelItem[] = []
|
||||||
selectedId: number
|
selectedId: number
|
||||||
|
|
||||||
// ng-select options
|
// ng-select options
|
||||||
|
@ -32,10 +27,14 @@ export class SelectChannelComponent implements ControlValueAccessor {
|
||||||
clearable = false
|
clearable = false
|
||||||
searchable = false
|
searchable = false
|
||||||
|
|
||||||
get channels () {
|
ngOnChanges () {
|
||||||
return this.items.map(c => Object.assign(c, {
|
this.channels = this.items.map(c => {
|
||||||
avatarPath: c.avatarPath ? c.avatarPath : VideoChannel.GET_DEFAULT_AVATAR_URL()
|
const avatarPath = c.avatarPath
|
||||||
}))
|
? c.avatarPath
|
||||||
|
: VideoChannel.GET_DEFAULT_AVATAR_URL()
|
||||||
|
|
||||||
|
return Object.assign({}, c, { avatarPath })
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
propagateChange = (_: any) => { /* empty */ }
|
propagateChange = (_: any) => { /* empty */ }
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { Component, forwardRef, Input, OnInit } from '@angular/core'
|
import { Component, forwardRef, Input, OnInit } from '@angular/core'
|
||||||
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms'
|
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms'
|
||||||
import { SelectOptionsItem } from './select-options.component'
|
import { SelectOptionsItem } from '../../../../types/select-options-item.model'
|
||||||
|
|
||||||
export type ItemSelectCheckboxValue = { id?: string | number, group?: string } | string
|
export type ItemSelectCheckboxValue = { id?: string | number, group?: string } | string
|
||||||
|
|
||||||
|
|
|
@ -10,5 +10,9 @@
|
||||||
(ngModelChange)="onModelChange()"
|
(ngModelChange)="onModelChange()"
|
||||||
></my-select-options>
|
></my-select-options>
|
||||||
|
|
||||||
<input *ngIf="isCustomValue()" [(ngModel)]="customValue" (ngModelChange)="onModelChange()" type="text" class="form-control" />
|
<ng-container *ngIf="isCustomValue()">
|
||||||
|
<input [(ngModel)]="customValue" (ngModelChange)="onModelChange()" [type]="inputType" class="form-control" />
|
||||||
|
|
||||||
|
<span *ngIf="inputSuffix" class="input-suffix">{{ inputSuffix }}</span>
|
||||||
|
</ng-container>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { Component, forwardRef, Input, OnChanges } from '@angular/core'
|
import { Component, forwardRef, Input, OnChanges } from '@angular/core'
|
||||||
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms'
|
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms'
|
||||||
import { SelectOptionsItem } from './select-options.component'
|
import { SelectOptionsItem } from '../../../../types/select-options-item.model'
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'my-select-custom-value',
|
selector: 'my-select-custom-value',
|
||||||
|
@ -20,6 +20,8 @@ export class SelectCustomValueComponent implements ControlValueAccessor, OnChang
|
||||||
@Input() searchable = false
|
@Input() searchable = false
|
||||||
@Input() groupBy: string
|
@Input() groupBy: string
|
||||||
@Input() labelForId: string
|
@Input() labelForId: string
|
||||||
|
@Input() inputSuffix: string
|
||||||
|
@Input() inputType = 'text'
|
||||||
|
|
||||||
customValue: number | string = ''
|
customValue: number | string = ''
|
||||||
selectedId: number | string
|
selectedId: number | string
|
||||||
|
|
|
@ -1,13 +1,6 @@
|
||||||
import { Component, forwardRef, Input } from '@angular/core'
|
import { Component, forwardRef, Input } from '@angular/core'
|
||||||
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms'
|
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms'
|
||||||
|
import { SelectOptionsItem } from '../../../../types/select-options-item.model'
|
||||||
export type SelectOptionsItem = {
|
|
||||||
id: string | number
|
|
||||||
label: string
|
|
||||||
description?: string
|
|
||||||
group?: string
|
|
||||||
groupLabel?: string
|
|
||||||
}
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'my-select-options',
|
selector: 'my-select-options',
|
||||||
|
|
|
@ -33,15 +33,20 @@ ng-select ::ng-deep {
|
||||||
|
|
||||||
.root {
|
.root {
|
||||||
display:flex;
|
display:flex;
|
||||||
|
align-items: center;
|
||||||
|
|
||||||
> my-select-options {
|
> my-select-options {
|
||||||
flex-grow: 1;
|
flex-grow: 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
input[type=text] {
|
my-select-options + input {
|
||||||
margin-left: 5px;
|
margin-left: 5px;
|
||||||
|
|
||||||
@include peertube-input-text($form-base-input-width);
|
@include peertube-input-text($form-base-input-width);
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.input-suffix {
|
||||||
|
margin-left: 5px;
|
||||||
|
}
|
||||||
|
|
|
@ -3,9 +3,10 @@ import { forkJoin, Subject, Subscription } from 'rxjs'
|
||||||
import { first } from 'rxjs/operators'
|
import { first } from 'rxjs/operators'
|
||||||
import { Component, Input, OnDestroy, OnInit } from '@angular/core'
|
import { Component, Input, OnDestroy, OnInit } from '@angular/core'
|
||||||
import { AuthService, Notifier, ServerService, User, UserService } from '@app/core'
|
import { AuthService, Notifier, ServerService, User, UserService } from '@app/core'
|
||||||
import { FormReactive, FormValidatorService, ItemSelectCheckboxValue, SelectOptionsItem } from '@app/shared/shared-forms'
|
import { FormReactive, FormValidatorService, ItemSelectCheckboxValue } from '@app/shared/shared-forms'
|
||||||
import { UserUpdateMe } from '@shared/models'
|
import { UserUpdateMe } from '@shared/models'
|
||||||
import { NSFWPolicyType } from '@shared/models/videos/nsfw-policy.type'
|
import { NSFWPolicyType } from '@shared/models/videos/nsfw-policy.type'
|
||||||
|
import { SelectOptionsItem } from '../../../types/select-options-item.model'
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'my-user-video-settings',
|
selector: 'my-user-video-settings',
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
export interface SelectOptionsItem {
|
||||||
|
id: string | number
|
||||||
|
label: string
|
||||||
|
description?: string
|
||||||
|
group?: string
|
||||||
|
groupLabel?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface SelectChannelItem extends SelectOptionsItem {
|
||||||
|
id: number
|
||||||
|
support: string
|
||||||
|
avatarPath?: string
|
||||||
|
}
|
Loading…
Reference in New Issue