new api integrated

This commit is contained in:
2017-10-29 12:04:30 +01:00
parent 1c9739c5cf
commit 4f4e072542
12 changed files with 174 additions and 36 deletions

View File

@@ -94,13 +94,13 @@
<div id="prototypControls">
<label>L</label>
<input type="range" class="laser slider" value="0" max="128">
<input type="range" class="laser slider" value="1" min="1" max="128">
<label>M1</label>
<input type="range" class="motor slider" value="0" max="128" data-motor-nr="1">
<input type="range" class="motor slider" value="1" min="1" max="128" data-motor-nr="1">
<label>M2</label>
<input type="range" class="motor slider" value="0" max="128" data-motor-nr="2">
<input type="range" class="motor slider" value="1" min="1" max="128" data-motor-nr="2">
<label>M3</label>
<input type="range" class="motor slider" value="0" max="128" data-motor-nr="3">
<input type="range" class="motor slider" value="1" min="1" max="128" data-motor-nr="3">
</div>
<div id="prototypControls">
<text class="sectionDesc">last uri:</text>

View File

@@ -99,7 +99,8 @@ var $ = function(selector){
let update = function(endpoint, method, props) {
Sui.http.ajax({
method: method,
endpoint: node.api[endpoint] + (props ? props.join('/') : ''),
endpoint: node.api[endpoint],
data: props,
cache: false
}, actuator.onResponse || null);
};
@@ -107,7 +108,7 @@ var $ = function(selector){
let handle = function(event) {
update.call(this,
actuator.api,
'GET',
actuator.method,
actuator.data ?
actuator.data.call(this) : [this.value]
);
@@ -147,7 +148,7 @@ var $ = function(selector){
if(!cache) {
data['_'] = new Date().getTime();
}
var serializedData = Sui.util.serialize(data);
var serializedData = data; //Sui.util.serialize(data);
var endPointUrl = (config.method === 'GET' || config.method === 'DELETE') && data ? config.endpoint+'?'+serializedData : config.endpoint;
var postData = config.method === 'POST' || config.method === 'PUT' ? serializedData : null;
@@ -166,23 +167,30 @@ var $ = function(selector){
};
[{
api: 'MOTOR',
method: 'GET',
method: 'POST',
selector: '.motor.slider',
event: 'change',
data: function(){
return [this.getAttribute('data-motor-nr'), this.value];
data: function() {
let payload = {};
payload['motor' + this.getAttribute('data-motor-nr')] = this.value;
return Sui.util.serialize(payload);
},
onResponse: debugResponse
}, {
api: 'LASER',
method: 'GET',
method: 'POST',
selector: '.laser.slider',
event: 'change',
onResponse: debugResponse
onResponse: debugResponse,
data: function() {
return Sui.util.serialize({
laser: this.value
});
}
}].forEach(Sui.link({
api: {
MOTOR: '/motor/', // {motorNr}/{value}
LASER: '/laser/' // {value}
MOTOR: '/spirograph', // {motorNr}/{value}
LASER: '/spirograph' // {value}
}
}));
});

View File

@@ -1,5 +1,5 @@
{
"apMode": 0,
"SSID": "",
"Password": ""
}
"SSID": "tErAx1d",
"Password": "ramalamadingdong"
}