Sengi-Windows-MacOS-Linux/src/app/app.component.ts

102 lines
2.9 KiB
TypeScript
Raw Normal View History

2018-09-10 03:55:16 +02:00
import { Component, OnInit, OnDestroy } from '@angular/core';
2019-02-11 04:23:10 +01:00
import { Subscription, Observable } from 'rxjs';
import { Select } from '@ngxs/store';
// import { ElectronService } from 'ngx-electron';
2018-03-15 01:48:52 +01:00
2019-02-11 04:23:10 +01:00
import { NavigationService, LeftPanelType } from './services/navigation.service';
import { StreamElement } from './states/streams.state';
2019-02-26 05:38:15 +01:00
import { OpenMediaEvent } from './models/common.model';
2018-03-15 01:48:52 +01:00
@Component({
2019-02-11 04:23:10 +01:00
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
2018-03-15 01:48:52 +01:00
})
2019-02-26 05:38:15 +01:00
export class AppComponent implements OnInit, OnDestroy {
2019-02-11 04:23:10 +01:00
title = 'Sengi';
floatingColumnActive: boolean;
tutorialActive: boolean;
2019-02-26 05:38:15 +01:00
// mediaViewerActive: boolean = false;
openedMediaEvent: OpenMediaEvent
2019-02-25 06:04:09 +01:00
2019-02-11 04:23:10 +01:00
private columnEditorSub: Subscription;
2019-02-26 05:38:15 +01:00
private openMediaSub: Subscription;
private streamSub: Subscription;
2019-02-11 04:23:10 +01:00
@Select(state => state.streamsstatemodel.streams) streamElements$: Observable<StreamElement[]>;
constructor(private readonly navigationService: NavigationService) {
}
ngOnInit(): void {
2019-02-26 05:38:15 +01:00
this.streamSub = this.streamElements$.subscribe((streams: StreamElement[]) => {
if (streams && streams.length === 0) {
2019-02-11 04:23:10 +01:00
this.tutorialActive = true;
} else {
this.tutorialActive = false;
}
});
this.columnEditorSub = this.navigationService.activatedPanelSubject.subscribe((type: LeftPanelType) => {
if (type === LeftPanelType.Closed) {
this.floatingColumnActive = false;
} else {
this.floatingColumnActive = true;
}
});
2019-02-26 05:38:15 +01:00
this.openMediaSub = this.navigationService.activatedMediaSubject.subscribe((openedMediaEvent: OpenMediaEvent) => {
if (openedMediaEvent) {
this.openedMediaEvent = openedMediaEvent;
// this.mediaViewerActive = true;
2019-03-08 04:33:10 +01:00
2019-02-26 05:38:15 +01:00
}
});
2019-02-11 04:23:10 +01:00
}
ngOnDestroy(): void {
2019-02-26 05:38:15 +01:00
this.streamSub.unsubscribe();
2019-02-11 04:23:10 +01:00
this.columnEditorSub.unsubscribe();
2019-02-26 05:38:15 +01:00
this.openMediaSub.unsubscribe();
}
2019-03-08 04:33:10 +01:00
closeMedia() {
2019-02-26 05:38:15 +01:00
this.openedMediaEvent = null;
2019-02-11 04:23:10 +01:00
}
2019-03-08 04:33:10 +01:00
drag: boolean;
drag2: boolean;
private dragCounter: number = 0;
dragenter(event): boolean {
event.stopPropagation();
event.preventDefault();
this.drag = true;
return false;
}
dragleave(event): boolean {
event.stopPropagation();
event.preventDefault();
this.drag = false;
return false;
}
dragover(event): boolean{
event.stopPropagation();
event.preventDefault();
return false;
}
drop(event): boolean {
event.stopPropagation();
event.preventDefault();
let files = event.dataTransfer.files;
for(let file of files){
console.warn(file.name);
console.warn(file);
};
this.drag = false;
return false;
}
2018-03-15 01:48:52 +01:00
}