From fd001c26ced7e40896634ca6ff41854e4f0a2eed Mon Sep 17 00:00:00 2001 From: 4gray <4gray@users.noreply.github.com> Date: Sun, 6 Aug 2023 23:52:38 +0200 Subject: [PATCH] feat(stalker): add import stalker portal component --- src/app/app-routing.module.ts | 7 ++ src/app/home/home.component.html | 21 ++++-- src/app/home/home.module.ts | 2 + .../stalker-portal-import.component.html | 54 +++++++++++++++ .../stalker-portal-import.component.ts | 69 +++++++++++++++++++ 5 files changed, 146 insertions(+), 7 deletions(-) create mode 100644 src/app/home/stalker-portal-import/stalker-portal-import.component.html create mode 100644 src/app/home/stalker-portal-import/stalker-portal-import.component.ts diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index e7f084c48..135e5eb64 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -36,6 +36,13 @@ const routes: Routes = [ (c) => c.XtreamMainContainerComponent ), }, + { + path: 'portals/:id', + loadComponent: () => + import('./stalker/stalker-main-container.component').then( + (c) => c.StalkerMainContainerComponent + ), + }, { path: '**', redirectTo: '', diff --git a/src/app/home/home.component.html b/src/app/home/home.component.html index 72da861a7..9d1690d05 100644 --- a/src/app/home/home.component.html +++ b/src/app/home/home.component.html @@ -46,9 +46,7 @@ - + @@ -59,14 +57,12 @@ - + - text_format + video_library
{{ 'HOME.TABS.XTREME_IMPORT' | translate }}
@@ -75,6 +71,17 @@
+ + + dashboard +
+ {{ 'HOME.TABS.STALKER_PORTAL_IMPORT' | translate }} +
+
+ + + +
diff --git a/src/app/home/home.module.ts b/src/app/home/home.module.ts index f645965e6..585e654cb 100644 --- a/src/app/home/home.module.ts +++ b/src/app/home/home.module.ts @@ -5,6 +5,7 @@ import { DragDropFileUploadDirective } from './file-upload/drag-drop-file-upload import { FileUploadComponent } from './file-upload/file-upload.component'; import { HomeComponent } from './home.component'; import { HomeRoutingModule } from './home.routing'; +import { StalkerPortalImportComponent } from './stalker-portal-import/stalker-portal-import.component'; import { TextImportComponent } from './text-import/text-import.component'; import { UrlUploadComponent } from './url-upload/url-upload.component'; import { XtreamCodeImportComponent } from './xtream-code-import/xtream-code-import.component'; @@ -15,6 +16,7 @@ import { XtreamCodeImportComponent } from './xtream-code-import/xtream-code-impo HomeRoutingModule, SharedModule, XtreamCodeImportComponent, + StalkerPortalImportComponent, ], declarations: [ DragDropFileUploadDirective, diff --git a/src/app/home/stalker-portal-import/stalker-portal-import.component.html b/src/app/home/stalker-portal-import/stalker-portal-import.component.html new file mode 100644 index 000000000..5336ca695 --- /dev/null +++ b/src/app/home/stalker-portal-import/stalker-portal-import.component.html @@ -0,0 +1,54 @@ +
+ + {{ + 'HOME.STALKER_PORTAL.TITLE' | translate + }} + + + + {{ + 'HOME.STALKER_PORTAL.SERVER_URL' | translate + }} + + {{ + 'HOME.STALKER_PORTAL.URL_VALIDATION_ERROR' | translate + }} + {{ 'SETTINGS.EPG_URL_ERROR' | translate }} + + + {{ + 'HOME.STALKER_PORTAL.MAC_ADDRESS' | translate + }} + + + + +
diff --git a/src/app/home/stalker-portal-import/stalker-portal-import.component.ts b/src/app/home/stalker-portal-import/stalker-portal-import.component.ts new file mode 100644 index 000000000..0a21fa798 --- /dev/null +++ b/src/app/home/stalker-portal-import/stalker-portal-import.component.ts @@ -0,0 +1,69 @@ +import { Component, inject } from '@angular/core'; +import { + FormControl, + FormGroup, + FormsModule, + ReactiveFormsModule, + Validators, +} from '@angular/forms'; +import { MatButtonModule } from '@angular/material/button'; +import { MatFormFieldModule } from '@angular/material/form-field'; +import { MatInputModule } from '@angular/material/input'; +import { Store } from '@ngrx/store'; +import { TranslateModule } from '@ngx-translate/core'; +import { v4 as uuid } from 'uuid'; +import { Playlist } from '../../../../shared/playlist.interface'; +import { DataService } from '../../services/data.service'; +import { addPlaylist } from '../../state/actions'; + +@Component({ + standalone: true, + imports: [ + FormsModule, + ReactiveFormsModule, + MatFormFieldModule, + MatInputModule, + MatButtonModule, + TranslateModule, + ], + selector: 'app-stalker-portal-import', + templateUrl: './stalker-portal-import.component.html', + styles: [ + ` + :host { + display: flex; + margin: 10px; + justify-content: center; + } + + form { + width: 100%; + } + `, + ], +}) +export class StalkerPortalImportComponent { + URL_REGEX = /^(http|https|file):\/\/[^ "]+$/; + + form = new FormGroup({ + _id: new FormControl(uuid()), + title: new FormControl('', [Validators.required]), + macAddress: new FormControl(''), + password: new FormControl(''), + username: new FormControl(''), + portalUrl: new FormControl('', [ + Validators.required, + Validators.pattern(this.URL_REGEX), + ]), + importDate: new FormControl(new Date().toISOString()), + }); + + dataService = inject(DataService); + store = inject(Store); + + addPlaylist() { + this.store.dispatch( + addPlaylist({ playlist: this.form.value as Playlist }) + ); + } +}