Merge pull request #19 from Kareadita/feature/web-cleanup
Implemented some safety checks on library editor modal. Added a place…
This commit is contained in:
commit
0614d55733
5 changed files with 26 additions and 10 deletions
|
|
@ -80,7 +80,6 @@ export class DirectoryPickerComponent implements OnInit {
|
||||||
}
|
}
|
||||||
|
|
||||||
shareFolder(folderName: string, event: any) {
|
shareFolder(folderName: string, event: any) {
|
||||||
console.log(`You selected ${folderName} as your folder to share!`);
|
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,9 @@
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
|
<div class="alert alert-info" *ngIf="errorMessage !== ''">
|
||||||
|
<strong>Error: </strong> {{errorMessage}}
|
||||||
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="library-name">Name</label>
|
<label for="library-name">Name</label>
|
||||||
<input id="library-name" class="form-control" formControlName="name" type="text">
|
<input id="library-name" class="form-control" formControlName="name" type="text">
|
||||||
|
|
@ -25,13 +28,13 @@
|
||||||
<div class="list-group">
|
<div class="list-group">
|
||||||
<li class="list-group-item" *ngFor="let folder of selectedFolders; let i = index">
|
<li class="list-group-item" *ngFor="let folder of selectedFolders; let i = index">
|
||||||
{{folder}}
|
{{folder}}
|
||||||
<!-- TODO: Implement ability to remove folders added-->
|
<button class="btn pull-right mr-2 btn-sm" (click)="removeFolder(folder)"><i class="fa fa-times-circle"></i></button>
|
||||||
</li>
|
</li>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<button type="button" class="btn btn-light" (click)="reset()">Reset</button>
|
<button type="button" class="btn btn-light" (click)="reset()">Reset</button>
|
||||||
<button type="button" class="btn btn-secondary" (click)="close()">Cancel</button>
|
<button type="button" class="btn btn-secondary" (click)="close()">Cancel</button>
|
||||||
<button type="submit" class="btn btn-primary" (click)="submitLibrary()">Save</button>
|
<button type="submit" class="btn btn-primary" (click)="submitLibrary()" [disabled]="!libraryForm.dirty">Save</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { Component, Input, OnChanges, OnInit } from '@angular/core';
|
import { Component, Input, OnInit } from '@angular/core';
|
||||||
import { FormControl, FormGroup, Validators } from '@angular/forms';
|
import { FormControl, FormGroup, Validators } from '@angular/forms';
|
||||||
import { NgbActiveModal, NgbModal } from '@ng-bootstrap/ng-bootstrap';
|
import { NgbActiveModal, NgbModal } from '@ng-bootstrap/ng-bootstrap';
|
||||||
import { Library } from 'src/app/_models/library';
|
import { Library } from 'src/app/_models/library';
|
||||||
|
|
@ -10,7 +10,7 @@ import { DirectoryPickerComponent, DirectoryPickerResult } from '../directory-pi
|
||||||
templateUrl: './library-editor-modal.component.html',
|
templateUrl: './library-editor-modal.component.html',
|
||||||
styleUrls: ['./library-editor-modal.component.scss']
|
styleUrls: ['./library-editor-modal.component.scss']
|
||||||
})
|
})
|
||||||
export class LibraryEditorModalComponent implements OnInit, OnChanges {
|
export class LibraryEditorModalComponent implements OnInit {
|
||||||
|
|
||||||
@Input() library: Library | undefined = undefined;
|
@Input() library: Library | undefined = undefined;
|
||||||
|
|
||||||
|
|
@ -20,6 +20,7 @@ export class LibraryEditorModalComponent implements OnInit, OnChanges {
|
||||||
});
|
});
|
||||||
|
|
||||||
selectedFolders: string[] = [];
|
selectedFolders: string[] = [];
|
||||||
|
errorMessage = '';
|
||||||
|
|
||||||
constructor(private modalService: NgbModal, private libraryService: LibraryService, public modal: NgbActiveModal) { }
|
constructor(private modalService: NgbModal, private libraryService: LibraryService, public modal: NgbActiveModal) { }
|
||||||
|
|
||||||
|
|
@ -27,27 +28,37 @@ export class LibraryEditorModalComponent implements OnInit, OnChanges {
|
||||||
this.setValues();
|
this.setValues();
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnChanges() {
|
|
||||||
console.log('Library: ', this.library);
|
removeFolder(folder: string) {
|
||||||
|
this.selectedFolders = this.selectedFolders.filter(item => item !== folder);
|
||||||
}
|
}
|
||||||
|
|
||||||
submitLibrary() {
|
submitLibrary() {
|
||||||
const model = this.libraryForm.value;
|
const model = this.libraryForm.value;
|
||||||
model.folders = this.selectedFolders;
|
model.folders = this.selectedFolders;
|
||||||
|
|
||||||
|
if (this.libraryForm.errors) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (this.library !== undefined) {
|
if (this.library !== undefined) {
|
||||||
model.id = this.library.id;
|
model.id = this.library.id;
|
||||||
this.libraryService.update(model).subscribe(() => {
|
this.libraryService.update(model).subscribe(() => {
|
||||||
this.close(true);
|
this.close(true);
|
||||||
|
}, err => {
|
||||||
|
this.errorMessage = err;
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
this.libraryService.create(model).subscribe(() => {
|
this.libraryService.create(model).subscribe(() => {
|
||||||
this.close(true);
|
this.close(true);
|
||||||
|
}, err => {
|
||||||
|
this.errorMessage = err;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
close(returnVal= false) {
|
close(returnVal= false) {
|
||||||
|
const model = this.libraryForm.value;
|
||||||
this.modal.close(returnVal);
|
this.modal.close(returnVal);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@
|
||||||
<button class="btn btn-primary" (click)="openEditLibraryAccess(member)"><i class="fa fa-pencil" title="Edit {{member.username | titlecase}}"></i></button>
|
<button class="btn btn-primary" (click)="openEditLibraryAccess(member)"><i class="fa fa-pencil" title="Edit {{member.username | titlecase}}"></i></button>
|
||||||
</div>
|
</div>
|
||||||
</h4>
|
</h4>
|
||||||
<div>Last Active: {{member.lastActive | date}}</div>
|
<div>Last Active: {{member.lastActive | date: 'dd/MM/yyyy'}}</div>
|
||||||
<div *ngIf="!member.isAdmin">Sharing: {{formatLibraries(member)}}</div>
|
<div *ngIf="!member.isAdmin">Sharing: {{formatLibraries(member)}}</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,11 @@
|
||||||
<!-- <li class="nav-item">
|
<!-- <li class="nav-item">
|
||||||
<input type="text" placeholder="Search bar">
|
<input type="text" placeholder="Search bar">
|
||||||
</li> -->
|
</li> -->
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
|
<div class="container-fluid" style="max-width: 400px">
|
||||||
|
<input class="form-control me-2" type="search" placeholder="Search" aria-label="Search">
|
||||||
|
<!-- TODO: Implement autocomplete for searching -->
|
||||||
|
</div>
|
||||||
|
|
||||||
<!-- TODO: Put SignalR notification button dropdown here. -->
|
<!-- TODO: Put SignalR notification button dropdown here. -->
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue