Merge branch 'release/1.4.0' into develop

This commit is contained in:
Chocobozzz 2019-09-05 10:19:35 +02:00
commit 00aab0666c
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
7 changed files with 19 additions and 17 deletions

View File

@ -10,7 +10,7 @@
<div class="wrapper" [hidden]="signupDone"> <div class="wrapper" [hidden]="signupDone">
<div class="register-form"> <div class="register-form">
<my-custom-stepper linear *ngIf="!signupDone"> <my-custom-stepper linear *ngIf="!signupDone">
<cdk-step [stepControl]="formStepUser" i18n-label label="User information"> <cdk-step [stepControl]="formStepUser" i18n-label label="User">
<my-register-step-user <my-register-step-user
[hasCodeOfConduct]="!!aboutHtml.codeOfConduct" [hasCodeOfConduct]="!!aboutHtml.codeOfConduct"
(formBuilt)="onUserFormBuilt($event)" (termsClick)="onTermsClick()" (codeOfConductClick)="onCodeOfConductClick()" (formBuilt)="onUserFormBuilt($event)" (termsClick)="onTermsClick()" (codeOfConductClick)="onCodeOfConductClick()"
@ -20,7 +20,7 @@
<button i18n cdkStepperNext [disabled]="!formStepUser || !formStepUser.valid">Next</button> <button i18n cdkStepperNext [disabled]="!formStepUser || !formStepUser.valid">Next</button>
</cdk-step> </cdk-step>
<cdk-step [stepControl]="formStepChannel" i18n-label label="Channel information"> <cdk-step [stepControl]="formStepChannel" i18n-label label="Channel">
<my-register-step-channel (formBuilt)="onChannelFormBuilt($event)" [username]="getUsername()"></my-register-step-channel> <my-register-step-channel (formBuilt)="onChannelFormBuilt($event)" [username]="getUsername()"></my-register-step-channel>
<button i18n cdkStepperNext (click)="signup()" <button i18n cdkStepperNext (click)="signup()"

View File

