我正在开发类似于Tableau提供的UI命名空间示例扩展(Github Link)的扩展。
我已将文件托管在应用程序服务器(启用https)中,并将trex文件指向托管在此处的文件。
我可以将扩展名拖到Tableau Desktop,从对话框中选择输入,然后根据提供的输入刷新页面。
保存仪表板并将其发布到Tableau Server之后,我看不到发布之前保存的更改。回到初始状态“配置扩展到继续”。
我尝试直接在Tableau Server中对其进行编辑,但仍然导致相同的问题。
发布工作簿时不会保存更改。
请问我是否缺少某些东西,或者有人有同样的问题可以解决?
答案 0 :(得分:4)
研究和代码更改后,我找到了解决该问题的方法。
在UI命名空间示例中,我们需要包含一个函数来检查以前保存的设置并基于此填充UI。 您可以打开.twb文件来查看保存的设置。
以前,仅将选定的数据源保存为设置。但是除了数据源之外,我还提供了一个代码,用于将选定的间隔保存为设置。当用户下次单击“配置”时,这对于保留间隔状态非常有用。
用于检查uiNamespace.js中是否已经存在设置的代码段:
$(document).ready(function () {
// When initializing an extension, an optional object is passed that maps a special ID (which
// must be 'configure') to a function. This, in conjuction with adding the correct context menu
// item to the manifest, will add a new "Configure..." context menu item to the zone of extension
// inside a dashboard. When that context menu item is clicked by the user, the function passed
// here will be executed.
tableau.extensions.initializeAsync({'configure': configure}).then(function () {
// First, check for any saved settings and populate our UI based on them.
checkForSettings(tableau.extensions.settings.getAll());
}, function (err) {
// Something went wrong in initialization
console.log('Error while Initializing: ' + err.toString());
})
.then(function() {
// This event allows for the parent extension and popup extension to keep their
// settings in sync. This event will be triggered any time a setting is
// changed for this extension, in the parent or popup (i.e. when settings.saveAsync is called).
tableau.extensions.settings.addEventListener(tableau.TableauEventType.SettingsChanged, (settingsEvent) => {
updateExtensionBasedOnSettings(settingsEvent.newSettings)
});
});
});
function checkForSettings (settings) {
if(Object.keys(settings).length > 0)
{
updateExtensionBasedOnSettings(settings);
selectedInterval = JSON.parse(settings.intervalCount);
$('#interval').text(selectedInterval);
setupRefreshInterval(selectedInterval);
defaultIntervalInMin = selectedInterval;
$('#inactive').hide();
$('#active').show();
}
}
用于将所选间隔保存为uiNamespaceDialog.js中的设置的代码段:
function closeDialog() {
let currentSettings = tableau.extensions.settings.getAll();
tableau.extensions.settings.set(datasourcesSettingsKey, JSON.stringify(selectedDatasources));
tableau.extensions.settings.set(intervalCountKey, JSON.stringify($('#interval').val()));
tableau.extensions.settings.saveAsync().then((newSavedSettings) => {
tableau.extensions.ui.closeDialog($('#interval').val());
});
}
完整代码可在GitHub.中找到 现在,一旦我们在Tableau Desktop中进行了更改并将其发布到Tableau Server,就将保存配置。
此更改还将解决Web编辑issue(直接在tableau服务器中编辑扩展名)。