diff --git a/ui/package-lock.json b/ui/package-lock.json index 032edc2..4fa82ca 100644 --- a/ui/package-lock.json +++ b/ui/package-lock.json @@ -8765,6 +8765,14 @@ "integrity": "sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw==", "dev": true }, + "toppy": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/toppy/-/toppy-2.3.3.tgz", + "integrity": "sha512-y2YXC/VsFUuT8zSqfCaOeGpB3KEI6EwB+7B/6UeNNtv97EIZ4pDHGdbhP118TkfjtnMRZSoazpPm1p9DvgDwVQ==", + "requires": { + "tslib": "^1.9.0" + } + }, "tough-cookie": { "version": "2.4.3", "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.4.3.tgz", diff --git a/ui/package.json b/ui/package.json index b33a8c1..ed50700 100644 --- a/ui/package.json +++ b/ui/package.json @@ -21,6 +21,7 @@ "@angular/router": "~8.0.0", "font-awesome": "^4.7.0", "rxjs": "~6.4.0", + "toppy": "^2.3.3", "tslib": "^1.9.0", "zone.js": "~0.9.1" }, diff --git a/ui/src/app/app.module.ts b/ui/src/app/app.module.ts index 8a5e535..25936b3 100644 --- a/ui/src/app/app.module.ts +++ b/ui/src/app/app.module.ts @@ -7,12 +7,14 @@ import { IndexComponent } from './index/index.component'; import { InputComponent } from './input/input.component'; import {FormsModule} from '@angular/forms'; import {HttpClientModule} from '@angular/common/http'; +import { OutputComponent } from './output/output.component'; @NgModule({ declarations: [ AppComponent, IndexComponent, - InputComponent + InputComponent, + OutputComponent ], imports: [ BrowserModule, diff --git a/ui/src/app/index/index.component.html b/ui/src/app/index/index.component.html index a818b01..e8aff22 100644 --- a/ui/src/app/index/index.component.html +++ b/ui/src/app/index/index.component.html @@ -21,7 +21,7 @@ - Hey, {{ fullName }} + Hey, {{ user?.full_name }} @@ -29,7 +29,9 @@ - + +
diff --git a/ui/src/app/index/index.component.ts b/ui/src/app/index/index.component.ts index 6c2c1a8..52e8d31 100644 --- a/ui/src/app/index/index.component.ts +++ b/ui/src/app/index/index.component.ts @@ -1,4 +1,5 @@ import { Component, OnInit } from '@angular/core'; +import {APIService, UserResponse} from '../api.service'; @Component({ selector: 'app-index', @@ -6,13 +7,15 @@ import { Component, OnInit } from '@angular/core'; styleUrls: ['./index.component.scss'] }) export class IndexComponent implements OnInit { - loggedIn: boolean; - fullName: string; + loggedIn = false; + user: UserResponse; - constructor() { } + constructor(private apiService: APIService) { } ngOnInit() { - this.loggedIn = true; - this.fullName = 'Full name here'; + this.apiService.getUser().subscribe(resp => { + this.loggedIn = true; + this.user = resp; + }); } } diff --git a/ui/src/app/input/input.component.ts b/ui/src/app/input/input.component.ts index 035228b..020381a 100644 --- a/ui/src/app/input/input.component.ts +++ b/ui/src/app/input/input.component.ts @@ -1,4 +1,7 @@ -import { Component, OnInit } from '@angular/core'; +import {Component, Input, OnInit} from '@angular/core'; +import {GlobalPosition, InsidePlacement, Toppy, ToppyControl} from 'toppy'; +import {APIService} from '../api.service'; +import {OutputComponent} from '../output/output.component'; @Component({ selector: 'app-input', @@ -6,21 +9,56 @@ import { Component, OnInit } from '@angular/core'; styleUrls: ['./input.component.scss'] }) export class InputComponent implements OnInit { - featureLevel = 0; + @Input() featureLevel = 0; + @Input() locked = true; + + popup: ToppyControl; popupOpened: boolean; - locked = false; format = 'video'; quality = 'high'; pageSize = 50; link = ''; - constructor() { } + constructor(private toppy: Toppy, + private api: APIService) { } ngOnInit() { + this.popup = this.toppy + .position(new GlobalPosition({ + placement: InsidePlacement.TOP, + width: 'auto', + height: 'auto', + offset: 150 + })) + .config({ + backdrop: true, + closeOnEsc: true, + }) + .content(OutputComponent) + .create(); + + this.popup.listen('t_close').subscribe(() => { + this.popupOpened = false; + this.link = ''; + }); } submit() { - console.log('input submit'); + this.api.createFeed({ + url: this.link, + format: this.format, + quality: this.quality, + page_size: this.pageSize, + }).subscribe( + (resp) => { + this.popup.content.props.address = resp.id; + this.popup.open(); + this.popupOpened = true; + }, + err => { + alert(err); + } + ); } allow600() { diff --git a/ui/src/app/output/output.component.html b/ui/src/app/output/output.component.html new file mode 100644 index 0000000..6ffc025 --- /dev/null +++ b/ui/src/app/output/output.component.html @@ -0,0 +1,31 @@ +
+ + + + +
diff --git a/ui/src/app/output/output.component.scss b/ui/src/app/output/output.component.scss new file mode 100644 index 0000000..f96ed80 --- /dev/null +++ b/ui/src/app/output/output.component.scss @@ -0,0 +1,28 @@ +.frame { + background: #56524b; + text-align: center; + z-index: 10; + outline: 9999px solid rgba(0,0,0,0.8); + padding: 5px; + + input { + width: auto; + font-size: 3em; + border: none; + background: none; + border-bottom: 1px dotted black; + } +} + +.links { + padding-top: 5px; + + span { + padding-right: 15px; + } + + a:hover { + color: #EB8C11; + background: rgb(68, 65, 60); + } +} diff --git a/ui/src/app/output/output.component.spec.ts b/ui/src/app/output/output.component.spec.ts new file mode 100644 index 0000000..fe90778 --- /dev/null +++ b/ui/src/app/output/output.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { OutputComponent } from './output.component'; + +describe('OutputComponent', () => { + let component: OutputComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ OutputComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(OutputComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/ui/src/app/output/output.component.ts b/ui/src/app/output/output.component.ts new file mode 100644 index 0000000..362295f --- /dev/null +++ b/ui/src/app/output/output.component.ts @@ -0,0 +1,30 @@ +import { Component, OnInit } from '@angular/core'; +import {ToppyControl} from 'toppy'; + +@Component({ + selector: 'app-output', + templateUrl: './output.component.html', + styleUrls: ['./output.component.scss'] +}) +export class OutputComponent implements OnInit { + address: string; + canCopy: boolean; + + constructor(private overlay: ToppyControl) { + this.address = overlay.content.props.address; + } + + ngOnInit() { + this.canCopy = document.queryCommandSupported('copy'); + } + + copyToClipboard(input) { + input.select(); + document.execCommand('copy'); + input.setSelectionRange(0, 0); + } + + close() { + this.overlay.close(); + } +}