Skip to content

Commit 0b6d038

Browse files
authored
Merge pull request #1 from Mugilraj-Govindarajan/master
Sample(ES-837309): Schedule graphQl sample added
2 parents 4e42068 + 16eba24 commit 0b6d038

29 files changed

+860
-1
lines changed

GraphQl/package.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"name": "graphql-server",
3+
"version": "1.0.0",
4+
"description": "",
5+
"main": "index.js",
6+
"scripts": {
7+
"dev": "graphpack --port 4400",
8+
"build": "graphpack build"
9+
},
10+
"author": "",
11+
"license": "ISC",
12+
"devDependencies": {
13+
"graphpack": "^1.0.9"
14+
},
15+
"dependencies": {
16+
"@syncfusion/ej2-data": "^19.2.55"
17+
}
18+
}

GraphQl/src/db.js

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
2+
export let eventsData = [
3+
{
4+
Id: 1,
5+
Subject: 'Server Maintenance',
6+
StartTime: new Date(2021, 1, 11, 10, 0).toISOString(),
7+
EndTime: new Date(2021, 1, 11, 11, 30).toISOString(),
8+
Location: 'Seattle'
9+
}, {
10+
Id: 2,
11+
Subject: 'Art & Painting Gallery',
12+
StartTime: new Date(2021, 1, 12, 12, 0).toISOString(),
13+
EndTime: new Date(2021, 1, 12, 14, 0).toISOString(),
14+
Location: 'Costa Rica'
15+
}, {
16+
Id: 3,
17+
Subject: 'Dany Birthday Celebration',
18+
StartTime: new Date(2021, 1, 13, 10, 0).toISOString(),
19+
EndTime: new Date(2021, 1, 13, 11, 30).toISOString(),
20+
Location: 'Kirkland'
21+
}, {
22+
Id: 4,
23+
Subject: 'John Wedding Anniversary',
24+
StartTime: new Date(2021, 1, 14, 9, 0).toISOString(),
25+
EndTime: new Date(2021, 1, 14, 10, 0).toISOString(),
26+
Location: 'Redmond'
27+
}, {
28+
Id: 5,
29+
Subject: 'ISA Annual Conference',
30+
StartTime: new Date(2021, 1, 15, 10, 0).toISOString(),
31+
EndTime: new Date(2021, 1, 15, 11, 30).toISOString(),
32+
Location: 'USA'
33+
}, {
34+
Id: 6,
35+
Subject: 'Equipment Maintenance',
36+
StartTime: new Date(2021, 1, 16, 12, 0).toISOString(),
37+
EndTime: new Date(2021, 1, 16, 14, 0).toISOString(),
38+
Location: 'Seattle',
39+
}, {
40+
Id: 7,
41+
Subject: 'Aircraft Maintenance',
42+
StartTime: new Date(2021, 1, 17, 10, 0).toISOString(),
43+
EndTime: new Date(2021, 1, 17, 11, 30).toISOString(),
44+
Location: 'Seattle'
45+
}, {
46+
Id: 8,
47+
Subject: 'Facilities Maintenance',
48+
StartTime: new Date(2021, 1, 19, 9, 30).toISOString(),
49+
EndTime: new Date(2021, 1, 19, 11, 0).toISOString(),
50+
Location: 'Seattle'
51+
}, {
52+
Id: 9,
53+
Subject: 'Britto Birthday Celebration',
54+
StartTime: new Date(2021, 1, 21, 11, 0).toISOString(),
55+
EndTime: new Date(2021, 1, 21, 13, 0).toISOString(),
56+
Location: 'Greenland'
57+
}, {
58+
Id: 10,
59+
Subject: 'Justin Wedding Anniversary',
60+
StartTime: new Date(2021, 1, 22, 9, 30).toISOString(),
61+
EndTime: new Date(2021, 1, 22, 11, 0).toISOString(),
62+
Location: 'Finland'
63+
}, {
64+
Id: 11,
65+
Subject: 'AIEA Annual Meet',
66+
StartTime: new Date(2021, 1, 9, 10, 0).toISOString(),
67+
EndTime: new Date(2021, 1, 9, 11, 30).toISOString(),
68+
Location: 'USA'
69+
}, {
70+
Id: 12,
71+
Subject: 'AAN Conference',
72+
StartTime: new Date(2021, 1, 7, 10, 30).toISOString(),
73+
EndTime: new Date(2021, 1, 7, 12, 30).toISOString(),
74+
Location: 'USA'
75+
}, {
76+
Id: 13,
77+
Subject: 'Photography Gallery',
78+
StartTime: new Date(2021, 1, 5, 10, 0).toISOString(),
79+
EndTime: new Date(2021, 1, 5, 11, 30).toISOString(),
80+
Location: 'Chennai'
81+
}, {
82+
Id: 14,
83+
Subject: 'Beach Clean-up',
84+
StartTime: new Date(2021, 1, 14, 12, 0).toISOString(),
85+
EndTime: new Date(2021, 1, 14, 14, 0).toISOString(),
86+
Location: 'Mumbai'
87+
}, {
88+
Id: 15,
89+
Subject: 'Turtle Walk',
90+
StartTime: new Date(2021, 1, 19, 13, 0).toISOString(),
91+
EndTime: new Date(2021, 1, 19, 14, 30).toISOString(),
92+
Location: 'Costa Rica'
93+
}, {
94+
Id: 16,
95+
Subject: 'Silent Walk for Cancer day',
96+
StartTime: new Date(2021, 1, 22, 13, 0).toISOString(),
97+
EndTime: new Date(2021, 1, 22, 14, 30).toISOString(),
98+
Location: 'Chennai'
99+
}, {
100+
Id: 17,
101+
Subject: 'Beach Clean-up',
102+
StartTime: new Date(2021, 1, 13, 14, 0).toISOString(),
103+
EndTime: new Date(2021, 1, 13, 16, 0).toISOString(),
104+
Location: 'Mumbai'
105+
}, {
106+
Id: 18,
107+
Subject: 'Photography Gallery',
108+
StartTime: new Date(2021, 1, 15, 14, 0).toISOString(),
109+
EndTime: new Date(2021, 1, 15, 16, 0).toISOString(),
110+
Location: 'Chennai'
111+
}
112+
];

