UI 命名空间 Tableau 扩展更改未保存在 Tableau Server 中
UI Namespace Tableau Extension changes not saving in Tableau Server
我正在开发类似于 Tableau 提供的 UI 命名空间示例扩展 (Github Link) 的扩展。
我已将文件托管在应用程序服务器中(启用 https)并将 trex 文件指向托管在那里的文件。
我能够将扩展程序拖到 Tableau Desktop,select 来自对话框的输入,页面会根据提供的输入进行刷新。
在我保存仪表板并将其发布到 Tableau 服务器后,我无法看到发布前保存的更改。它回到初始状态 "Configure extension to Proceed".
我尝试直接在 Tableau Server 中对其进行编辑,但仍然出现同样的问题。
发布工作簿时不会保存更改。
如果我遗漏了什么或者是否有人有同样的问题可以解决,请告诉我好吗?
经过研究和代码更改,我找到了问题的解决方法。
在 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 server 中编辑扩展)。
我正在开发类似于 Tableau 提供的 UI 命名空间示例扩展 (Github Link) 的扩展。
我已将文件托管在应用程序服务器中(启用 https)并将 trex 文件指向托管在那里的文件。
我能够将扩展程序拖到 Tableau Desktop,select 来自对话框的输入,页面会根据提供的输入进行刷新。
在我保存仪表板并将其发布到 Tableau 服务器后,我无法看到发布前保存的更改。它回到初始状态 "Configure extension to Proceed".
我尝试直接在 Tableau Server 中对其进行编辑,但仍然出现同样的问题。
发布工作簿时不会保存更改。
如果我遗漏了什么或者是否有人有同样的问题可以解决,请告诉我好吗?
经过研究和代码更改,我找到了问题的解决方法。
在 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 server 中编辑扩展)。