From 09a33e72501affb6d07507e396151f02d16daf9a Mon Sep 17 00:00:00 2001 From: Danijel Anđelković Date: Mon, 6 Jun 2022 02:45:47 +0200 Subject: 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. --- .../_modals/share-dialog/share-dialog.component.ts | 70 ++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 frontend/src/app/_modals/share-dialog/share-dialog.component.ts (limited to 'frontend/src/app/_modals/share-dialog/share-dialog.component.ts') 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, @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; +} -- cgit v1.2.3