node-red-dashboard icon indicating copy to clipboard operation
node-red-dashboard copied to clipboard

Add v-calendar from Vuetify Labs

Open joepavitt opened this issue 1 year ago • 5 comments

Description

Requested here: https://discourse.nodered.org/t/vuetify-labs-v-calendar-component-possible-to-add/90185

Quick win to include it from the Vuetify Labs components

Have you provided an initial effort estimate for this issue?

I have provided an initial effort estimate

joepavitt avatar Aug 15 '24 09:08 joepavitt

See main.mjs for where to import this

joepavitt avatar Aug 22 '24 07:08 joepavitt

This doesn't looks good need to investigate more and holding this off for https://github.com/FlowFuse/node-red-dashboard/issues/1180 and revisit after completing it

Image

Image

Expected UI should be like this Check this Vuetify demo

Image

gayanSandamal avatar Aug 23 '24 07:08 gayanSandamal

I was able to override the css to change the look of the buttons but couldn't get the data from the labs examples to render. Is there some Dashboard magic happening preventing this?

Bobo-amg avatar Sep 14 '24 10:09 Bobo-amg

This doesnt look too bad if button styles are overriden in the template and a smaller theme setting is selected - though i would prefer to understand why our default dashboard styles make this look so bad!

also, not sure why the buttons are always blue (instead of the tertiary style in the vuetify demo)

Template

<template>
  <v-row class="fill-height">
    <v-col>
      <v-sheet height="600">
        <v-calendar
          ref="calendar"
          v-model="today"
          :events="events"
          color="primary"
          type="month"
        ></v-calendar>
      </v-sheet>
    </v-col>
  </v-row>
</template>

<script>

  export default {
    data: () => ({
      focus: '',
      events: [],
      colors: [
        'blue',
        'indigo',
        'deep-purple',
        'cyan',
        'green',
        'orange',
        'grey darken-1',
      ],
      names: [
        'Meeting',
        'Holiday',
        'PTO',
        'Travel',
        'Event',
        'Birthday',
        'Conference',
        'Party',
      ],
      today: []
    }),
    mounted() {
      console.log('mounted')
      const adapter = useDate()
      this.fetchEvents({
        start: adapter.startOfDay(adapter.startOfMonth(new Date())),
        end: adapter.endOfDay(adapter.endOfMonth(new Date())),
      })
    },
    methods: {
      getEventColor(event) {
        return event.color
      },
      fetchEvents({ start, end }) {
         console.log('fetchEvents')
        const events = []

        const min = start
        const max = end
        const days = (max.getTime() - min.getTime()) / 86400000
        const eventCount = this.rnd(days, days + 20)

        for (let i = 0; i < eventCount; i++) {
          const allDay = this.rnd(0, 3) === 0
          const firstTimestamp = this.rnd(min.getTime(), max.getTime())
          const first = new Date(firstTimestamp - (firstTimestamp % 900000))
          const secondTimestamp = this.rnd(2, allDay ? 288 : 8) * 900000
          const second = new Date(first.getTime() + secondTimestamp)

          events.push({
            title: this.names[this.rnd(0, this.names.length - 1)],
            start: first,
            end: second,
            color: this.colors[this.rnd(0, this.colors.length - 1)],
            allDay: !allDay,
          })
        }

        this.events = events
      },
      rnd(a, b) {
        return Math.floor((b - a + 1) * Math.random()) + a
      },
    },
  }
</script>

<style>
.v-calendar .v-btn.v-btn--density-default, .v-btn.v-btn--density-compact, .v-btn.v-btn--density-comfortable {
    height: unset !important;
    min-height: unset !important;
}
</style>

Image

Steve-Mcl avatar Oct 29 '24 17:10 Steve-Mcl

for the memory banks:

Adding

import { VCalendar, VCalendarDay, VCalendarHeader, VCalendarMonthDay } from 'vuetify/labs/VCalendar'

and

const vuetify = createVuetify({
    components: {
        ...components,
        VCalendar,
        VCalendarDay,
        VCalendarHeader,
        VCalendarMonthDay,
        VNumberInput,
        VTreeview
    },
    ...

to ui/src/main.mjs permits calendar to be used.

Steve-Mcl avatar Oct 30 '24 08:10 Steve-Mcl