Skip to content

Commit

Permalink
Intial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
GermanBluefox committed Jan 21, 2025
0 parents commit 855e475
Show file tree
Hide file tree
Showing 31 changed files with 62,803 additions and 0 deletions.
16 changes: 16 additions & 0 deletions .github/auto-merge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Configure here which dependency updates should be merged automatically.
# The recommended configuration is the following:
- match:
# Only merge patches for production dependencies
dependency_type: production
update_type: 'semver:patch'
- match:
# Except for security fixes, here we allow minor patches
dependency_type: production
update_type: 'security:minor'
- match:
# and development dependencies can have a minor update, too
dependency_type: development
update_type: 'semver:minor'
# The syntax is based on the legacy dependabot v1 automerged_updates syntax, see:
# https://dependabot.com/docs/config-file/#automerged_updates
18 changes: 18 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
version: 2
updates:
# Maintain dependencies for GitHub Actions
- package-ecosystem: github-actions
directory: '/'
schedule:
interval: monthly
time: '04:00'
timezone: Europe/Berlin

- package-ecosystem: npm
directory: '/'
schedule:
interval: monthly
time: '04:00'
timezone: Europe/Berlin
open-pull-requests-limit: 5
versioning-strategy: increase
78 changes: 78 additions & 0 deletions .github/stale.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# Configuration for probot-stale - https://github.com/probot/stale

# Number of days of inactivity before an Issue or Pull Request becomes stale
daysUntilStale: 90

# Number of days of inactivity before an Issue or Pull Request with the stale label is closed.
# Set to false to disable. If disabled, issues still need to be closed manually, but will remain marked as stale.
daysUntilClose: 7

# Only issues or pull requests with all of these labels are check if stale. Defaults to `[]` (disabled)
onlyLabels: []

# Issues or Pull Requests with these labels will never be considered stale. Set to `[]` to disable
exemptLabels:
- enhancement
- security
- bug

# Set to true to ignore issues in a project (defaults to false)
exemptProjects: true

# Set to true to ignore issues in a milestone (defaults to false)
exemptMilestones: true

# Set to true to ignore issues with an assignee (defaults to false)
exemptAssignees: false

# Label to use when marking as stale
staleLabel: wontfix

# Comment to post when marking as stale. Set to `false` to disable
markComment: >
This issue has been automatically marked as stale because it has not had
recent activity. It will be closed if no further activity occurs within the next 7 days.
Please check if the issue is still relevant in the most current version of the adapter
and tell us. Also check that all relevant details, logs and reproduction steps
are included and update them if needed.
Thank you for your contributions.
Dieses Problem wurde automatisch als veraltet markiert, da es in letzter Zeit keine Aktivitäten gab.
Es wird geschlossen, wenn nicht innerhalb der nächsten 7 Tage weitere Aktivitäten stattfinden.
Bitte überprüft, ob das Problem auch in der aktuellsten Version des Adapters noch relevant ist,
und teilt uns dies mit. Überprüft auch, ob alle relevanten Details, Logs und Reproduktionsschritte
enthalten sind bzw. aktualisiert diese.
Vielen Dank für Eure Unterstützung.
# Comment to post when removing the stale label.
# unmarkComment: >
# Your comment here.

# Comment to post when closing a stale Issue or Pull Request.
closeComment: >
This issue has been automatically closed because of inactivity. Please open a new
issue if still relevant and make sure to include all relevant details, logs and
reproduction steps.
Thank you for your contributions.
Dieses Problem wurde aufgrund von Inaktivität automatisch geschlossen. Bitte öffnet ein
neues Issue, falls dies noch relevant ist und stellt sicher das alle relevanten Details,
Logs und Reproduktionsschritte enthalten sind.
Vielen Dank für Eure Unterstützung.
# Limit the number of actions per hour, from 1-30. Default is 30
limitPerRun: 30

# Limit to only `issues` or `pulls`
only: issues
# Optionally, specify configuration settings that are specific to just 'issues' or 'pulls':
# pulls:
# daysUntilStale: 30
# markComment: >
# This pull request has been automatically marked as stale because it has not had
# recent activity. It will be closed if no further activity occurs. Thank you
# for your contributions.

# issues:
# exemptLabels:
# - confirmed
22 changes: 22 additions & 0 deletions .github/workflows/dependabot-automerge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Automatically merge Dependabot PRs when version comparison is within the range
# that is configured in .github/auto-merge.yml

name: Auto-Merge Dependabot PRs

on:
pull_request_target:

jobs:
auto-merge:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Check if PR should be auto-merged
uses: ahmadnassri/action-dependabot-auto-merge@v2
with:
# This must be a personal access token with push access
github-token: ${{ secrets.AUTO_MERGE_TOKEN }}
# By default, squash and merge, so Github chooses nice commit messages
command: squash and merge
90 changes: 90 additions & 0 deletions .github/workflows/test-and-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# This is a composition of lint and test scripts
# Make sure to update this file along with the others

name: Test and Release