GraphQl/src/resolvers.js

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import { eventsData } from "./db";
2+
3+
const resolvers = {
4+
Query: {
5+
getEvents: (parent, datamanager, context, info) => {
6+
const dataArgs = datamanager;
7+
const params = JSON.parse(dataArgs.datamanager.params);
8+
console.log('startDate: ' + params.StartDate + ' EndDate: ' + params.EndDate);
9+
var data = eventsData.filter(x => new Date(x.StartTime) >= new Date(params.StartDate) && new Date(x.EndTime) <= new Date(params.EndDate));
10+
return {result: data || eventsData};
11+
}
12+
},
13+
14+
Mutation: {
15+
batchUpdate: (parent, { added, changed, deleted }, context, info) => {
16+
if (added && added.length > 0) {
17+
console.log('added: ' + added.length);
18+
added.forEach((order) => {
19+
eventsData.push(order);
20+
});
21+
}
22+
if (changed && changed.length > 0) {
23+
console.log('changed: ' + changed.length);
24+
changed.forEach((order) => {
25+
let newOrder = eventsData.find(app => app.Id === order.Id);
26+
newOrder.Id = order.Id;
27+
newOrder.Subject = order.Subject;
28+
newOrder.StartTime = order.StartTime;
29+
newOrder.EndTime = order.EndTime;
30+
newOrder.Location = order.Location;
31+
newOrder.IsAllDay = order.IsAllDay;
32+
newOrder.RecurrenceRule = order.RecurrenceRule;
33+
newOrder.StartTimezone = order.StartTimezone;
34+
newOrder.EndTimezone = order.EndTimezone;
35+
});
36+
}
37+
if (deleted && deleted.length > 0) {
38+
console.log('deleted: ' + deleted.length);
39+
deleted.forEach((order) => {
40+
const orderIndex = eventsData.findIndex(app => app.Id === parseInt(order.Id));
41+
if (orderIndex === -1) throw new Error("app not found." + order.Id);
42+
eventsData.splice(orderIndex, 1);
43+
});
44+
}
45+
}
46+
}
47+
};
48+
49+
export default resolvers;

