Я пользователь Qlik Sense Api, и я немного расстроен, поскольку документы Qlik очень запутывают.
Поэтому у меня есть три вещи, которые мне нужно сделать.
Спасибо
require(['js/qlik'], function (qlik) {
// I need to get the current logged in user from here
// and also a list of apps this user can view
});
Обновить:
// for getting the user this works like a charm
var global = qlik.getGlobal(config);
global.getAuthenticatedUser(function(reply){
alert('User:'+reply.qReturn);
});
Для получения приложений был предложен следующий код. Я не уверен, как они отличаются.
// This one is what I have found from trying various code snippets found in the documentation.
// This seems to work but there are errors when displaying the apps with the below code snippet.
qlik.getGlobal(self.config).getAppList(function(list) {console.log(list);});
// suggested snippet gives the following errors.
qlik.getAppList(function(list) {console.log(list);});
Error: "WebSocket connection to 'ws://localhost:8000/app/%3Ftransient%3D?reloadUri=http%3A%2F%2Flocalhost%3A8000%2F' failed: Connection closed before receiving a handshake response"
qlik.getGlobal(self.config).getAppList(function(list) {
ia.getList('sheet', function (reply) {
$('#qlik-cont').append('<div id="div-' + key + '"></div>');
var stop = setInterval(function(){
ia.global.getProgress(ia.model.handle).then(function(progress)
{
console.log("DoReload progress", progress);
});
}, 100);
ia.doReload().then(function(result){
if (result) {
ia.getObject('div-' + key, reply.qInfo.qId);
}
else {
console.log('Reload failed');
}
})
.finally(function(){
clearInterval(stop);
});
});
}
});
Приведенный выше код приводит к следующей ошибке "Неверная визуализация Визуализация не найдена на сервере: лист"
Спасибо
Чтобы ответить на ваши вопросы:
1) Чтобы получить пользователя, getAuthenticatedUser
проверку подлинности, используйте getAuthenticatedUser
, например:
var global = qlik.getGlobal(config);
global.getAuthenticatedUser(function(reply){
alert('User:'+reply.qReturn);
});
2) Чтобы получить список приложений, используйте getAppList
, например:
qlik.getAppList(function(list){
var str = "";
list.forEach(function(value) {
str += value.qDocName + '('+ value.qDocId +') ';
});
alert(str);
}
};
3) Здесь приведено описание всех возможностей, которые вы можете использовать: http://help.qlik.com/en-US/sense-developer/June2017/Subsystems/APIs/Content/capability-apis-reference.htm