Skip to content

Commit

Permalink
Merge pull request #1317 from totaldebug/beta
Browse files Browse the repository at this point in the history
Release
  • Loading branch information
marksie1988 authored Dec 6, 2023
2 parents 2c01273 + 0b96a12 commit 9aee788
Show file tree
Hide file tree
Showing 14 changed files with 905 additions and 947 deletions.
2 changes: 2 additions & 0 deletions .devcontainer/post-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ yarn install
pip3 install -r docs/requirements.txt
pip3 install sphinx-autobuild pre-commit

export PATH="${PATH}:/home/debug/.local/bin"

pre-commit install --hook-type commit-msg

echo "Done!"
119 changes: 60 additions & 59 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,61 +1,62 @@
module.exports = {
parser: '@typescript-eslint/parser', // Specifies the ESLint parser
//extends: [
// 'prettier', // Uses eslint-config-prettier to disable ESLint rules from @typescript-eslint/eslint-plugin that would conflict with prettier
// 'plugin:prettier/recommended', // Enables eslint-plugin-prettier and displays prettier errors as ESLint errors. Make sure this is always the last configuration in the extends array.
//],
parserOptions: {
ecmaVersion: 2018, // Allows for the parsing of modern ECMAScript features
sourceType: 'module', // Allows for the use of imports
experimentalDecorators: true,
},
plugins: ['@typescript-eslint', 'prettier'],
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:prettier/recommended',
'plugin:import/recommended',
'plugin:import/typescript',
],
rules: {
"@typescript-eslint/camelcase": 0,
'import/no-unresolved': 'error',
'import/order': [
'error',
{
groups: [
'builtin', // Built-in imports (come from NodeJS native) go first
'external', // <- External imports
'internal', // <- Absolute imports
['sibling', 'parent'], // <- Relative imports, the sibling and parent types they can be mingled together
'index', // <- index imports
'unknown', // <- unknown
],
'newlines-between': 'always',
alphabetize: {
/* sort in ascending order. Options: ["ignore", "asc", "desc"] */
order: 'asc',
/* ignore case. Options: [true, false] */
caseInsensitive: true,
},
},
],
'sort-imports': [
'error',
{
ignoreCase: false,
ignoreDeclarationSort: true, // don"t want to sort import lines, use eslint-plugin-import instead
ignoreMemberSort: false,
memberSyntaxSortOrder: ['none', 'all', 'multiple', 'single'],
allowSeparatedGroups: true,
},
]
},
settings: {
'import/resolver': {
typescript: {
project: './tsconfig.json',
},
},
},
parser: '@typescript-eslint/parser', // Specifies the ESLint parser
//extends: [
// 'prettier', // Uses eslint-config-prettier to disable ESLint rules from @typescript-eslint/eslint-plugin that would conflict with prettier
// 'plugin:prettier/recommended', // Enables eslint-plugin-prettier and displays prettier errors as ESLint errors. Make sure this is always the last configuration in the extends array.
//],
parserOptions: {
ecmaVersion: 2018, // Allows for the parsing of modern ECMAScript features
sourceType: 'module', // Allows for the use of imports
experimentalDecorators: true,
},
plugins: ['@typescript-eslint', 'prettier'],
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:prettier/recommended',
'plugin:import/recommended',
'plugin:import/typescript',
],
rules: {
'@typescript-eslint/camelcase': 0,
'import/no-unresolved': 'error',
'import/order': [
'error',
{
groups: [
'builtin', // Built-in imports (come from NodeJS native) go first
'external', // <- External imports
'internal', // <- Absolute imports
['sibling', 'parent'], // <- Relative imports, the sibling and parent types they can be mingled together
'index', // <- index imports
'unknown', // <- unknown
],
'newlines-between': 'always',
alphabetize: {
/* sort in ascending order. Options: ["ignore", "asc", "desc"] */
order: 'asc',
/* ignore case. Options: [true, false] */
caseInsensitive: true,
},
},
],
'@typescript-eslint/no-explicit-any': 'off',
'sort-imports': [
'error',
{
ignoreCase: false,
ignoreDeclarationSort: true, // don"t want to sort import lines, use eslint-plugin-import instead
ignoreMemberSort: false,
memberSyntaxSortOrder: ['none', 'all', 'multiple', 'single'],
allowSeparatedGroups: true,
},
],
},
settings: {
'import/resolver': {
typescript: {
project: './tsconfig.json',
},
},
},
};
26 changes: 12 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "atomic-calendar-revive",
"version": "9.2.0",
"version": "9.2.1-beta.1",
"description": "Calendar Card for Home Assistant",
"main": "atomic-calendar-revive.js",
"scripts": {
Expand All @@ -24,11 +24,11 @@
"license": "ISC",
"devDependencies": {
"@babel/cli": "^7.23.0",
"@babel/core": "^7.23.2",
"@babel/core": "^7.23.3",
"@babel/plugin-proposal-class-properties": "^7.18.6",
"@babel/plugin-proposal-decorators": "^7.23.2",
"@babel/plugin-transform-template-literals": "^7.22.5",
"@babel/preset-env": "^7.23.2",
"@babel/plugin-proposal-decorators": "^7.23.3",
"@babel/plugin-transform-template-literals": "^7.23.3",
"@babel/preset-env": "^7.23.3",
"@rollup/plugin-babel": "^6.0.4",
"@rollup/plugin-commonjs": "^25.0.7",
"@rollup/plugin-eslint": "^9.0.5",
Expand All @@ -38,25 +38,25 @@
"@semantic-release/changelog": "^6.0.3",
"@semantic-release/exec": "^6.0.3",
"@semantic-release/git": "^10.0.1",
"@typescript-eslint/eslint-plugin": "^6.9.1",
"@typescript-eslint/parser": "^6.9.1",
"@typescript-eslint/eslint-plugin": "^6.11.0",
"@typescript-eslint/parser": "^6.11.0",
"babel-preset-minify": "^0.5.2",
"commitizen": "^4.3.0",
"conventional-changelog-conventionalcommits": "^7.0.2",
"cz-conventional-changelog": "^3.3.0",
"eslint": "^8.52.0",
"eslint": "^8.53.0",
"eslint-config-prettier": "^9.0.0",
"eslint-import-resolver-typescript": "^3.6.1",
"eslint-plugin-import": "^2.29.0",
"eslint-plugin-prettier": "^5.0.1",
"prettier": "^3.0.3",
"rollup": "^4.3.0",
"prettier": "^3.1.0",
"rollup": "^4.4.0",
"rollup-plugin-serve": "^2.0.2",
"rollup-plugin-typescript2": "^0.36.0",
"semantic-release": "^22.0.7"
},
"dependencies": {
"@formatjs/icu-messageformat-parser": "^2.7.0",
"@formatjs/icu-messageformat-parser": "^2.7.2",
"@lit-labs/scoped-registry-mixin": "^1.0.3",
"@lit/reactive-element": "^2.0.1",
"@material/mwc-formfield": "^0.27.0",
Expand All @@ -74,13 +74,11 @@
"custom-card-helpers": "^1.9.0",
"dayjs": "^1.11.10",
"lit": "^3.0.2",
"lit-element": "^4.0.0",
"npm": "^10.2.3",
"typescript": "^5.2.2"
},
"resolutions": {
"lit": "^2.2.6",
"lit-element": "^3.2.0",
"lit": "^3.0.2",
"@lit/reactive-element": "2.0.1"
},
"bugs": {
Expand Down
52 changes: 22 additions & 30 deletions rollup.config.mjs
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import typescript from 'rollup-plugin-typescript2';
import commonjs from '@rollup/plugin-commonjs';
import { nodeResolve } from '@rollup/plugin-node-resolve';
import babel from '@rollup/plugin-babel';
import terser from "@rollup/plugin-terser";
import json from '@rollup/plugin-json';
import commonjs from '@rollup/plugin-commonjs';
import eslint from '@rollup/plugin-eslint';
import ignore from './rollup-plugins/ignore';
import { ignoreTextfieldFiles } from './elements/ignore/textfield';
import { ignoreSwitchFiles } from './elements/ignore/switch';
import json from '@rollup/plugin-json';
import { nodeResolve } from '@rollup/plugin-node-resolve';
import terser from '@rollup/plugin-terser';
import typescript from 'rollup-plugin-typescript2';

import { ignoreSelectFiles } from './elements/ignore/select';
import { ignoreSwitchFiles } from './elements/ignore/switch';
import { ignoreTextfieldFiles } from './elements/ignore/textfield';
import ignore from './rollup-plugins/ignore';

const plugins = [
nodeResolve({
Expand All @@ -23,40 +24,31 @@ const plugins = [
exclude: 'node_modules/**',
babelHelpers: 'bundled',
compact: true,
extensions: [
'.js',
'.ts',
],
extensions: ['.js', '.ts'],
presets: [
[
'@babel/env',
{
"modules": false,
"targets": "> 2.5%, not dead"
}
modules: false,
targets: '> 2.5%, not dead',
},
],
],
plugins: [
[
"@babel/plugin-proposal-decorators",
'@babel/plugin-proposal-decorators',
{
"legacy": true
}
legacy: true,
},
],
[
"@babel/plugin-proposal-class-properties"
],
[
"@babel/plugin-transform-template-literals"
]
]
['@babel/plugin-proposal-class-properties'],
['@babel/plugin-transform-template-literals'],
],
}),
terser(),
ignore(
{
files: [...ignoreTextfieldFiles, ...ignoreSwitchFiles, ...ignoreSelectFiles].map((file) => require.resolve(file)),
}
),
ignore({
files: [...ignoreTextfieldFiles, ...ignoreSwitchFiles, ...ignoreSelectFiles].map((file) => require.resolve(file)),
}),
];

