123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164 |
- 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 '<div id="Unibase_serviceProvider" default="" data-validate="parsley" data-isdynamic="false"><div class="b-b bg-white header serviceProviderHeader"><strong class="text-dark">Service Provider</strong><a class="btn btn-sm ml-auto"><i class="ti-help-alt" title="help" href="javascript:;" target="_blank"></i></a></div><div data-simplebar class="simple-scroll-bar scrollable service-provider-body"><div id="Unibase_ValidationSummary" class="clear mt-10"></div><div class="card"><div class="card-body"><div class="row"> <div class="col-sm-12"><ul class="list-group no-border m-t-n-sm list-group no-border providers-list divproviders"> </ul></div> <div class="alert alert-info wrapper-lg" id="div_Providers">There is no Providers</div></div></div></div></div><div id="div_serviceProviderFooter" class="bg-white footer"><a class="btn btn-light btn-sm btn-center mr-auto btn-close" id="btnClose">Close</a><a class="btn btn-primary btn-center btn-sm text-white" id="btnRefresh">Refresh</a></div></div>';
- }
- 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('<li class="providers-item"><div class= "row card-header"><strong class="col-sm-5">Name</strong><strong class="col-sm-5">Display Text</strong> </div></li>');
- for (var i = 0; i < response.result.length; i++) {
- var html = '';
- var data = response.result[i];
- var html = '<li class="row list-group-item integ-details providers-item li-' + data.ServiceId + '">' +
- '<div class="row"><div class="h5 col-sm-5 providerServiceName" id="providerServiceName" style="overflow: hidden;text-overflow:ellipsis;white-space:nowrap;">' + data.ProviderName + "_" + data.ServiceName + '</div>' +
- '<div class="col-sm-6"><input type="textbox" id="txt_displayName_' + data.ServiceId + '" class="txt_displayName col-sm-12 required" value="' + data.ProviderName + "_" + data.ServiceName + '"/></div>' +
- '<a onclick="javascript:Unibase.Platform.Integrations.Components.CreateServiceProvider.Instance().saveServiceIntegrator(' + data.ServiceId + ');" class="btn btn-primary divInstall_' + data.ServiceId + ' pull-right">Add</a></div>';
- html += '</li>';
- $(".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 = {}));
|