# Run this job on all pushes and pull requests
# as well as tags with a semantic version
on:
push:
branches:
- main
tags:
# normal versions
- 'v?[0-9]+.[0-9]+.[0-9]+'
# pre-releases
- 'v?[0-9]+.[0-9]+.[0-9]+-**'
pull_request: {}

# Cancel previous PR/branch runs when a new commit is pushed
concurrency:
group: ${{ github.ref }}
cancel-in-progress: true

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- run: npm i --force
- run: NODE_OPTIONS=--max_old_space_size=4096 npm run build

# Deploys the final package to NPM
deploy:
needs: [build]

# Trigger this step only when a commit on master is tagged with a version number
if: |
contains(github.event.head_commit.message, '[skip ci]') == false &&
github.event_name == 'push' &&
startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Use Node.js 20.x
uses: actions/setup-node@v4
with:
node-version: 20.x

- name: Extract the version and commit body from the tag
id: extract_release
# The body may be multiline, therefore we need to escape some characters
run: |
VERSION="${{ github.ref }}"
VERSION=${VERSION##*/}
VERSION=${VERSION##*v}
echo "::set-output name=VERSION::$VERSION"
BODY=$(git show -s --format=%b)
BODY="${BODY//'%'/'%25'}"
BODY="${BODY//$'\n'/'%0A'}"
BODY="${BODY//$'\r'/'%0D'}"
echo "::set-output name=BODY::$BODY"
- name: Install Dependencies
run: npm install --force

- name: Build
run: npm run build

- name: Publish package to npm
run: |
npm config set //registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}
npm whoami
npm publish
- name: Create Github Release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release v${{ steps.extract_release.outputs.VERSION }}
draft: false
# Prerelease versions create pre-releases on GitHub
prerelease: ${{ contains(steps.extract_release.outputs.VERSION, '-') }}
body: ${{ steps.extract_release.outputs.BODY }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/node_modules
/.idea
6 changes: 6 additions & 0 deletions .releaseconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"plugins": ["license"],
"exec": {
"before_commit": "npm run build"
}
}
22 changes: 22 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
The MIT License (MIT)

Copyright (c) 2025 Denis Haev <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

98 changes: 98 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# Web component to select objects from ioBroker (admin or web)

Before dialog creation, the socket file must be loaded. You can find the code [here](https://github.com/ioBroker/ioBroker.ws.client/tree/main/dist/esm).

But it is always better to load the client part from the ioBroker server.
```html
<script src="http://iobrokerIP:8081/lib/js/socket.io.js"></script>
<!-- or for web server -->
<script src="http://iobrokerIP:8082/lib/js/socket.io.js"></script>

<!-- Load SelectID web component -->
<script src="./iobrokerSelectId.umd.js"></script>
```

In this scenario, you can ensure that the loaded version is compatible with the backend.
For example, the ioBroker web server might use socket.io or a pure web socket connection.
Therefore, you must ensure that the correct client library is loaded.

How to use with Dynamic creation:
```js
function openSelectIdIdalog(selected) {
window._iobOnSelected = function (newId, newObj, oldId, oldObj) {
let selectDialog = document.getElementById('iob-select-id');
if (selectDialog) {
selectDialog.setAttribute('open', 'false');
}

console.log('Selected ' + newId);
};

if (!window._iobSelectDialog) {
window._iobSelectDialog = document.createElement('iobroker-select-id');
window._iobSelectDialog.setAttribute('id', 'iob-select-id');
// Place here the real port of ioBroker admin or web instance
window._iobSelectDialog.setAttribute('port', window.location.port);
// Place here the real port of ioBroker admin or web instance
window._iobSelectDialog.setAttribute('host', window.location.host);
// Place here the real protocol http: or https:
window._iobSelectDialog.setAttribute('protocol', window.location.protocol);
window._iobSelectDialog.setAttribute('language', 'en');
// This is a name of a global function
window._iobSelectDialog.setAttribute('onclose', '_iobOnSelected');
window._iobSelectDialog.setAttribute('all', 'true');
window._iobSelectDialog.setAttribute('selected', selected);
window._iobSelectDialog.setAttribute('open', 'true');
document.body.appendChild(window._iobSelectDialog);
} else {
window._iobSelectDialog.setAttribute('all', allowAll ? 'true' : 'false');
window._iobSelectDialog.setAttribute('selected', $('#node-input-topic').val());
window._iobSelectDialog.setAttribute('open', 'true');
}
}
openSelectIdIdalog();
```

Or static:
```html
<iobroker-select-id
port="8081"
host="localhost"
protocol="http:"
language="en"
onclose="_iobOnSelected"
all="true"
selected="system.adapter.admin.0"
open="true"
></iobroker-select-id>
```

## Changelog
<!--
### **WORK IN PROGRESS**
-->
### **WORK IN PROGRESS**
- (@GermanBluefox) Initial commit

## License
The MIT License (MIT)

Copyright (c) 2025 Denis Haev <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Loading

0 comments on commit 855e475

Please sign in to comment.