This commit is contained in:
2015-06-12 09:05:18 +02:00
parent 0a63e3752c
commit 0399674af7
35 changed files with 77 additions and 19 deletions
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
@@ -1,25 +1,33 @@
define([
"dojo/_base/config",
'dojo/_base/declare',
'dstore/Rest',
'dstore/RequestMemory',
'dstore/SimpleQuery',
'dstore/Trackable',
'dstore/Tree',
'dojo/_base/lang',
'dstore/Store',
'dojo/request',
'dstore/QueryResults',
'dstore/Cache',
"hos/Socket",
"dojo/request/xhr",
"dojox/uuid/generateRandomUuid"
], function(config, declare, Rest, RequestMemory, SimpleQuery, Trackable, Tree, Socket, xhr, generateRandomUuid){
], function(config, declare, lang, Store, request, QueryResults, Cache, Socket, xhr, generateRandomUuid){
var RuleEngineStore = declare([Rest, RequestMemory, SimpleQuery, Trackable, Tree], {
_getTarget: function(id){
var target = this.target;
if(!target.slice(-1) == '/'){
target += "/";
}
return target + "packages" + id;
var _RuleEngineStore = declare([Store], {
_request: function (target, options) {
// Most responses will be in JSON, so we make that the default expected format.
options = lang.mixin({ handleAs: 'json' }, options);
options.headers = lang.mixin({}, this.headers, options.headers);
return request(this.target + target, options);
},
fetch: function () {
return new QueryResults(this._request('packages'));
}
});
var RuleEngineStore = declare([_RuleEngineStore, Cache], {
isValidFetchCache: true
});
var _store = new RuleEngineStore({
target: config.hos.ruleEngineUrl
View File
View File
View File
View File
View File
View File
View File
View File
View File
+24 -3
View File
@@ -41,10 +41,31 @@
"dojo/on",
"dojo/domReady!"
], function(RuleEngine, domConstruct, dom, on){
var test1 = RuleEngine.get("rulepkg01");
//var test1 = RuleEngine.get("rulepkg01");
var test1 = RuleEngine.fetch().then(function(results){
console.log("results1: ", results);
});
console.log("test1: ", test1);
var test2 = RuleEngine.filter({arg01: "param01"});
console.log("test2: ", test2);
var f1 = RuleEngine.filter();
var c1 = f1.fetch();
c1.then(function(data) {
console.log("data: ", data);
RuleEngine.emit('update', {id: data.id, target: data});
});
f1.on('update', function(data) {
console.log("update");
});
RuleEngine.filter().fetch().then(function(data) {
console.log("data1: ", data);
});
RuleEngine.filter().fetch().then(function(data) {
console.log("data2: ", data);
});
RuleEngine.filter().fetch().then(function(data) {
console.log("data3: ", data);
});
//var test2 = RuleEngine.filter({arg01: "param01"});
//console.log("test2: ", test2);
});
</script>
@@ -102,6 +102,9 @@
console.log("Update: ", update);
}
);
_devices.filter().on('update', function(event){
console.log("Observe2 triggered: ", event);
});
_devices.on('update', function(event){
// this will be called any time a market is added, removed, or updated
console.log("Observe triggered: ", event);