Skip to content

Commit

Permalink
Added Search in configuration functionality.
Browse files Browse the repository at this point in the history
  • Loading branch information
petersirka committed Feb 6, 2024
1 parent fdb2633 commit 76ad4c5
Show file tree
Hide file tree
Showing 4 changed files with 129 additions and 16 deletions.
5 changes: 3 additions & 2 deletions app.bundle

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/forms/nodes.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<ui-component name="searchinput" path="%searchinstances" config="placeholder:@(Search);autofocus:1" style="border-left:0;border-top:0;border-right:0"></ui-component>
<ui-component name="viewbox" path="common.windows" config="parent:auto;margin:29" class="invisible">
<ui-component name="search" path="%searchinstances" config="selector:.item;datasource:flow.data">
<ui-bind path="flow.data" config="template:.item">
<ui-bind path="flow.data" config="template:.item" class="block">
<script type="text/html">
{{ foreach m in value }}
{{ if m.key !== 'groups' && m.key !== 'paused' && m.key !== 'tabs' }}
Expand Down
105 changes: 105 additions & 0 deletions public/forms/search.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
--PATH=searchform--

<style>
.--PATH-- .item { height: 28px; border-bottom: 1px solid #E0E0E0; font-size: 12px; line-height: 27px; cursor: pointer; }
.--PATH-- .item:hover { background-color: rgba(0,0,0,.03); }
.--PATH-- .monospace { float: left; margin: 6px 5px 0 5px; padding: 0 3px; color: #777; font-size: 11px; background-color: rgba(0,0,0,.08); line-height: 16px; border-radius: var(--radius); }
.--PATH-- .name { text-overflow: ellipsis; white-space: nowrap; overflow: hidden; }
.--PATH-- .name i { width: 13px; text-align: center; margin-right: 5px; }
.--PATH-- .name code { font-size: 11px; color: #999; margin-left: 5px; }
.--PATH-- .ishidden { color: #E73323; }
.--PATH-- .singleton { color: #5C1DC4; }
.--PATH-- .controls span { margin-left: 7px; cursor: pointer; }
.ui-dark .--PATH-- .monospace { background-color: rgba(200,200,200,.08); }
.ui-dark .--PATH-- .item { border-bottom-color: #444; }
.ui-dark .--PATH-- .item:hover { background-color: rgba(200,200,200,.04); }
</style>

<ui-plugin path="--PATH--" class="--PATH--">
<ui-component name="searchinput" path="?.search" config="placeholder:@(Search);autofocus:1" style="border-left:0;border-top:0;border-right:0"></ui-component>
<ui-component name="viewbox" path="common.windows" config="parent:auto;margin:29" class="invisible">
<ui-bind path="?.response" config="template" class="block">
<script type="text/html">
{{ if !value || !value.length }}
<div class="padding" style="padding-top:10px">
<div class="help">
<i class="ti ti-database-alt"></i>@(0 matches)
</div>
</div>
{{ fi }}
{{ foreach m in value }}
<div class="item exec" data-exec="flow/find" data-search="{{ m.key }} {{ m.value.Component.name }} {{ m.value.note }}" data-id="{{ m.key }}">
<div class="controls">
{{ if m.value.Component.settings }}<span class="exec" data-exec="flow/settings" data-prevent="true" title="@(Settings)"><i class="ti ti-wrench"></i></span>{{ fi }}
{{ if !m.value.Component.meta || m.value.Component.meta.remove !== false }}
<span class="exec" data-exec="?/remove" data-prevent="true" title="@(Remove)"><i class="ti ti-trash red"></i></span>
{{ fi }}
</div>
<span class="monospace">{{ m.key }}</span>
<div class="name{{ if m.value.Component.meta && m.value.Component.meta.singleton }} singleton{{ fi }}{{ if m.value.Component.meta && m.value.Component.meta.hidden }} ishidden{{ fi }}"><i class="{{ m.value.Component.icon }}"></i><b>{{ m.value.Component.name }}</b> <code>{{ m.text }}</code></div>
</div>
{{ end }}
</script>
</ui-bind>
</ui-component>
</ui-plugin>

<script>
PLUGIN('--PATH--', function(exports) {

exports.remove = function(el) {
var id = ATTRD(el);
EXEC('-approve/show', '@(Are you sure you want to remove selected node?)', '"ti ti-trash" @(Remove)', function() {
Designer.op.remove(id);
SET('flow.changed', true);
});
};

exports.findinvalue = function(val, search) {
if (val) {
val = val.toString();
var index = val.toLowerCase().indexOf(search);
if (index !== -1) {
var beg = index - 20;
if (beg < 0)
beg = 0;
return val.substring(beg, index + search.length + 20);
}
}
};

exports.watch('search', function(value) {

var arr = [];

if (!value) {
exports.set('response', arr);
return;
}

value = value.toLowerCase();

for (var instance of flow.instances) {
var values = Object.values(instance.config);
for (var val of values) {
var res = null;
if (val instanceof Array) {
for (var m of val) {
var values2 = Object.values(m);
for (var val2 of values2) {
res = exports.findinvalue(val2, value);
res && arr.push({ key: instance.id, value: instance, text: res });
}
}
} else {
res = exports.findinvalue(val, value);
res && arr.push({ key: instance.id, value: instance, text: res });
}
}
}

exports.set('response', arr);
});

});
</script>
33 changes: 20 additions & 13 deletions public/parts/flow.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<button title="@(Variables)" class="exec" data-exec="?/variables"><i class="ti ti-variables"></i></button>
<button title="@(Console)" class="exec" data-exec="?/console" is="is-button" path="common.logs.errors.items.length" config=".red"><i class="ti ti-bug"></i></button>
<!-- <button title="@(Reset)" class="exec hidden" data-exec="?/reset" is="is-button" path="common.logs.errors.items.length" config="show"><i class="ti ti-clean"></i></button> -->
<button title="@(Search)" class="exec" data-exec="?/search"><i class="ti ti-file-search"></i></button>
</div>

<div>
Expand Down Expand Up @@ -863,6 +864,18 @@
}, 500, add);
};

exports.search = function() {
var id = 'search';

if (common.windows.findItem('id', id)) {
SETTER('windows/focus', id);
return;
}

PUSH('common.windows', { id: id, cachekey: id, html: '<ui-import config="url:@{#}/forms/search.html"></ui-import>', title: '@(Search in configuration)', actions: { move: true, autosave: true, close: true, maximize: false, minimize: false }, offset: { x: ((WW / 2) - 250) >> 0, y: ((WH / 2) - 300) >> 0, width: 500, height: 600, minwidth: 200, minheight: 300, maxwidth: 500, maxheight: 800 }});

};

exports.sources = function() {
SET('common.form', 'sourcesform');
};
Expand Down Expand Up @@ -1244,6 +1257,7 @@
opt.element = el;
opt.items = [];
opt.items.push({ id: 'nodes', name: '@(Active nodes)', icon: 'ti ti-list' });
opt.items.push({ id: 'search', name: '@(Search in configuration)', icon: 'ti ti-file-search' });
opt.items.push({ id: 'version', name: '@(Version)', icon: 'ti ti-info-circle' });
opt.items.push('-');
opt.items.push({ id: 'download', name: '@(Download)', icon: 'ti ti-download' });
Expand Down Expand Up @@ -1296,23 +1310,19 @@
SET('common.form', 'versionform');
break;
case 'nodes':
exports.nodes();
case 'search':
case 'exportasbase64':
case 'exportascomponent':
case 'importascomponent':
case 'clear':
exports[item.id]();
break;
case 'curvedlines':
TOGGLE('common.curvedlines');
break;
case 'reset_stats':
SETTER('websocket/send', { TYPE: 'reset_stats' });
break;
case 'exportascomponent':
exports.exportascomponent();
break;
case 'exportasbase64':
exports.exportasbase64();
break;
case 'importascomponent':
exports.importascomponent();
break;
case 'export':
case 'download':
SETTER('websocket/send', { TYPE: 'export', callback: ERROR(function(response) {
Expand All @@ -1329,9 +1339,6 @@
case 'restart':
SETTER('approve/show', '@(Are you sure you want to restart this FlowStream process?)', '"ti ti-sync" @(Restart)', ASETTER('websocket/send', { TYPE: 'restart' }));
break;
case 'clear':
exports.clear();
break;
}

};
Expand Down

0 comments on commit 76ad4c5

Please sign in to comment.