8000 Added new components. · totaljs/flowstreamcomponents@5200b53 · GitHub
[go: up one dir, main page]

Skip to content

Commit 5200b53

Browse files
committed
Added new components.
1 parent 0d42db9 commit 5200b53

File tree

3 files changed

+322
-49
lines changed

3 files changed

+322
-49
lines changed

components/logger.html

Lines changed: 125 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -2,72 +2,153 @@
22

33
exports.id = 'logger';
44
exports.name = 'Logger';
5-
exports.group = 'Total.js API';
6-
exports.version = '2';
7-
exports.icon = 'ti ti-search';
5+
exports.group = 'Common';
6+
exports.version = '1';
7+
exports.icon = 'ti ti-history';
88
exports.author = 'Total.js';
9-
exports.config = { token: '', type: 'info', message: '', reference: '', url: '' };
9+
exports.config = { id: 'id', name: '{{ data.name }}', status: 'Step 1' };
1010
exports.inputs = [{ id: 'input', name: 'Input' }];
11+
exports.outputs = [{ id: 'output', name: 'Output' }];
1112

1213
exports.make = function(instance, config) {
1314

15+
var Tname;
16+
17+
instance.configure = function() {
18+
Tname = Tangular.compile(config.name);
19+
};
20+
21+
instance.call = function(data, callback) {
22+
let db = 'nosql/logs';
23+
switch (data.TYPE) {
24+
case 'items':
25+
DATA.list(db).autoquery(data, 'id,name,messageid,status,dtcreated:Date', 'dtcreated_desc', 100).callback((err, response) => callback(response));
26+
break;
27+
case 'remove':
28+
DATA.remove(db).id(data.id).callback((err, response) => callback(SUCCESS(response ? true : false)));
29+
break;
30+
case 'clear':
31+
DATA.remove(db).callback(() => callback(SUCCESS(true)));
32+
break;
33+
}
34+
};
35+
1436
instance.message = function($) {
15-
var msg = {};
16-
msg.schema = instance.main.$schema.name;
67E6 17-
msg.ip = $.ip;
18-
msg.data = JSON.stringify($.data);
19-
msg.url = config.url || instance.href() || CONF.url;
20-
msg.app = config.name || CONF.name;
21-
msg.type = config.type;
22-
msg.message = $.variables(config.message);
23-
$.destroy();
24-
TotalAPI($.variables(config.token), 'logger', msg, function(err) {
25-
instance.status({ response: err ? err.toString() : '' });
26-
});
37+
let id = $.data[config.id];
38+
let name = Tname($);
39+
DATA.insert('nosql/logs', { id: UID(), messageid: id, instanceid: instance.id, name: name, status: config.status, dtcreated: new Date() });
40+
instance.status({ date: new Date(), id: id });
41+
$.send('output');
2742
};
2843

44+
instance.configure();
2945
};
3046

3147
</script>
3248

49+
<readme>
50+
The component logs information about incoming data.
51+
</readme>
52+
3353
<style>
34-
.CLASS .error { font-size: 12px; padding: 10px; color: red; }
54+
.CLASS { width: 250px; }
3555
</style>
3656

37-
<readme>
38-
The component logs incoming messages into the Total.js Cloud Logger.
39-
</readme>
57+
<body>
58+
<header>
59+
<button class="button">History</button>
60+
<i class="$ICON"></i>$NAME
61+
</header>
62+
<footer style="padding:10px" class="fs12">
63+
<ui-bind path="CONFIG.status" config="text" class="block b" style="font-size:16px"></ui-bind>
64+
<hr style="margin:10px 0" />
65+
<ui-bind path="STATUS" config="template" class="block">
66+
<script type="text/html">
67+
<div class="hellip">Message: {{ if value && value.id }}<b>{{ value.id }}</b>{{ else }}---{{ fi }}</div>
68+
<div>Last status: {{ if value && value.date }}{{ value.date | format('[ts]') }}{{ else }}---{{ fi }}</div>
69+
</script>
70+
</ui-bind>
71+
</footer>
72+
</body>
4073

4174
<settings>
42-
<div class="padding bg-smoke">
43-
<ui-component name="input" path="?.token" config="required:1;camouflage:*">Total API token</ui-component>
44-
<div class="help">Supports dynamic arguments in the form <code>{key}</code></div>
45-
</div>
4675
<div class="padding">
47-
<div class="row">
48-
<div class="col-md-3 m">
49-
<ui-component name="input" path="?.type" config="dirsource:info|Info,error|Error,warning|Warning,success|Success;required:1">Type</ui-component>
76+
<div class="grid-3">
77+
<div class="m">
78+
<ui-component name="input" path="?.id" config="required:1;monospace:1">Message ID</ui-component>
5079
</div>
51-
<div class="col-md-3 m">
52-
<ui-component name="input" path="?.app">App name</ui-component>
80+
<div class="m">
81+
<ui-component name="input" path="?.name" config="required:1;monospace:1">Snapshot name</ui-component>
5382
</div>
54-
<div class="col-md-3 m">
55-
<ui-component name="input" path="?.reference">Reference</ui-component>
56-
</div>
57-
<div class="col-md-3 m">
58-
<ui-component name="input" path="?.url">URL address</ui-component>
83+
<div class="m">
84+
<ui-component name="input" path="?.status" config="required:1">Snapshot status</ui-component>
5985
</div>
6086
</div>
61-
<ui-component name="input" path="?.message" config="required:1;maxlength:200">Message</ui-component>
62-
<div class="help">Supports dynamic arguments in the form <code>{key}</code></div>
6387
</div>
6488
</settings>
6589

