Skip to content

Commit

Permalink
Merge pull request #976 from zebrunner/develop
Browse files Browse the repository at this point in the history
2.7.1
  • Loading branch information
vdelendik authored Jun 11, 2024
2 parents 7d19c1d + ed80244 commit 3379432
Show file tree
Hide file tree
Showing 9 changed files with 96 additions and 26 deletions.
48 changes: 44 additions & 4 deletions lib/units/ios-device/plugins/group.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,10 @@ module.exports = syrup.serial()
}

dbapi.loadDeviceBySerial(options.serial).then((device) => {
// No device version = First device session
if (!device.version) {
// No device size/type = First device session
if (!device.display.width || !device.display.height || !device.deviceType) {
// Get device type
let deviceType
handleRequest({
method: 'GET',
uri: `${baseUrl}/wda/device/info`,
Expand All @@ -83,12 +84,12 @@ module.exports = syrup.serial()
.then((deviceInfo) => {
let deviceInfoModel = deviceInfo.value.model.toLowerCase()
let deviceInfoName = deviceInfo.value.name.toLowerCase()
let deviceType
if (deviceInfoModel.includes("tv") || deviceInfoName.includes("tv")) {
deviceType = "Apple TV"
} else {
deviceType = "iPhone"
}
}
// Store device type
log.info('Storing device type value: ' + deviceType)
dbapi.setDeviceType(options.serial, deviceType)
})
Expand All @@ -107,6 +108,45 @@ module.exports = syrup.serial()
.then((sessionResponse) => {
let sessionId = sessionResponse.sessionId

// Store device version
log.info('Storing device version')
push.send([
wireutil.global,
wireutil.envelope(new wire.SdkIosVersion(
options.serial,
sessionResponse.value.capabilities.device,
sessionResponse.value.capabilities.sdkVersion,
))
])

// Store battery info
if (deviceType !== 'Apple TV') {
handleRequest({
method: 'GET',
uri: `${baseUrl}/session/${sessionId}/wda/batteryInfo`,
json: true,
})
.then((batteryInfoResponse) => {
let batteryState = iosutil.batteryState(batteryInfoResponse.value.state)
let batteryLevel = iosutil.batteryLevel(batteryInfoResponse.value.level)

push.send([
wireutil.global,
wireutil.envelope(new wire.BatteryIosEvent(
options.serial,
'good',
'usb',
batteryState,
batteryLevel,
'n/a',
100,
))
])
})
.catch((err) => log.error('Error storing battery', err))
}

// Store size info
return handleRequest({
method: 'GET',
uri: `${baseUrl}/session/${sessionId}/window/size`,
Expand Down
22 changes: 22 additions & 0 deletions lib/units/ios-device/plugins/util/iosutil.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,28 @@ let iosutil = {
},
getUri: function(host, port) {
return `http://${host}:${port}`
},
batteryState: function (state) {
switch (state) {
case 0:
return 'full'
case 1:
return 'unplugged'
case 2:
return 'charging'
case 3:
return 'full'
default:
break;
}
},
batteryLevel: function (level) {
switch (level) {
case -1:
return 100
default:
return parseInt(level * 100, 10)
}
}
}

Expand Down
21 changes: 10 additions & 11 deletions lib/units/ios-device/plugins/wda/WdaClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ module.exports = syrup.serial()
this.setStatus(3)
if (this.deviceType !== 'Apple TV') {
this.getOrientation()
this.batteryIosEvent()
}

this.setVersion(sessionResponse)
Expand Down Expand Up @@ -505,7 +506,7 @@ module.exports = syrup.serial()
})
},
setVersion: function(currentSession) {
log.info('Setting device version: ' + currentSession.value.capabilities.sdkVersion)
log.info('Setting current device version: ' + currentSession.value.capabilities.sdkVersion)

push.send([
wireutil.global,
Expand Down Expand Up @@ -592,27 +593,25 @@ module.exports = syrup.serial()
json: true,
})
.then((batteryInfoResponse) => {
let status = '-'

if (batteryInfoResponse.value.state === 3) {
status = 'full'
}
if (batteryInfoResponse.value.state === 2) {
status = 'charging'
}
let batteryState = iosutil.batteryState(batteryInfoResponse.value.state)
let batteryLevel = iosutil.batteryLevel(batteryInfoResponse.value.level)

push.send([
wireutil.global,
wireutil.envelope(new wire.BatteryIosEvent(
options.serial,
'good',
'usb',
status,
parseInt(batteryInfoResponse.value.level * 100, 10),
batteryState,
batteryLevel,
'n/a',
100,
))
])
})
.then(() => {
log.info('Setting new device battery info')
})
.catch((err) => log.info(err))
},
getTreeElements: function() {
Expand Down
4 changes: 2 additions & 2 deletions res/app/device-list/column/device-column-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -750,13 +750,13 @@ function DeviceNoteCell(options) {

i.className = 'device-note-edit fa fa-pencil pointer'

td.appendChild(span)
td.appendChild(i)
td.appendChild(span)

return td
}
, update: function(td, item) {
var span = td.firstChild
var span = td.children[1]
var t = span.firstChild

t.nodeValue = options.value(item)
Expand Down
10 changes: 5 additions & 5 deletions res/app/device-list/details/device-list-details-directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ module.exports = function DeviceListDetailsDirective(
var i = e.target
var id = i.parentNode.parentNode.id
var device = mapping[id]
var xeditableWrapper = i.parentNode.firstChild
var xeditableWrapper = i.parentNode.querySelector('.xeditable-wrapper')
var xeditableSpan = document.createElement('span')
var childScope = scope.$new()

Expand All @@ -134,11 +134,11 @@ module.exports = function DeviceListDetailsDirective(
for (var i = 0; i < tr.cells.length; i++) {
var col = tr.cells[i]

if (col.firstChild &&
col.firstChild.nodeName.toLowerCase() === 'span' &&
col.firstChild.classList.contains('xeditable-wrapper')) {
if (col.children[1] &&
col.children[1].nodeName.toLowerCase() === 'span' &&
col.children[1].classList.contains('xeditable-wrapper')) {

var xeditableWrapper = col.firstChild
var xeditableWrapper = col.children[1]
var children = xeditableWrapper.children

// Remove all childs under xeditablerWrapper
Expand Down
2 changes: 1 addition & 1 deletion res/app/device-list/device-list.css
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ img.device-icon-smallest {
}

.stf-device-list .device-note-edit {
margin-left: 15px;
margin-right: 15px;
visibility: hidden;
}

Expand Down
5 changes: 4 additions & 1 deletion res/auth/ldap/scripts/signin/signin.pug
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
.alert.alert-danger(ng-show='error')
span(ng-show='error.$invalid', translate) Check errors below
span(ng-show='error.$incorrect', translate) Incorrect login details
span(ng-show='error.$server', translate) Server error. Check log output.
span(ng-show='error.$server', translate)
| We do not recognize that username or password.
br
| Please check your spelling and try again or use another login option.

.form-group
.input-group
Expand Down
5 changes: 4 additions & 1 deletion res/auth/mock/scripts/signin/signin.pug
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
.alert.alert-danger(ng-show='error')
span(ng-show='error.$invalid', translate) Check errors below
span(ng-show='error.$incorrect', translate) Incorrect login details
span(ng-show='error.$server', translate) Server error. Check log output.
span(ng-show='error.$server', translate)
| We do not recognize that username or password.
br
| Please check your spelling and try again or use another login option.

.form-group
.input-group
Expand Down
5 changes: 4 additions & 1 deletion res/auth/zebrunner/scripts/signin/signin.pug
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
.alert.alert-danger(ng-show='error')
span(ng-show='error.$invalid', translate) Check errors below
span(ng-show='error.$incorrect', translate) Invalid credentials or user has been deactivated
span(ng-show='error.$server', translate) Server error. Check log output.
span(ng-show='error.$server', translate)
| We do not recognize that username or password.
br
| Please check your spelling and try again or use another login option.

.form-group
.input-group
Expand Down

0 comments on commit 3379432

Please sign in to comment.