fbe7f7a7
Apichat.Tum
add api google
|
1
2
|
'use strict'
|
1244ae71
Apichat.Tum
new response
|
3
4
5
6
|
const console = process.console
const yamlConfig = require('node-yaml-config')
const path = require('path')
const async = require('async')
|
f6a4415a
Apichat.Tum
start smart-rms-c...
|
7
|
const config = yamlConfig.load(path.join(__dirname, '/../../config/config.yml'))
|
1244ae71
Apichat.Tum
new response
|
8
|
|
f6a4415a
Apichat.Tum
start smart-rms-c...
|
9
10
11
12
13
|
const lib = require('../lib')
// lib.authorize()
// lib.listEvents()
// lib.createEvent()
|
1244ae71
Apichat.Tum
new response
|
14
15
|
const url = config.server.url
|
f3f14fef
TUM.Apichat
add value config ...
|
16
|
const port = config.server.port
|
cf86e9a3
Apichat.Tum
- ui with oauth2 ...
|
17
|
|
1244ae71
Apichat.Tum
new response
|
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
function strToTime(date) {
var strDate = new Date(date)
return strDate.getTime()
}
function ggToKendo(data) {
var dataToArr = []
try {
for (var n = 0; n < data.items.length; n++) {
dataToArr.push({
"TaskID": data.items[n].etag,
"OwnerID": 2,
"Title": data.items[n].summary,
"Description": data.items[n].description,
"StartTimezone": "Asia/Bangkok",
"Start": new Date(data.items[n].start.dateTime),
"End": new Date(data.items[n].end.dateTime),
"EndTimezone": "Asia/Bangkok",
"RecurrenceRule": null,
"RecurrenceID": null,
"RecurrenceException": null,
"IsAllDay": false
})
}
} catch (error) {
console.error(error.message)
} finally {
|
77034810
Apichat.Tum
fix REST API
|
45
46
47
|
return dataToArr
}
}
|
cf86e9a3
Apichat.Tum
- ui with oauth2 ...
|
48
49
50
51
52
53
54
55
56
57
|
function home(req, res) {
res.render('index')
}
function index(req, res) {
lib.getNewToken((err, authUrl) => {
if (err) {
console.error(err.message)
} else {
|
77034810
Apichat.Tum
fix REST API
|
58
|
res.send(authUrl)
|
1244ae71
Apichat.Tum
new response
|
59
60
|
}
})
|
cf86e9a3
Apichat.Tum
- ui with oauth2 ...
|
61
62
63
64
65
66
67
68
69
70
71
72
73
|
}
function setToken(req, res) {
var code = req.body.code
lib.setNewToken(code, (err, token) => {
if (err) {
res.send(err)
res.end()
} else {
res.send(token)
res.end()
}
})
|
1244ae71
Apichat.Tum
new response
|
74
|
}
|
cf86e9a3
Apichat.Tum
- ui with oauth2 ...
|
75
76
77
78
79
80
81
82
|
function events(req, res) {
lib.authorize((err, auth, authUrl) => {
if (err) {
res.send(err)
} else if (authUrl) {
console.info(authUrl)
res.send(authUrl)
|
f6a4415a
Apichat.Tum
start smart-rms-c...
|
83
84
|
res.end()
} else {
|
1244ae71
Apichat.Tum
new response
|
85
86
87
|
lib.listEvents(auth, (err, response) => {
if (err) {
res.send(err)
|
cf86e9a3
Apichat.Tum
- ui with oauth2 ...
|
88
89
|
} else {
res.jsonp(ggToKendo(response))
|
1244ae71
Apichat.Tum
new response
|
90
|
}
|
cf86e9a3
Apichat.Tum
- ui with oauth2 ...
|
91
|
})
|
1244ae71
Apichat.Tum
new response
|
92
|
}
|
cf86e9a3
Apichat.Tum
- ui with oauth2 ...
|
93
|
|
fbe7f7a7
Apichat.Tum
add api google
|
94
|
})
|
cf86e9a3
Apichat.Tum
- ui with oauth2 ...
|
95
96
97
|
}
function create(req, res) {
|
1244ae71
Apichat.Tum
new response
|
98
99
100
|
let payload = req.body
let summary = payload.summary
|
cf86e9a3
Apichat.Tum
- ui with oauth2 ...
|
101
102
103
|
let description = payload.description
let email = payload.email
let startDate = payload.startDate
|
1244ae71
Apichat.Tum
new response
|
104
|
let startTimezone = payload.startTimezone
|
cf86e9a3
Apichat.Tum
- ui with oauth2 ...
|
105
|
let endDate = payload.endDate
|
1244ae71
Apichat.Tum
new response
|
106
|
let endTimezone = payload.endTimezone
|
f6a4415a
Apichat.Tum
start smart-rms-c...
|
107
108
109
110
111
|
let extendedProperties = payload.extendedProperties
lib.authorize((err, auth) => {
let options = lib.eventBuilder(payload)
if (err) {
|
1244ae71
Apichat.Tum
new response
|
112
|
res.send(err)
|
fbe7f7a7
Apichat.Tum
add api google
|
113
|
} else {
|
cf86e9a3
Apichat.Tum
- ui with oauth2 ...
|
114
|
options.auth = auth
|
f6a4415a
Apichat.Tum
start smart-rms-c...
|
115
|
}
|
1244ae71
Apichat.Tum
new response
|
116
|
|
cf86e9a3
Apichat.Tum
- ui with oauth2 ...
|
117
|
lib.createEvent(options, (err, result) => {
|
fbe7f7a7
Apichat.Tum
add api google
|
118
119
120
121
122
123
124
|
if (err) {
res.send(err)
} else {
res.send(result)
}
})
})
|
cf86e9a3
Apichat.Tum
- ui with oauth2 ...
|
125
126
|
}
|
77034810
Apichat.Tum
fix REST API
|
127
|
module.exports.index = index
|
1244ae71
Apichat.Tum
new response
|
128
129
|
module.exports.events = events
module.exports.create = create
|
77034810
Apichat.Tum
fix REST API
|
130
|
module.exports.home = home
|
1244ae71
Apichat.Tum
new response
|
131
|
module.exports.setToken = setToken
|
77034810
Apichat.Tum
fix REST API
|
|
|
cf86e9a3
Apichat.Tum
- ui with oauth2 ...
|
|
|
fbe7f7a7
Apichat.Tum
add api google
|
|
|
cf86e9a3
Apichat.Tum
- ui with oauth2 ...
|
|
|
f6a4415a
Apichat.Tum
start smart-rms-c...
|
|
|
f6a4415a
Apichat.Tum
start smart-rms-c...
|
|
|
77034810
Apichat.Tum
fix REST API
|
|
|
1244ae71
Apichat.Tum
new response
|
|
|
f6a4415a
Apichat.Tum
start smart-rms-c...
|
|
|
77034810
Apichat.Tum
fix REST API
|
|
|
f6a4415a
Apichat.Tum
start smart-rms-c...
|
|
|
f6a4415a
Apichat.Tum
start smart-rms-c...
|
|
|
a54f2679
DESKTOP-RBJDHSM\ADMIN
fix API
|
|
|
f6a4415a
Apichat.Tum
start smart-rms-c...
|
|
|
1244ae71
Apichat.Tum
new response
|
|
|
a54f2679
DESKTOP-RBJDHSM\ADMIN
fix API
|
|
|
f6a4415a
Apichat.Tum
start smart-rms-c...
|
|
|
a54f2679
DESKTOP-RBJDHSM\ADMIN
fix API
|
|
|
f6a4415a
Apichat.Tum
start smart-rms-c...
|
|
|
1244ae71
Apichat.Tum
new response
|
|
|
f6a4415a
Apichat.Tum
start smart-rms-c...
|
|
|
1244ae71
Apichat.Tum
new response
|
|
|
f6a4415a
Apichat.Tum
start smart-rms-c...
|
|
|
77034810
Apichat.Tum
fix REST API
|
|
|
1244ae71
Apichat.Tum
new response
|
|
|
77034810
Apichat.Tum
fix REST API
|
|
|
1244ae71
Apichat.Tum
new response
|
|
|
77034810
Apichat.Tum
fix REST API
|
|
|
fbe7f7a7
Apichat.Tum
add api google
|
|
|
f3f14fef
TUM.Apichat
add value config ...
|
|
|
77034810
Apichat.Tum
fix REST API
|
|
|
1244ae71
Apichat.Tum
new response
|
|
|
21a1ff19
Apichat.Tum
fix follow smartr...
|
|
|
1244ae71
Apichat.Tum
new response
|
|
|
77034810
Apichat.Tum
fix REST API
|
|
|
1244ae71
Apichat.Tum
new response
|
|
|
77034810
Apichat.Tum
fix REST API
|
|
|
1244ae71
Apichat.Tum
new response
|
|
|
77034810
Apichat.Tum
fix REST API
|
|
|
1244ae71
Apichat.Tum
new response
|
|
|
77034810
Apichat.Tum
fix REST API
|
|
|
1244ae71
Apichat.Tum
new response
|
|
|
77034810
Apichat.Tum
fix REST API
|
|
|
1244ae71
Apichat.Tum
new response
|
|
|
77034810
Apichat.Tum
fix REST API
|
|
|
1244ae71
Apichat.Tum
new response
|
|
|
77034810
Apichat.Tum
fix REST API
|
|
|
1244ae71
Apichat.Tum
new response
|
|
|
77034810
Apichat.Tum
fix REST API
|
|
|
1244ae71
Apichat.Tum
new response
|
|
|
77034810
Apichat.Tum
fix REST API
|
|
|
1244ae71
Apichat.Tum
new response
|
|
|
77034810
Apichat.Tum
fix REST API
|
|
|
1244ae71
Apichat.Tum
new response
|
|
|
7598c58f
Apichat.Tum
add eventTypeID /...
|
|
|
1244ae71
Apichat.Tum
new response
|
|
|
7598c58f
Apichat.Tum
add eventTypeID /...
|
|
|
77034810
Apichat.Tum
fix REST API
|
|
|
fbe7f7a7
Apichat.Tum
add api google
|
|
|
f3f14fef
TUM.Apichat
add value config ...
|
|
|
fbe7f7a7
Apichat.Tum
add api google
|
|
|