aboutsummaryrefslogtreecommitdiff
path: root/frontend/src/app/Shared.ts
blob: d088fff9ba93858d8e4358b48011e5d5b13dfe35 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import { ElementRef, EventEmitter } from "@angular/core";
import { NgbModal } from "@ng-bootstrap/ng-bootstrap";
import { MatDialog, MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
import { AlertDialogComponent } from './_modals/alert-dialog/alert-dialog.component';
import { YesNoDialogComponent } from './_modals/yes-no-dialog/yes-no-dialog.component';

class Shared {
    constructor(
        public loggedIn: boolean,
        public username: string = '',
        public userId: string = '',
        public photoId: string = '1',
        public dialog?: MatDialog
        //public alertDialog?: ElementRef
    ) { }


    openDialog(title: string, message: string): void {

        if (this.dialog) {
            const dialogRef = this.dialog.open(AlertDialogComponent, {
                width: '350px',
                data: { title: title, message: message }
            });
            dialogRef.afterClosed().subscribe(res => {
                //nesto
            });
        }
    }
    openYesNoDialog(title: string, message: string, yesFunction: Function): void {

        if (this.dialog) {
            const dialogRef = this.dialog.open(YesNoDialogComponent, {
                width: '350px',
                data: { title: title, message: message, yesFunction }
            });
            dialogRef.afterClosed().subscribe(res => {
                //nesto
            });
        }
    }

    bgScroll: EventEmitter<number> = new EventEmitter();

    emitBGScrollEvent(value: number) {
        this.bgScroll.emit(value);
    }
}

export default new Shared(false);