This repository was archived by the owner on Jan 7, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck-authorization.html
More file actions
138 lines (121 loc) · 5.23 KB
/
check-authorization.html
File metadata and controls
138 lines (121 loc) · 5.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
<script type="text/javascript">
RED.nodes.registerType('check-authorization', {
category: 'ProcessCube',
color: '#02AFD6',
defaults: {
name: { value: '' },
options: {
value: [{ claim: '' }],
},
},
inputs: 1,
outputs: 2,
outputLabels: function (index) {
if (index === 0) {
return 'Authorized'
} else {
return 'Unauthorized'
}
},
icon: 'font-awesome/fa-sign-in',
label: function () {
return this.name || 'check-authorization';
},
oneditprepare: function () {
$('#node-input-size').elementSizer({
width: '#node-input-width',
height: '#node-input-height',
group: '#node-input-group',
});
function generateOption(i, option) {
const container = $('<li/>', {
style: 'background: var(--red-ui-secondary-background, #fff); margin:0; padding:8px 0px 0px;',
});
const row = $('<div/>').appendTo(container);
$('<input/>', {
class: 'node-input-option-claim',
type: 'text',
style: 'margin-left:7px; width:calc(85%);',
placeholder: 'Claim',
value: option.claim,
})
.appendTo(row)
.typedInput({
type: 'str',
types: ['str'],
});
// Create delete button for the option
const finalSpan = $('<span/>', {
style: 'float:right; margin-right:8px;',
}).appendTo(row);
const deleteButton = $('<a/>', {
href: '#',
class: 'editor-button editor-button-small',
style: 'margin-top:7px; margin-left:5px;',
}).appendTo(finalSpan);
$('<i/>', { class: 'fa fa-remove' }).appendTo(deleteButton);
deleteButton.click(function () {
container.css({
background: 'var(--red-ui-secondary-background-inactive, #fee)',
});
container.fadeOut(300, function () {
$(this).remove();
});
});
$('#node-input-option-container').append(container);
}
$('#node-input-add-option').click(function () {
generateOption($('#node-input-option-container').children().length + 1, {});
$('#node-input-option-container-div').scrollTop(
$('#node-input-option-container-div').get(0).scrollHeight
);
});
for (let i = 0; i < this.options.length; i++) {
const option = this.options[i];
generateOption(i + 1, option);
}
$('#node-input-option-container').sortable({
axis: 'y',
handle: '.node-input-option-handle',
cursor: 'move',
});
},
oneditsave: function () {
const options = $('#node-input-option-container').children();
const node = this;
node.options = [];
options.each(function (i) {
const option = $(this);
const o = {
claim: option.find('.node-input-option-claim').val(),
};
node.options.push(o);
});
},
});
</script>
<script type="text/html" data-template-name="check-authorization">
<div class="form-row">
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name" />
</div>
<div class="form-row form-row-flex node-input-option-container-row" style="margin-bottom: 0px;width: 100%">
<label for="node-input-width" style="vertical-align:top"><i class="fa fa-list-alt"></i> Claims</label>
<div id="node-input-option-container-div" style="box-sizing:border-box; border-radius:5px; height:257px; padding:5px; border:1px solid var(--red-ui-form-input-border-color, #ccc); overflow-y:scroll; display:inline-block; width: 70%;">
<ol id="node-input-option-container" style="list-style-type:none; margin:0;"></ol>
</div>
</div>
<!-- Add Claim Button -->
<div class="form-row">
<a href="#" class="editor-button editor-button-small" id="node-input-add-option" style="margin-top:4px; margin-left:103px;"><i class="fa fa-plus"></i> <span>action</span></a>
</div>
</script>
<script type="text/markdown" data-help-name="check-authorization">
A Node that checks if a user has the specified claims
## Configs
: name (string): name of the node
: claims (list of strings): the claims the user needs to be authorized
### References
- [The ProcessCube© Developer Network](https://processcube.io) - All documentation for the ProcessCube© platform
- [ProcessCube© LowCode Integration](https://processcube.io/docs/node-red) - LowCode integration in ProcessCube©
</script>