mirror of
https://github.com/4gray/iptvnator.git
synced 2026-10-08 09:01:03 -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">
|
||||
<input
|
||||
type="url"
|
||||
matInput
|
||||
placeholder="Playlist URL (m3u, m3u8)"
|
||||
#playlistUrl
|
||||
formControlName="playlistUrl"
|
||||
/>
|
||||
</mat-form-field>
|
||||
<button
|
||||
mat-flat-button
|
||||
[disabled]="!playlistUrl.value"
|
||||
[disabled]="!form.valid"
|
||||
color="primary"
|
||||
type="submit"
|
||||
>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { Component, Output, EventEmitter } from '@angular/core';
|
||||
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
||||
|
||||
@Component({
|
||||
selector: 'app-url-upload',
|
||||
@@ -8,4 +9,22 @@ import { Component, Output, EventEmitter } from '@angular/core';
|
||||
export class UrlUploadComponent {
|
||||
/** Emits url string to the parent component on form submit */
|
||||
@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