Hi Rob,
thanks for helping out. yeah, sorry that did not work yesterday (the code highlighting)
This is my code SERVER SIDE
function deleteStream (guid) {
return HTTP.call( 'DELETE', 'http://'+config.host+'/'+config.virtualProxy+'/qrs/stream/'+guid+'?xrfkey='+config.xrfkey,
{
headers: {
'hdr-usr' : config.headerValue,
'X-Qlik-xrfkey': config.xrfkey
}
}, function( error, response ) {
if ( error ) {
console.error( error );
throw new Meteor.Error('error stream delete', error)
} else {
console.log( response );
return response;
}
});
};
function createStream (name) {
console.log('create the stream with name', name);
var myPromise = qrs.post('/qrs/stream', null, {"name": name})
.catch(err => {
console.log(err);
throw new Meteor.Error(err)
})
return myPromise
};
function getStreams () {
return qrs.get('/qrs/stream/full');
};
Meteor.methods({
generateStreamAndApp (customers) {
check(customers, Array);
return generateStreamAndApp(customers);
},
getApps () {
return new Promise((resolve, reject) => {
qsocks.Connect(engineConfig)
.then(function(global) {
global.getDocList().then(function(docList) {
resolve(docList) ;
});
})
})
.catch(err => {
throw new Meteor.Error(err)
})
},
copyApp (guid, name) {
check(guid, String);
check(name, String);
return copyApp(guid,name);
},
deleteApp (guid) {
check(guid, String);
return deleteApp(guid);
},
deleteStream (guid) {
check(guid, String);
return deleteStream(guid);
},
countApps(){
return qrs.get('/qrs/app/count');
},
countStreams(){
return qrs.get('/qrs/stream/count');
},
createStream (name) {
return createStream(name);
},
getStreams () {
return getStreams();
},
getSecurityRules () {
return getSecurityRules();
},
// updateAppsCollection(){
// console.log('Method: update the local mongoDB with fresh data from Qlik Sense');
This is my code on the client
Template.body.events({
'submit .new-customer'(event) {
// Prevent default browser form submit
event.preventDefault();
// Get value from form element
const target = event.target;
const customerName = target.text.value;
// Insert a task into the collection
Customers.insert({
name: customerName,
createdAt: new Date(), // current time
});
// Clear form
target.text.value = '';
},
'click .generateStreamAndApp'() {
console.log('click event generateStreamAndApp');
var selectedCustomers = Customers.find({checked: true}).fetch();
// var selectedCustomers = Customers.find().fetch();
console.log('get customers from database, and pass them to the generateStreamAndApp method', selectedCustomers);
var templateGuid = '893f8063-2387-4bc3-90f0-d672e8a467d3';
Meteor.call('generateStreamAndApp',selectedCustomers,templateGuid, function(err, result) {
if (err) {
sAlert.error(err);
console.log(err);
} else {
console.log('generateStreamAndApp succes', result);
sAlert.success('Streams and apps created, and apps have been published into the stream of the customer ');
updateSenseInfo();
}
});
},