Initial commit
This commit is contained in:
51
templates/widget-template/index.js
Normal file
51
templates/widget-template/index.js
Normal file
@ -0,0 +1,51 @@
|
||||
// ##RUNTIME_IMPORT##
|
||||
import { bootstrap, createHttpClient } from "@telia-ace/widget-core-flamingo";
|
||||
// ##PLUGIN_IMPORTS##
|
||||
|
||||
const client = createHttpClient("https://widgets.ace.teliacompany.net/v1");
|
||||
|
||||
const getDetails = async () => {
|
||||
const currentScript = new URL(import.meta.url);
|
||||
const parts = currentScript.pathname.replace('/v1/install/', '').split('/');
|
||||
|
||||
const organization = parts[0];
|
||||
const distribution = parts[1];
|
||||
|
||||
const resp = await fetch(`https://widgets.ace.teliacompany.net/v1/widget/dist/${organization}/${distribution}`);
|
||||
const json = await resp.json();
|
||||
|
||||
return json.id;
|
||||
};
|
||||
|
||||
(async () => {
|
||||
getDetails();
|
||||
|
||||
let widgetId = "";
|
||||
|
||||
try {
|
||||
widgetId = await getDetails();
|
||||
} catch {
|
||||
console.log("Widget not found");
|
||||
return;
|
||||
}
|
||||
|
||||
bootstrap(
|
||||
{
|
||||
httpClient: client,
|
||||
apps: [
|
||||
{
|
||||
renderStrategy: "trigger",
|
||||
autoActivate: true,
|
||||
// widgetId: "__#_#WIDGET_ID__#__#",
|
||||
widgetId: widgetId,
|
||||
triggerIcon: "question",
|
||||
},
|
||||
],
|
||||
},
|
||||
(siteConfig) => {
|
||||
siteConfig.applications.forEach((config) => {
|
||||
// ##PLUGINS##
|
||||
});
|
||||
},
|
||||
);
|
||||
})();
|
||||
Reference in New Issue
Block a user