analytics/assets/js/dashboard/mount.js

39 lines
1.2 KiB
JavaScript
Raw Normal View History

import React from 'react';
import ReactDOM from 'react-dom';
import 'url-search-params-polyfill';
import Router from './router'
2020-07-15 12:14:53 +03:00
import ErrorBoundary from './error-boundary'
import * as api from './api'
const container = document.getElementById('stats-react-container')
if (container) {
const site = {
domain: container.dataset.domain,
offset: container.dataset.offset,
hasGoals: container.dataset.hasGoals === 'true',
statsBegin: container.dataset.statsBegin,
embedded: container.dataset.embedded,
background: container.dataset.background,
2022-05-03 10:38:59 +03:00
isDbip: container.dataset.isDbip === 'true',
flags: JSON.parse(container.dataset.flags),
validIntervalsByPeriod: JSON.parse(container.dataset.validIntervalsByPeriod)
}
const loggedIn = container.dataset.loggedIn === 'true'
const currentUserRole = container.dataset.currentUserRole
const sharedLinkAuth = container.dataset.sharedLinkAuth
if (sharedLinkAuth) {
api.setSharedLinkAuth(sharedLinkAuth)
}
2020-07-15 12:14:53 +03:00
const app = (
<ErrorBoundary>
<Router site={site} loggedIn={loggedIn} currentUserRole={currentUserRole} />
2020-07-15 12:14:53 +03:00
</ErrorBoundary>
)
ReactDOM.render(app, container);
}