GraphQl/src/schema.graphql

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
input Sort {
2+
name: String!
3+
direction: String!
4+
}
5+
6+
input Aggregate {
7+
field: String!
8+
type: String!
9+
}
10+
11+
#Syncfusion DataManager query params
12+
13+
input DataManager {
14+
skip: Int
15+
take: Int
16+
sorted: [Sort]
17+
group: [String]
18+
table: String
19+
select: [String]
20+
where: String
21+
search: String
22+
requiresCounts: Boolean
23+
aggregates: [Aggregate]
24+
params: String
25+
}
26+
27+
# Schedule Appointment field names
28+
input AppointmentFields {
29+
Id: Int!
30+
Subject: String
31+
StartTime: String!
32+
EndTime: String!
33+
Location: String
34+
IsAllDay: Boolean
35+
Guid: String
36+
RecurrenceRule: String
37+
StartTimezone: String
38+
EndTimezone: String
39+
}
40+
41+
type Appointment {
42+
Id: Int!
43+
Subject: String
44+
StartTime: String!
45+
EndTime: String!
46+
Location: String
47+
IsAllDay: Boolean
48+
RecurrenceRule: String
49+
StartTimezone: String
50+
EndTimezone: String
51+
}
52+
53+
type ReturnType {
54+
result: [Appointment]
55+
}
56+
57+
type Query {
58+
getEvents(datamanager: DataManager): ReturnType
59+
}
60+
61+
type Mutation {
62+
batchUpdate(added: [AppointmentFields], changed: [AppointmentFields], deleted: [AppointmentFields]): Appointment
63+
}

README.md

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,32 @@
1-
# ej2-angular-scheduler-crud-graphql-adaptor
1+
# ej2-angular-scheduler-crud-graphql-adaptor
2+
3+
This project is a skeleton application used to create [Syncfusion Angular Components](https://www.syncfusion.com/angular-ui-components) web application.
4+
5+
## Add Syncfusion Grid component in your application
6+
7+
Refer the following UG documenation for adding Syncfusion Angular component in your application
8+
* [Getting Started of Syncfusion Angular Scheduler component](https://ej2.syncfusion.com/angular/documentation/schedule/getting-started)
9+
10+
## GraphQL Server setup
11+
12+
You can setup GraphQL server by using `graphpack` npm package. Find the following link for getting more details for your reference.
13+
[`https://www.npmjs.com/package/graphpack`](https://www.npmjs.com/package/graphpack)
14+
15+
## Run the GraphQL Server
16+
17+
```
18+
npm run dev
19+
```
20+
21+
## Run the client Schedule application
22+
23+
```
24+
npm start
25+
```
26+
27+
## Resources
28+
29+
You can also refer the below resources to know more details about Syncfusion Angular Scheduler components.
30+
* [Demo](https://ej2.syncfusion.com/angular/demos/#/material/schedule/default)
31+
* [Documentation](https://helpej2.syncfusion.com/angular/documentation/schedule/)
32+
* [GraphQL with Syncfusion DataManager](https://ej2.syncfusion.com/angular/documentation/data/adaptors/#graphql-adaptor)

Schedule/.browserslistrc

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# This file is used by the build system to adjust CSS and JS output to support the specified browsers below.
2+
# For additional information regarding the format and rule options, please see:
3+
# https://github.com/browserslist/browserslist#queries
4+
5+
# For the full list of supported browsers by the Angular framework, please see:
6+
# https://angular.io/guide/browser-support
7+
8+
# You can see what browsers were selected by your queries by running:
9+
# npx browserslist
10+
11+
last 1 Chrome version
12+
last 1 Firefox version
13+
last 2 Edge major versions
14+
last 2 Safari major versions
15+
last 2 iOS major versions
16+
Firefox ESR

Schedule/.editorconfig

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Editor configuration, see https://editorconfig.org
2+
root = true
3+
4+
[*]
5+
charset = utf-8
6+
indent_style = space
7+
indent_size = 2
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true
10+
11+
[*.ts]
12+
quote_type = single
13+
14+
[*.md]
15+
max_line_length = off
16+
trim_trailing_whitespace = false

Schedule/.gitignore

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# See http://help.github.com/ignore-files/ for more about ignoring files.
2+
3+
# compiled output
4+
/dist
5+
/tmp
6+
/out-tsc
7+
# Only exists if Bazel was run
8+
/bazel-out
9+
10+
# dependencies
11+
/node_modules
12+
13+
# profiling files
14+
chrome-profiler-events*.json
15+
16+
# IDEs and editors
17+
/.idea
18+
.project
19+
.classpath
20+
.c9/
21+
*.launch
22+
.settings/
23+
*.sublime-workspace
24+
25+
# IDE - VSCode
26+
.vscode/*
27+
!.vscode/settings.json
28+
!.vscode/tasks.json
29+
!.vscode/launch.json
30+
!.vscode/extensions.json
31+
.history/*
32+
33+
# misc
34+
/.angular/cache
35+
/.sass-cache
36+
/connect.lock
37+
/coverage
38+
/libpeerconnection.log
39+
npm-debug.log
40+
yarn-error.log
41+
testem.log
42+
/typings
43+
44+
# System Files
45+
.DS_Store
46+
Thumbs.db

0 commit comments

Comments
 (0)