Skip to content

Commit

Permalink
Update UI.
Browse files Browse the repository at this point in the history
  • Loading branch information
petersirka committed Aug 7, 2017
1 parent 1d96d75 commit 89edaa6
Show file tree
Hide file tree
Showing 34 changed files with 325 additions and 390 deletions.
15 changes: 8 additions & 7 deletions httproute/httproute.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,16 @@ exports.html = `<div class="padding">
<section>
<label>@(Main settings)</label>
<div class="padding npb">
<div data-jc="textbox" data-jc-path="url" class="m" data-required="true" data-maxlength="500" data-placeholder="/api/test">@(URL address)</div>
<div data-jc="dropdown" data-jc-path="method" data-required="true" data-options=";GET;POST;PUT;DELETE;OPTIONS" class="m">@(HTTP method)</div>
<div data-jc="textbox" data-jc-path="url" class="m" data-jc-config="required:true;maxlength:500;placeholder:/api/test">@(URL address)</div>
<div data-jc="dropdown" data-jc-path="method" data-jc-config="required:true;items:,GET,POST,PUT,DELETE,OPTIONS" class="m">@(HTTP method)</div>
<div class="row">
<div class="col-md-8 m">
<div data-jc="textbox" data-jc-path="flags" data-placeholder="json">@(Additional flags)</div>
<div data-jc="textbox" data-jc-path="flags" data-jc-config="placeholder:json">@(Additional flags)</div>
<div class="help m">@(Separate flags by comma e.g. <code>json, authorize</code>)</div>
</div>
<div class="col-md-4 m">
<div data-jc="textbox" data-jc-path="size" data-placeholder="in kB" data-increment="true" data-jc-type="number" data-maxlength="10" data-align="center">@(Max. request size)</div>
<div data-jc="textbox" data-jc-path="size" data-jc-config="placeholder:in kB;increment:true;type:number;maxlength:10;align:center">@(Max. request size)</div>
<div class="help m">@(In <code>kB</code> kilobytes)</div>
</div>
</div>
Expand All @@ -50,9 +50,10 @@ exports.html = `<div class="padding">
<div data-jc="checkbox" data-jc-path="emptyresponse" class="b black">@(Automaticlly respond with 200 OK?)</div>
<div class="help m">@(If not checked you need to use HTTP response component to respond to the request.)</div>
<hr />
<div data-jc="keyvalue" data-jc-path="headers" data-placeholder-key="@(Header name)" data-placeholder-value="@(Header value and press enter)" class="m">@(Custom headers)</div>
<div data-jc="keyvalue" data-jc-path="cookies" data-placeholder-key="@(Cookie name)" data-placeholder-value="@(Cookie value and press enter)" class="m">@(Cookies)</div>
</div><script>
<div data-jc="keyvalue" data-jc-path="headers" data-jc-config="placeholderkey:@(Header name);placeholdervalue:@(Header value and press enter)" class="m">@(Custom headers)</div>
<div data-jc="keyvalue" data-jc-path="cookies" data-jc-config="placeholderkey:@(Cookie name);placeholdervalue:@(Cookie value and press enter)" class="m">@(Cookies)</div>
</div>
<script>
ON('open.httproute', function(component, options) {
if (options.flags instanceof Array) {
options.flags = options.flags.remove(function(item) {
Expand Down
2 changes: 1 addition & 1 deletion lastusage/lastusage.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ This component remembers date and time of last usage.`;
exports.html = `<div class="padding">
<div class="row">
<div class="col-md-4">
<div data-jc="textbox" data-jc-path="format" data-placeholder="@(dd.MM.yyyy HH:mm:ss)" data-maxlength="25" data-align="center">@(Date format)</div>
<div data-jc="textbox" data-jc-path="format" data-jc-config="placeholder:@(dd.MM.yyyy HH:mm:ss);maxlength:25;align:center">@(Date format)</div>
</div>
</div>
</div>`;
Expand Down
75 changes: 32 additions & 43 deletions megatimer/megatimer.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ exports.output = 1;
exports.click = true;
exports.author = 'Martin Smola';
exports.icon = 'calendar';
exports.options = {
exports.options = {
weekly: {
days: {
monday: [],
Expand Down Expand Up @@ -40,40 +40,40 @@ exports.html = `
.weekly-day-button>button { width: 100%; }
.weekly-inline-edit .button-remove { margin-top: 10px; }
</style>
<div class="padding">
<div class="padding">
<div class="row m">
<div class="col-md-3">
<div data-jc="checkbox" data-jc-path="enabled">@(Enabled)</div>
<div data-jc="dropdown" data-jc-path="type" data-options=";@(Hourly)|hourly;@(Daily)|daily;@(Weekly)|weekly;@(Monthly)|monthly;@(Yearly)|yearly" class="m">Timer type</div>
<div data-jc="dropdown" data-jc-path="type" data-jc-config="items:,@(Hourly)|hourly,@(Daily)|daily,@(Weekly)|weekly,@(Monthly)|monthly,@(Yearly)|yearly" class="m">Timer type</div>
</div>
</div>
<section class="m">
<label><i class="fa fa-database"></i>@(Data)</label>
<div class="padding npb">
<div class="padding npb">
<div class="row">
<div class="col-md-3">
<div data-jc="dropdown" data-jc-path="datatype" data-options=";String|string;Number|number;Boolean|boolean;Date|date;Object|object" class="m">@(Data type (String by default))</div>
<div data-jc="dropdown" data-jc-path="datatype" data-jc-config="items:,String|string,Number|number,Boolean|boolean,Date|date,Object|object" class="m">@(Data type (String by default))</div>
</div>
<div class="col-md-9">
<div data-jc="textbox" data-jc-path="ondata" data-placeholder="@(e.g. Hello world or 123 or { hello: 'world'} or ['hello', 'world']))" class="m">@(On data)</div>
<div data-jc="textbox" data-jc-path="offdata" data-placeholder="@(e.g. Hello world or 123 or { hello: 'world'} or ['hello', 'world']))" class="m">@(Off data)</div>
<div data-jc="textbox" data-jc-path="ondata" data-jc-config="placeholder:@(e.g. Hello world or 123 or { hello: 'world'} or ['hello', 'world']))" class="m">@(On data)</div>
<div data-jc="textbox" data-jc-path="offdata" data-jc-config="placeholder:@(e.g. Hello world or 123 or { hello: 'world'} or ['hello', 'world']))" class="m">@(Off data)</div>
</div>
</div>
</div>
</div>
</section>
<div data-jc="visible" data-jc-path="type" data-if="value === 'daily'">
<div data-jc="visible" data-jc-path="type" data-jc-config="if:value === 'daily'">
<section>
<label><i class="fa fa-edit"></i>@(Daily timer)</label>
<div class="padding npb">
@TODO
@TODO
</div>
</section>
</div>
<div data-jc="visible" data-jc-path="type" data-if="value === 'hourly'">
<div data-jc="visible" data-jc-path="type" data-jc-config="if:value === 'hourly'">
<section>
<label><i class="fa fa-edit"></i>@(Hourly timer)</label>
<div class="padding npb">
Expand All @@ -82,7 +82,7 @@ exports.html = `
</section>
</div>
<div data-jc="visible" data-jc-path="type" data-if="value === 'weekly'">
<div data-jc="visible" data-jc-path="type" data-jc-config="if:value === 'weekly'">
<section>
<label><i class="fa fa-calendar"></i>@(Weekly timer)</label>
<div class="padding npb">
Expand Down Expand Up @@ -185,12 +185,12 @@ exports.html = `
</div>
</div>
<script type="text/html" id="template-weekly-inline-edit">
<div class="weekly-inline-edit hidden" id="weekly-inline-edit">
<div class="inline-edit">
<div data-jc="dropdown" data-jc-path="megatimercomponent.form.type" data-options="On|on;Off|off" class="m">@(Type)</div>
<div data-jc="dropdown" data-jc-path="megatimercomponent.form.time" data-source="megatimercomponent.hours" class="m">@(Time)</div>
<div data-jc="dropdown" data-jc-path="megatimercomponent.form.type" data-jc-options="items:On|on,Off|off" class="m">@(Type)</div>
<div data-jc="dropdown" data-jc-path="megatimercomponent.form.time" data-jc-options="source:megatimercomponent.hours" class="m">@(Time)</div>
<button class="button"><i class="fa fa-check"></i>&nbsp;@(Set)</button>
<button class="button button-remove"><i class="fa fa-trash"></i>&nbsp;@(Remove)</button>
</div>
Expand All @@ -201,14 +201,12 @@ exports.html = `
$('body').append($('#template-weekly-inline-edit').html());
COMPONENT('megatimercomponent-hours', function() {
var self = this;
var $form;
COMPONENT('megatimercomponent-hours', function(self) {
var index, $parent, $form;
var visible = false;
var index;
var $parent;
self.make = function() {
self.make = function() {
$form = $('#weekly-inline-edit');
$parent = self.element.parent();
self.element.on('click', function(e){
Expand All @@ -220,8 +218,8 @@ exports.html = `
var pos = $this.offset();
$form.css({top: pos.top + 30, left: pos.left, width: $this.css('width')});
$form.find('.button-remove').attr('data-index', data.index);
$form.removeClass('hidden');
visible = true;
$form.removeClass('hidden');
visible = true;
SET('megatimercomponent.form', { type: data.type || 'on', time: data.time || '12:00'});
$form.find('button').off('click').on('click', function(){
Expand All @@ -245,7 +243,7 @@ exports.html = `
});
$form.off('click').on('click', function(e){
e.stopPropagation();
});
});
});
$('body').on('click', function(){
Expand All @@ -263,18 +261,11 @@ exports.html = `
var megatimercomponent = {};
megatimercomponent.hours = ["00:00","00:15","00:30","00:45","01:00","01:15","01:30","01:45","02:00","02:15","02:30","02:45","03:00","03:15","03:30","03:45","04:00","04:15","04:30","04:45","05:00","05:15","05:30","05:45","06:00","06:15","06:30","06:45","07:00","07:15","07:30","07:45","08:00","08:15","08:30","08:45","09:00","09:15","09:30","09:45","10:00","10:15","10:30","10:45","11:00","11:15","11:30","11:45","12:00","12:15","12:30","12:45","13:00","13:15","13:30","13:45","14:00","14:15","14:30","14:45","15:00","15:15","15:30","15:45","16:00","16:15","16:30","16:45","17:00","17:15","17:30","17:45","18:00","18:15","18:30","18:45","19:00","19:15","19:30","19:45","20:00","20:15","20:30","20:45","21:00","21:15","21:30","21:45","22:00","22:15","22:30","22:45","23:00","23:15","23:30","23:45"];
</script>
`;
</script>`;

exports.readme = `# Timer
Timer will trigger flow at the given times and dates. You can optionally define a data-type of the output and the data.
`;
Timer will trigger flow at the given times and dates. You can optionally define a data-type of the output and the data.`;

var WEEKDAYS = {
'monday': 1,
Expand All @@ -284,7 +275,7 @@ var WEEKDAYS = {
'friday': 5,
'saturday': 6,
'sunday': 7
}
};

exports.install = function(instance) {
instance.options.enabled = true;
Expand Down Expand Up @@ -323,10 +314,10 @@ exports.install = function(instance) {
var daynumber = WEEKDAYS[dayname]; // sunday === 7 not 0 !!!
var day = weekly.days[dayname];
var add = 0;

if (daynumber < todayday)
// 7 - (wed - tue) => 7 - (3 - 2) => 7 - 1 => 6
add = 7 - (todayday - daynumber);
add = 7 - (todayday - daynumber);

if (daynumber > todayday)
add = daynumber - todayday;
Expand Down Expand Up @@ -363,9 +354,8 @@ exports.install = function(instance) {
instance.status(options.type);

if (timers[options.type])
timers[options.type]();
};

timers[options.type]();
}

F.on('service', function(){

Expand All @@ -387,13 +377,12 @@ exports.install = function(instance) {

var t = queue[index];

t.expire = new Date().setTime(t.expire + delay);
t.expire = new Date().setTime(t.expire + delay);

var key = t.type + 'data';
var key = t.type + 'data';
var data = instance.options[key];
data = instance.options.datatype === 'object' ? JSON.parse(data) : data;
instance.options.enabled && instance.send(data);

instance.options.enabled && instance.send2(data);
});

};
Expand Down
8 changes: 4 additions & 4 deletions merge/merge.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ exports.icon = 'compress';
exports.html = `<div class="padding">
<div class="row">
<div class="col-md-3 m">
<div data-jc="textbox" data-jc-path="count" data-required="true" data-placeholder="5" data-jc-type="number" data-increment="true" data-align="center">@(Count)</div>
<div data-jc="textbox" data-jc-path="count" data-jc-config="required:true;placeholder:5;type:number;increment:true;align:center">@(Count)</div>
<div class="help">@(Count of messages per queue)</div>
</div>
<div class="col-md-3 m">
<div data-jc="textbox" data-jc-path="timeout" data-placeholder="5" data-jc-type="number" data-increment="true" data-align="center">@(Timeout in ms)</div>
<div data-jc="textbox" data-jc-path="timeout" data-jc-config="placeholder:5;type:number;increment:true;align:center">@(Timeout in ms)</div>
<div class="help">@(0 means "timeout is disabled")</div>
</div>
</div>
Expand Down Expand Up @@ -49,10 +49,10 @@ exports.install = function(instance) {
if (instance.options.id) {
var msg = instance.make(arr);
msg.id = id;
instance.send(msg);
instance.send2(msg);
delete data[id];
} else {
instance.send(arr);
instance.send2(arr);
data[id] = [];
}

Expand Down
10 changes: 5 additions & 5 deletions mergetoobject/mergetoobject.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ exports.author = 'Martin Smola';
exports.icon = 'compress';

exports.html = `<div class="padding">
<div data-jc="textboxlist" data-jc-path="props" data-maxlength="50" data-placeholder="property name" data-icon="fa-list">Properties</div>
<div data-jc="textboxlist" data-jc-path="props" data-jc-config="maxlength:50;placeholder:@(a property name);icon:list">@(Properties)</div>
<div class="help">@(Data comming to each of the inputs will be assign to a property from top to bottom. The first input to the first property.)</div>
<script>
ON('save.mergetoobject', function(component, options) {
Expand Down Expand Up @@ -38,12 +38,12 @@ exports.install = function(instance) {
if (!prop)
instance.debug('No property name for current input:', response.index);
else
data[id][prop] = response.data;
data[id][prop] = response.data;

instance.status(Object.keys(data[id]).join(', '), 'red');
if (Object.keys(data[id]).length === instance.options.props.length) {
response.data = data[id];
instance.send(response);
instance.send2(response);
setTimeout2(instance.id, () => instance.status(''), 500, 10);
data[id] = {};
}
Expand All @@ -56,9 +56,9 @@ exports.install = function(instance) {
instance.on('options', function() {
if (instance.options.props && instance.options.props.length)
instance.status('');
else
else
instance.status('Not configured', 'red');
});

instance.status(instance.options.props && instance.options.props.lenght ? '' : 'Not configured', 'red');
instance.status(instance.options.props && instance.options.props.length ? '' : 'Not configured', 'red');
};
4 changes: 2 additions & 2 deletions messengersender/messengersender.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ This component can send message.
- input has to be a Markdown content`;

exports.html = `<div class="padding">
<div data-jc="dropdown" data-jc-path="from" data-source="messengerdata.users" data-empty="" class="m" data-required="true">@(Who is the sender?)</div>
<div data-jc="dropdown" data-jc-path="location" data-source="messengerdata.channels" data-empty="@(Current location)" class="m">@(Location)</div>
<div data-jc="dropdown" data-jc-path="from" data-jc-config="source:messengerdata.users;required:true;empty:" class="m">@(Who is the sender?)</div>
<div data-jc="dropdown" data-jc-path="location" data-jc-config="source:messengerdata.channels;empty:@(Current location);required:true" class="m">@(Location)</div>
</div>
<script>TRIGGER('{0}', 'messengerdata');</script>`.format(TRIGGER);

Expand Down
4 changes: 1 addition & 3 deletions modified/modified.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,13 @@ exports.install = function(instance) {
var counter = 0;
instance.on('data', function(response) {
var data = response.data;

if (data instanceof Buffer)
data = data.toString('base64');
else if (typeof(data) === 'object' || data instanceof Date)
data = JSON.stringify(data);

if (backup !== data) {
backup = data;
instance.send(response);
instance.send2(response);
} else {
counter++;
instance.status('Not modified: {0}x'.format(counter));
Expand Down
7 changes: 2 additions & 5 deletions monitorconsumption/monitorconsumption.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ __Data Example__:
exports.html = `<div class="padding">
<div class="row">
<div class="col-md-3 m">
<div data-jc="textbox" data-jc-path="interval" data-placeholder="@(5000)" data-increment="true" data-jc-type="number" data-required="true" data-maxlength="10">@(Interval in milliseconds)</div>
<div data-jc="textbox" data-jc-path="interval" data-jc-config="placeholder:10000;increment:true;type:number;required:true;maxlength:10;align:center">@(Interval in milliseconds)</div>
</div>
</div>
<hr />
Expand Down Expand Up @@ -110,10 +110,7 @@ exports.install = function(instance) {

if (instance.options.enabled) {
tproc = setTimeout(instance.custom.run, instance.options.interval);
if (instance.send2)
instance.send2(current);
else
instance.send(current);
instance.send2(current);
}

instance.custom.status();
Expand Down
2 changes: 1 addition & 1 deletion monitorcpu/monitorcpu.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ exports.install = function(instance) {
chunk.toString('utf8').parseTerminal(fields, instance.custom.parse);
current.count = current.cores.length;
if (current.count) {
instance.send(current);
instance.send2(current);
instance.custom.status();
}
};
Expand Down
9 changes: 4 additions & 5 deletions monitordisk/monitordisk.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ __Data Example__:
exports.html = `<div class="padding">
<div class="row">
<div class="col-md-3 m">
<div data-jc="textbox" data-jc-path="interval" data-placeholder="@(10000)" data-increment="true" data-jc-type="number" data-required="true" data-maxlength="10">@(Interval in milliseconds)</div>
<div data-jc="textbox" data-jc-path="interval" data-jc-config="placeholder:10000;increment:true;type:number;required:true;maxlength:10;align:center">@(Interval in milliseconds)</div>
</div>
<div class="col-md-3 m">
<div data-jc="textbox" data-jc-path="path" data-placeholder="/" data-required="true">@(Path)</div>
<div data-jc="textbox" data-jc-path="path" data-jc-config="placeholder:/;required:true">@(Path)</div>
</div>
</div>
</div>`;
Expand Down Expand Up @@ -63,7 +63,7 @@ exports.install = function(instance) {
current.free = line[2].parseInt();
current.used = line[1].parseInt();
instance.custom.status();
instance.send(current);
instance.send2(current);
});
});
};
Expand All @@ -78,8 +78,7 @@ exports.install = function(instance) {
instance.on('click', function() {
instance.options.enabled = !instance.options.enabled;
instance.custom.status();
if (instance.options.enabled)
instance.custom.run();
instance.options.enabled && instance.custom.run();
});

instance.on('close', function() {
Expand Down
Loading

0 comments on commit 89edaa6

Please sign in to comment.