@kumologica/sdk 3.6.0-beta12 → 3.6.0-beta13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -21320,7 +21320,7 @@ RED.view.tools = (function() {
21320
21320
  RED.sidebar.info.init();
21321
21321
  RED.sidebar.test.init();
21322
21322
  RED.sidebar.git.init();
21323
- RED.sidebar.kumohub.init();
21323
+ //RED.sidebar.kumohub.init();
21324
21324
  RED.sidebar.azure.init();
21325
21325
  RED.sidebar.awsDeploy.init();
21326
21326
 
@@ -26842,833 +26842,7 @@ RED.sidebar.azure = (function () {
26842
26842
  init: init,
26843
26843
  show: show,
26844
26844
  };
26845
- })();;RED.sidebar.kumohub = (function () {
26846
- marked.setOptions({
26847
- renderer: new marked.Renderer(),
26848
- gfm: true,
26849
- tables: true,
26850
- breaks: false,
26851
- pedantic: false,
26852
- sanitize: true,
26853
- smartLists: true,
26854
- smartypants: false,
26855
- });
26856
-
26857
- var content;
26858
- var sections;
26859
- var functionSection;
26860
- var environmentSection;
26861
- var initialised = false;
26862
- var parameters;
26863
- var SELECT_KUMOHUB_PROFILE = 'Select Kumohub profile...';
26864
- var DEFINE_KUMOHUB_PROFILE = 'Define Kumohub profile';
26865
- let workspaces; // workspaces from kumohub.io
26866
- // store for workspace, storage, policy from profile before kumohub login
26867
- let profileWorkspace;
26868
- let profileStage;
26869
- let profilePolicy;
26870
-
26871
- const DEPLOYING = 'DEPLOYING';
26872
- const NOTDEPLOYING = 'NOTDEPLOYING';
26873
- let deployState = NOTDEPLOYING;
26874
-
26875
- function initCss() {
26876
- $('<style>')
26877
- .text(
26878
- `
26879
- select {
26880
- outline: 1.5px solid #ccc;
26881
- }
26882
- select:focus {
26883
- outline: 1.5px solid #ccc;
26884
- outline-offset: 0px;
26885
- }
26886
- .invalid {
26887
- border: 1px solid red;
26888
- }
26889
-
26890
- .valid {
26891
- border: 1px solid green;
26892
- }
26893
- datalist {
26894
- max-height: 300px;
26895
- overflow-y: auto !important;
26896
- }
26897
- .editor-button-xsmall {
26898
- height: 16px;
26899
- min-width: 16px;
26900
- line-height: 14px;
26901
- font-size: 10px;
26902
- border-radius: 2px;
26903
- padding: 0 2px;
26904
- }
26905
- `
26906
- )
26907
- .appendTo(document.head);
26908
- }
26909
-
26910
- function initHTML() {
26911
- initCss();
26912
- content = document.createElement('div');
26913
- content.className = 'sidebar-kumohub';
26914
-
26915
- RED.actions.add('core:show-kumohub-tab', show);
26916
-
26917
- var stackContainer = $('<div>', {
26918
- class: 'sidebar-node-info-stack',
26919
- }).appendTo(content);
26920
-
26921
- let headerContentHtml = `
26922
- <div class="sidebar-title-wrapper">
26923
- <span>Deploy: Kumohub</span>
26924
- </div>
26925
- <div id="kumohub-sidebar-header" class="sidebar-header">
26926
- <div id="kumohub-instrumentation" class="node-info">
26927
- <div id="kumohub-profiles-wrapper">
26928
- <span style="padding-left: 3px">Profiles</span>
26929
- <select id="kumohub-sidebar-profiles" class="palette-textinput" style="padding: 0px;">
26930
- <option value="Select Kumohub profile..." style="color:#3988CB !important">Click to select one...</option>
26931
- </select>
26932
- </div>
26933
-
26934
- <div id="kumohub-wrapper">
26935
- <!-- connect btn -->
26936
- <div>
26937
- <a id="kumohub-sidebar-connect-btn" class="sidebar-header-button" href="#">
26938
- <i id="kumohub-sidebar-connect-icon" class="fa fa-circle" style="color: red"></i>
26939
- Connect
26940
- </a>
26941
- </div>
26942
-
26943
- <!-- deploy btn -->
26944
- <div style="margin-right: 4px;">
26945
- <a id="kumohub-sidebar-deploy-btn" class="sidebar-header-button" href="#">
26946
- <i id="kumohub-sidebar-deploy-icon" class="fa fa-cloud-upload"></i>
26947
- Deploy
26948
- </a>
26949
- </div>
26950
-
26951
- <!-- export btn -->
26952
- <div id="kumohub-options-dropdown">
26953
- <a id="kumohub-sidebar-export-btn" class="sidebar-header-button" href="#">
26954
- <i class="fa fa-ellipsis-h"></i>
26955
- </a>
26956
- </div>
26957
- <div id="kumohub-options-dropdown-content">
26958
- <span id="kumohub-buildZipBtn" class="option">Export as Zip</span>
26959
- <!--span id="kumohub-exportServerlessBtn" class="option">Serverless</span-->
26960
- </div>
26961
- </div>
26962
- </div>
26963
- <table hidden id="kumohub-sidebar-error" class="node-info" style="margin: 0px;">
26964
- <tr>
26965
- <td style="border: 0px solid white; padding: 3px; width: 100%;">
26966
- <p style="font-size: 12px; margin: 0px; text-align: center; color:red;"><span>Kumohub profile has not been configured</span></p>
26967
- </td>
26968
-
26969
- <td style="border: 0px solid white; padding: 3px;">
26970
- <a id="kumohub-sidebar-error-help-btn" class="editor-button editor-button-xsmall" href="https://docs.kumologica.com/docs/guide/GettingStarted.html#installation" target="_blank">
26971
- <i class="fa fa-question"></i>
26972
- </a>
26973
- </td>
26974
-
26975
- <td style="border: 0px solid white; padding: 3px 6px 3px 3px;">
26976
- <a id="kumohub-sidebar-error-close-btn" class="editor-button editor-button-xsmall" href="#">
26977
- <i class="fa fa-times"></i></a>
26978
- </td>
26979
- </tr>
26980
- </table>
26981
- </div>
26982
- `;
26983
-
26984
- $(headerContentHtml).appendTo(stackContainer);
26985
-
26986
- let bodyContainer = $(`<div id="kumohub-sidebar-body" style="display:none"></div>`);
26987
- bodyContainer.appendTo(stackContainer);
26988
-
26989
- sections = RED.stack
26990
- .create({
26991
- container: bodyContainer,
26992
- })
26993
- .hide();
26994
-
26995
- // function section
26996
- functionSection = sections.add({
26997
- title: 'function',
26998
- collapsible: true,
26999
- });
27000
- functionSection.expand();
27001
-
27002
- // environment section
27003
- environmentSection = sections.add({
27004
- title: 'environment',
27005
- collapsible: true,
27006
- });
27007
- //environmentSection.expand();
27008
-
27009
- RED.sidebar.addTab({
27010
- id: 'kumohub',
27011
- label: 'Kumohub',
27012
- name: 'Kumohub Deployer',
27013
- iconClass: 'fa fa-cloud',
27014
- action: 'core:show-kumohub-tab',
27015
- content: content,
27016
- pinned: true,
27017
- enableOnEdit: true,
27018
- onchange: onchange,
27019
- onsame: onsame
27020
- });
27021
-
27022
- // Function content init
27023
- let functionSectionHtml = `
27024
- <table class="node-info">
27025
- <tr class="node-info-node-row">
27026
- <td>Service Name</td>
27027
- <td colspan="2" style="background: white"><input style="width:100%" id="kumohub-fn-name" class="palette-textinput" pattern="[a-zA-Z0-9-_]{1,64}" type="text"></td>
27028
- </tr>
27029
- <tr class="node-info-node-row">
27030
- <td>Description</td>
27031
- <td colspan="2" style="background: white"><input style="width:100%" id="kumohub-fn-description" class="palette-textinput" type="text"></td>
27032
- </tr>
27033
- <tr class="node-info-node-row">
27034
- <td>Memory (MB)</td>
27035
- <td colspan="2" style="background: white"><input id="kumohub-fn-memory" class="palette-textinput" type="number" min="128" max="1536"></td>
27036
- </tr>
27037
- <tr class="node-info-node-row">
27038
- <td>Timeout (s)</td>
27039
- <td colspan="2" style="background: white"><input id="kumohub-fn-timeout" class="palette-textinput" type="number" min="5" max="900"></td>
27040
- </tr>
27041
- <tr class="node-info-node-row">
27042
- <td>Workspace</td>
27043
- <td colspan="2" style="background: white">
27044
- <select type="text" class="palette-textinput" id="kumohub-fn-workspace" style="float: left; width: 100%; padding: 0px; outline: 0px solid #ccc; ">
27045
- <option value="UNDEFINED" selected="true">Undefined</option>
27046
- </select>
27047
- </td>
27048
- </tr>
27049
-
27050
- <tr class="node-info-node-row">
27051
- <td>Stage</td>
27052
- <td colspan="2" style="background: white">
27053
- <select type="text" class="palette-textinput" id="kumohub-fn-stage" style="float: left; width: 100%; padding: 0px; outline: 0px solid #ccc; ">
27054
- <option value="UNDEFINED" selected="true">Undefined</option>
27055
- </select>
27056
- </td>
27057
- </tr>
27058
-
27059
- <tr class="node-info-node-row">
27060
- <td>Policy</td>
27061
- <td colspan="2" style="background: white">
27062
- <select type="text" class="palette-textinput" id="kumohub-fn-policy" style="float: left; width: 100%; padding: 0px; outline: 0px solid #ccc; ">
27063
- <option value="Public" selected="true">Public</option>
27064
- </select>
27065
- </td>
27066
- </tr>
27067
- </table>
27068
- `;
27069
- $(functionSectionHtml).appendTo(functionSection.content);
27070
- functionSection.container.show();
27071
-
27072
- // Environment section init
27073
- let environmentSectionHtml = `
27074
- <div style="display:flex; flex-direction: column; justify-content: flex-start;">
27075
- <div style="display:flex; justify-content: flex-end; padding:6px">
27076
- <a id="kumohub-add-environment-variable" href="#" class="editor-button editor-button-small red-ui-editableList-addButton">
27077
- <i class="fa fa-plus"></i> Add
27078
- </a>
27079
- </div>
27080
- <div id="kumohub-fn-env" style="display:flex; flex-direction: column">
27081
- <table id="kumohub-fn-env-table" class="node-info" style="table-layout: fixed">
27082
-
27083
- </table>
27084
- </div>
27085
- </div>
27086
- `;
27087
- $(environmentSectionHtml).appendTo(environmentSection.content);
27088
- environmentSection.container.show();
27089
-
27090
- // Tooltips
27091
- RED.popover.tooltip($('#kumohub-sidebar-deploy-btn'), 'Deploy to Kumohub');
27092
- RED.popover.tooltip($('#kumohub-options-dropdown'), 'Other Kumohub Operations');
27093
- RED.popover.tooltip($('#kumohub-sidebar-connect-btn'), 'Connect to Kumohub');
27094
- }
27095
-
27096
- function onchange(){
27097
- RED.actions.invoke('core:show-sidebar');
27098
- }
27099
-
27100
- function onsame(){
27101
- RED.actions.invoke('core:hide-sidebar');
27102
- }
27103
-
27104
- function sanitizeLambdaName(name) {
27105
- return name
27106
- .replace('.json', '')
27107
- .trim()
27108
- .replace(/^@/, '')
27109
- .replace(/[^a-zA-Z0-9-_]/g, '_')
27110
- .substr(0, 140);
27111
- }
27112
-
27113
- function setLambdaName(name) {
27114
- $('#kumohub-fn-name').val(sanitizeLambdaName(name));
27115
- }
27116
-
27117
- function setValues(params) {
27118
- // storing for setting it up after login to kumohub
27119
- profileWorkspace = params.workspace || params.account;
27120
- profileStage = params.stage;
27121
- profilePolicy = params.policy;
27122
- console.log(`profile stored: ${profileWorkspace} - ${profileStage} - ${profilePolicy}`);
27123
-
27124
- if (!initialised) {
27125
- parameters = params;
27126
- return;
27127
- }
27128
-
27129
- if (params && (params.name || params.functionName)) {
27130
- setLambdaName(params.name || params.functionName || params["service-name"]);
27131
- } else {
27132
- if (window.__kumologica.settings.projectFlowName) {
27133
- setLambdaName(window.__kumologica.settings.projectFlowName);
27134
- }
27135
- }
27136
- if (!params) {
27137
- return;
27138
- }
27139
- if (params.profile) {
27140
- setProfile(params.profile);
27141
- }
27142
- if (params.description) {
27143
- $('#kumohub-fn-description').val(params.description);
27144
- }
27145
- if (params.memory) {
27146
- $('#kumohub-fn-memory').val(params.memory);
27147
- }
27148
- if (params.timeout) {
27149
- $('#kumohub-fn-timeout').val(params.timeout);
27150
- }
27151
- if (params.account) {
27152
- $('#kumohub-fn-workspace').val(params.workspace || params.account);
27153
- fillStages(params.workspace || params.account);
27154
- }
27155
- if (params.workspace) {
27156
- $('#kumohub-fn-workspace').val(params.workspace);
27157
- fillStages(params.workspace);
27158
- }
27159
-
27160
- if (params.stage) {
27161
- $('#kumohub-fn-stage').val(params.stage);
27162
- }
27163
- if (params.policy) {
27164
- $('#kumohub-fn-policy').val(params.policy);
27165
- }
27166
-
27167
- if (params.environment && params.environment.length > 0) {
27168
- let environmentTable = $('#kumohub-fn-env-table');
27169
-
27170
- params.environment.forEach(function (e, i) {
27171
- $(`
27172
- <tr class="node-info-node-row">
27173
- <td style="background: white; width:46%"><input id="kumohub-fn-env-key" class="palette-textinput" type="text" placeholder="key" style="width:100%" value="${e.key}"></td>
27174
- <td style="background: white; width:46%"><input id="kumohub-fn-env-val" class="palette-textinput" type="text" placeholder="value" style="width:100%" value="${e.value}"></td>
27175
- <td id="kumohub-fn-env-row" style="text-align:center; width:8%" class="removeRow"><i class="fa fa-minus"></i></td>
27176
- </tr>`).appendTo(environmentTable);
27177
- });
27178
- }
27179
- }
27180
-
27181
- function getValues() {
27182
- // Basic information
27183
- let fnProfile = getProfile();
27184
- let fnName = $('#kumohub-fn-name').val();
27185
- let fnDescription = $('#kumohub-fn-description').val();
27186
- let fnMemory = $('#kumohub-fn-memory').val();
27187
- let fnTimeout = $('#kumohub-fn-timeout').val();
27188
- let fnStage = $('#kumohub-fn-stage').val();
27189
- let fnAccount = $('#kumohub-fn-account').val();
27190
- let fnWorkspace = $('#kumohub-fn-workspace').val();
27191
- let fnPolicy = $('#kumohub-fn-policy').val();
27192
-
27193
- // Environment variables
27194
- let environment = [];
27195
- let envvarRows = $('#kumohub-fn-env-table tr');
27196
-
27197
- envvarRows.map((index, row) => {
27198
- let envvar = $(row).find('td').find('input');
27199
- let key = $(envvar[0]).val();
27200
- let value = $(envvar[1]).val();
27201
- environment.push({ key, value });
27202
- });
27203
-
27204
- return {
27205
- profile: fnProfile,
27206
- "service-name": fnName,
27207
- description: fnDescription,
27208
- memory: fnMemory,
27209
- timeout: fnTimeout,
27210
- workspace: fnWorkspace || fnAccount,
27211
- stage: fnStage,
27212
- environment: environment,
27213
- policy: fnPolicy
27214
- };
27215
- }
27216
-
27217
- function fillWorkspaces() {
27218
- let dropdown = $('#kumohub-fn-workspace');
27219
-
27220
- if (workspaces.length > 0) {
27221
- dropdown.empty();
27222
- }
27223
- workspaces.forEach(function (w) {
27224
- dropdown.append($('<option></option>').val(w.name).text(w.name));
27225
- });
27226
-
27227
- if (profileWorkspace) {
27228
- $('#kumohub-fn-workspace').val(profileWorkspace);
27229
- fillStages(profileWorkspace);
27230
- }
27231
- }
27232
-
27233
- function fillStages(fnWorkspace) {
27234
-
27235
- let dropdown = $('#kumohub-fn-stage');
27236
- if (fnWorkspace == "UNDEFINED") {
27237
- //dropdown.append($('<option></option>').val("UNDEFINED").text("Undefined"));
27238
- return;
27239
- }
27240
- let ws;
27241
-
27242
- if (workspaces) {
27243
- ws = workspaces.find(w => w.name === fnWorkspace);
27244
- }
27245
-
27246
- if (ws) {
27247
- dropdown.empty();
27248
- if (ws.stages && ws.stages.length > 0) {
27249
- ws.stages.forEach(function (s) {
27250
- dropdown.append($('<option></option>').val(s.name).text(s.name));
27251
- });
27252
- if (profileStage) {
27253
- $('#kumohub-fn-stage').val(profileStage);
27254
- fillPolicies(fnWorkspace, profileStage);
27255
- }
27256
- } else {
27257
- dropdown.append($('<option></option>').val("UNDEFINED").text("Undefined"));
27258
- }
27259
-
27260
- }
27261
- }
27262
-
27263
- function fillPolicies(workspace, stage) {
27264
-
27265
- let dropdown = $('#kumohub-fn-policy');
27266
- if (workspace == "UNDEFINED") {
27267
- //dropdown.append($('<option></option>').val("UNDEFINED").text("Undefined"));
27268
- return;
27269
- }
27270
- let ws;
27271
-
27272
- if (workspaces) {
27273
- ws = workspaces.find(w => w.name === workspace);
27274
- }
27275
-
27276
- if (ws) {
27277
- let st = ws.stages.find(s => s.name === stage);
27278
- if (st && st.policies) {
27279
- dropdown.empty();
27280
-
27281
- if (st.policies && st.policies.length > 0) {
27282
- st.policies.forEach(function (p) {
27283
- dropdown.append($('<option></option>').val(p.name).text(p.name));
27284
- });
27285
- if (profilePolicy) {
27286
- $('#kumohub-fn-policy').val(profilePolicy);
27287
- }
27288
- } else {
27289
- dropdown.append($('<option></option>').val("Public").text("Public"));
27290
- }
27291
- }
27292
- }
27293
- }
27294
-
27295
- function fillProfiles() {
27296
- try {
27297
- const profiles = window.__kumologica.kumohub.listProfiles();
27298
- let dropdown = $('#kumohub-sidebar-profiles');
27299
-
27300
- if (profiles.length > 0) {
27301
- dropdown.empty();
27302
- dropdown.append($('<option disabled>Available Kumohub Profiles</option>'));
27303
- }
27304
- profiles.forEach(function (profile) {
27305
- dropdown.append($('<option></option>').val(profile).text(profile));
27306
- });
27307
-
27308
- // in case kumohub-config.json was loaded already and
27309
- // setValues could not select correct profile, doing it now
27310
- if (window.__kumologica.kumohub.profile) {
27311
- setProfile(window.__kumologica.kumohub.profile);
27312
- }
27313
- } catch (Error) {
27314
- console.log(`error: ${Error}`);
27315
- showProfileError();
27316
- }
27317
- }
27318
-
27319
- function getProfile() {
27320
- return $('#kumohub-sidebar-profiles').find(':selected').val();
27321
- }
27322
-
27323
- function setProfile(profile) {
27324
- window.__kumologica.kumohub.profile = profile;
27325
-
27326
- // Show the body if profile is set to existing profile
27327
- if (profile != SELECT_KUMOHUB_PROFILE &&
27328
- $('#kumohub-sidebar-profiles').find('option[value=' + profile + ']').length) {
27329
-
27330
- $(`#kumohub-sidebar-profiles option[value='${SELECT_KUMOHUB_PROFILE}']`).remove();
27331
- $('#kumohub-sidebar-profiles').val(profile);
27332
- } else {
27333
- $('#kumohub-sidebar-profiles').val(SELECT_KUMOHUB_PROFILE);
27334
- }
27335
- }
27336
-
27337
-
27338
- function showProfileError() {
27339
- $('#kumohub-sidebar-error').show();
27340
- }
27341
-
27342
- RED.events.on('settings:cloud-config-changed', function() {
27343
- fillProfiles();
27344
- });
27345
-
27346
- // event triggered when kumohub-config.json file has been loaded
27347
- RED.events.on('kumohub-config', function () {
27348
- if (!$('#kumohub-fn-name').val() &&
27349
- window.__kumologica.settings.projectFlowName
27350
- ) {
27351
- setLambdaName(window.__kumologica.settings.projectFlowName);
27352
- }
27353
-
27354
- if (window.__kumologica.settings.kumohubConfig ) {
27355
- const params = window.__kumologica.settings.kumohubConfig.getKumohubConfig();
27356
-
27357
- setValues(params);
27358
-
27359
- } else {
27360
- console.log('kumologica.settings.kumohubConfig not present');
27361
- }
27362
- });
27363
-
27364
- function initJs() {
27365
- fillProfiles();
27366
-
27367
- // Initialize fields with default values
27368
- if (window.__kumologica.settings.projectFlowName) {
27369
- setLambdaName(window.__kumologica.settings.projectFlowName);
27370
- }
27371
-
27372
- $('#kumohub-fn-description').val('kumologica flow');
27373
- $('#kumohub-fn-memory').val('512');
27374
- $('#kumohub-fn-timeout').val('20');
27375
-
27376
- $('#kumohub-fn-timeout, #kumohub-fn-workspace, #kumohub-fn-stage, #kumohub-fn-policy, #kumohub-fn-memory, #kumohub-fn-description, #kumohub-fn-name').change(function () {
27377
- saveSettings();
27378
- });
27379
-
27380
- $('#kumohub-fn-name').change(function () {
27381
- this.value = sanitizeLambdaName(this.value);
27382
- });
27383
-
27384
- $('#kumohub-fn-workspace').on('change', function() {
27385
- fillStages( this.value );
27386
- });
27387
-
27388
- $('#kumohub-fn-stage').on('change', function() {
27389
- fillPolicies($('#kumohub-fn-workspace').val(), this.value);
27390
- });
27391
-
27392
- $('#kumohub-sidebar-profiles').change(function () {
27393
-
27394
- if (this.value) {
27395
- $('#kumohub-sidebar-body').show();
27396
- }
27397
- saveSettings();
27398
-
27399
- if (this.value != SELECT_KUMOHUB_PROFILE) {
27400
- $(`#kumohub-sidebar-profiles option[value='${SELECT_KUMOHUB_PROFILE}']`).remove();
27401
- window.__kumologica.kumohub.profile = this.value;
27402
- disconnectFromKumohub();
27403
- }
27404
- });
27405
-
27406
- // Attach the environment variables
27407
- $('#kumohub-add-environment-variable').click((e) => {
27408
- let environmentTable = $('#kumohub-fn-env-table');
27409
- let environmentRowHtml = `
27410
- <tr class="node-info-node-row">
27411
- <td style="background: white; width:46%"><input id="kumohub-fn-env-key" class="palette-textinput" type="text" placeholder="key" style="width:100%"></td>
27412
- <td style="background: white; width:46%"><input id="kumohub-fn-env-val" class="palette-textinput" type="text" placeholder="value" style="width:100%"></td>
27413
- <td id="kumohub-fn-env-row" style="text-align:center; width:8%" class="removeRow"><i class="fa fa-minus"></i></td>
27414
- </tr>`;
27415
- $(environmentRowHtml).appendTo(environmentTable);
27416
-
27417
- $('#kumohub-fn-env-table')
27418
- .find('input')
27419
- .each(function () {
27420
- $(this).change(function () {
27421
- saveSettings();
27422
- });
27423
- });
27424
- });
27425
-
27426
- $('#kumohub-fn-env-table')
27427
- .find('input')
27428
- .each(function () {
27429
- $(this).change(function () {
27430
- saveSettings();
27431
- });
27432
- });
27433
-
27434
- $('#kumohub-fn-env-table').on('click', '.removeRow', function () {
27435
- $(this).parent().remove();
27436
- saveSettings();
27437
- });
27438
-
27439
- // Close export menu when click in the window
27440
- $('.sidebar-kumohub').click(function (e) {
27441
- $('#kumohub-options-dropdown-content').hide();
27442
- });
27443
-
27444
- // Connect to AWS button
27445
- $('#kumohub-sidebar-connect-btn').click((e) => {
27446
- e.preventDefault();
27447
- connectToKumohub();
27448
- });
27449
-
27450
- // Deploy to kumohub button
27451
- $('#kumohub-sidebar-deploy-btn').click((e) => {
27452
- e.preventDefault();
27453
- deploy();
27454
- });
27455
-
27456
- $('#kumohub-buildZipBtn').click((e) => {
27457
- e.preventDefault();
27458
- hideMenu();
27459
- buildZip();
27460
- });
27461
-
27462
- // Export cloudformation script
27463
- $('#kumohub-exportCloudFormationBtn').click((e) => {
27464
- e.preventDefault();
27465
- hideMenu();
27466
- exportScript(window.__kumologica.cloud.provider.aws);
27467
- });
27468
-
27469
- // Export serverless script
27470
- $('#kumohub-exportServerlessBtn').click((e) => {
27471
- e.preventDefault();
27472
- hideMenu();
27473
- exportScript(window.__kumologica.cloud.provider.serverless);
27474
- });
27475
-
27476
- $('#kumohub-options-dropdown').click((e) => {
27477
- e.stopPropagation();
27478
-
27479
- $('#kumohub-sidebar-export-btn').toggleClass('dropdown-selected');
27480
-
27481
- $('#kumohub-options-dropdown-content').toggle();
27482
- });
27483
-
27484
- initialised = true;
27485
- if (parameters) {
27486
- setValues(parameters);
27487
- }
27488
-
27489
- connectUIDisconnected();
27490
- }
27491
-
27492
- function hideMenu() {
27493
- $('#kumohub-sidebar-export-btn').removeClass('dropdown-selected');
27494
- $('#kumohub-options-dropdown-content').hide();
27495
- }
27496
-
27497
- async function exportScript(provider) {
27498
-
27499
- $('#workspace-terminal').show();
27500
- try {
27501
- await window.__kumologica.cloud.generateScript(
27502
- provider,
27503
- RED.header.getCurrentProjectInfo(),
27504
- getValues()
27505
- );
27506
- } catch (Error) {
27507
- handleError(Error);
27508
- }
27509
- }
27510
-
27511
- async function buildZip(provider) {
27512
-
27513
- $('#workspace-terminal').show();
27514
- try {
27515
- await window.__kumologica.kumohub.build(RED.header.getCurrentProjectInfo());
27516
- /*await window.__kumologica.cloud.generateScript(
27517
- provider,
27518
- RED.header.getCurrentProjectInfo(),
27519
- getValues()
27520
- );*/
27521
- } catch (Error) {
27522
- handleError(Error);
27523
- }
27524
- }
27525
-
27526
- async function connectToKumohub() {
27527
- profile = getProfile();
27528
-
27529
- if (!profile || profile == SELECT_KUMOHUB_PROFILE) {
27530
- RED.notify(`<strong>Error</strong>: Please select Kumohub profile before connecting to Kumohub account.`, 'error');
27531
- return;
27532
- }
27533
-
27534
- if (window.__kumologica.kumohub.isLoggedIn(profile)) {
27535
- RED.notify(`<strong>Information</strong>: Already connected to ${profile} Kumohub account.`, 'info');
27536
- return;
27537
- }
27538
-
27539
- connectUIConnecting();
27540
-
27541
- try {
27542
- await window.__kumologica.kumohub.login(profile);
27543
- workspaces = await window.__kumologica.kumohub.getWorkspaces(profile);
27544
-
27545
- fillWorkspaces(profileWorkspace);
27546
- } catch (err) {
27547
- connectUIDisconnected();
27548
-
27549
- RED.notify(`<strong>Error</strong>: ${err.stderr? err.stderr: err}`, 'error');
27550
- return;
27551
- }
27552
- connectUIConnected();
27553
- }
27554
-
27555
- function disconnectFromKumohub() {
27556
- window.__kumologica.kumohub.logout();
27557
- connectUIDisconnected();
27558
- }
27559
-
27560
- function connectUIDisconnected() {
27561
- // show connect button
27562
- $('#kumohub-sidebar-connect-btn').show();
27563
- if ($('#kumohub-sidebar-connect-btn') && $('#kumohub-sidebar-connect-btn').html()) {
27564
- $('#kumohub-sidebar-connect-btn').html($('#kumohub-sidebar-connect-btn').html().replace('Connecting', 'Connect'));
27565
- }
27566
- $('#kumohub-sidebar-connect-icon').attr({'class': 'fa fa-circle'});
27567
- $('#kumohub-sidebar-connect-icon').css({'color': 'red'});
27568
- // hide deploy and export buttons
27569
- $('#kumohub-sidebar-deploy-btn').hide();
27570
- $('#kumohub-sidebar-export-btn').hide();
27571
- $('#kumohub-sidebar-body').hide();
27572
- }
27573
-
27574
- function connectUIConnecting() {
27575
- $('#kumohub-sidebar-connect-icon').attr({'class': 'fa fa-spinner fa-spin'});
27576
- $('#kumohub-sidebar-connect-icon').css({'color': 'black'});
27577
- }
27578
-
27579
- function connectUIConnected() {
27580
- // hide connect button
27581
- $('#kumohub-sidebar-connect-btn').hide();
27582
- //$('#kumohub-sidebar-connect-btn').html($('#kumohub-sidebar-connect-btn').html().replace('Connect', 'Connected'));
27583
- //$('#kumohub-sidebar-connect-icon').attr({'class': 'fa fa-circle'});
27584
- //$('#kumohub-sidebar-connect-icon').css({'color': 'green'});
27585
-
27586
- // show deploy and options buttons
27587
- $('#kumohub-sidebar-deploy-btn').show();
27588
-
27589
- // dont show until functionality implemented
27590
- $('#kumohub-sidebar-export-btn').show();
27591
- $('#kumohub-sidebar-body').show();
27592
- }
27593
-
27594
- function deployingUIDeploying() {
27595
- $('#kumohub-sidebar-deploy-icon').attr({'class': 'fa fa-spinner fa-spin'});
27596
- }
27597
- function deployingUINotDeploying() {
27598
- $('#kumohub-sidebar-deploy-icon').attr({'class': 'fa fa-cloud-upload'});
27599
- }
27600
-
27601
- async function deploy() {
27602
-
27603
- const profile = getProfile();
27604
- if (!profile || profile == SELECT_KUMOHUB_PROFILE) {
27605
- RED.notify(`Please select kumohub profile before deploying flows.`, 'error');
27606
- return;
27607
- }
27608
-
27609
- if (deployState == DEPLOYING) {
27610
- RED.notify(`<strong>Information</strong>: Already deploying to Kumohub.`, 'info');
27611
- return;
27612
- }
27613
-
27614
- RED.deploy.save();
27615
-
27616
- deployingUIDeploying();
27617
- deployState = DEPLOYING;
27618
-
27619
- $('#workspace-terminal').show();
27620
-
27621
- let params = getValues();
27622
-
27623
- let envs = params.environment;
27624
-
27625
- if (envs) {
27626
- let variables = {Variables: {}};
27627
-
27628
- envs.forEach(function(e) {
27629
- variables.Variables[e.key] = e.value;
27630
- });
27631
- params.environment = {};
27632
- params.environment = JSON.stringify(variables);
27633
- };
27634
-
27635
- try {
27636
- await window.__kumologica.kumohub.deploy(
27637
- RED.header.getCurrentProjectInfo(),
27638
- params
27639
- );
27640
-
27641
- } catch (Error) {
27642
- handleError(Error);
27643
- }
27644
-
27645
- deployState = NOTDEPLOYING;
27646
- deployingUINotDeploying();
27647
- }
27648
-
27649
- function handleError(error) {
27650
- let msg = error.toString();
27651
- RED.notify(msg, 'error');
27652
- }
27653
-
27654
- function saveSettings() {
27655
- window.__kumologica.settings.kumohubConfig.setKumohubConfig(getValues());
27656
- }
27657
-
27658
- function show() {
27659
- RED.sidebar.show('kumohub');
27660
- }
27661
-
27662
- function init() {
27663
- initHTML();
27664
- initJs();
27665
- }
27666
-
27667
- return {
27668
- init: init,
27669
- show: show,
27670
- };
27671
- })();;RED.palette = (function () {
26845
+ })();;RED.palette = (function () {
27672
26846
  const options = {
27673
26847
  nodes: {
27674
26848
  header: 'palette-option-nodes-a',