Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions GraphQl/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "graphql-server",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"dev": "graphpack --port 4400",
"build": "graphpack build"
},
"author": "",
"license": "ISC",
"devDependencies": {
"graphpack": "^1.0.9"
},
"dependencies": {
"@syncfusion/ej2-data": "^19.2.55"
}
}
112 changes: 112 additions & 0 deletions GraphQl/src/db.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@

export let eventsData = [
{
Id: 1,
Subject: 'Server Maintenance',
StartTime: new Date(2021, 1, 11, 10, 0).toISOString(),
EndTime: new Date(2021, 1, 11, 11, 30).toISOString(),
Location: 'Seattle'
}, {
Id: 2,
Subject: 'Art & Painting Gallery',
StartTime: new Date(2021, 1, 12, 12, 0).toISOString(),
EndTime: new Date(2021, 1, 12, 14, 0).toISOString(),
Location: 'Costa Rica'
}, {
Id: 3,
Subject: 'Dany Birthday Celebration',
StartTime: new Date(2021, 1, 13, 10, 0).toISOString(),
EndTime: new Date(2021, 1, 13, 11, 30).toISOString(),
Location: 'Kirkland'
}, {
Id: 4,
Subject: 'John Wedding Anniversary',
StartTime: new Date(2021, 1, 14, 9, 0).toISOString(),
EndTime: new Date(2021, 1, 14, 10, 0).toISOString(),
Location: 'Redmond'
}, {
Id: 5,
Subject: 'ISA Annual Conference',
StartTime: new Date(2021, 1, 15, 10, 0).toISOString(),
EndTime: new Date(2021, 1, 15, 11, 30).toISOString(),
Location: 'USA'
}, {
Id: 6,
Subject: 'Equipment Maintenance',
StartTime: new Date(2021, 1, 16, 12, 0).toISOString(),
EndTime: new Date(2021, 1, 16, 14, 0).toISOString(),
Location: 'Seattle',
}, {
Id: 7,
Subject: 'Aircraft Maintenance',
StartTime: new Date(2021, 1, 17, 10, 0).toISOString(),
EndTime: new Date(2021, 1, 17, 11, 30).toISOString(),
Location: 'Seattle'
}, {
Id: 8,
Subject: 'Facilities Maintenance',
StartTime: new Date(2021, 1, 19, 9, 30).toISOString(),
EndTime: new Date(2021, 1, 19, 11, 0).toISOString(),
Location: 'Seattle'
}, {
Id: 9,
Subject: 'Britto Birthday Celebration',
StartTime: new Date(2021, 1, 21, 11, 0).toISOString(),
EndTime: new Date(2021, 1, 21, 13, 0).toISOString(),
Location: 'Greenland'
}, {
Id: 10,
Subject: 'Justin Wedding Anniversary',
StartTime: new Date(2021, 1, 22, 9, 30).toISOString(),
EndTime: new Date(2021, 1, 22, 11, 0).toISOString(),
Location: 'Finland'
}, {
Id: 11,
Subject: 'AIEA Annual Meet',
StartTime: new Date(2021, 1, 9, 10, 0).toISOString(),
EndTime: new Date(2021, 1, 9, 11, 30).toISOString(),
Location: 'USA'
}, {
Id: 12,
Subject: 'AAN Conference',
StartTime: new Date(2021, 1, 7, 10, 30).toISOString(),
EndTime: new Date(2021, 1, 7, 12, 30).toISOString(),
Location: 'USA'
}, {
Id: 13,
Subject: 'Photography Gallery',
StartTime: new Date(2021, 1, 5, 10, 0).toISOString(),
EndTime: new Date(2021, 1, 5, 11, 30).toISOString(),
Location: 'Chennai'
}, {
Id: 14,
Subject: 'Beach Clean-up',
StartTime: new Date(2021, 1, 14, 12, 0).toISOString(),
EndTime: new Date(2021, 1, 14, 14, 0).toISOString(),
Location: 'Mumbai'
}, {
Id: 15,
Subject: 'Turtle Walk',
StartTime: new Date(2021, 1, 19, 13, 0).toISOString(),
EndTime: new Date(2021, 1, 19, 14, 30).toISOString(),
Location: 'Costa Rica'
}, {
Id: 16,
Subject: 'Silent Walk for Cancer day',
StartTime: new Date(2021, 1, 22, 13, 0).toISOString(),
EndTime: new Date(2021, 1, 22, 14, 30).toISOString(),
Location: 'Chennai'
}, {
Id: 17,
Subject: 'Beach Clean-up',
StartTime: new Date(2021, 1, 13, 14, 0).toISOString(),
EndTime: new Date(2021, 1, 13, 16, 0).toISOString(),
Location: 'Mumbai'
}, {
Id: 18,
Subject: 'Photography Gallery',
StartTime: new Date(2021, 1, 15, 14, 0).toISOString(),
EndTime: new Date(2021, 1, 15, 16, 0).toISOString(),
Location: 'Chennai'
}
];
49 changes: 49 additions & 0 deletions GraphQl/src/resolvers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { eventsData } from "./db";

