Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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
/**
* 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, OnInit } from '@angular/core';
import { NgForm } from '@angular/forms';
import { Router } from '@angular/router';
import { ToastrService } from 'ngx-toastr';
import { SearchService } from 'src/app/instance/store/services/search.service';
@Component({
selector: 'app-form-attribut',
templateUrl: './form-sample.component.html',
})
export class FormSampleComponent implements OnInit {
@Input() instanceName: string = null;
@Input() faSymbol: string = null;
@Input() type: string = null;
@Input() label: string = null;
@Input() textButton: string = null;
@Input() datasetName: string = null;
constructor(
private router: Router,
private search: SearchService,
private toastr: ToastrService
) {}
ngOnInit(): void {}
submit(f: NgForm): void {
const query: string = `${this.datasetName}?a=count&c=1::eq::${f.value.inputVal}`;
this.search.retrieveDataLength(query).subscribe((data) => {
switch (data[0].nb) {
case 0:
this.toastr.error(
'Target ID does not exist',
'Navigation error'
);
break;
case 1:
const route: string = `/instance/${this.instanceName}/search/detail/${this.datasetName}/${f.value.inputVal}`;
this.router.navigate([route]);
break;
default:
console.log('Problem occured during the navigation');
}
});
}
}