diff options
author | Danijel Anđelković <adanijel99@gmail.com> | 2022-06-06 02:45:47 +0200 |
---|---|---|
committer | Danijel Anđelković <adanijel99@gmail.com> | 2022-06-06 02:45:47 +0200 |
commit | 09a33e72501affb6d07507e396151f02d16daf9a (patch) | |
tree | 573d977f1e7d0130d0287a669e6bbaa516b2106e /frontend/src/app/_modals/share-dialog/share-dialog.component.ts | |
parent | 542acf92fd69fea61afbef34f12cd6147f919bc8 (diff) |
Dodao deljenje datasetova i modela, dialog za podesavanje opcija za deljenje (isPublic accessibleByLink), sa mogucnoscu kopiranja linka za deljenje. Dodao stranice za prikaz javnih datasetova / modela.
Diffstat (limited to 'frontend/src/app/_modals/share-dialog/share-dialog.component.ts')
-rw-r--r-- | frontend/src/app/_modals/share-dialog/share-dialog.component.ts | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/frontend/src/app/_modals/share-dialog/share-dialog.component.ts b/frontend/src/app/_modals/share-dialog/share-dialog.component.ts new file mode 100644 index 00000000..2331cd8b --- /dev/null +++ b/frontend/src/app/_modals/share-dialog/share-dialog.component.ts @@ -0,0 +1,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; +} |