@hcl-software/node-red-domino
Version:
Connect NodeRED to HCL Domino
154 lines (138 loc) • 4.99 kB
HTML
<!-- Copyright (C) 2023 HCL America Inc. Apache-2.0 license https://www.apache.org/licenses/LICENSE-2.0 -->
<script type="text/javascript">
RED.nodes.registerType('domino-access', {
category: 'config',
defaults: {
name: { required: true },
authtype: { value: 'basic', required: true },
baseUrl: { value: 'http://localhost:8880', required: true },
},
credentials: {
// basic, oauth
scope: { type: 'text' },
// basic
username: { type: 'text' },
// basic
password: { type: 'password' },
// oauth
appId: { type: 'text' },
// oauth
appSecret: { type: 'password' },
// oauth
refreshToken: { type: 'password' },
// token
token: { type: 'password' },
},
label: function () {
if (this.credentials) {
return this.name + ': ' + this.credentials.scope;
}
return this.name;
},
oneditprepare: function () {
function hideAllCredentialConfig() {
$('#node-config-div-scope').hide();
$('#node-config-div-username').hide();
$('#node-config-div-password').hide();
$('#node-config-div-appId').hide();
$('#node-config-div-appSecret').hide();
$('#node-config-div-refreshToken').hide();
$('#node-config-div-token').hide();
}
// defaults
$('#node-config-input-scope').val('$DATA');
hideAllCredentialConfig();
$('#node-config-div-scope').show();
$('#node-config-div-username').show();
$('#node-config-div-password').show();
getAuthMethods()
.then((ti) => $('#node-config-input-authtype').typedInput(ti))
.catch((e) => console.error(e));
// getScopes($('#node-config-input-baseUrl').val())
// .then((ti) => {
// ti.types[0].multiple = 'true';
// $('#node-config-input-scope').typedInput(ti);
// })
// .catch((e) => console.error(e));
$('#node-config-input-authtype').on('change', function () {
hideAllCredentialConfig();
const authtype = $('#node-config-input-authtype').val();
if (authtype === 'basic') {
$('#node-config-div-scope').show();
$('#node-config-div-username').show();
$('#node-config-div-password').show();
} else if (authtype === 'oauth') {
$('#node-config-div-scope').show();
$('#node-config-div-appId').show();
$('#node-config-div-appSecret').show();
$('#node-config-div-refreshToken').show();
} else if (authtype === 'token') {
$('#node-config-div-token').show();
}
});
}
});
</script>
<script type="text/html" data-template-name="domino-access">
<div class="form-row">
<label for="node-config-input-name"><i class="fa fa-tag"></i> Name</label>
<input type="text" id="node-config-input-name" placeholder="Name" />
</div>
<div class="form-row">
<label for="node-config-input-authtype">
<i class="fa fa-user"></i> Auth type
</label>
<input type="text" id="node-config-input-authtype" />
</div>
<div class="form-row">
<label for="node-config-input-baseUrl">
<i class="fa fa-globe"></i> Base URL
</label>
<input type="url" id="node-config-input-baseUrl" />
</div>
<div class="form-row" id="node-config-div-scope">
<label for="node-config-input-scope">
<i class="fa fa-gears"></i> Scopes
</label>
<input type="text" id="node-config-input-scope" />
</div>
<div class="form-row" id="node-config-div-username">
<label for="node-config-input-username">
<i class="fa fa-user"></i> Username
</label>
<input type="text" id="node-config-input-username" />
</div>
<div class="form-row" id="node-config-div-password">
<label for="node-config-input-password">
<i class="fa fa-file"></i> Password
</label>
<input type="password" id="node-config-input-password" />
</div>
<div class="form-row" id="node-config-div-appId">
<label for="node-config-input-appId">
<i class="fa fa-user"></i> Application ID
</label>
<input type="text" id="node-config-input-appId" />
</div>
<div class="form-row" id="node-config-div-appSecret">
<label for="node-config-input-appSecret">
<i class="fa fa-file"></i> Application Secret
</label>
<input type="password" id="node-config-input-appSecret" />
</div>
<div class="form-row" id="node-config-div-refreshToken">
<label for="node-config-input-refreshToken">
<i class="fa fa-file"></i> Refresh Token
</label>
<input type="password" id="node-config-input-refreshToken" />
</div>
<div class="form-row" id="node-config-div-token">
<label for="node-config-input-token">
<i class="fa fa-file"></i> Token
</label>
<input type="password" id="node-config-input-token" />
</div>
</script>
<script type="text/html" data-help-name="domino-access">
<p>Credentials for Domino</p>
</script>