2023-03-04 22:38:38 +05:30
|
|
|
import Vue from 'vue';
|
|
|
|
import { darkModeEnabled } from '~/lib/utils/color_utils';
|
|
|
|
import { setUrlParams } from '~/lib/utils/url_utility';
|
|
|
|
|
|
|
|
export function getFrameSrc(url) {
|
|
|
|
return `${setUrlParams({ theme: darkModeEnabled() ? 'dark' : 'light' }, url)}&kiosk`;
|
|
|
|
}
|
|
|
|
|
|
|
|
const mountVueComponent = (element) => {
|
2023-05-08 21:46:49 +05:30
|
|
|
const { frameUrl, observabilityUrl } = element.dataset;
|
2023-03-04 22:38:38 +05:30
|
|
|
|
2023-05-08 21:46:49 +05:30
|
|
|
try {
|
|
|
|
if (
|
|
|
|
!observabilityUrl ||
|
|
|
|
!frameUrl ||
|
|
|
|
new URL(frameUrl)?.host !== new URL(observabilityUrl).host
|
|
|
|
)
|
|
|
|
return;
|
|
|
|
|
|
|
|
// eslint-disable-next-line no-new
|
|
|
|
new Vue({
|
|
|
|
el: element,
|
|
|
|
render(h) {
|
|
|
|
return h('iframe', {
|
|
|
|
style: {
|
|
|
|
height: '366px',
|
|
|
|
width: '768px',
|
|
|
|
},
|
|
|
|
attrs: {
|
|
|
|
src: getFrameSrc(frameUrl),
|
|
|
|
frameBorder: '0',
|
|
|
|
},
|
|
|
|
});
|
|
|
|
},
|
|
|
|
});
|
|
|
|
} catch (e) {
|
|
|
|
// eslint-disable-next-line no-console
|
|
|
|
console.error(e);
|
|
|
|
}
|
2023-03-04 22:38:38 +05:30
|
|
|
};
|
|
|
|
|
|
|
|
export default function renderObservability(elements) {
|
|
|
|
elements.forEach((element) => {
|
|
|
|
mountVueComponent(element);
|
|
|
|
});
|
|
|
|
}
|