export default {
Expand Down
3 changes: 1 addition & 2 deletions src/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ export class AtomicCalendarReviveEditor extends ScopedRegistryHost(LitElement) i
`;
}


private renderNumberProperty(property: NumberProperty): TemplateResult {
return html`
<br />
Expand Down Expand Up @@ -650,7 +649,7 @@ export class AtomicCalendarReviveEditor extends ScopedRegistryHost(LitElement) i
get _entityOptions() {
const entities = Object.keys(this.hass.states).filter((eid) => eid.substr(0, eid.indexOf('.')) === 'calendar');
let entityOptions;
if (typeof this._config?.entities != 'undefined' || typeof this._config?.entities != null) {
if (this._config?.entities != 'undefined' || this._config?.entities != 'null') {
entityOptions = entities.map((eid) => {
let matchingConfigEnitity = this._config?.entities.find(
(entity) => ((entity && entity.entity) || entity) === eid,
Expand Down
28 changes: 13 additions & 15 deletions src/functions/sort_events.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import dayjs from 'dayjs';

import EventClass from '../lib/event.class';

// Function to sort events
Expand Down Expand Up @@ -28,28 +29,27 @@ export default function sortEvents(events, config) {
}
});

// Sort all-day events by entity and title
const allDayEvents = events.filter((event) => event.isAllDay);

allDayEvents.sort((a, b) => {
if (a.entity !== b.entity) {
return a.entity.localeCompare(b.entity);
} else {
return a.title.localeCompare(b.title);
}
});

// Combine sorted all-day and non-all-day events
const sortedEvents = [...events];

// Create an array to store the all day events.
const allDayEventsArray: EventClass[] = [];

// Iterate over the sorted events array and move all of the all day events to the allDayEvents array.
sortedEvents.forEach((event: EventClass, index) => {
for (let i = sortedEvents.length - 1; i >= 0; i--) {
const event = sortedEvents[i];
if (event.isAllDayEvent) {
allDayEventsArray.push(event);
sortedEvents.splice(index, 1);
sortedEvents.splice(i, 1);
}
}

// Sort the all day events.
allDayEventsArray.sort((a, b) => {
if (a.entity !== b.entity) {
return a.entity.entity_id.localeCompare(b.entity);
} else {
return a.title.localeCompare(b.title);
}
});

Expand All @@ -63,7 +63,6 @@ export default function sortEvents(events, config) {
sortedEvents.unshift(...allDayEventsArray);
}


if (config.sortBy === 'milestone') {
// Move finished events to the bottom when sorting by milestone
sortedEvents.sort((a, b) => {
Expand All @@ -73,6 +72,5 @@ export default function sortEvents(events, config) {
return 0;
});
}
console.log(sortedEvents);
return sortedEvents;
}
12 changes: 8 additions & 4 deletions src/helpers/get-icon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@ import EventClass from '../lib/event.class';
import { atomicCardConfig } from '../types/config';

// Function to get the icon for a specific entity
export function getEntityIcon(entityId: string, hass: HomeAssistant): string {
export function getEntityIcon(entityId: string, hass: HomeAssistant): string | null {
const stateObj = hass.states[entityId];

if (entityId === undefined) {
return null;
}

if (stateObj) {
return stateObj.attributes.icon || 'mdi:circle';
} else {
Expand All @@ -32,9 +36,9 @@ export function getEventIcon(config: atomicCardConfig, event: EventClass, hass:
icon = getEntityIcon(event.entityConfig.entity, hass);
}

if (config.showEventIcon) {
return html`<ha-icon class="event-icon" style="color: ${iconColor};" icon="${icon}"></ha-icon>`;
} else {
if (!config.showEventIcon || icon === null) {
return html``; // Return an empty HTML element if config.showEventIcon is false
} else {
return html`<ha-icon class="event-icon" style="color: ${iconColor};" icon="${icon}"></ha-icon>`;
}
}
Loading

0 comments on commit 9aee788

Please sign in to comment.