Skip to content
This repository was archived by the owner on Sep 25, 2021. It is now read-only.

Commit 2face8b

Browse files
committed
dependencies fixed
1 parent 8c07b42 commit 2face8b

12 files changed

Lines changed: 1093 additions & 1188 deletions

.babelrc

100644100755
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@
44
"@babel/preset-env",
55
{
66
"modules": false,
7-
"targets": {
8-
"esmodules": true
9-
}
7+
"targets": "> 2.5%, not dead"
8+
109
}
1110
],
1211
["minify"]

.eslintrc.js

100644100755
File mode changed.

.gitignore

100644100755
File mode changed.

README.md

100644100755
Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# atomic calendar card v0.7.9
1+
# atomic calendar card v0.7.5
22
Advanced calendar card for Home Assistant with Lovelace
33

44
Calendar card with advanced settings. It loads calendar events from Home Assistant - Google calendar component.
@@ -64,11 +64,6 @@ If you have any suggestions about design or functionality, please let me know, o
6464
| dateFormat | string | optional | v0.7.2 | `LL` Custom date format - see https://devhints.io/moment for examples
6565
| hoursFormat | string | optional | v0.7.3 | `default` Custom hours format - you can set `12h` or `24h` or `default` (default for local HA language settings) or even provide your custom, like `HH:mm` or `h:mm A` - see https://devhints.io/moment for examples
6666
| startDaysAhead | integer | optional | v0.7.3 | `0` If you set more than 0, events will be loaded starting `x` days from today. For example `1` - the component will show events starting from tomorrow.
67-
| showHours | boolean | optional | v0.7.6 | `true` Show the time od duration of event (the bottom line)
68-
| showCalNameInEvent | boolean | optional | v0.7.6 | `false` Show calendar name in event title, to distinguish between multiple calendars
69-
| showNoEventsForToday | boolean | optional | v0.7.6 | `false` Show "no events for today" if no events (configurable text)
70-
| noEventsForTodayText | string | optional | v0.7.6 | `No events for today` "no events for today" text, if showNoEventsForToday is enabled
71-
7267

7368
### Text colors and fonts
7469
| Name | Type | Since | Description |
@@ -99,13 +94,6 @@ If you have any suggestions about design or functionality, please let me know, o
9994
| showProgressBar | boolean | optional | v0.5.5 | `true` Show event progress with moving icon. Don't enable when showCurrentEventLine - will look bad
10095
| progressBarColor | string | v0.5.5 | `default color` Color of progress bar
10196

102-
### Entity options (configurations for each calendar)
103-
| Name | Type | Since | Description |
104-
|------|:----:|:-----:|-------------|
105-
| type | string | optional | v0.5.5 | `` Type of calendar (in calendar mode) Icon1, Icon2, Icon3, Birthday. Explained below.
106-
| blacklist | string | v0.7.9 | `` List of comma separated blacklisted keywords. Events containing any of them will not be shown.
107-
108-
10997
## 3. Calendar Mode
11098
The second mode of view - calendar mode - is to show full month calendar with simple events icons or colors, for most important, infrequent events, like holiday or birthday.
11199
You can change mode by clicking "Calendar" title, or even make it default view.
@@ -219,21 +207,19 @@ This card will show maximum 5 events from each calendar. It's because of Home As
219207

