mirror of
https://github.com/4gray/iptvnator.git
synced 2026-10-08 17:06:15 -08:00
feat: validation of playlist url
This commit is contained in:
2 files changed
+22
-3
No files matched your search
@@ -1,15 +1,15 @@
|
|||||||
<form (ngSubmit)="urlAdded.emit(playlistUrl.value)">
|
<form (ngSubmit)="urlAdded.emit(form.value.playlistUrl)" [formGroup]="form">
|
||||||
<mat-form-field class="full-width">
|
<mat-form-field class="full-width">
|
||||||
<input
|
<input
|
||||||
type="url"
|
type="url"
|
||||||
matInput
|
matInput
|
||||||
placeholder="Playlist URL (m3u, m3u8)"
|
placeholder="Playlist URL (m3u, m3u8)"
|
||||||
#playlistUrl
|
formControlName="playlistUrl"
|
||||||
/>
|
/>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
<button
|
<button
|
||||||
mat-flat-button
|
mat-flat-button
|
||||||
[disabled]="!playlistUrl.value"
|
[disabled]="!form.valid"
|
||||||
color="primary"
|
color="primary"
|
||||||
type="submit"
|
type="submit"
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { Component, Output, EventEmitter } from '@angular/core';
|
import { Component, Output, EventEmitter } from '@angular/core';
|
||||||
|
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-url-upload',
|
selector: 'app-url-upload',
|
||||||
@@ -8,4 +9,22 @@ import { Component, Output, EventEmitter } from '@angular/core';
|
|||||||
export class UrlUploadComponent {
|
export class UrlUploadComponent {
|
||||||
/** Emits url string to the parent component on form submit */
|
/** Emits url string to the parent component on form submit */
|
||||||
@Output() urlAdded: EventEmitter<string> = new EventEmitter();
|
@Output() urlAdded: EventEmitter<string> = new EventEmitter();
|
||||||
|
|
||||||
|
/** Form group with playlist url */
|
||||||
|
form: FormGroup;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates an instance of component
|
||||||
|
* @param fb angulars form builder
|
||||||
|
*/
|
||||||
|
constructor(private fb: FormBuilder) {
|
||||||
|
const urlRegex = '(https?://.*?.(m3u|m3u8))';
|
||||||
|
this.form = this.fb.group({
|
||||||
|
playlistUrl: [
|
||||||
|
'',
|
||||||
|
// eslint-disable-next-line @typescript-eslint/unbound-method
|
||||||
|
[Validators.required, Validators.pattern(urlRegex)],
|
||||||
|
],
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user