Skip to content

Commit

Permalink
chore: lint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
hawkeye64 committed Jul 16, 2019
1 parent 09e6398 commit 2e19b8f
Show file tree
Hide file tree
Showing 39 changed files with 607 additions and 607 deletions.
116 changes: 58 additions & 58 deletions lib/camera.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,146 +77,146 @@ class Camera {
switch (name) {
case 'access':
if (!this.access) {
let Access = require('./modules/access')
const Access = require('./modules/access')
this.access = new Access()
}
break
case 'accessrules':
if (!this.accessrules) {
let AccessRules = require('./modules/accessrules')
const AccessRules = require('./modules/accessrules')
this.accessrules = new AccessRules()
}
break
case 'action':
if (!this.action) {
let Action = require('./modules/action')
const Action = require('./modules/action')
this.action = new Action()
}
break
case 'analytics':
if (!this.analytics) {
let Analytics = require('./modules/analytics')
const Analytics = require('./modules/analytics')
this.analytics = new Analytics()
}
break
case 'core':
if (!this.core) {
let Core = require('./modules/core')
const Core = require('./modules/core')
this.core = new Core()
this.core.init(this.serviceAddress, this.username, this.password)
}
break
case 'credential':
if (!this.credential) {
let Credential = require('./modules/credential')
const Credential = require('./modules/credential')
this.credential = new Credential()
}
break
case 'deviceio':
if (!this.deviceio) {
let DeviceIO = require('./modules/deviceio')
const DeviceIO = require('./modules/deviceio')
this.deviceio = new DeviceIO()
}
break
case 'display':
if (!this.display) {
let Display = require('./modules/display')
const Display = require('./modules/display')
this.display = new Display()
}
break
case 'door':
if (!this.door) {
let Door = require('./modules/door')
const Door = require('./modules/door')
this.door = new Door()
}
break
case 'events':
if (!this.events) {
let Events = require('./modules/events')
const Events = require('./modules/events')
this.events = new Events()
}
break
case 'imaging':
if (!this.imaging) {
let Imaging = require('./modules/imaging')
const Imaging = require('./modules/imaging')
this.imaging = new Imaging()
}
break
case 'media':
if (!this.media) {
let Media = require('./modules/media')
const Media = require('./modules/media')
this.media = new Media()
this.media.init(this.timeDiff, this.serviceAddress, this.username, this.password)
}
break
case 'media2':
if (!this.media2) {
let Media2 = require('./modules/media2')
const Media2 = require('./modules/media2')
this.media2 = new Media2()
}
break
case 'ptz':
if (!this.ptz) {
let Ptz = require('./modules/ptz')
const Ptz = require('./modules/ptz')
this.ptz = new Ptz()
}
break
case 'receiver':
if (!this.receiver) {
let Receiver = require('./modules/receiver')
const Receiver = require('./modules/receiver')
this.receiver = new Receiver()
}
break
case 'recording':
if (!this.recording) {
let Recording = require('./modules/recording')
const Recording = require('./modules/recording')
this.recording = new Recording()
}
break
case 'replay':
if (!this.replay) {
let Replay = require('./modules/replay')
const Replay = require('./modules/replay')
this.replay = new Replay()
}
break
case 'schedule':
if (!this.schedule) {
let Schedule = require('./modules/schedule')
const Schedule = require('./modules/schedule')
this.schedule = new Schedule()
}
break
case 'search':
if (!this.search) {
let Search = require('./modules/search')
const Search = require('./modules/search')
this.search = new Search()
}
break
case 'security':
if (!this.security) {
let Security = require('./modules/security')
const Security = require('./modules/security')
this.security = new Security()
}
break
case 'snapshot':
if (!this.snapshot) {
let Snapshot = require('./utils/snapshot')
const Snapshot = require('./utils/snapshot')
this.snapshot = new Snapshot()
let defaultProfile = this.getDefaultProfile()
const defaultProfile = this.getDefaultProfile()
if (defaultProfile) {
let snapshotUri = defaultProfile.SnapshotUri.Uri
const snapshotUri = defaultProfile.SnapshotUri.Uri
this.snapshot.init(snapshotUri, this.username, this.password)
}
}
break
case 'thermal':
if (!this.thermal) {
let Thermal = require('./modules/thermal')
const Thermal = require('./modules/thermal')
this.thermal = new Thermal()
}
break
case 'videoanalytics':
if (!this.videoanalytics) {
let VideoAnalytics = require('./modules/videoanalytics')
const VideoAnalytics = require('./modules/videoanalytics')
this.videoanalytics = new VideoAnalytics()
}
break
Expand Down Expand Up @@ -290,7 +290,7 @@ class Camera {
return this.coreGetScopes()
})
.then(() => {
let info = this.getInformation()
const info = this.getInformation()
resolve(info)
})
.catch(error => {
Expand Down Expand Up @@ -323,7 +323,7 @@ class Camera {
* Returns the ONVIF device's informaton. Available after connection.
*/
getInformation () {
let o = this.deviceInformation
const o = this.deviceInformation
if (o) {
return JSON.parse(JSON.stringify(o))
}
Expand Down Expand Up @@ -357,16 +357,16 @@ class Camera {
return new Promise((resolve, reject) => {
this.core.getServices(true)
.then(results => {
let response = results.data.GetServicesResponse
let services = response.Service
const response = results.data.GetServicesResponse
const services = response.Service

// the appropriate modules will be automatically added
// to camera based on the onvif device's services.
// if GetServics is not supported, the GetCapabilities
// fallback will be used.
services.forEach(service => {
this.checkForProxy(service)
let namespace = service.Namespace
const namespace = service.Namespace
if (namespace === 'http://www.onvif.org/ver10/device/wsdl') {
this.core.version = service.Version
}
Expand Down Expand Up @@ -428,7 +428,7 @@ class Camera {
// if not, then we may be behind a proxy and it needs
// do be dealt with
checkForProxy (service) {
let xaddrPath = new URL(service.XAddr)
const xaddrPath = new URL(service.XAddr)
if (xaddrPath.hostname === this.serviceAddress.hostname) {
// no proxy
return
Expand All @@ -442,21 +442,21 @@ class Camera {
return new Promise((resolve, reject) => {
this.core.getCapabilities()
.then(results => {
let c = results['data']['GetCapabilitiesResponse']['Capabilities']
const c = results['data']['GetCapabilitiesResponse']['Capabilities']
if (!c) {
reject(new Error('Failed to initialize the device: No capabilities were found.'))
return
}
// the appropriate modules will be automatically added
// to camera based on the onvif device's capabilities.
if ('Analytics' in c) {
let analytics = c['Analytics']
const analytics = c['Analytics']
this.checkForProxy(analytics)
if (analytics && 'XAddr' in analytics) {
if (!this.analytics) {
this.add('analytics')
if (this.analytics) {
let serviceAddress = new URL(analytics['XAddr'])
const serviceAddress = new URL(analytics['XAddr'])
this.analytics.init(this.timeDiff, serviceAddress, this.username, this.password)
}
}
Expand All @@ -471,13 +471,13 @@ class Camera {
}
}
if ('Events' in c) {
let events = c['Events']
const events = c['Events']
this.checkForProxy(events)
if (events && 'XAddr' in events) {
if (!this.events) {
this.add('events')
if (this.events) {
let serviceAddress = new URL(events['XAddr'])
const serviceAddress = new URL(events['XAddr'])
this.events.init(this.timeDiff, serviceAddress, this.username, this.password)
}
}
Expand All @@ -492,39 +492,39 @@ class Camera {
}
}
if ('Imaging' in c) {
let imaging = c['Imaging']
const imaging = c['Imaging']
this.checkForProxy(imaging)
if (imaging && 'XAddr' in imaging) {
if (!this.imaging) {
this.add('imaging')
if (this.imaging) {
let serviceAddress = new URL(imaging['XAddr'])
const serviceAddress = new URL(imaging['XAddr'])
this.imaging.init(this.timeDiff, serviceAddress, this.username, this.password)
}
}
}
}
if ('Media' in c) {
let media = c['Media']
const media = c['Media']
this.checkForProxy(media)
if (media && 'XAddr' in media) {
if (!this.media) {
this.add('media')
if (this.media) {
let serviceAddress = new URL(media['XAddr'])
const serviceAddress = new URL(media['XAddr'])
this.media.init(this.timeDiff, serviceAddress, this.username, this.password)
}
}
}
}
if ('PTZ' in c) {
let ptz = c['PTZ']
const ptz = c['PTZ']
this.checkForProxy(ptz)
if (ptz && 'XAddr' in ptz) {
if (!this.ptz) {
this.add('ptz')
if (this.ptz) {
let serviceAddress = new URL(ptz['XAddr'])
const serviceAddress = new URL(ptz['XAddr'])
this.ptz.init(this.timeDiff, serviceAddress, this.username, this.password)
}
}
Expand Down Expand Up @@ -557,12 +557,12 @@ class Camera {
return new Promise((resolve, reject) => {
this.core.getScopes()
.then(results => {
let scopes = results['data']['GetScopesResponse']['Scopes']
const scopes = results['data']['GetScopesResponse']['Scopes']
this.deviceInformation.Ptz = false
scopes.forEach((scope) => {
let s = scope['ScopeItem']
const s = scope['ScopeItem']
if (s.indexOf('onvif://www.onvif.org/hardware/') === 0) {
let hardware = s.split('/').pop()
const hardware = s.split('/').pop()
this.deviceInformation.Hardware = hardware
}
else if (s.indexOf('onvif://www.onvif.org/type/Streaming') === 0) {
Expand Down Expand Up @@ -596,11 +596,11 @@ class Camera {
this.deviceInformation.ProfileT = true
}
else if (s.indexOf('onvif://www.onvif.org/location/country/') === 0) {
let country = s.split('/').pop()
const country = s.split('/').pop()
this.deviceInformation.Country = country
}
else if (s.indexOf('onvif://www.onvif.org/location/city/') === 0) {
let city = s.split('/').pop()
const city = s.split('/').pop()
this.deviceInformation.City = city
}
else if (s.indexOf('onvif://www.onvif.org/name/') === 0) {
Expand All @@ -623,12 +623,12 @@ class Camera {
return new Promise((resolve, reject) => {
this.media.getProfiles()
.then(results => {
let profiles = results['data']['GetProfilesResponse']['Profiles']
const profiles = results['data']['GetProfilesResponse']['Profiles']
if (!profiles) {
reject(new Error('Failed to initialize the device: The targeted device does not any media profiles.'))
return
}
let profileList = this.parseProfiles(profiles)
const profileList = this.parseProfiles(profiles)
this.profileList = this.profileList.concat(profileList)
resolve()
})
Expand All @@ -640,7 +640,7 @@ class Camera {
}

parseProfiles (profiles) {
let profileList = []
const profileList = []

profiles.forEach((profile) => {
profileList.push(profile)
Expand All @@ -665,15 +665,15 @@ class Camera {

mediaGetStreamURI () {
return new Promise((resolve, reject) => {
let protocols = ['UDP', 'HTTP', 'RTSP']
const protocols = ['UDP', 'HTTP', 'RTSP']
let profileIndex = 0
let protocolIndex = 0
let getStreamUri = () => {
let profile = this.profileList[profileIndex]
const getStreamUri = () => {
const profile = this.profileList[profileIndex]
if (profile) {
let protocol = protocols[protocolIndex]
const protocol = protocols[protocolIndex]
if (protocol) {
let token = profile['$']['token']
const token = profile['$']['token']
this.media.getStreamUri('RTP-Unicast', protocol, token)
.then(results => {
profile.StreamUri = results['data']['GetStreamUriResponse']['MediaUri']
Expand Down Expand Up @@ -703,14 +703,14 @@ class Camera {
mediaGetSnapshotUri () {
return new Promise((resolve, reject) => {
let profileIndex = 0
let getSnapshotUri = () => {
let profile = this.profileList[profileIndex]
const getSnapshotUri = () => {
const profile = this.profileList[profileIndex]
if (profile) {
// this.media.getSnapshotUri(profile['token'])
this.media.getSnapshotUri(profile['$']['token'])
.then(results => {
try {
let service = {}
const service = {}
service.XAddr = results['data']['GetSnapshotUriResponse']['MediaUri']['Uri']
this.checkForProxy(service)
profile.SnapshotUri = results['data']['GetSnapshotUriResponse']['MediaUri']
Expand Down
Loading

0 comments on commit 2e19b8f

Please sign in to comment.