diff --git a/README.md b/README.md index 280a1a8744b44..6bb7d94965497 100644 --- a/README.md +++ b/README.md @@ -95,6 +95,12 @@ yarn build-static-viz yarn build-viz ``` +Test frontent + +``` +npx serve resources/frontend_client/ +``` + Copy to Steedos Analytics ``` diff --git a/frontend/src/metabase/lib-viz.js b/frontend/src/metabase/lib-viz.js new file mode 100644 index 0000000000000..508f76d9a00b7 --- /dev/null +++ b/frontend/src/metabase/lib-viz.js @@ -0,0 +1,99 @@ +// /* +// * This file is subject to the terms and conditions defined in +// * file 'LICENSE-EMBEDDING.txt', which is part of this source code package. +// */ + +// import "regenerator-runtime/runtime"; + +// // Use of classList.add and .remove in Background and FitViewPort Hocs requires +// // this polyfill so that those work in older browsers +// import "classlist-polyfill"; + +// import "number-to-locale-string"; + +// // This is conditionally aliased in the webpack config. +// // If EE isn't enabled, it loads an empty file. +// // Should be imported before any other metabase import +// import "ee-overrides"; // eslint-disable-line import/no-unresolved, import/no-duplicates + +// // If enabled this monkeypatches `t` and `jt` to return blacked out +// // strings/elements to assist in finding untranslated strings. +// import "metabase/lib/i18n-debug"; + +// // set the locale before loading anything else +// import "metabase/lib/i18n"; + +// // NOTE: why do we need to load this here? +// import "metabase/lib/colors"; + +// // NOTE: this loads all builtin plugins +// import "metabase/plugins/builtin"; + +// // router +// import { useRouterHistory } from "react-router"; +// import { createHistory } from "history"; + +// import { refreshSiteSettings } from "metabase/redux/settings"; +// import { initializeEmbedding } from "metabase/lib/embed"; +// import api from "metabase/lib/api"; +// import MetabaseSettings from "metabase/lib/settings"; +// import registerVisualizations from "metabase/visualizations/register"; +// import { PLUGIN_APP_INIT_FUCTIONS } from "metabase/plugins"; + +// import { getStore } from "./store"; + +// // remove trailing slash +// const BASENAME = window.MetabaseRoot.replace(/\/+$/, ""); + +// api.basename = BASENAME; + +// // eslint-disable-next-line react-hooks/rules-of-hooks +// const browserHistory = useRouterHistory(createHistory)({ +// basename: BASENAME, +// }); + +// function _init(reducers, callback) { +// const store = getStore(reducers, browserHistory); + +// let root; + +// registerVisualizations(); + +// initializeEmbedding(store); + +// store.dispatch(refreshSiteSettings()); + +// PLUGIN_APP_INIT_FUCTIONS.forEach(init => init({ root })); + +// window.Metabase = window.Metabase || {}; +// window.Metabase.store = store; +// window.Metabase.settings = MetabaseSettings; + +// if (callback) { +// callback(store); +// } +// } + +// export function init(...args) { +// if (document.readyState !== "loading") { +// _init(...args); +// } else { +// document.addEventListener("DOMContentLoaded", () => _init(...args)); +// } +// } + +import { init } from "./app"; + +import reducersPublic from "./reducers-public"; + +import Visualization from "./visualizations/components/Visualization"; + +const getRoutes = () => { + return; +}; + +export const initApp = callback => { + init(reducersPublic, getRoutes, callback); +}; + +export { Visualization }; diff --git a/webpack.viz.config.js b/webpack.viz.config.js index c20d33fc1e374..17e36c2009eb1 100644 --- a/webpack.viz.config.js +++ b/webpack.viz.config.js @@ -8,6 +8,8 @@ const SRC_PATH = __dirname + "/frontend/src/metabase"; const BUILD_PATH = __dirname + "/resources/frontend_client"; const CLJS_SRC_PATH = __dirname + "/frontend/src/cljs_release"; const LIB_SRC_PATH = __dirname + "/frontend/src/metabase-lib"; +const ENTERPRISE_SRC_PATH = + __dirname + "/enterprise/frontend/src/metabase-enterprise"; const WEBPACK_BUNDLE = process.env.WEBPACK_BUNDLE || "development"; const devMode = WEBPACK_BUNDLE !== "production"; @@ -24,7 +26,7 @@ const CSS_CONFIG = { }; module.exports = env => { - const shouldDisableMinimization = env.WEBPACK_WATCH === true; + const shouldDisableMinimization = devMode || env.WEBPACK_WATCH === true; return { mode: "production", @@ -36,9 +38,9 @@ module.exports = env => { entry: { "lib-viz": { - import: "./visualizations/components/Visualization/index.ts", + import: "./lib-viz.js", library: { - name: "Visualizations", + name: "Visualization", type: "var", }, }, @@ -47,6 +49,8 @@ module.exports = env => { output: { path: BUILD_PATH + "/app/dist", filename: "[name].bundle.js", + library: 'Visualization', + libraryTarget: 'umd', }, module: { @@ -100,6 +104,14 @@ module.exports = env => { cljs: CLJS_SRC_PATH, "metabase-lib": LIB_SRC_PATH, style: SRC_PATH + "/css/core/index", + ace: __dirname + "/node_modules/ace-builds/src-min-noconflict", "ee-plugins": + process.env.MB_EDITION === "ee" + ? ENTERPRISE_SRC_PATH + "/plugins" + : SRC_PATH + "/lib/noop", + "ee-overrides": + process.env.MB_EDITION === "ee" + ? ENTERPRISE_SRC_PATH + "/overrides" + : SRC_PATH + "/lib/noop", }, }, optimization: {