{"id":229,"date":"2020-04-10T03:46:21","date_gmt":"2020-04-10T03:46:21","guid":{"rendered":"https:\/\/docs.theironnetwork.org\/hulk\/?page_id=229"},"modified":"2020-04-13T11:45:05","modified_gmt":"2020-04-13T11:45:05","slug":"adding-widgets","status":"publish","type":"page","link":"https:\/\/docs.theironnetwork.org\/hulk\/adding-widgets\/","title":{"rendered":"Adding Widgets"},"content":{"rendered":"\n<h5> Adding a new widget <\/h5>\n\n\n\n<p> Please follow the given steps to add a new widget in the template. We  are taking an example of adding a \u201cNew Widget\u201d on the \u201cDashboard\u201d but you can add any widget on any of the dashboard in the  template: <\/p>\n\n\n\n<p><strong>Step 1:<\/strong> Please create a new widget file(of extension .js) in the folder <code>src-&gt;components-&gt;Widgets<\/code>. We have created a file named <code>NewWidget.js<\/code> in the same folder. <\/p>\n\n\n\n<p><strong>Step 2: <\/strong>Now add the code in the widget file as per your requirements. For Example we have added the simple text block in the  widget file as given in the code snippet below: <\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">  \/*\n* new widget\n *\/\nimport React, { Component } from 'react';\n \nexport default class NewWidget extends Component {\n   render() {\n      return (\n         &lt;div className=\"new-widget\">\n            &lt;div className=\"bg-primary p-50 mb-30\">\n               &lt;h2 className=\"text-light\">{'This is a new widget'}&lt;\/h2>\n            &lt;\/div>\n        &lt;\/div>\n      )\n   }\n}; <\/pre>\n\n\n\n<p><strong>Step 3:<\/strong> Open<code>src->routes->dashboard->dashboard1->index.js<\/code> file and add the <code>NewWidget<\/code> in the <code>paper<\/code>section <code>                &lt;Paper className={classes.Paper} square><\/code> as given in the code and also import the <code>NewWidget<\/code> at the top like other import statements already imported. <\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"> import React, { Component } from 'react';\n import { withStyles } from '@material-ui\/styles';\n import { Paper, Box, Container, Typography } from '@material-ui\/core';\n import IntlMessages from 'util\/IntlMessages';\n import { withTheme } from '@material-ui\/core\/styles';\n import NewWidgets from 'components\/Widgets\/NewWidgets'\n const styles = theme => ({\n     Paper: {\n         padding: '0.75rem',\n         backgroundColor: 'transparent',\n         boxShadow: 'none',\n         '&amp;:first-child': {\n             paddingTop: '24px',\n         },\n         '&amp;:last-child': {\n             paddingBottom: '30px',\n         }\n     }\n });\n class Dashboard1 extends Component {\n     state = {\n         ratings: [\n             { value: 885, name: 'Positive (93.4%)', itemStyle: { color: this.props.theme.palette.primary.main } },\n             { value: 215, name: 'Negative (6.6%)', itemStyle: { color: this.props.theme.palette.warning.main } }\n         ]\n     }\n UNSAFE_componentWillReceiveProps(newProps){\n         let newRatings = this.state.ratings;\n         for(let i = 0; i&lt; newRatings.length; i++){\n             if(i === 0){\n                 newRatings[i].itemStyle.color = newProps.theme.palette.primary.main;\n             } else {\n                 newRatings[i].itemStyle.color = newProps.theme.palette.warning.main;                \n             }\n         }\n         this.setState({ratings : newRatings})\n     }\n\n     render(){\n       const { classes } = this.props;\n       return(\n         &lt;div className=\"webanalytics-dashboard\">\n            &lt;Container maxWidth=\"lg\">\n               &lt;Box px={2} pt={4} pb={3}>\n                  &lt;Typography variant=\"h3\"> \n                     &lt;IntlMessages id=\"widgets.welcome\" \/> \n                  &lt;\/Typography>\n                  &lt;Typography variant=\"body2\" color=\"textSecondary\">\n                     Explore your own powerful admin panel and keep track of all activity of &lt;span className=\"hl-text\">&lt;IntlMessages id=\"widgets.quickStats\" \/> &lt;\/span> \n                   &lt;\/Typography>\n                   &lt;Paper className={classes.Paper} square>\n                      &lt;NewWidgets \/>\n                   &lt;\/Paper>\n               &lt;\/Box>\n            &lt;\/Container>\n         &lt;\/div>\n       );\n    }        \n  )\n}\nexport default withStyles(styles)(withTheme(Dashboard1)); <\/pre>\n\n\n\n<p> Now save the file and open the browser, you will see your newly added widget on your dashboard like below screenshot: <\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"1024\" height=\"484\" src=\"https:\/\/docs.theironnetwork.org\/hulk\/wp-content\/uploads\/sites\/13\/2020\/04\/Hulk-Reactjs-Redux-Material-Design-Admin-Template-1024x484.png\" alt=\"\" class=\"wp-image-356\" srcset=\"https:\/\/docs.theironnetwork.org\/hulk\/wp-content\/uploads\/sites\/13\/2020\/04\/Hulk-Reactjs-Redux-Material-Design-Admin-Template-1024x484.png 1024w, https:\/\/docs.theironnetwork.org\/hulk\/wp-content\/uploads\/sites\/13\/2020\/04\/Hulk-Reactjs-Redux-Material-Design-Admin-Template-300x142.png 300w, https:\/\/docs.theironnetwork.org\/hulk\/wp-content\/uploads\/sites\/13\/2020\/04\/Hulk-Reactjs-Redux-Material-Design-Admin-Template-768x363.png 768w, https:\/\/docs.theironnetwork.org\/hulk\/wp-content\/uploads\/sites\/13\/2020\/04\/Hulk-Reactjs-Redux-Material-Design-Admin-Template.png 1349w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h5> Adding an existing widget <\/h5>\n\n\n\n<p> Please follow the given steps to add an existing widget in the template.  We are taking an example of adding a \u201cTask List\u201d on the \u201cDashboard1\u201d but you can add any widget on any of the dashboard in the  template: <\/p>\n\n\n\n<p><strong>Step 1: <\/strong>Open<code>src->routes->dashboard->dashboard1->index.js<\/code> file and add the <code>TaskList<\/code> in the <code>paper<\/code>section  <code>&lt;Paper className={classes.Paper} square><\/code>  as given in the code and also import the <code>TaskList<\/code>at the top like other import statements already imported. <\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">import React, { Component } from 'react';\n import { withStyles } from '@material-ui\/styles';\n import { Paper, Box, Container, Typography } from '@material-ui\/core';\n import IntlMessages from 'util\/IntlMessages';\n import { withTheme } from '@material-ui\/core\/styles';\n import TaskList from 'components\/Widgets\/TaskList'\n const styles = theme => ({\n     Paper: {\n         padding: '0.75rem',\n         backgroundColor: 'transparent',\n         boxShadow: 'none',\n         '&amp;:first-child': {\n             paddingTop: '24px',\n         },\n         '&amp;:last-child': {\n             paddingBottom: '30px',\n         }\n     }\n });\n class Dashboard1 extends Component {\n     state = {\n         ratings: [\n             { value: 885, name: 'Positive (93.4%)', itemStyle: { color: this.props.theme.palette.primary.main } },\n             { value: 215, name: 'Negative (6.6%)', itemStyle: { color: this.props.theme.palette.warning.main } }\n         ]\n     }\n UNSAFE_componentWillReceiveProps(newProps){\n         let newRatings = this.state.ratings;\n         for(let i = 0; i&lt; newRatings.length; i++){\n             if(i === 0){\n                 newRatings[i].itemStyle.color = newProps.theme.palette.primary.main;\n             } else {\n                 newRatings[i].itemStyle.color = newProps.theme.palette.warning.main;                \n             }\n         }\n         this.setState({ratings : newRatings})\n     }\n\n     render(){\n       const { classes } = this.props;\n       return(\n         &lt;div className=\"webanalytics-dashboard\">\n            &lt;Container maxWidth=\"lg\">\n               &lt;Box px={2} pt={4} pb={3}>\n                  &lt;Typography variant=\"h3\"> \n                     &lt;IntlMessages id=\"widgets.welcome\" \/> \n                  &lt;\/Typography>\n                  &lt;Typography variant=\"body2\" color=\"textSecondary\">\n                     Explore your own powerful admin panel and keep track of all activity of &lt;span className=\"hl-text\">&lt;IntlMessages id=\"widgets.quickStats\" \/> &lt;\/span> \n                   &lt;\/Typography>\n                   &lt;Paper className={classes.Paper} square>\n                      &lt;TaskList \/>\n                   &lt;\/Paper>\n               &lt;\/Box>\n            &lt;\/Container>\n         &lt;\/div>\n       );\n    }        \n  )\n}\nexport default withStyles(styles)(withTheme(Dashboard1));<\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"1024\" height=\"484\" src=\"https:\/\/docs.theironnetwork.org\/hulk\/wp-content\/uploads\/sites\/13\/2020\/04\/Hulk-Reactjs-Redux-Material-Design-Admin-Template1-1-1024x484.png\" alt=\"\" class=\"wp-image-371\" srcset=\"https:\/\/docs.theironnetwork.org\/hulk\/wp-content\/uploads\/sites\/13\/2020\/04\/Hulk-Reactjs-Redux-Material-Design-Admin-Template1-1-1024x484.png 1024w, https:\/\/docs.theironnetwork.org\/hulk\/wp-content\/uploads\/sites\/13\/2020\/04\/Hulk-Reactjs-Redux-Material-Design-Admin-Template1-1-300x142.png 300w, https:\/\/docs.theironnetwork.org\/hulk\/wp-content\/uploads\/sites\/13\/2020\/04\/Hulk-Reactjs-Redux-Material-Design-Admin-Template1-1-768x363.png 768w, https:\/\/docs.theironnetwork.org\/hulk\/wp-content\/uploads\/sites\/13\/2020\/04\/Hulk-Reactjs-Redux-Material-Design-Admin-Template1-1.png 1349w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><figcaption> Added Task List on Dashboard 1<\/figcaption><\/figure>\n\n\n\n<blockquote class=\"wp-block-quote\"><p> It does not matters whether you are using the seed project or the complete template, the steps remains the same for both.  <\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>Adding a new widget Please follow the given steps to add a new widget in the template. We are taking an example of adding a \u201cNew Widget\u201d on the \u201cDashboard\u201d but you can add any widget on any of the dashboard in the template: Step 1: Please create a new widget file(of extension .js) in [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":2,"comment_status":"closed","ping_status":"closed","template":"","meta":[],"_links":{"self":[{"href":"https:\/\/docs.theironnetwork.org\/hulk\/wp-json\/wp\/v2\/pages\/229"}],"collection":[{"href":"https:\/\/docs.theironnetwork.org\/hulk\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/docs.theironnetwork.org\/hulk\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/docs.theironnetwork.org\/hulk\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.theironnetwork.org\/hulk\/wp-json\/wp\/v2\/comments?post=229"}],"version-history":[{"count":27,"href":"https:\/\/docs.theironnetwork.org\/hulk\/wp-json\/wp\/v2\/pages\/229\/revisions"}],"predecessor-version":[{"id":386,"href":"https:\/\/docs.theironnetwork.org\/hulk\/wp-json\/wp\/v2\/pages\/229\/revisions\/386"}],"wp:attachment":[{"href":"https:\/\/docs.theironnetwork.org\/hulk\/wp-json\/wp\/v2\/media?parent=229"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}