"use strict";(self.webpackChunkdocs_openc3_com=self.webpackChunkdocs_openc3_com||[]).push([["1615"],{4706:function(e,t,i){i.r(t),i.d(t,{default:()=>u,frontMatter:()=>l,metadata:()=>s,assets:()=>c,toc:()=>r,contentTitle:()=>d});var s=JSON.parse('{"id":"guides/custom-widgets","title":"Custom Widgets","description":"How to build custom widgets for use in Telemetry Viewer","source":"@site/docs/guides/custom-widgets.md","sourceDirName":"guides","slug":"/guides/custom-widgets","permalink":"/tools/staticdocs/docs/guides/custom-widgets","draft":false,"unlisted":false,"editUrl":"https://github.com/OpenC3/cosmos/tree/main/docs.openc3.com/docs/guides/custom-widgets.md","tags":[],"version":"current","frontMatter":{"title":"Custom Widgets","description":"How to build custom widgets for use in Telemetry Viewer","sidebar_custom_props":{"myEmoji":"\uD83D\uDD28"}},"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"}}'),o=i("2322"),n=i("2840");let l={title:"Custom Widgets",description:"How to build custom widgets for use in Telemetry Viewer",sidebar_custom_props:{myEmoji:"\uD83D\uDD28"}},d=void 0,c={},r=[{value:"Custom Widgets",id:"custom-widgets",level:2},{value:"Helloworld Widget",id:"helloworld-widget",level:3}];function a(e){let t={a:"a",admonition:"admonition",code:"code",h2:"h2",h3:"h3",img:"img",p:"p",pre:"pre",...(0,n.a)(),...e.components};return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)(t.p,{children:["COSMOS allows you to build custom widgets which can be deployed with your ",(0,o.jsx)(t.a,{href:"/tools/staticdocs/docs/configuration/plugins",children:"plugin"})," and used in ",(0,o.jsx)(t.a,{href:"/tools/staticdocs/docs/tools/tlm-viewer",children:"Telemetry Viewer"}),". Building custom widgets can utilize any javascript frameworks but since COSMOS is written with Vue.js, we will use that framework in this tutorial. Please see the ",(0,o.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,o.jsx)(t.h2,{id:"custom-widgets",children:"Custom Widgets"}),"\n",(0,o.jsxs)(t.p,{children:["We're basically going to follow the COSMOS ",(0,o.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,o.jsxs)(t.p,{children:["If you look at the bottom of the Demo's ",(0,o.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,o.jsx)(t.pre,{children:(0,o.jsx)(t.code,{className:"language-ruby",children:"WIDGET BIG\nWIDGET HELLOWORLD\n"})}),"\n",(0,o.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,o.jsx)(t.code,{children:"tools/widgets/BigWidget/BigWidget.umd.min.js"}),". Similarly it looks for HELLOWORLD at ",(0,o.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,o.jsx)(t.h3,{id:"helloworld-widget",children:"Helloworld Widget"}),"\n",(0,o.jsxs)(t.p,{children:["The Helloworld Widget source code is found in the plugin's src directory and is called ",(0,o.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,o.jsx)(t.pre,{children:(0,o.jsx)(t.code,{className:"language-vue",children:'\n \x3c!-- Implement widget here --\x3e\n\n\n