mirror of https://github.com/Ombi-app/Ombi
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
52 lines
1.7 KiB
52 lines
1.7 KiB
import { Component, OnInit } from '@angular/core';
|
|
import { FormGroup, FormBuilder } from '@angular/forms';
|
|
|
|
import { SettingsService } from '../../services/settings.service';
|
|
import { NotificationService } from "../../services/notification.service";
|
|
|
|
@Component({
|
|
templateUrl: './ombi.component.html',
|
|
})
|
|
export class OmbiComponent implements OnInit {
|
|
|
|
constructor(private settingsService: SettingsService,
|
|
private notificationService: NotificationService,
|
|
private fb: FormBuilder) { }
|
|
|
|
form: FormGroup;
|
|
|
|
ngOnInit(): void {
|
|
this.settingsService.getOmbi().subscribe(x => {
|
|
this.form = this.fb.group({
|
|
port: [x.port],
|
|
collectAnalyticData: [x.collectAnalyticData],
|
|
apiKey: [{ value: x.apiKey, disabled: true }],
|
|
externalUrl: [x.externalUrl],
|
|
allowExternalUsersToAuthenticate: [x.allowExternalUsersToAuthenticate]
|
|
});
|
|
});
|
|
}
|
|
|
|
|
|
refreshApiKey() {
|
|
this.settingsService.resetOmbiApi().subscribe(x => {
|
|
this.form.patchValue({
|
|
apiKey: x
|
|
});
|
|
});
|
|
}
|
|
|
|
onSubmit(form: FormGroup) {
|
|
if (form.invalid) {
|
|
this.notificationService.error("Validation", "Please check your entered values");
|
|
return;
|
|
}
|
|
this.settingsService.saveOmbi(form.value).subscribe(x => {
|
|
if (x) {
|
|
this.notificationService.success("Settings Saved", "Successfully saved Ombi settings");
|
|
} else {
|
|
this.notificationService.success("Settings Saved", "There was an error when saving the Ombi settings");
|
|
}
|
|
});
|
|
}
|
|
} |