"use strict";(self.webpackChunkdocs_openc3_com=self.webpackChunkdocs_openc3_com||[]).push([[413],{8383:(e,t,i)=>{i.r(t),i.d(t,{assets:()=>c,contentTitle:()=>l,default:()=>u,frontMatter:()=>n,metadata:()=>d,toc:()=>r});var s=i(1085),o=i(1184);const n={title:"Custom Widgets"},l=void 0,d={id:"guides/custom-widgets",title:"Custom Widgets",description:"COSMOS allows you to build custom widgets which can be deployed with your plugin and used in Telemetry Viewer. Building custom widgets can utilitize any javascript frameworks but since COSMOS is written with Vue.js, we will use that framework in this tutorial. Please see the Widget Generator guide for information about generating the scaffolding for a custom widget.",source:"@site/docs/guides/custom-widgets.md",sourceDirName:"guides",slug:"/guides/custom-widgets",permalink:"/tools/staticdocs/docs/guides/custom-widgets",draft:!1,unlisted:!1,editUrl:"https://github.com/OpenC3/cosmos/tree/main/docs.openc3.com/docs/guides/custom-widgets.md",tags:[],version:"current",frontMatter:{title:"Custom Widgets"},sidebar:"defaultSidebar",previous:{title:"COSMOS and NASA cFS",permalink:"/tools/staticdocs/docs/guides/cfs"},next:{title:"Little Endian Bitfields",permalink:"/tools/staticdocs/docs/guides/little-endian-bitfields"}},c={},r=[{value:"Custom Widgets",id:"custom-widgets",level:2},{value:"Helloworld Widget",id:"helloworld-widget",level:3}];function a(e){const t={a:"a",admonition:"admonition",code:"code",h2:"h2",h3:"h3",img:"img",p:"p",pre:"pre",...(0,o.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(t.p,{children:["COSMOS allows you to build custom widgets which can be deployed with your ",(0,s.jsx)(t.a,{href:"/tools/staticdocs/docs/configuration/plugins",children:"plugin"})," and used in ",(0,s.jsx)(t.a,{href:"/tools/staticdocs/docs/tools/tlm-viewer",children:"Telemetry Viewer"}),". Building custom widgets can utilitize any javascript frameworks but since COSMOS is written with Vue.js, we will use that framework in this tutorial. Please see the ",(0,s.jsx)(t.a,{href:"../getting-started/generators#widget-generator",children:"Widget Generator"})," guide for information about generating the scaffolding for a custom widget."]}),"\n",(0,s.jsx)(t.h2,{id:"custom-widgets",children:"Custom Widgets"}),"\n",(0,s.jsxs)(t.p,{children:["We're basically going to follow the COSMOS ",(0,s.jsx)(t.a,{href:"https://github.com/OpenC3/cosmos/tree/main/openc3-cosmos-init/plugins/packages/openc3-cosmos-demo",children:"Demo"})," and explain how that custom widget was created."]}),"\n",(0,s.jsxs)(t.p,{children:["If you look at the bottom of the Demo's ",(0,s.jsx)(t.a,{href:"https://github.com/OpenC3/cosmos/blob/main/openc3-cosmos-init/plugins/packages/openc3-cosmos-demo/plugin.txt",children:"plugin.txt"})," file you'll see we declare the widgets:"]}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-ruby",children:"WIDGET BIG\nWIDGET HELLOWORLD\n"})}),"\n",(0,s.jsxs)(t.p,{children:["When the plugin is deployed this causes COSMOS to look for the as-built widgets. For the BIG widget it will look for the widget at ",(0,s.jsx)(t.code,{children:"tools/widgets/BigWidget/BigWidget.umd.min.js"}),". Similarly it looks for HELLOWORLD at ",(0,s.jsx)(t.code,{children:"tools/widgets/HelloworldWidget/HelloworldWidget.umd.min.js"}),". These directories and file names may seem mysterious but it's all about how the widgets get built."]}),"\n",(0,s.jsx)(t.h3,{id:"helloworld-widget",children:"Helloworld Widget"}),"\n",(0,s.jsxs)(t.p,{children:["The Helloworld Widget source code is found in the plugin's src directory and is called ",(0,s.jsx)(t.a,{href:"https://github.com/OpenC3/cosmos/blob/main/openc3-cosmos-init/plugins/packages/openc3-cosmos-demo/src/HelloworldWidget.vue",children:"HelloworldWidget.vue"}),". The basic structure is as follows:"]}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-vue",children:'\n\n