"git@gitlab.lam.fr:anis/anis-client.git" did not exist on "94c6b671ca68991d8bb5547782260d55fd3d8ba5"
Newer
Older
/**
* This file is part of Anis Client.
*
* @copyright Laboratoire d'Astrophysique de Marseille / CNRS
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import { Component, Input, Output, TemplateRef, EventEmitter } from '@angular/core';
import { FormGroup } from '@angular/forms';
import { BsModalService } from 'ngx-bootstrap/modal';
import { BsModalRef } from 'ngx-bootstrap/modal/bs-modal-ref.service';
import { FileInfo } from 'src/app/metamodel/models';
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
@Component({
selector: 'app-data-path-form-control',
templateUrl: 'data-path-form-control.component.html'
})
export class DataPathFormControlComponent {
@Input() form: FormGroup;
@Input() rootDirectory: FileInfo[];
@Input() rootDirectoryIsLoading: boolean;
@Input() rootDirectoryIsLoaded: boolean;
@Output() loadRootDirectory: EventEmitter<string> = new EventEmitter();
modalRef: BsModalRef;
fileExplorerPath = '';
fileExplorerPristine = true;
constructor(private modalService: BsModalService) { }
openModal(template: TemplateRef<any>) {
this.fileExplorerPristine = true;
this.fileExplorerPath = this.form.controls.data_path.value;
if (!this.fileExplorerPath) {
this.fileExplorerPath = '';
}
this.modalRef = this.modalService.show(template);
this.loadRootDirectory.emit(this.fileExplorerPath);
}
dataPathAction(fileInfo: FileInfo): void {
if (fileInfo.name === '.' || fileInfo.type !== 'dir') {
return;
}
if (fileInfo.name === '..') {
this.fileExplorerPath = this.fileExplorerPath.substr(0, this.fileExplorerPath.lastIndexOf("/"));
} else {
this.fileExplorerPath += '/' + fileInfo.name;
}
this.fileExplorerPristine = false;
this.loadRootDirectory.emit(this.fileExplorerPath);
}
selectDirectory() {
this.form.controls.data_path.setValue(this.fileExplorerPath);
this.modalRef.hide();
}
}