const resolvers = {
Query: {
getEvents: (parent, datamanager, context, info) => {
const dataArgs = datamanager;
const params = JSON.parse(dataArgs.datamanager.params);
console.log('startDate: ' + params.StartDate + ' EndDate: ' + params.EndDate);
var data = eventsData.filter(x => new Date(x.StartTime) >= new Date(params.StartDate) && new Date(x.EndTime) <= new Date(params.EndDate));
return {result: data || eventsData};
}
},

Mutation: {
batchUpdate: (parent, { added, changed, deleted }, context, info) => {
if (added && added.length > 0) {
console.log('added: ' + added.length);
added.forEach((order) => {
eventsData.push(order);
});
}
if (changed && changed.length > 0) {
console.log('changed: ' + changed.length);
changed.forEach((order) => {
let newOrder = eventsData.find(app => app.Id === order.Id);
newOrder.Id = order.Id;
newOrder.Subject = order.Subject;
newOrder.StartTime = order.StartTime;
newOrder.EndTime = order.EndTime;
newOrder.Location = order.Location;
newOrder.IsAllDay = order.IsAllDay;
newOrder.RecurrenceRule = order.RecurrenceRule;
newOrder.StartTimezone = order.StartTimezone;
newOrder.EndTimezone = order.EndTimezone;
});
}
if (deleted && deleted.length > 0) {
console.log('deleted: ' + deleted.length);
deleted.forEach((order) => {
const orderIndex = eventsData.findIndex(app => app.Id === parseInt(order.Id));
if (orderIndex === -1) throw new Error("app not found." + order.Id);
eventsData.splice(orderIndex, 1);
});
}
}
}
};

export default resolvers;
63 changes: 63 additions & 0 deletions GraphQl/src/schema.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
input Sort {
name: String!
direction: String!
}

input Aggregate {
field: String!
type: String!
}

#Syncfusion DataManager query params

input DataManager {
skip: Int
take: Int
sorted: [Sort]
group: [String]
table: String
select: [String]
where: String
search: String
requiresCounts: Boolean
aggregates: [Aggregate]
params: String
}

# Schedule Appointment field names
input AppointmentFields {
Id: Int!
Subject: String
StartTime: String!
EndTime: String!
Location: String
IsAllDay: Boolean
Guid: String
RecurrenceRule: String
StartTimezone: String
EndTimezone: String
}

type Appointment {
Id: Int!
Subject: String
StartTime: String!
EndTime: String!
Location: String
IsAllDay: Boolean
RecurrenceRule: String
StartTimezone: String
EndTimezone: String
}

type ReturnType {
result: [Appointment]
}

type Query {
getEvents(datamanager: DataManager): ReturnType
}

type Mutation {
batchUpdate(added: [AppointmentFields], changed: [AppointmentFields], deleted: [AppointmentFields]): Appointment
}
33 changes: 32 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,32 @@
# ej2-angular-scheduler-crud-graphql-adaptor
# ej2-angular-scheduler-crud-graphql-adaptor

This project is a skeleton application used to create [Syncfusion Angular Components](https://www.syncfusion.com/angular-ui-components) web application.

## Add Syncfusion Grid component in your application

Refer the following UG documenation for adding Syncfusion Angular component in your application
* [Getting Started of Syncfusion Angular Scheduler component](https://ej2.syncfusion.com/angular/documentation/schedule/getting-started)

## GraphQL Server setup

You can setup GraphQL server by using `graphpack` npm package. Find the following link for getting more details for your reference.
[`https://www.npmjs.com/package/graphpack`](https://www.npmjs.com/package/graphpack)

## Run the GraphQL Server

```
npm run dev
```

## Run the client Schedule application

```
npm start
```

## Resources

You can also refer the below resources to know more details about Syncfusion Angular Scheduler components.
* [Demo](https://ej2.syncfusion.com/angular/demos/#/material/schedule/default)
* [Documentation](https://helpej2.syncfusion.com/angular/documentation/schedule/)
* [GraphQL with Syncfusion DataManager](https://ej2.syncfusion.com/angular/documentation/data/adaptors/#graphql-adaptor)
16 changes: 16 additions & 0 deletions Schedule/.browserslistrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# This file is used by the build system to adjust CSS and JS output to support the specified browsers below.
# For additional information regarding the format and rule options, please see:
# https://github.com/browserslist/browserslist#queries

# For the full list of supported browsers by the Angular framework, please see:
# https://angular.io/guide/browser-support

# You can see what browsers were selected by your queries by running:
# npx browserslist

last 1 Chrome version
last 1 Firefox version
last 2 Edge major versions
last 2 Safari major versions
last 2 iOS major versions
Firefox ESR
16 changes: 16 additions & 0 deletions Schedule/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Editor configuration, see https://editorconfig.org
root = true

[*]
charset = utf-8
indent_style = space
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true

[*.ts]
quote_type = single

[*.md]
max_line_length = off
trim_trailing_whitespace = false
46 changes: 46 additions & 0 deletions Schedule/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# See http://help.github.com/ignore-files/ for more about ignoring files.

# compiled output
/dist
/tmp
/out-tsc
# Only exists if Bazel was run
/bazel-out

# dependencies
/node_modules

# profiling files
chrome-profiler-events*.json

# IDEs and editors
/.idea
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace

# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
.history/*

# misc
/.angular/cache
/.sass-cache
/connect.lock
/coverage
/libpeerconnection.log
npm-debug.log
yarn-error.log
testem.log
/typings

# System Files
.DS_Store
Thumbs.db
Loading