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

@@ -12,7 +12,8 @@ var Sui = {
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);
};
@@ -20,7 +21,7 @@ var Sui = {
let handle = function(event) {
update.call(this,
actuator.api,
'GET',
actuator.method,
actuator.data ?
actuator.data.call(this) : [this.value]
);
@@ -60,7 +61,7 @@ var Sui = {
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;

View File

@@ -4,23 +4,30 @@ Sui.ready(() => {
};
[{
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}
}
}));
});