fix linting errors
This commit is contained in:
94
nextcloud.js
94
nextcloud.js
@@ -1,11 +1,11 @@
|
||||
module.exports = function (RED) {
|
||||
let dav = require('dav')
|
||||
let webdav = require('webdav')
|
||||
const dav = require('dav')
|
||||
const webdav = require('webdav')
|
||||
const fs = require('fs')
|
||||
const ICAL = require('ical.js');
|
||||
let moment = require('moment');
|
||||
const ICAL = require('ical.js')
|
||||
const moment = require('moment')
|
||||
|
||||
function NextcloudConfigNode(n) {
|
||||
function NextcloudConfigNode (n) {
|
||||
RED.nodes.createNode(this, n)
|
||||
this.address = n.address
|
||||
}
|
||||
@@ -16,17 +16,16 @@ module.exports = function (RED) {
|
||||
}
|
||||
})
|
||||
|
||||
function NextcloudCalDav(n) {
|
||||
function NextcloudCalDav (n) {
|
||||
RED.nodes.createNode(this, n)
|
||||
this.server = RED.nodes.getNode(n.server)
|
||||
this.calendar = n.calendar
|
||||
this.future = n.future || true;
|
||||
this.futureWeeks = n.futureWeeks || 4;
|
||||
let node = this
|
||||
this.future = n.future || true
|
||||
this.futureWeeks = n.futureWeeks || 4
|
||||
const node = this
|
||||
|
||||
node.on('input', function (msg) {
|
||||
|
||||
//dav.debug.enabled = true;
|
||||
node.on('input', (msg) => {
|
||||
// dav.debug.enabled = true;
|
||||
const xhr = new dav.transport.Basic(
|
||||
new dav.Credentials({
|
||||
username: node.server.credentials.user,
|
||||
@@ -53,16 +52,16 @@ module.exports = function (RED) {
|
||||
let icsList = { 'payload': { 'name': calendar.displayName, 'data': [] } }
|
||||
calendarEntries.forEach(function (calendarEntry) {
|
||||
try {
|
||||
let jCalData = ICAL.parse(calendarEntry.calendarData);
|
||||
let component = new ICAL.Component(jCalData);
|
||||
let vevent = component.getFirstSubcomponent('vevent');
|
||||
var event = new ICAL.Event(vevent);
|
||||
icsList.payload.data.push(convertEvent(event));
|
||||
let jCalData = ICAL.parse(calendarEntry.calendarData)
|
||||
let component = new ICAL.Component(jCalData)
|
||||
let vevent = component.getFirstSubcomponent('vevent')
|
||||
var event = new ICAL.Event(vevent)
|
||||
icsList.payload.data.push(convertEvent(event))
|
||||
} catch (error) {
|
||||
node.error("Error parsing calendar data: " + error);
|
||||
node.error('Error parsing calendar data: ' + error)
|
||||
}
|
||||
})
|
||||
node.send(icsList);
|
||||
node.send(icsList)
|
||||
}, function () {
|
||||
node.error('Nextcloud:CalDAV -> get ics went wrong.')
|
||||
})
|
||||
@@ -73,31 +72,30 @@ module.exports = function (RED) {
|
||||
})
|
||||
})
|
||||
|
||||
function convertEvent(event) {
|
||||
let retVal = {};
|
||||
retVal.start = event.startDate.toString();
|
||||
retVal.end = event.endDate.toString();
|
||||
retVal.summary = event.summary || '';
|
||||
retVal.description = event.description || '';
|
||||
retVal.attendees = event.attendees;
|
||||
retVal.duration = event.duration;
|
||||
retVal.location = event.location || '';
|
||||
retVal.organizer = event.organizer || '';
|
||||
retVal.uid = event.uid || '';
|
||||
retVal.isRecurring = event.isRecurring();
|
||||
return retVal;
|
||||
function convertEvent (event) {
|
||||
const retVal = {}
|
||||
retVal.start = event.startDate.toString()
|
||||
retVal.end = event.endDate.toString()
|
||||
retVal.summary = event.summary || ''
|
||||
retVal.description = event.description || ''
|
||||
retVal.attendees = event.attendees
|
||||
retVal.duration = event.duration
|
||||
retVal.location = event.location || ''
|
||||
retVal.organizer = event.organizer || ''
|
||||
retVal.uid = event.uid || ''
|
||||
retVal.isRecurring = event.isRecurring()
|
||||
return retVal
|
||||
}
|
||||
}
|
||||
RED.nodes.registerType('nextcloud-caldav', NextcloudCalDav)
|
||||
|
||||
|
||||
function NextcloudCardDav(n) {
|
||||
function NextcloudCardDav (n) {
|
||||
RED.nodes.createNode(this, n)
|
||||
this.server = RED.nodes.getNode(n.server)
|
||||
this.addressBook = n.addressBook
|
||||
let node = this
|
||||
const node = this
|
||||
|
||||
node.on('input', function (msg) {
|
||||
node.on('input', (msg) => {
|
||||
const xhr = new dav.transport.Basic(
|
||||
new dav.Credentials({
|
||||
username: node.server.credentials.user,
|
||||
@@ -142,19 +140,17 @@ module.exports = function (RED) {
|
||||
}, function () {
|
||||
node.error('Nextcloud:CardDAV -> get addressBooks went wrong.')
|
||||
})
|
||||
|
||||
})
|
||||
}
|
||||
RED.nodes.registerType('nextcloud-carddav', NextcloudCardDav)
|
||||
|
||||
|
||||
function NextcloudWebDavList(n) {
|
||||
function NextcloudWebDavList (n) {
|
||||
RED.nodes.createNode(this, n)
|
||||
this.server = RED.nodes.getNode(n.server)
|
||||
this.directory = n.directory
|
||||
let node = this
|
||||
const node = this
|
||||
|
||||
node.on('input', function (msg) {
|
||||
node.on('input', (msg) => {
|
||||
const webDavUri = node.server.address + '/remote.php/webdav/'
|
||||
const client = webdav(webDavUri, node.server.credentials.user, node.server.credentials.pass)
|
||||
let directory = ''
|
||||
@@ -175,14 +171,13 @@ module.exports = function (RED) {
|
||||
}
|
||||
RED.nodes.registerType('nextcloud-webdav-list', NextcloudWebDavList)
|
||||
|
||||
|
||||
function NextcloudWebDavOut(n) {
|
||||
function NextcloudWebDavOut (n) {
|
||||
RED.nodes.createNode(this, n)
|
||||
this.server = RED.nodes.getNode(n.server)
|
||||
this.filename = n.filename
|
||||
let node = this
|
||||
const node = this
|
||||
|
||||
node.on('input', function (msg) {
|
||||
node.on('input', (msg) => {
|
||||
const webDavUri = node.server.address + '/remote.php/webdav/'
|
||||
const client = webdav(webDavUri, node.server.credentials.user, node.server.credentials.pass)
|
||||
let filename = ''
|
||||
@@ -206,22 +201,21 @@ module.exports = function (RED) {
|
||||
}
|
||||
RED.nodes.registerType('nextcloud-webdav-out', NextcloudWebDavOut)
|
||||
|
||||
|
||||
function NextcloudWebDavIn(n) {
|
||||
function NextcloudWebDavIn (n) {
|
||||
RED.nodes.createNode(this, n)
|
||||
this.server = RED.nodes.getNode(n.server)
|
||||
this.directory = n.directory
|
||||
this.filename = n.filename
|
||||
let node = this
|
||||
const node = this
|
||||
|
||||
node.on('input', function (msg) {
|
||||
node.on('input', (msg) => {
|
||||
// Read upload file
|
||||
let filename = node.filename
|
||||
if (msg.filename) {
|
||||
filename = msg.filename
|
||||
}
|
||||
const name = filename.substr((filename.lastIndexOf('/') + 1), filename.length)
|
||||
const file = fs.readFileSync(filename);
|
||||
const file = fs.readFileSync(filename)
|
||||
// Set upload directory
|
||||
let directory = '/'
|
||||
if (msg.directory) {
|
||||
|
||||
@@ -22,7 +22,14 @@
|
||||
"moment": "^2.22.2",
|
||||
"webdav": "^1.5.2"
|
||||
},
|
||||
"devDependencies": {},
|
||||
"devDependencies": {
|
||||
"eslint": "^5.6.0",
|
||||
"eslint-config-standard": "^12.0.0",
|
||||
"eslint-plugin-import": "^2.14.0",
|
||||
"eslint-plugin-node": "^7.0.1",
|
||||
"eslint-plugin-promise": "^4.0.1",
|
||||
"eslint-plugin-standard": "^4.0.0"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user