dashbord預設需要手動選擇action->set auto refresh來設定頁面自動重新整理。
沒有通過url參數來指定自動重新整理的功能,這樣就不友善通過iframe來使用dashbord
我改了下superset的代碼來實作這個功能。
修改DashBoard.jsx檔案,在componentDidMount方法中加入以下代碼(标紅的代碼)
function getUrlParam(name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //構造一個含有目标參數的正規表達式對象
var href = window.location.href
var search = href.substr(href.indexOf('?'))
var r = search.substr(1).match(reg); //比對目标參數
if (r != null) return unescape(r[2]);
return null; //傳回參數值
}
class Dashboard extends React.PureComponent {
constructor(props) {
super(props);
this.refreshTimer = null;
this.firstLoad = true;
this.loadingLog = new ActionLog({
impressionId: props.impressionId,
actionType: LOG_ACTIONS_PAGE_LO