220208
1. Go to your Home Assistant config directory (where you have configuration.yaml file)
221209
2. Create a subdirectory `custom_components/google` and go inside:
222-
3. Download files. Important: in Home Assistant 92.0 and above all 4 files are needed! It will be ignored if you have only calendar.py.
223-
![calendar.py](https://raw.githubusercontent.com/home-assistant/home-assistant/master/homeassistant/components/google/calendar.py)
224-
![services.yaml](https://raw.githubusercontent.com/home-assistant/home-assistant/master/homeassistant/components/google/services.yaml)
225-
![manifest.json](https://raw.githubusercontent.com/home-assistant/home-assistant/master/homeassistant/components/google/manifest.json)
210+
3. Download files. Important: in Home Assistant 89.0 and above all 3 files are needed! It will be ignored if you have only calendar.py. ![Google.py](https://raw.githubusercontent.com/home-assistant/home-assistant/master/homeassistant/components/google/calendar.py)
226211
![__init__.py](https://raw.githubusercontent.com/home-assistant/home-assistant/master/homeassistant/components/google/__init__.py)
212+
![tts.py](https://raw.githubusercontent.com/home-assistant/home-assistant/master/homeassistant/components/google/tts.py)
213+
227214

228215
```
229-
mkdir -p custom_components/google
230-
cd custom_components/google
216+
mkdir -p custom_components/calendar
217+
cd custom_components/calendar
231218
wget https://raw.githubusercontent.com/home-assistant/home-assistant/master/homeassistant/components/google/calendar.py
232-
wget https://raw.githubusercontent.com/home-assistant/home-assistant/master/homeassistant/components/google/services.yaml
233-
wget https://raw.githubusercontent.com/home-assistant/home-assistant/master/homeassistant/components/google/manifest.json
234219
wget https://raw.githubusercontent.com/home-assistant/home-assistant/master/homeassistant/components/google/__init__.py
220+
wget https://raw.githubusercontent.com/home-assistant/home-assistant/master/homeassistant/components/google/tts.py
235221
```
236-
4. Open the calendar.py file with text editor and change ``'maxResults': 5,`` to anything you want.
222+
4. Open the Google.py file with text editor and change ``'maxResults': 5,`` to anything you want.
237223
5. Save the file and restart Home Assistant.
238224
239225
## 7. Automatic update

app.js

100644100755
Lines changed: 22 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ class AtomicCalendar extends LitElement {
2222
this.firstrun = true;
2323
}
2424

25-
26-
2725
static get properties() {
2826
return {
2927
hass: Object,
@@ -32,15 +30,10 @@ class AtomicCalendar extends LitElement {
3230
selectedMonth: Object
3331
}
3432
}
35-
36-
37-
3833
updated() {}
3934

4035
render() {
41-
42-
43-
if(this.firstrun){
36+
if(this.firstrun){
4437
let timeFormat = moment.localeData(this.hass.language).longDateFormat('LT')
4538
if (this.config.hoursFormat=='12h') timeFormat = 'h:mm A'
4639
else if (this.config.hoursFormat=='24h') timeFormat = 'H:mm'
@@ -53,11 +46,8 @@ class AtomicCalendar extends LitElement {
5346
LT: timeFormat
5447
}
5548
});
56-
let timeOffset = new Date().getTimezoneOffset()
57-
let start = moment().add(this.config.startDaysAhead, 'days').startOf('day').format('YYYY-MM-DDTHH:mm:ss');
58-
let end = moment().add((this.config.maxDaysToShow + this.config.startDaysAhead), 'days').endOf('day').format('YYYY-MM-DDTHH:mm:ss');
5949
this.firstrun=false
60-
console.log("atomic_calendar v0.7.9 loaded")
50+
console.log("atomic_calendar v0.8.1b loaded")
6151
}
6252

6353

@@ -94,7 +84,7 @@ class AtomicCalendar extends LitElement {
9484
9585
<ha-card class="cal-card">
9686
<div class="cal-titleContainer">
97-
<div class="cal-title" @click='${e => this.handleToggle(e)}'>
87+
<div class="cal-title" @click='${e => this.handleToggle()}'>
9888
${this.config.title}
9989
</div>
10090
@@ -116,19 +106,14 @@ class AtomicCalendar extends LitElement {
116106
</div>
117107
</ha-card>`
118108
}
119-
120-
static get styles() {
121-
122-
}
123109

124110
firstTimeConfig() {
125111

126112

127113
}
128114

129115

130-
131-
handleToggle(e) {
116+
handleToggle() {
132117
if (this.config.enableModeChange) {
133118
this.modeToggle == 1 ? this.modeToggle = 2 : this.modeToggle = 1
134119
this.requestUpdate()
@@ -495,8 +480,7 @@ class AtomicCalendar extends LitElement {
495480
* generate Event Title (summary) HTML
496481
*
497482
*/
498-
getTitleHTML(event, isEventNext) {
499-
483+
getTitleHTML(event) {
500484
const titletext = (this.config.showCalNameInEvent) ? event.eventClass.organizer.displayName+": " + event.title : event.title
501485

502486
const titleColor = (this.config.showColors && typeof event.config.titleColor != 'undefined') ? event.config.titleColor : this.config.titleColor
@@ -623,7 +607,7 @@ class AtomicCalendar extends LitElement {
623607
<div>${currentEventLine}</div>
624608
<div class="event-right">
625609
<div class="event-main" >
626-
${this.getTitleHTML(event,isEventNext)}
610+
${this.getTitleHTML(event)}
627611
${hoursHTML}
628612
</div>
629613
<div class="event-location">
@@ -654,7 +638,7 @@ class AtomicCalendar extends LitElement {
654638
.replace(locale.format('YYYY'), '') // remove year
655639
.replace(/\s\s+/g, ' ') // remove double spaces, if any
656640
.trim() // remove spaces from the start and the end
657-
.replace(/[рг]\./, '') // remove year letter from RU/UK locales
641+
.replace(/[??]\./, '') // remove year letter from RU/UK locales
658642
.replace(/de$/, '') // remove year prefix from PT
659643
.replace(/b\.$/, '') // remove year prefix from SE
660644
.trim() // remove spaces from the start and the end
@@ -668,12 +652,14 @@ class AtomicCalendar extends LitElement {
668652
* @return {bool}
669653
*/
670654
checkFilter(str, filter) {
655+
if(typeof filter != 'undefined' && filter!=''){
671656
const keywords = filter.split(',')
672657
return (keywords.some((keyword) => {
673658
if (RegExp('(?:^|\\s)' + keyword.trim(), 'i').test(str))
674659
return true
675660
else return false
676661
}))
662+
} else return false
677663

678664
}
679665

@@ -688,30 +674,16 @@ class AtomicCalendar extends LitElement {
688674
let start = moment().add(this.config.startDaysAhead, 'days').startOf('day').add(timeOffset,'minutes').format('YYYY-MM-DDTHH:mm:ss');
689675
let end = moment().add((this.config.maxDaysToShow + this.config.startDaysAhead), 'days').endOf('day').add(timeOffset,'minutes').format('YYYY-MM-DDTHH:mm:ss');
690676
let calendarUrlList = []
691-
this.config.entities.map(entity =>
692-
calendarUrlList.push([`calendars/${entity.entity}?start=${start}Z&end=${end}Z`, entity.blacklist ])
693-
)
677+
this.config.entities.map(entity =>{
678+
calendarUrlList.push([`calendars/${entity.entity}?start=${start}Z&end=${end}Z`])
679+
})
694680
try {
695681
return await (Promise.all(calendarUrlList.map(url =>
696-
this.hass.callApi('get', url[0]))).then((result, n) => {
682+
this.hass.callApi('get', url[0]))).then((result) => {
697683
let ev = [].concat.apply([], (result.map((singleCalEvents, i) => {
698-
let singleEvent = []
699-
let blacklist = calendarUrlList[1][1]
700-
singleCalEvents.map(evt => {
701-
702-
if(!blacklist || (blacklist && !this.checkFilter(evt.summary, blacklist))){
703-
singleEvent.push(new EventClass(evt, this.config.entities[i] ))
704-
}
705-
706-
707-
})
708-
return singleEvent
709-
//return singleCalEvents.map(evt => new EventClass(evt, this.config.entities[i], calendarUrlList[1] ))
684+
return singleCalEvents.map(evt => new EventClass(evt, this.config.entities[i]))
710685
})))
711686

712-
// sort events
713-
ev = ev.sort((a, b) => moment(a.startTimeToShow) - moment(b.startTimeToShow))
714-
715687
// grouping events by days, returns object with days and events
716688
const groupsOfEvents = ev.reduce(function (r, a) {
717689
r[a.daysToSort] = r[a.daysToSort] || []
@@ -732,6 +704,7 @@ class AtomicCalendar extends LitElement {
732704
}
733705

734706

707+
735708
/**
736709
* gets events from HA to Calendar mode
737710
*
@@ -744,22 +717,22 @@ class AtomicCalendar extends LitElement {
744717
// calendarUrlList[url, type of event configured for this callendar,filters]
745718
let calendarUrlList = []
746719
this.config.entities.map(entity => {
747-
if (entity.type) {
720+
if (typeof entity.type != 'undefined') {
748721
calendarUrlList.push([`calendars/${entity.entity}?start=${start}Z&end=${end}Z`, entity.type,
749-
entity.blacklist ? entity.blacklist : ''
722+
typeof entity.blacklist!= 'undefined' ? entity.blacklist : ''
750723
])
751724
}
752725
})
753726

754727
Promise.all(calendarUrlList.map(url =>
755-
this.hass.callApi('get', url[0]))).then((result, i) => {
728+
this.hass.callApi('get', url[0]))).then((result) => {
756729
if (monthToGet == this.monthToGet)
757730
result.map((eventsArray, i) => {
758731
this.month.map(m => {
759732
const calendarTypes = calendarUrlList[i][1]
760733
const calendarUrl = calendarUrlList[i][0]
761-
const calendarBlacklist = calendarUrlList[i][2]
762-
eventsArray.map((event, i) => {
734+
const calendarBlacklist = (typeof calendarUrlList[i][2] != 'undefined') ? calendarUrlList[i][2] : ''
735+
eventsArray.map((event) => {
763736
const startTime = event.start.dateTime ? moment(event.start.dateTime) : moment(event.start.date).startOf('day')
764737
const endTime = event.end.dateTime ? moment(event.end.dateTime) : moment(event.end.date).subtract(1, 'days').endOf('day')
765738

@@ -811,9 +784,6 @@ class AtomicCalendar extends LitElement {
811784
buildCalendar(selectedMonth) {
812785
const firstDay = moment(selectedMonth).startOf('month')
813786
const dayOfWeekNumber = firstDay.day()
814-
const startDate = moment(firstDay).add(this.config.firstDayOfWeek - dayOfWeekNumber, 'days')
815-
const endDate = moment(firstDay).add(42 - dayOfWeekNumber + this.config.firstDayOfWeek, 'days')
816-
817787
this.month = [];
818788
let weekShift = 0;
819789
(dayOfWeekNumber - this.config.firstDayOfWeek) >=0 ? weekShift = 0 : weekShift = 7
@@ -915,7 +885,7 @@ class AtomicCalendar extends LitElement {
915885
const month = this.month
916886
const weekDays = moment.weekdaysMin(true)
917887
const htmlDayNames = weekDays.map((day) => html `
918-
<th class="cal" style="padding-bottom: 8px;">${day}</th>`)
888+
<th class="cal" style="padding-bottom: 8px; color: ${this.config.titleColor};">${day}</th>`)
919889

920890
this.content = html `
921891
<div class="calTitleContainer">
@@ -1025,6 +995,7 @@ class EventClass {
1025995
this._startTime = this.eventClass.start.dateTime ? moment(this.eventClass.start.dateTime) : moment(this.eventClass.start.date).startOf('day')
1026996
this._endTime = this.eventClass.end.dateTime ? moment(this.eventClass.end.dateTime) : moment(this.eventClass.end.date).subtract(1, 'days').endOf('day')
1027997
this.isFinished = false;
998+
1028999
}
10291000

10301001
get titleColor() {

atomic_calendar.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/atomic_calendar.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)