@ -34,7 +34,7 @@ export class VideoBlacklistService {
) )
} }
getAutoBlacklistedAsVideoList (videoPagination: ComponentPagination): Observable<{ videos: Video[], totalVideos: number}> { getAutoBlacklistedAsVideoList (videoPagination: ComponentPagination): Observable<ResultList<Video>> {
const pagination = this.restService.componentPaginationToRestPagination(videoPagination) const pagination = this.restService.componentPaginationToRestPagination(videoPagination)
// prioritize first created since waiting longest // prioritize first created since waiting longest
@ -48,9 +48,10 @@ export class VideoBlacklistService {
return this.authHttp.get<ResultList<VideoBlacklist>>(VideoBlacklistService.BASE_VIDEOS_URL + 'blacklist', { params }) return this.authHttp.get<ResultList<VideoBlacklist>>(VideoBlacklistService.BASE_VIDEOS_URL + 'blacklist', { params })
.pipe( .pipe(
map(res => { map(res => {
const videos = res.data.map(videoBlacklist => new Video(videoBlacklist.video)) return {
const totalVideos = res.total total: res.total,
return { videos, totalVideos } data: res.data.map(videoBlacklist => new Video(videoBlacklist.video))
}
}), }),
catchError(res => this.restExtractor.handleError(res)) catchError(res => this.restExtractor.handleError(res))
) )

View File

@ -31,7 +31,7 @@
<div class="video-info-privacy"> <div class="video-info-privacy">
<ng-container *ngIf="displayOptions.privacyText">{{ video.privacy.label }}</ng-container> <ng-container *ngIf="displayOptions.privacyText">{{ video.privacy.label }}</ng-container>
<ng-container *ngIf="displayOptions.privacyText && getStateLabel(video)"> - </ng-container> <ng-container *ngIf="displayOptions.privacyText && displayOptions.state && getStateLabel(video)"> - </ng-container>
<ng-container *ngIf="displayOptions.state">{{ getStateLabel(video) }}</ng-container> <ng-container *ngIf="displayOptions.state">{{ getStateLabel(video) }}</ng-container>
</div> </div>

View File

@ -95,6 +95,8 @@ export class VideoMiniatureComponent implements OnInit {
} }
getStateLabel (video: Video) { getStateLabel (video: Video) {
if (!video.state) return ''
if (video.privacy.id !== VideoPrivacy.PRIVATE && video.state.id === VideoState.PUBLISHED) { if (video.privacy.id !== VideoPrivacy.PRIVATE && video.state.id === VideoState.PUBLISHED) {
return this.i18n('Published') return this.i18n('Published')
} }

View File

@ -261,7 +261,7 @@ export class VideosRedundancyScheduler extends AbstractScheduler {
} }
private async purgeCacheIfNeeded (candidateToDuplicate: CandidateToDuplicate) { private async purgeCacheIfNeeded (candidateToDuplicate: CandidateToDuplicate) {
while (this.isTooHeavy(candidateToDuplicate)) { while (await this.isTooHeavy(candidateToDuplicate)) {
const redundancy = candidateToDuplicate.redundancy const redundancy = candidateToDuplicate.redundancy
const toDelete = await VideoRedundancyModel.loadOldestLocalExpired(redundancy.strategy, redundancy.minLifetime) const toDelete = await VideoRedundancyModel.loadOldestLocalExpired(redundancy.strategy, redundancy.minLifetime)
if (!toDelete) return if (!toDelete) return

View File

@ -1,9 +1,9 @@
import { Model, Sequelize } from 'sequelize-typescript' import { Model, Sequelize } from 'sequelize-typescript'
import * as validator from 'validator' import * as validator from 'validator'
import { Col } from 'sequelize/types/lib/utils' import { Col } from 'sequelize/types/lib/utils'
import { OrderItem, literal } from 'sequelize' import { col, literal, OrderItem } from 'sequelize'
type SortType = { sortModel: any, sortValue: string } type SortType = { sortModel: string, sortValue: string }
// Translate for example "-name" to [ [ 'name', 'DESC' ], [ 'id', 'ASC' ] ] // Translate for example "-name" to [ [ 'name', 'DESC' ], [ 'id', 'ASC' ] ]
function getSort (value: string, lastSort: OrderItem = [ 'id', 'ASC' ]): OrderItem[] { function getSort (value: string, lastSort: OrderItem = [ 'id', 'ASC' ]): OrderItem[] {
@ -51,10 +51,10 @@ function getVideoSort (value: string, lastSort: OrderItem = [ 'id', 'ASC' ]): Or
return [ firstSort, lastSort ] return [ firstSort, lastSort ]
} }
function getSortOnModel (model: any, value: string, lastSort: OrderItem = [ 'id', 'ASC' ]): OrderItem[] { function getBlacklistSort (model: any, value: string, lastSort: OrderItem = [ 'id', 'ASC' ]): OrderItem[] {
const [ firstSort ] = getSort(value) const [ firstSort ] = getSort(value)
if (model) return [ [ model, firstSort[0], firstSort[1] ], lastSort ] if (model) return [ [ literal(`"${model}.${firstSort[ 0 ]}" ${firstSort[ 1 ]}`) ], lastSort ] as any[] // FIXME: typings
return [ firstSort, lastSort ] return [ firstSort, lastSort ]
} }
@ -155,7 +155,7 @@ export {
buildLocalAccountIdsIn, buildLocalAccountIdsIn,
getSort, getSort,
getVideoSort, getVideoSort,
getSortOnModel, getBlacklistSort,
createSimilarityAttribute, createSimilarityAttribute,
throwIfNotValid, throwIfNotValid,
buildServerIdsFollowedBy, buildServerIdsFollowedBy,

View File

@ -1,11 +1,11 @@
import { AllowNull, BelongsTo, Column, CreatedAt, DataType, Default, ForeignKey, Is, Model, Table, UpdatedAt } from 'sequelize-typescript' import { AllowNull, BelongsTo, Column, CreatedAt, DataType, Default, ForeignKey, Is, Model, Table, UpdatedAt } from 'sequelize-typescript'
import { getSortOnModel, SortType, throwIfNotValid } from '../utils' import { getBlacklistSort, SortType, throwIfNotValid } from '../utils'
import { VideoModel } from './video' import { VideoModel } from './video'
import { ScopeNames as VideoChannelScopeNames, SummaryOptions, VideoChannelModel } from './video-channel' import { ScopeNames as VideoChannelScopeNames, SummaryOptions, VideoChannelModel } from './video-channel'
import { isVideoBlacklistReasonValid, isVideoBlacklistTypeValid } from '../../helpers/custom-validators/video-blacklist' import { isVideoBlacklistReasonValid, isVideoBlacklistTypeValid } from '../../helpers/custom-validators/video-blacklist'
import { VideoBlacklist, VideoBlacklistType } from '../../../shared/models/videos' import { VideoBlacklist, VideoBlacklistType } from '../../../shared/models/videos'
import { CONSTRAINTS_FIELDS } from '../../initializers/constants' import { CONSTRAINTS_FIELDS } from '../../initializers/constants'
import { FindOptions } from 'sequelize' import { FindOptions, literal } from 'sequelize'
import { ThumbnailModel } from './thumbnail' import { ThumbnailModel } from './thumbnail'
import * as Bluebird from 'bluebird' import * as Bluebird from 'bluebird'
import { MVideoBlacklist, MVideoBlacklistFormattable } from '@server/typings/models' import { MVideoBlacklist, MVideoBlacklistFormattable } from '@server/typings/models'
@ -59,14 +59,13 @@ export class VideoBlacklistModel extends Model<VideoBlacklistModel> {
return { return {
offset: start, offset: start,
limit: count, limit: count,
order: getSortOnModel(sort.sortModel, sort.sortValue) order: getBlacklistSort(sort.sortModel, sort.sortValue)
} }
} }
const countQuery = buildBaseQuery() const countQuery = buildBaseQuery()
const findQuery = buildBaseQuery() const findQuery = buildBaseQuery()
findQuery.subQuery = false
findQuery.include = [ findQuery.include = [
{ {
model: VideoModel, model: VideoModel,