mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-04 10:19:35 +02:00

* Add NSFW flags to videos so the publisher can add more NSFW context * Add NSFW summary to videos, similar to content warning system so the publisher has a free text to describe NSFW aspect of its video * Add additional "warn" NSFW policy: the video thumbnail is not blurred and we display a tag below the video miniature, the video player includes the NSFW warning (with context if available) and it also prevent autoplay * "blur" NSFW settings inherits "warn" policy and also blur the video thumbnail * Add NSFW flag settings to users so they can have more granular control about what content they want to hide, warn or display
71 lines
2 KiB
TypeScript
71 lines
2 KiB
TypeScript
import { NgIf, NgTemplateOutlet } from '@angular/common'
|
|
import { AfterContentInit, Component, contentChildren, forwardRef, input, model, TemplateRef } from '@angular/core'
|
|
import { ControlValueAccessor, FormsModule, NG_VALUE_ACCESSOR } from '@angular/forms'
|
|
import { HelpComponent } from '../shared-main/buttons/help.component'
|
|
import { PeerTubeTemplateDirective } from '../shared-main/common/peertube-template.directive'
|
|
|
|
@Component({
|
|
selector: 'my-peertube-checkbox',
|
|
styleUrls: [ './peertube-checkbox.component.scss' ],
|
|
templateUrl: './peertube-checkbox.component.html',
|
|
providers: [
|
|
{
|
|
provide: NG_VALUE_ACCESSOR,
|
|
useExisting: forwardRef(() => PeertubeCheckboxComponent),
|
|
multi: true
|
|
}
|
|
],
|
|
imports: [ FormsModule, NgIf, NgTemplateOutlet, HelpComponent ]
|
|
})
|
|
export class PeertubeCheckboxComponent implements ControlValueAccessor, AfterContentInit {
|
|
readonly checked = model(false)
|
|
readonly inputName = input<string>(undefined)
|
|
readonly labelText = input<string>(undefined)
|
|
readonly labelInnerHTML = input<string>(undefined)
|
|
readonly helpPlacement = input('top auto')
|
|
readonly recommended = input(false)
|
|
|
|
disabled = false
|
|
describedby: string
|
|
|
|
readonly templates = contentChildren(PeerTubeTemplateDirective)
|
|
|
|
labelTemplate: TemplateRef<any>
|
|
helpTemplate: TemplateRef<any>
|
|
|
|
ngAfterContentInit () {
|
|
{
|
|
const t = this.templates().find(t => t.name() === 'label')
|
|
if (t) this.labelTemplate = t.template
|
|
}
|
|
|
|
{
|
|
const t = this.templates().find(t => t.name() === 'help')
|
|
if (t) this.helpTemplate = t.template
|
|
}
|
|
}
|
|
|
|
propagateChange = (_: any) => {
|
|
// empty
|
|
}
|
|
|
|
writeValue (checked: boolean) {
|
|
this.checked.set(checked)
|
|
}
|
|
|
|
registerOnChange (fn: (_: any) => void) {
|
|
this.propagateChange = fn
|
|
}
|
|
|
|
registerOnTouched () {
|
|
// Unused
|
|
}
|
|
|
|
onModelChange () {
|
|
this.propagateChange(this.checked())
|
|
}
|
|
|
|
setDisabledState (isDisabled: boolean) {
|
|
this.disabled = isDisabled
|
|
}
|
|
}
|