aboutsummaryrefslogtreecommitdiff
path: root/frontend/src/app/_modals/share-dialog
diff options
context:
space:
mode:
Diffstat (limited to 'frontend/src/app/_modals/share-dialog')
-rw-r--r--frontend/src/app/_modals/share-dialog/share-dialog.component.css0
-rw-r--r--frontend/src/app/_modals/share-dialog/share-dialog.component.html14
-rw-r--r--frontend/src/app/_modals/share-dialog/share-dialog.component.spec.ts25
-rw-r--r--frontend/src/app/_modals/share-dialog/share-dialog.component.ts70
4 files changed, 109 insertions, 0 deletions
diff --git a/frontend/src/app/_modals/share-dialog/share-dialog.component.css b/frontend/src/app/_modals/share-dialog/share-dialog.component.css
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/frontend/src/app/_modals/share-dialog/share-dialog.component.css
diff --git a/frontend/src/app/_modals/share-dialog/share-dialog.component.html b/frontend/src/app/_modals/share-dialog/share-dialog.component.html
new file mode 100644
index 00000000..32584197
--- /dev/null
+++ b/frontend/src/app/_modals/share-dialog/share-dialog.component.html
@@ -0,0 +1,14 @@
+<h1 mat-dialog-title class="text-center">Podeli {{data.fileType == 0 ? 'izvor podataka' : 'konfiguraciju neuronske mreže'}}</h1>
+<div mat-dialog-content class="mt-5 mb-3 mx-1">
+ <form>
+ <mat-checkbox class="m-2" [(ngModel)]="data.file.isPublic" [ngModelOptions]="{standalone: true}" (change)="publicChanged()">Svi mogu da vide </mat-checkbox>
+ <mat-checkbox class="m-2" [(ngModel)]="data.file.accessibleByLink" [ngModelOptions]="{standalone: true}" (change)="linkChanged()">Osobe sa linkom mogu da vide</mat-checkbox>
+ <div class="input-group my-3">
+ <input type="text" [value]="link" class="form-control" placeholder="" aria-label="Copy link button addon" aria-describedby="button-copy">
+ <button class="btn btn-outline-primary" type="button" id="button-copy" (click)="copy()" [disabled]="!data.file.accessibleByLink"><div class="mt-1"><mat-icon *ngIf="data.file.accessibleByLink">link</mat-icon><mat-icon *ngIf="!data.file.accessibleByLink">link_off</mat-icon></div></button>
+ </div>
+ </form>
+</div>
+<div mat-dialog-actions class="justify-content-center">
+ <button mat-stroked-button (click)="close()">Gotovo</button>
+</div> \ No newline at end of file
diff --git a/frontend/src/app/_modals/share-dialog/share-dialog.component.spec.ts b/frontend/src/app/_modals/share-dialog/share-dialog.component.spec.ts
new file mode 100644
index 00000000..51bd4c9a
--- /dev/null
+++ b/frontend/src/app/_modals/share-dialog/share-dialog.component.spec.ts
@@ -0,0 +1,25 @@
+import { ComponentFixture, TestBed } from '@angular/core/testing';
+
+import { ShareDialogComponent } from './share-dialog.component';
+
+describe('ShareDialogComponent', () => {
+ let component: ShareDialogComponent;
+ let fixture: ComponentFixture<ShareDialogComponent>;
+
+ beforeEach(async () => {
+ await TestBed.configureTestingModule({
+ declarations: [ ShareDialogComponent ]
+ })
+ .compileComponents();
+ });
+
+ beforeEach(() => {
+ fixture = TestBed.createComponent(ShareDialogComponent);
+ component = fixture.componentInstance;
+ fixture.detectChanges();
+ });
+
+ it('should create', () => {
+ expect(component).toBeTruthy();
+ });
+});
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;
+}