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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
import { Component, Inject, Input, OnInit } from '@angular/core';
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
import Dataset from 'src/app/_data/Dataset';
import { FolderType } from 'src/app/_data/FolderFile';
import Model from 'src/app/_data/Model';
import { DatasetsService } from 'src/app/_services/datasets.service';
import { ModelsService } from 'src/app/_services/models.service';
interface DialogData {
file: (Dataset | Model);
fileType: FolderType;
}
@Component({
selector: 'app-share-dialog',
templateUrl: './share-dialog.component.html',
styleUrls: ['./share-dialog.component.css']
})
export class ShareDialogComponent implements OnInit {
constructor(public dialogRef: MatDialogRef<ShareDialogComponent>, @Inject(MAT_DIALOG_DATA) public data: DialogData, private modelsService: ModelsService, private datasetsService: DatasetsService) {
}
link: string = '';
ngOnInit(): void {
let link = window.location.origin;
if (this.data.fileType == FolderType.Dataset) {
link += '/dataset/';
} else if (this.data.fileType == FolderType.Model) {
link += '/model/';
}
link += this.data.file._id;
this.link = link;
}
close() {
this.dialogRef.close();
}
copy() {
navigator.clipboard.writeText(this.link);
}
publicChanged() {
if (this.data.fileType == FolderType.Dataset) {
this.datasetsService.updateDatasetIsPublic(this.data.file._id, this.data.file.isPublic).subscribe(() => {
});
} else if (this.data.fileType == FolderType.Model) {
this.modelsService.updateModelIsPublic(this.data.file._id, this.data.file.isPublic).subscribe(() => {
});
}
if (this.data.file.isPublic) {
this.data.file.accessibleByLink = true;
}
}
linkChanged() {
if (this.data.fileType == FolderType.Dataset) {
this.datasetsService.updateDatasetAccessibleByLink(this.data.file._id, this.data.file.accessibleByLink).subscribe(() => {
});
} else if (this.data.fileType == FolderType.Model) {
this.modelsService.updateModelAccessibleByLink(this.data.file._id, this.data.file.accessibleByLink).subscribe(() => {
});
}
}
FolderType = FolderType;
}
|