2018-03-24 23:17:44 -04:00
|
|
|
import { Component, OnInit } from "@angular/core";
|
|
|
|
import { ToasterService } from "angular2-toaster";
|
|
|
|
import { AdminNebApiService } from "../../../../shared/services/admin/admin-neb-api.service";
|
|
|
|
import { FE_NebConfiguration } from "../../../../shared/models/admin-responses";
|
|
|
|
import { FE_Integration } from "../../../../shared/models/integration";
|
2020-10-23 07:30:20 -04:00
|
|
|
import { TranslateService } from "@ngx-translate/core";
|
2021-08-16 18:00:59 -04:00
|
|
|
import { NgbActiveModal } from "@ng-bootstrap/ng-bootstrap";
|
2018-03-24 23:17:44 -04:00
|
|
|
|
|
|
|
interface GiphyConfig {
|
|
|
|
api_key: string;
|
|
|
|
use_downsized: boolean;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
templateUrl: "./giphy.component.html",
|
|
|
|
styleUrls: ["./giphy.component.scss", "../config-dialog.scss"],
|
|
|
|
})
|
2021-08-16 18:00:59 -04:00
|
|
|
export class AdminNebGiphyConfigComponent implements OnInit {
|
2018-03-24 23:17:44 -04:00
|
|
|
|
|
|
|
public isLoading = true;
|
|
|
|
public isUpdating = false;
|
|
|
|
public config: GiphyConfig;
|
|
|
|
public integration: FE_Integration;
|
|
|
|
public neb: FE_NebConfiguration;
|
|
|
|
|
2021-08-16 18:00:59 -04:00
|
|
|
constructor(public modal: NgbActiveModal,
|
2018-03-24 23:17:44 -04:00
|
|
|
private adminNebApi: AdminNebApiService,
|
2020-10-23 07:30:20 -04:00
|
|
|
private toaster: ToasterService,
|
|
|
|
public translate: TranslateService) {
|
|
|
|
this.translate = translate;
|
2018-03-24 23:17:44 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
public ngOnInit() {
|
|
|
|
this.adminNebApi.getIntegrationConfiguration(this.neb.id, this.integration.type).then(config => {
|
|
|
|
this.config = config;
|
|
|
|
this.isLoading = false;
|
|
|
|
}).catch(err => {
|
|
|
|
console.error(err);
|
2020-10-23 07:30:20 -04:00
|
|
|
this.translate.get('Error loading configuration').subscribe((res: string) => {this.toaster.pop("error", res); });
|
2018-03-24 23:17:44 -04:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public save() {
|
|
|
|
this.isUpdating = true;
|
|
|
|
this.adminNebApi.setIntegrationConfiguration(this.neb.id, this.integration.type, this.config).then(() => {
|
2020-10-23 07:30:20 -04:00
|
|
|
this.translate.get('Configuration updated').subscribe((res: string) => {this.toaster.pop("success", res); });
|
2021-08-16 18:00:59 -04:00
|
|
|
this.modal.close();
|
2018-03-24 23:17:44 -04:00
|
|
|
}).catch(err => {
|
|
|
|
this.isUpdating = false;
|
|
|
|
console.error(err);
|
2020-10-23 07:30:20 -04:00
|
|
|
this.translate.get('Error updating integration').subscribe((res: string) => {this.toaster.pop("error", res); });
|
2018-03-24 23:17:44 -04:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|