Skip to content

Commit

Permalink
Merge pull request #46 from intri-in/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
intri-in authored Jun 19, 2023
2 parents 6ae8b2d + 858f7e7 commit 97a9ea0
Show file tree
Hide file tree
Showing 14 changed files with 606 additions and 214 deletions.
15 changes: 15 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
v0.1.8
- Features added to Gantt view:
- Double click edits task
- Drag and drop, expansion/contraction enabled.
- Added help option.
- Fixed type error in HomeTasks.tsx
- Fixed mysql port variable in docker-compose.yml.sample
- Bumped up some @fullcalendar packages. Meant to fix some bugs with fullcalendar not working with NextJS.
- Bumped version to 0.1.8
- Calendar Views now have more options
- Switch to enable showing tasks
- Option to select displayed calendars
- API Change: caldav/calendars/events/db/all now also includes caldav_accounts_id for each event in output
- Bug fix: Done tasks being shown in lists filtered just with Labels.

v0.1.7
- Added constant VERSION_NUMBER
- Breaking change:
Expand Down
2 changes: 1 addition & 1 deletion COMMITMESSAGE.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
- Bumped up some @fullcalendar packages. Meant to fix some bugs with fullcalendar not working with NextJS.
- Bug fix: Done tasks being shown in lists filtered just with Labels.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "manage-my-damn-life-nextjs",
"version": "0.1.7",
"version": "0.1.8",
"private": true,
"scripts": {
"dev": "next dev",
Expand Down
84 changes: 73 additions & 11 deletions src/components/fullcalendar/DashboardView.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@ import { getEmptyEventDataObject, getParsedEvent, isAllDayEvent, majorTaskFilter
import bootstrap from "@fullcalendar/bootstrap";
import interactionPlugin from '@fullcalendar/interaction'
import Offcanvas from 'react-bootstrap/Offcanvas';
import { BiTask } from "react-icons/bi";
import rrulePlugin from '@fullcalendar/rrule'
import { ISODatetoHuman, ISODatetoHumanISO, getI18nObject } from "@/helpers/frontend/general";
import { getI18nObject } from "@/helpers/frontend/general";
import EventEditor from "../events/EventEditor";
import moment from "moment";
import { getRandomString } from "@/helpers/crypto";
import { getObjectForAPICall, makeGenerateICSRequest } from "@/helpers/frontend/ics";
import { toast } from "react-toastify";
import { getMessageFromAPIResponse } from "@/helpers/frontend/response";
import { FULLCALENDAR_BUSINESS_HOURS } from "@/config/constants";
import { withRouter } from "next/router";
import { RecurrenceHelper } from "@/helpers/frontend/classes/RecurrenceHelper";
import { FULLCALENDAR_VIEWLIST } from "./FullCalendarHelper";
import { getDefaultViewForCalendar } from "@/helpers/frontend/settings";
import { ListGroupCalDAVAccounts } from "./ListGroupCalDAVAccounts";
import { Preference_CalendarsToShow } from "@/helpers/frontend/classes/UserPreferences/Preference_CalendarsToShow";

class DashboardView extends Component {
calendarRef = React.createRef()
Expand All @@ -34,7 +34,7 @@ class DashboardView extends Component {
super(props)
this.i18next = getI18nObject()
var initialViewCalendar = "timeGridDay"
this.state = { showEventEditor: false, viewValue: initialViewCalendar, events: null, eventEdited: false, eventDataDashBoard: {}, initialViewCalendar: initialViewCalendar, allEvents: {}, recurMap: {}, selectedID: "", calendarAR: props.calendarAR }
this.state = { showEventEditor: false, viewValue: initialViewCalendar, events: null, eventEdited: false, eventDataDashBoard: {}, initialViewCalendar: initialViewCalendar, allEvents: {}, recurMap: {}, selectedID: "", calendarAR: props.calendarAR,showTasksChecked: false, allEventsFromServer: null, caldav_accounts:null }
this.viewChanged = this.viewChanged.bind(this)
this.eventClick = this.eventClick.bind(this)
this.handleDateClick = this.handleDateClick.bind(this)
Expand All @@ -43,6 +43,9 @@ class DashboardView extends Component {
this.eventDrop = this.eventDrop.bind(this)
this.eventResize = this.eventResize.bind(this)
this.scheduleEvent = this.scheduleEvent.bind(this)
this.showTasksChanged = this.showTasksChanged.bind(this)
this.addEventsToCalendar = this.addEventsToCalendar.bind(this)
this.userPreferencesChanged = this.userPreferencesChanged.bind(this)
}


Expand All @@ -57,15 +60,15 @@ class DashboardView extends Component {

const view = await getDefaultViewForCalendar()
calendarApi.changeView(view)
this.setState({viewValue: view})
this.setState({viewValue: view, showTasksChecked: true})

}

async getCaldavAccountsfromDB() {
var caldav_accounts = await getCaldavAccountsfromServer()
if (caldav_accounts != null && caldav_accounts.success == true) {
if (caldav_accounts.data.message.length > 0) {

this.setState({caldav_accounts: caldav_accounts.data.message})
} else {
this.props.router.push("/accounts/caldav?message=ADD_A_CALDAV_ACCOUNT")
}
Expand Down Expand Up @@ -287,13 +290,18 @@ class DashboardView extends Component {
return false

}
async getAllEventsfromServer() {
var allEvents = await getAllEvents()
async addEventsToCalendar(allEvents){
var finalEvents = []


if (isValidResultArray(allEvents.data.message)) {

for (let i = 0; i < allEvents.data.message.length; i++) {
for (const j in allEvents.data.message[i].events) {
var userWantsToSee = Preference_CalendarsToShow.getShowValueForCalendar(allEvents.data.message[i].info.caldav_accounts_id, allEvents.data.message[i].events[j].calendar_id)
if(userWantsToSee ==false){
continue
}
var event = allEvents.data.message[i].events[j]
if (event.deleted == "1" || event.deleted == "TRUE") {
continue
Expand Down Expand Up @@ -422,7 +430,7 @@ class DashboardView extends Component {
this.state.allEvents[data.uid] = { data: data, event: allEvents.data.message[i].events[j] }

}
else if (event.type == "VTODO") {
else if (event.type == "VTODO" && this.state.showTasksChecked==true) {
var data = returnGetParsedVTODO(allEvents.data.message[i].events[j].data)
if (varNotEmpty(data) == false) {
continue
Expand Down Expand Up @@ -495,8 +503,41 @@ class DashboardView extends Component {
}

this.setState({ events: finalEvents })

}
async getAllEventsfromServer() {
var allEvents = await getAllEvents()
this.setState({allEventsFromServer: allEvents})

this.addEventsToCalendar(allEvents)
}

showTasksChanged(e)
{
this.setState(({ showTasksChecked }) => (
{
showTasksChecked: !showTasksChecked
}
), function () {
if(this.state.allEventsFromServer!=null)
{
this.addEventsToCalendar(this.state.allEventsFromServer)
}else{
this.getAllEventsfromServer()
}
});


}

userPreferencesChanged(){
if(this.state.allEventsFromServer!=null)
{
this.addEventsToCalendar(this.state.allEventsFromServer)
}else{
this.getAllEventsfromServer()
}
}
render() {

const eventDataDashBoard = this.state.eventDataDashBoard
Expand All @@ -508,13 +549,34 @@ class DashboardView extends Component {
{
options.push( <option key={FULLCALENDAR_VIEWLIST[i].name} value={FULLCALENDAR_VIEWLIST[i].name}>{this.i18next.t(FULLCALENDAR_VIEWLIST[i].saneName)}</option>)
}

var calendarsSelect= null
if(varNotEmpty(this.state.caldav_accounts) && Array.isArray(this.state.caldav_accounts) && this.state.caldav_accounts.length>0)
{
calendarsSelect = <ListGroupCalDAVAccounts onChange={this.userPreferencesChanged} caldav_accounts={this.state.caldav_accounts} />
}
return (<>
<Row style={{ padding: 20 }} >
<Col>

<Row style={{ padding: 20, flex:1 , justifyContent:"center", alignItems:"center", }} >
<Col >
<Form.Select value={this.state.viewValue} onChange={this.viewChanged}>
{options}
</Form.Select>
</Col>
<Col style={{}}>

<Form.Check
type="switch"
id="show_tasks_switch"
checked={this.state.showTasksChecked}
onClick={this.showTasksChanged}
label={this.i18next.t("SHOW_TASKS")}
/>

</Col>
<Col style={{textAlign:"center",}}>
{calendarsSelect}
</Col>
</Row>
<FullCalendar
plugins={[dayGridPlugin, timeGridPlugin, bootstrap5Plugin, interactionPlugin, rrulePlugin, listPlugin]}
Expand Down
102 changes: 102 additions & 0 deletions src/components/fullcalendar/ListGroupCalDAVAccounts.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
import { getI18nObject } from '@/helpers/frontend/general';
import { useEffect, useState } from 'react';
import Button from 'react-bootstrap/Button';
import Modal from 'react-bootstrap/Modal';
import Form from 'react-bootstrap/Form';
import Cookies from 'js-cookie'
import { getCalendarsToShow, isValid_UserPreference_CalendarsToShow } from '@/helpers/frontend/userpreference';
import { varNotEmpty } from '@/helpers/general';
import { Preference_CalendarsToShow } from '@/helpers/frontend/classes/UserPreferences/Preference_CalendarsToShow';
import { BsCalendarCheck } from 'react-icons/bs';
import OverlayTrigger from 'react-bootstrap/OverlayTrigger';
import Tooltip from 'react-bootstrap/Tooltip';
interface customProps{
caldav_accounts: {account:{name: string, caldav_accounts_id: number}, calendars: any }[];
onChange?: () => void;

}
export function ListGroupCalDAVAccounts(props: customProps ){
const [modalShow, setModalShow] = useState(false);
const i18next = getI18nObject()
const [prefObject, setPrefObject] =useState(getLatestPreferenceObject(props.caldav_accounts))



const onChangeChecked = (e, indexInPreferenceObject) =>{
var index = JSON.parse(e.target.id)
Preference_CalendarsToShow.update(index, e.target.checked)
setPrefObject(getLatestPreferenceObject(props.caldav_accounts))
if(props.onChange()!=undefined){
props.onChange()
}
}
var output=[]
if(props.caldav_accounts.length>0 )
{
for(const i in props.caldav_accounts){

output.push(<h3>{props.caldav_accounts[i].account.name}</h3>)
var calendarOutput =[]
if(varNotEmpty(props.caldav_accounts[i].calendars) && props.caldav_accounts[i].calendars)
for(const j in props.caldav_accounts[i].calendars){
var indexInPreferenceObject = Preference_CalendarsToShow.findIndex_Calendar(prefObject, props.caldav_accounts[i].account.caldav_accounts_id, props.caldav_accounts[i].calendars[j].calendars_id)
if(varNotEmpty(indexInPreferenceObject) && Array.isArray(indexInPreferenceObject) && indexInPreferenceObject.length>0)
{
calendarOutput.push(<Form.Check
inline type="checkbox" id={JSON.stringify(indexInPreferenceObject)} checked={prefObject[indexInPreferenceObject[0]].calendars[indexInPreferenceObject[1]].show} onClick={e => onChangeChecked( e, indexInPreferenceObject)} label={props.caldav_accounts[i].calendars[j].displayName}/>)

}

}

output.push(<Form>{calendarOutput}</Form>)

}
}
return(
<>
<Modal
show={modalShow}
onHide={() => setModalShow(false)}
size="lg"
aria-labelledby="contained-modal-title-vcenter"
centered
>
<Modal.Header closeButton>
<Modal.Title id="contained-modal-title-vcenter">
{i18next.t("SELECT_CALENDARS_TO_SHOW")}
</Modal.Title>
</Modal.Header>
<Modal.Body>
{output}
</Modal.Body>
<Modal.Footer>
<Button onClick={() => setModalShow(false)}>Close</Button>
</Modal.Footer>
</Modal>
<OverlayTrigger key="SELECT_CALENDARS_KEY" placement='top'
overlay={
<Tooltip id='tooltip_SELECT_CALENDARS'>
{i18next.t("SELECT_CALENDARS_TO_SHOW")}

</Tooltip>
}>
<Button size='sm' variant="primary" onClick={() => setModalShow(true)}>
<BsCalendarCheck size={24} /> </Button>

</OverlayTrigger>
</>
)

}


function getLatestPreferenceObject(caldav_accounts: {account:{name: string, caldav_accounts_id: number}, calendars: any }[]){
var calendarstoShow = Preference_CalendarsToShow.get()
if(Preference_CalendarsToShow.isValidObject(calendarstoShow) && Preference_CalendarsToShow.isUptoDate(caldav_accounts)){
return calendarstoShow
}else{
var newObj=Preference_CalendarsToShow.generateFromCaldavObject(caldav_accounts)
return newObj
}
}
2 changes: 2 additions & 0 deletions src/components/tasks/GenerateTaskUIList.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export default class GenerateTaskUIList extends Component{
}

componentDidMount(){

this.setState({showDone: this.props.showDone, })
//this.renderTasks(false)

Expand Down Expand Up @@ -171,6 +172,7 @@ export default class GenerateTaskUIList extends Component{
var hardFilter= todoList[1][key].todo.summary!=null && todoList[1][key].todo.summary!=undefined && (todoList[1][key].todo.deleted == null || todoList[1][key].todo.deleted == "")
var showTask = false
const showDone= this.state.showDone
console.log("showDone", showDone)
if(showDone)
{
showTask=true
Expand Down
2 changes: 1 addition & 1 deletion src/components/tasks/TaskView.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export function TaskView(props)
{
var output_list=(

<GenerateTaskUIList collapseButtonClicked={collapseButtonClicked} collapsed={collapsedArray} key="1" scheduleItem={props.scheduleItem} fetchEvents={props.fetchEvents} list={sortedList} todoList={props.todoList} level={-1} context={props.context} listColor={props.listColor} />)
<GenerateTaskUIList showDone={false} collapseButtonClicked={collapseButtonClicked} collapsed={collapsedArray} key="1" scheduleItem={props.scheduleItem} fetchEvents={props.fetchEvents} list={sortedList} todoList={props.todoList} level={-1} context={props.context} listColor={props.listColor} />)

}
else
Expand Down
2 changes: 1 addition & 1 deletion src/config/constants.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const VERSION_NUMBER = "0.1.7"
export const VERSION_NUMBER = "0.1.8"
/*
* SYSTEM_DEFAULT_LABEL_PREFIX: Default prefix applied to all system generated labels like
* "My Day"
Expand Down
Loading

0 comments on commit 97a9ea0

Please sign in to comment.