1
0
Fork 0
mirror of https://github.com/openstf/stf synced 2025-10-05 10:39:25 +02:00

Fixed device redirect when not usable.

This commit is contained in:
Gunther Brunner 2014-05-29 02:27:08 +09:00
parent aa8f8fd999
commit 12fc884f78
10 changed files with 62 additions and 64 deletions

View file

@ -3,8 +3,9 @@
button(type='button', ng-click='cancel()').close ×
h4.modal-title.text-danger
i.fa.fa-warning
span(translate) Device was disconnected
.modal-body.text-danger(translate) Device is not in use anymore
.button-spacer
span(translate) Device was disconnected
.modal-body.text-danger(translate) You are no longer controlling the device.
.modal-footer
button.btn.btn-primary(type='button', ng-click='ok()')
i.fa.fa-refresh

View file

@ -1,4 +1,4 @@
module.exports = function FatalMessageServiceFactory($modal, $location) {
module.exports = function ServiceFactory($modal, $location) {
var service = {}
var ModalInstanceCtrl = function ($scope, $modalInstance) {

View file

@ -2,7 +2,7 @@ describe('VersionUpdateService', function() {
beforeEach(module('stf.version-update'));
it('should ...', inject(function(FatalMessageService) {
it('should ...', inject(function(VersionUpdateService) {
//expect(FatalMessageService.doSomething()).toEqual('something');

View file

@ -99,16 +99,16 @@ module.exports = function DeviceServiceFactory($http, socket) {
// For convenience, add the sorting priority to each state
function getStateSorting(state) {
return {
'using': 1,
'available': 2,
'ready': 3,
'present': 4,
'busy': 5,
'absent': 6,
'preparing': 7,
'unauthorized': 8,
'offline': 9
}[state] || 10
'using': 10,
'available': 9,
'ready': 8,
'present': 7,
'busy': 6,
'absent': 5,
'preparing': 4,
'unauthorized': 3,
'offline': 2
}[state] || 1
}
function get(data) {

View file

@ -1,3 +1,5 @@
var Promise = require('bluebird')
module.exports = function GroupServiceFactory(
socket
, TransactionService
@ -6,6 +8,10 @@ module.exports = function GroupServiceFactory(
}
groupService.invite = function (device) {
if (!device.usable) {
return Promise.reject(new Error('Device is not usable'))
}
var tx = TransactionService.create(device)
socket.emit('group.invite', device.channel, tx.channel, {
requirements: {
@ -24,6 +30,10 @@ module.exports = function GroupServiceFactory(
}
groupService.kick = function (device) {
if (!device.usable) {
return Promise.reject(new Error('Device is not usable'))
}
var tx = TransactionService.create(device)
socket.emit('group.kick', device.channel, tx.channel, {
requirements: {

View file

@ -1,15 +1,4 @@
module.exports = function ControlPanesController(
$scope
, $http
, gettext
, $routeParams
, $location
, DeviceService
, GroupService
, ControlService
, StorageService
, FatalMessageService
) {
module.exports = function ControlPanesController($scope, $http, gettext, $routeParams, $timeout, $location, DeviceService, GroupService, ControlService, StorageService, FatalMessageService) {
var sharedTabs = [
{
title: gettext('Screenshots'),
@ -83,53 +72,46 @@ module.exports = function ControlPanesController(
$scope.installFileForced = function ($files) {
$scope.$apply(function () {
$scope.upload = {
progress: 0
, lastData: 'uploading'
progress: 0, lastData: 'uploading'
}
})
return StorageService.storeFile('apk', $files, {
filter: function(file) {
return /\.apk$/i.test(file.name)
}
})
.progressed(function(e) {
filter: function (file) {
return /\.apk$/i.test(file.name)
}
})
.progressed(function (e) {
if (e.lengthComputable) {
$scope.$apply(function () {
$scope.upload = {
progress: e.loaded / e.total * 100
, lastData: 'uploading'
progress: e.loaded / e.total * 100, lastData: 'uploading'
}
})
}
})
.then(function(res) {
.then(function (res) {
$scope.$apply(function () {
$scope.upload = {
progress: 100
, lastData: 'processing'
progress: 100, lastData: 'processing'
}
})
var href = res.data.resources.file0.href
return $http.get(href + '/manifest')
.then(function(res) {
.then(function (res) {
$scope.upload = {
progress: 100
, lastData: 'success'
, settled: true
progress: 100, lastData: 'success', settled: true
}
if (res.data.success) {
return $scope.installForced({
href: href
, launch: true
, manifest: res.data.manifest
href: href, launch: true, manifest: res.data.manifest
})
}
})
})
.catch(function(err) {
.catch(function (err) {
$scope.$apply(function () {
if (err.code === 'no_input_files') {
$scope.upload = null
@ -137,10 +119,7 @@ module.exports = function ControlPanesController(
else {
console.log('Upload error', err)
$scope.upload = {
progress: 100
, lastData: 'fail'
, settled: true
, error: err.message
progress: 100, lastData: 'fail', settled: true, error: err.message
}
}
})
@ -175,17 +154,22 @@ module.exports = function ControlPanesController(
return device
})
.catch(function () {
$location.path('/')
$timeout(function () {
$location.path('/')
})
})
$scope.$watch('device')
$scope.$watch('device.state', function (newValue, oldValue) {
if (newValue !== oldValue) {
if (oldValue === 'using') {
FatalMessageService.open(angular.copy($scope.device))
} else {
}
} else if (typeof newValue === 'undefined' && typeof oldValue === 'undefined') {
//FatalMessageService.open(angular.copy($scope.device))
}
}, true)
}

View file

@ -30,7 +30,7 @@ module.exports = function DeviceListCtrlDetails($scope, DeviceService, GroupServ
// })
$scope.tableSorting = {
stateSorting: 'asc' // initial sorting
stateSorting: 'desc' // initial sorting
}
// SettingsService.bind($scope, {
// key: 'tableSorting',

View file

@ -235,13 +235,9 @@ msgstr "開発者向け設定"
msgid "Device"
msgstr "デバイス"
#: /Users/a12907/STF/stf/tmp/html/app/components/stf/common-ui/modals/fatal-message/fatal-message.html
msgid "Device is not in use anymore"
msgstr "実機が使われなくなりました"
#: /Users/a12907/STF/stf/tmp/html/app/components/stf/common-ui/modals/fatal-message/fatal-message.html
msgid "Device was disconnected"
msgstr "デバイスがオフラインになりました"
msgstr "デバイスへの接続が切れました"
#: /Users/a12907/STF/stf/tmp/html/app/device-list/device-list.html
msgid "Devices"
@ -1038,6 +1034,13 @@ msgstr "Y DPI"
msgid "Yes"
msgstr "はい"
#: /Users/a12907/STF/stf/tmp/html/app/components/stf/common-ui/modals/fatal-message/fatal-message.html
msgid "You are no longer controlling the device."
msgstr "この実機のリモート操作ができなくなりました。"
#~ msgid "Device is not in use anymore"
#~ msgstr "実機が使われなくなりました"
#~ msgid "Device Port"
#~ msgstr "端末側のポート"

View file

@ -231,10 +231,6 @@ msgstr ""
msgid "Device"
msgstr ""
#: /Users/a12907/STF/stf/tmp/html/app/components/stf/common-ui/modals/fatal-message/fatal-message.html
msgid "Device is not in use anymore"
msgstr ""
#: /Users/a12907/STF/stf/tmp/html/app/components/stf/common-ui/modals/fatal-message/fatal-message.html
msgid "Device was disconnected"
msgstr ""
@ -1026,3 +1022,7 @@ msgstr ""
#: /Users/a12907/STF/stf/res/app/components/stf/device/device-info-filter/index.js
msgid "Yes"
msgstr ""
#: /Users/a12907/STF/stf/tmp/html/app/components/stf/common-ui/modals/fatal-message/fatal-message.html
msgid "You are no longer controlling the device."
msgstr ""

File diff suppressed because one or more lines are too long