Newer
Older
import { Component, OnInit } from '@angular/core';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { NotificationService } from '../../../service/notification/notification.service';
import { tap } from 'rxjs/internal/operators/tap';
import { LANG } from '../../translate.component';
import { catchError } from 'rxjs/operators';
import { of } from 'rxjs';
import { HttpClient } from '@angular/common/http';
@Component({
selector: 'app-docservers',
templateUrl: './docservers.component.html',
styleUrls: ['./docservers.component.scss']
})
export class DocserversComponent implements OnInit {
stepFormGroup: FormGroup;
constructor(
private _formBuilder: FormBuilder,
private notify: NotificationService,
) {
this.stepFormGroup = this._formBuilder.group({
docserversPath: ['/opt/maaarch/docservers/', Validators.required],
stateStep: ['', Validators.required],
this.stepFormGroup.controls['docserversPath'].valueChanges.pipe(
tap(() => this.stepFormGroup.controls['stateStep'].setValue(''))
).subscribe();
}
ngOnInit(): void {
}
isValidStep() {
return this.stepFormGroup === undefined ? false : this.stepFormGroup.valid;
}
getFormGroup() {
return this.stepFormGroup;
}
checkAvailability() {
const info = {
path: this.stepFormGroup.controls['docserversPath'].value,
};
/*this.http.get(`../rest/installer/docservers`, { params: info }).pipe(
tap((data: any) => {
this.notify.success(this.lang.rightInformations);
this.stepFormGroup.controls['stateStep'].setValue('success');
}),
catchError((err: any) => {
this.notify.error(this.lang.badInformations);
this.stepFormGroup.controls['stateStep'].setValue('');
return of(false);
})
).subscribe();*/
// FOR TEST
this.stepFormGroup.controls['stateStep'].setValue('success');
this.notify.success('TODO : waiting back docservers check');
getInfoToInstall(): any[] {
return [{
body: {
path: this.stepFormGroup.controls['docserversPath'].value,
route: '../rest/installer/docservers',
description: this.lang.stepDocserversActionDesc,
installPriority: 3
}];