var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var Unibase;
(function (Unibase) {
let Platform;
(function (Platform) {
let Integrations;
(function (Integrations) {
let Components;
(function (Components) {
class CreateServiceProvider extends Platform.Core.BaseComponent {
jsFiles() {
return ["platform/integrations/managers/integrationmanager.js", "platform/integrations/components/createintegrator.js", "platform/integrations/components/createserviceprovider.js", "platform/integrations/components/synclog.js"];
}
cssFiles() {
return [];
}
init() {
return __awaiter(this, void 0, void 0, function* () {
this.navigationHelper.popup(0, '', Unibase.Platform.Integrations.Components.CreateServiceProvider.Instance(), null, Platform.Helpers.Size.Large);
});
}
html(id, containerid) {
return '
';
}
load(id, containerid, callback) {
CreateServiceProvider.Instance().loadServiceProviders();
}
loadForm(FormId, Pk_Value, AppConfigurationId, Callback, ElementId) {
}
loadServiceProviders() {
var IntegratorId = Unibase.Themes.Providers.DetailHelper.recordId;
Unibase.Platform.Integrations.Managers.IntegrationManager.Instance().getservicesbyIntegrator(IntegratorId).then(function (response) {
if (response.result.length == 0) {
$('#div_Providers').show();
}
else {
$('#div_Providers').hide();
$(".providers-list").html('');
for (var i = 0; i < response.result.length; i++) {
var html = '';
var data = response.result[i];
var html = '' +
'' + data.ProviderName + "_" + data.ServiceName + '
' +
'
' +
'
Add ';
html += '';
$(".providers-item:last").after(html);
}
}
$.when($('.providerServiceName').filter(function () {
return $(this).css('text-overflow') == 'ellipsis';
}).each(function () {
if (this.offsetWidth < this.scrollWidth && !$(this).attr('title')) {
$(this).attr('title', $(this).text());
}
}));
});
}
saveServiceIntegrator(serviceId) {
if (serviceId != null && serviceId != undefined) {
var postdata = {
ServiceId: serviceId,
IntegratorId: Unibase.Themes.Providers.DetailHelper.recordId,
TimeInterval: Number(0),
IsUpdate: false,
DisplayText: $("#txt_displayName_" + serviceId).val() != undefined ? $("#txt_displayName_" + serviceId).val().toString() : ""
};
let appcontrolid = "Unibase_serviceProvider";
let result = Unibase.Platform.Forms.Components.FormViewer.Instance().requiredFieldValidation(appcontrolid);
if (result == false) {
MessageHelper.Instance().showError("Mandatory fields are missing", "Unibase_ValidationSummary");
return false;
}
else {
Unibase.Platform.Integrations.Managers.IntegrationManager.Instance().saveServiceIntegrator(postdata).then(function (response) {
if (response.status == Unibase.Data.Status.Success) {
$("#btnClose").click();
MessageHelper.Instance().showSuccess(response.message, '');
}
else
MessageHelper.Instance().showError(response.message, 'Unibase_ValidationSummary');
});
}
}
}
saveSettings(containerid, ServiceIntegratorId, isDownload) {
var instance = this;
if (isDownload == false)
$("#exeService_" + ServiceIntegratorId).text("Executing...");
else
$("#downloadData_" + ServiceIntegratorId).text("Downloading...");
var serviceSettingsObj = [];
$("#div_InputSettings").find(".item-row").each(function () {
var serviceSettingId = $(this).find(".hf_Header_Service").val();
var serviceId = $(this).find(".hf_Header_ServiceId").val();
var settingName = $(this).find(".txt_ConfigKey_Collection").val();
var settingValue = $(this).find(".txt_ConfigValue_Collection").val();
var settingTypeId = $(this).find(".hf_Header_SettingTypeId").val();
var obj = {
ServiceSettingId: Number(serviceSettingId),
ServiceId: Number(serviceId),
SettingName: settingName.toString(),
SettingValue: settingValue,
SettingTypeId: Number(settingTypeId),
IsInput: true
};
serviceSettingsObj.push(obj);
});
var executeService = {
ServiceSettings: serviceSettingsObj,
ServiceIntegratorId: Number(ServiceIntegratorId),
IsDownload: isDownload
};
this.fileCacheHelper.loadJsFile("platform/integrations/managers/integrationmanager.js", function () {
Unibase.Platform.Integrations.Managers.IntegrationManager.Instance().executeServiceRequest(executeService).then(function (response) {
if (isDownload == false) {
$("#exeService_" + ServiceIntegratorId).text("Execute Service");
if (containerid != "") {
$('#' + containerid).modal('hide');
$('#' + containerid).remove();
}
}
else {
instance.downloadfile(response.result);
$("#downloadData_" + ServiceIntegratorId).text("Download");
}
if (response.errors != null) {
alert(response.message);
return false;
}
else {
MessageHelper.Instance().showSuccess(response.message, "");
}
});
});
}
downloadfile(filepath) {
var urlsplitdata = filepath.split("/");
var urlfiledetails = urlsplitdata[urlsplitdata.length - 1].split(".");
filepath = filepath.split("/").join("\\");
var path = '/apis/v4/Documents/DownloadFile?filename=' + filepath.replace(window.location.origin + '/', '');
window.location.href = _appsettings.server_url() + path;
}
loadSyncLog(serviceIntegratorId) {
Unibase.Platform.Integrations.Components.SyncLog.serviceIntegratorId = serviceIntegratorId;
Unibase.Platform.Integrations.Components.SyncLog.Instance().loadForm(0, 0, 0, '', '');
}
static Instance() {
return new CreateServiceProvider();
}
}
Components.CreateServiceProvider = CreateServiceProvider;
})(Components = Integrations.Components || (Integrations.Components = {}));
})(Integrations = Platform.Integrations || (Platform.Integrations = {}));
})(Platform = Unibase.Platform || (Unibase.Platform = {}));
})(Unibase || (Unibase = {}));