66-
<body>
67-
<header>
68-
<i class="ICON"></i>NAME
69-
</header>
70-
<footer>
71-
<ui-bind path="!STATUS.response" config="text;show" class="error hidden"></ui-bind>
72-
</footer>
73-
</body>
90+
<script>
91+
92+
TOUCH(function(exports, reinit) {
93+
94+
var services = [];
95+
var Path = 'loggerbox';
96+
97+
if (!PLUGINS[Path]) {
98+
99+
PLUGIN(Path, function(exports) {
100+
101+
exports.reload = function(com) {
102+
if (exports.model.data)
103+
exports.refresh();
104+
};
105+
106+
exports.refresh = function() {
107+
exports.nul('data');
108+
};
109+
110+
exports.filter = function(type, filter, sort, page) {
111+
var model = GET(Path);
112+
if (!filter)
113+
filter = {};
114+
filter.TYPE = 'items';
115+
filter.page = page;
116+
filter.sort = sort;
117+
model.instance.call(filter, response => SET(Path + '.data', response));
118+
};
119+
120+
exports.button = function(name, row) {
121+
SETTER('approve/show', 'Are you sure you want to remove selected log?', ':remove: Remove', function() {
122+
var model = GET(Path);
123+
model.instance.call({ TYPE: 'remove', id: ATTRD(row) }, function(response) {
124+
if (response.success) {
125+
SETTER('notify/success', 'Removed.');
126+
exports.refresh();
127+
} else
128+
SETTER('notify/warning', 'Log not found in database.');
129+
});
130+
});
131+
};
132+
133+
exports.clear = function() {
134+
SETTER('approve/show', 'Are you sure you want to clear all logs?', ':remove: Clear', function() {
135+
var model = GET(Path);
136+
model.instance.call({ TYPE: 'clear' }, function(response) {
137+
SETTER('notify/success', 'Cleared.');
138+
exports.refresh();
139+
});
140+
});
141+
};
142+
});
143+
144+
$('body').append(('<ui-component name="box" path="*form" config="if:{0};width:940;scrollbar:0;title:Snapshots;icon:ti ti-save;reload:?/reload" plugin="{0}"><nav><button class="exec" data-exec="?/clear"><i class="ti ti-clean red"></i>Clear</button></nav><div><ui-component name="datagrid" path="?.data" config="height:.ui-box-body;margin:1;checkbox:0;click:?/click;exec:?/filter;noborder:1;button:?/button"><scri' + 'pt type="text/plain">[{ name: "messageid", text: "Message", width: 150, monospace: 1 },{ name: "status", text: "Status", width: 200 },{ name: "name", text: "Name", width: 300 },{ name: "dtcreated", text: "Created", type: "date", format: "[ts]" }, { type: "controls", template: "<button name=\\\"remove\\\"><i class=\\\"ti ti-trash red\\\"></i></button>" }]</scr' + 'ipt></ui-component></div><nav><button name="cancel" style="width:100%">Close</button></nav></ui-component>').format(Path));
145+
}
146+
147+
exports.element.on('click', 'button', function() {
148+
SET(Path, { id: exports.id, config: exports.config, instance: exports });
149+
SET('*form', Path);
150+
});
151+
152+
});
153+
154+
</script>

components/read.html

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
exports.id = 'read';
44
exports.name = 'Read';
5-
exports.group = 'Common';
5+
exports.group = 'Objects';
66
exports.version = '3';
77
exports.icon = 'ti ti-filter';
88
exports.author = 'Total.js';
@@ -123,7 +123,8 @@
123123
.CLASS-settings figure .controls span:first-child { margin-left: 0; }
124124
.CLASS-settings figure:first-child { border-top: 0; line-height: 24px; }
125125
.CLASS-settings figure:first-child div { line-height: 24px; }
126-
.CLASS footer { height: 40px; line-height: 40px; padding: 0 10px; font-size: 12px; }
126+
.CLASS footer { padding: 10px; font-size: 12px; }
127+
.CLASS footer hr { margin: 10px 0; }
127128

128129
.ui-dark .CLASS-settings .fields { border-color: #404040; }
129130
.ui-dark .CLASS-settings figure { border-top-color: #404040; }
@@ -133,10 +134,20 @@
133134

134135
<body>
135136
<header>
136-
<i class="ICON"></i>NAME
137+
<i class="$ICON"></i>$NAME
137138
</header>
138-
<footer is="is-footer" path="CONFIG.path" config="show;text span">
139-
Path: <span class="b"></span>
139+
<footer>
140+
<ui-bind path="CONFIG" config="template" class="block">
141+
<script type="text/html">
142+
{{ if value.path }}
143+
Path: <span class="b">{{ value.path }}</span>
144+
<hr />
145+
{{ fi }}
146+
{{ foreach m in value.schema }}
147+
<div class="monospace"><i class="ti ti-bull mr5 gray"></i>{{ m.pathfrom }} <i class="ti ti-long-arrow-right"></i> {{ m.pathto }}</div>
148+
{{ end }}
149+
</script>
150+
</ui-bind>
140151
</footer>
141152
</body>
142153

0 commit comments

Comments
 (0)
0