Skip to content

Commit

Permalink
feat(sidebar): Add Home Assistant sidebar
Browse files Browse the repository at this point in the history
  • Loading branch information
zachowj committed Dec 12, 2023
1 parent a36b08a commit 2da26cb
Show file tree
Hide file tree
Showing 18 changed files with 6,883 additions and 4 deletions.
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ ui/css/lib/
ui/js/lib/
docs/.vuepress/.temp
docs/.vuepress/.cache
resources/handlebars.min-v4.7.8.js
18 changes: 15 additions & 3 deletions docs/guide/diagnostics.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,21 @@

## Overview

In order to assist with troubleshooting, the supplied diagnostics flow serves as a valuable tool for collecting data about the runtime and the system environment. This flow can be [imported](https://nodered.org/docs/user-guide/editor/workspace/import-export) into Node-RED and ran. By doing so, it compiles crucial information regarding the runtime and the system environment, enabling users to easily share this data when addressing issues.
To assist with troubleshooting, a button has been added to the Node-RED editor that will run a diagnostics flow and copy the output to the clipboard. This output can then be pasted into a GitHub issue or a support forum.

## Flow
::: tip Note
Before version 0.62.0, the diagnostics flow was a separate flow that had to be imported into Node-RED. This flow is still available and can be found [here](#before-version-0-62-0).
:::

![screenshot of buton location](./images/diagnostics_04.png)

![gif for finding button](./images/diagnostics_05.gif)

## Before version 0.62.0

The supplied diagnostics flow serves as a valuable tool for collecting data about the runtime and the system environment. This flow can be [imported](https://nodered.org/docs/user-guide/editor/workspace/import-export) into Node-RED and run. By doing so, it compiles crucial information regarding the runtime and the system environment, enabling users to easily share this data when addressing issues.

### Flow

![screenshot](./images/diagnostics_01.png)

Expand All @@ -14,7 +26,7 @@ This flow can also be imported directly from the examples section in Node-RED.

- [How to import a flow](https://nodered.org/docs/user-guide/editor/workspace/import-export)

## Usage
### Usage

1. Import the flow into Node-RED.

Expand Down
Binary file added docs/guide/images/diagnostics_04.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/guide/images/diagnostics_05.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
69 changes: 68 additions & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,14 @@ const uiFormWrap =
'<script type="text/html" data-template-name="<%= data.type %>"><%= data.contents %></script>';
const uiHelpWrap =
'<script type="text/html" data-help-name="<%= data.type %>"><%= data.contents %></script>';
const uiHandlebarsWrap =
'<script type="text/html" id="handlebars-<%= data.id %>" data-template-name="<%= data.type %>"><%= data.contents %></script>';
const resourcePath = 'resources/node-red-contrib-home-assistant-websocket';
const resourceFiles = [
`<script src="${resourcePath}/select2.full.min.js?v=4.1.0-rc.0"></script>`,
`<link rel="stylesheet" href="${resourcePath}/select2.min.css?v=4.1.0-rc.0">`,
`<script src="${resourcePath}/maximize-select2-height.min.js?v=1.0.4"></script>`,
`<script src="${resourcePath}/handlebars.min-v4.7.8.js"></script>`,
];

const nodeMap = {
Expand Down Expand Up @@ -151,6 +154,35 @@ const buildEditor = lazypipe()
)
);

const buildSidebar = lazypipe()
.pipe(gulpHtmlmin, {
collapseWhitespace: true,
minifyCSS: true,
})
.pipe(() => wrap(uiFormWrap, { type: 'ha_sidebar' }, { variable: 'data' }));

const buildSidebarToolbar = lazypipe()
.pipe(gulpHtmlmin, {
collapseWhitespace: true,
minifyCSS: true,
})
.pipe(() =>
wrap(uiFormWrap, { type: 'ha_sidebar_toolbar' }, { variable: 'data' })
);

const buildHandlebars = lazypipe()
.pipe(gulpHtmlmin, {
collapseWhitespace: false,
minifyCSS: true,
})
.pipe(() =>
wrap(
uiHandlebarsWrap,
{ id: currentFilename, type: 'x-tmpl-handlebars' },
{ variable: 'data' }
)
);

// Covert markdown documentation to html and modify it to look more like Node-RED
// help files.
const buildHelp = lazypipe()
Expand Down Expand Up @@ -327,6 +359,33 @@ task('buildEditorFiles', (done) => {
})
);

const sidebarHtml = src(['src/editor/sidebar/index.html']).pipe(
flatmap((stream, file) => {
const [filename] = file.basename.split('.');

currentFilename = filename;
return stream.pipe(buildSidebar());
})
);

const sidebarToolbarHtml = src(['src/editor/sidebar/toolbar.html']).pipe(
flatmap((stream, file) => {
const [filename] = file.basename.split('.');

currentFilename = filename;
return stream.pipe(buildSidebarToolbar());
})
);

const handlebarsTemplates = src(['src/**/*.handlebars']).pipe(
flatmap((stream, file) => {
const [filename] = file.basename.split('.');

currentFilename = filename;
return stream.pipe(buildHandlebars());
})
);

const html = src([
'src/nodes/**/*.html',
`docs/node/*.md`,
Expand All @@ -353,7 +412,15 @@ task('buildEditorFiles', (done) => {
})
);

return merge([css, js, html, editorsHtml])
return merge([
css,
js,
html,
editorsHtml,
sidebarHtml,
sidebarToolbarHtml,
handlebarsTemplates,
])
.pipe(concat('index.html'))
.pipe(header(resourceFiles.join('')))
.pipe(dest(editorFilePath + '/'));
Expand Down
47 changes: 47 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@
"gulp-terser": "2.1.0",
"gulp-typescript": "6.0.0-alpha.1",
"gulp-wrap": "0.15.0",
"handlebars": "^4.7.8",
"husky": "8.0.3",
"jsonata": "1.8.6",
"lazypipe": "1.0.2",
Expand Down
Loading

0 comments on commit 2da26cb

Please sign in to comment.