mirror of
https://github.com/DeviceFarmer/stf.git
synced 2026-04-27 11:15:13 +02:00
Added support for switching charsets from the keyboard by pressing SHIFT+SPACE.
This commit is contained in:
@@ -1,11 +1,15 @@
|
||||
module.exports = function ControlPanesController($scope, $http, gettext, $routeParams, $timeout, $location, DeviceService, GroupService, ControlService, StorageService, FatalMessageService) {
|
||||
var sharedTabs = [
|
||||
{
|
||||
title: gettext('Screenshots'),
|
||||
icon: 'fa-camera',
|
||||
templateUrl: 'control-panes/screenshots/screenshots.jade',
|
||||
filters: ['native', 'web']
|
||||
},
|
||||
module.exports =
|
||||
function ControlPanesController($scope, $http, gettext, $routeParams,
|
||||
$timeout, $location, DeviceService, GroupService, ControlService,
|
||||
StorageService, FatalMessageService, hotkeys) {
|
||||
|
||||
var sharedTabs = [
|
||||
{
|
||||
title: gettext('Screenshots'),
|
||||
icon: 'fa-camera',
|
||||
templateUrl: 'control-panes/screenshots/screenshots.jade',
|
||||
filters: ['native', 'web']
|
||||
},
|
||||
// {
|
||||
// title: gettext('Inspect'),
|
||||
// icon: 'fa-pencil',
|
||||
@@ -24,157 +28,173 @@ module.exports = function ControlPanesController($scope, $http, gettext, $routeP
|
||||
// templateUrl: 'control-panes/cpu/cpu.jade',
|
||||
// filters: ['native', 'web']
|
||||
// },
|
||||
{
|
||||
title: gettext('Advanced'),
|
||||
icon: 'fa-bolt',
|
||||
templateUrl: 'control-panes/advanced/advanced.jade',
|
||||
filters: ['native', 'web']
|
||||
}
|
||||
]
|
||||
|
||||
$scope.topTabs = [
|
||||
{
|
||||
title: gettext('Dashboard'),
|
||||
icon: 'fa-dashboard fa-fw',
|
||||
templateUrl: 'control-panes/dashboard/dashboard.jade',
|
||||
filters: ['native', 'web']
|
||||
}
|
||||
].concat(angular.copy(sharedTabs), [
|
||||
{
|
||||
title: gettext('Info'),
|
||||
icon: 'fa-info',
|
||||
templateUrl: 'control-panes/info/info.jade',
|
||||
title: gettext('Advanced'),
|
||||
icon: 'fa-bolt',
|
||||
templateUrl: 'control-panes/advanced/advanced.jade',
|
||||
filters: ['native', 'web']
|
||||
}
|
||||
])
|
||||
]
|
||||
|
||||
$scope.topTabs = [
|
||||
{
|
||||
title: gettext('Dashboard'),
|
||||
icon: 'fa-dashboard fa-fw',
|
||||
templateUrl: 'control-panes/dashboard/dashboard.jade',
|
||||
filters: ['native', 'web']
|
||||
}
|
||||
].concat(angular.copy(sharedTabs), [
|
||||
{
|
||||
title: gettext('Info'),
|
||||
icon: 'fa-info',
|
||||
templateUrl: 'control-panes/info/info.jade',
|
||||
filters: ['native', 'web']
|
||||
}
|
||||
])
|
||||
|
||||
|
||||
$scope.belowTabs = [
|
||||
$scope.belowTabs = [
|
||||
// {
|
||||
// title: gettext('Activity'),
|
||||
// icon: 'fa-clock-o',
|
||||
// templateUrl: 'control-panes/activity/activity.jade',
|
||||
// filters: ['native', 'web']
|
||||
// },
|
||||
{
|
||||
title: gettext('Logs'),
|
||||
icon: 'fa-list-alt',
|
||||
templateUrl: 'control-panes/logs/logs.jade',
|
||||
filters: ['native', 'web']
|
||||
}
|
||||
].concat(angular.copy(sharedTabs))
|
||||
|
||||
$scope.device = null
|
||||
$scope.control = null
|
||||
|
||||
// @TODO Find a way to reuse this in the upload controller (or the other
|
||||
// way around)
|
||||
$scope.installFileForced = function ($files) {
|
||||
$scope.$apply(function () {
|
||||
$scope.upload = {
|
||||
progress: 0, lastData: 'uploading'
|
||||
{
|
||||
title: gettext('Logs'),
|
||||
icon: 'fa-list-alt',
|
||||
templateUrl: 'control-panes/logs/logs.jade',
|
||||
filters: ['native', 'web']
|
||||
}
|
||||
})
|
||||
].concat(angular.copy(sharedTabs))
|
||||
|
||||
return StorageService.storeFile('apk', $files, {
|
||||
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'
|
||||
}
|
||||
})
|
||||
$scope.device = null
|
||||
$scope.control = null
|
||||
|
||||
// @TODO Find a way to reuse this in the upload controller (or the other
|
||||
// way around)
|
||||
$scope.installFileForced = function ($files) {
|
||||
$scope.$apply(function () {
|
||||
$scope.upload = {
|
||||
progress: 0, lastData: 'uploading'
|
||||
}
|
||||
})
|
||||
.then(function (res) {
|
||||
$scope.$apply(function () {
|
||||
$scope.upload = {
|
||||
progress: 100, lastData: 'processing'
|
||||
|
||||
return StorageService.storeFile('apk', $files, {
|
||||
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'
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
var href = res.data.resources.file0.href
|
||||
return $http.get(href + '/manifest')
|
||||
.then(function (res) {
|
||||
.then(function (res) {
|
||||
$scope.$apply(function () {
|
||||
$scope.upload = {
|
||||
progress: 100, lastData: 'success', settled: true
|
||||
}
|
||||
|
||||
if (res.data.success) {
|
||||
return $scope.installForced({
|
||||
href: href, launch: true, manifest: res.data.manifest
|
||||
})
|
||||
progress: 100, lastData: 'processing'
|
||||
}
|
||||
})
|
||||
})
|
||||
.catch(function (err) {
|
||||
$scope.$apply(function () {
|
||||
if (err.code === 'no_input_files') {
|
||||
$scope.upload = null
|
||||
}
|
||||
else {
|
||||
console.log('Upload error', err)
|
||||
$scope.upload = {
|
||||
progress: 100, lastData: 'fail', settled: true, error: err.message
|
||||
|
||||
var href = res.data.resources.file0.href
|
||||
return $http.get(href + '/manifest')
|
||||
.then(function (res) {
|
||||
$scope.upload = {
|
||||
progress: 100, lastData: 'success', settled: true
|
||||
}
|
||||
|
||||
if (res.data.success) {
|
||||
return $scope.installForced({
|
||||
href: href, launch: true, manifest: res.data.manifest
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
.catch(function (err) {
|
||||
$scope.$apply(function () {
|
||||
if (err.code === 'no_input_files') {
|
||||
$scope.upload = null
|
||||
}
|
||||
}
|
||||
else {
|
||||
console.log('Upload error', err)
|
||||
$scope.upload = {
|
||||
progress: 100, lastData: 'fail', settled: true, error: err.message
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
$scope.installForced = function (options) {
|
||||
return $scope.control.install(options)
|
||||
.progressed(function (installResult) {
|
||||
$scope.$apply(function () {
|
||||
installResult.manifest = options.manifest
|
||||
$scope.installation = installResult
|
||||
})
|
||||
})
|
||||
.then(function (installResult) {
|
||||
$scope.$apply(function () {
|
||||
installResult.manifest = options.manifest
|
||||
$scope.treeData = installResult.manifest
|
||||
$scope.installation = installResult
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
DeviceService.get($routeParams.serial, $scope)
|
||||
.then(function (device) {
|
||||
return GroupService.invite(device)
|
||||
})
|
||||
.then(function (device) {
|
||||
$scope.device = device
|
||||
$scope.control = ControlService.create(device, device.channel)
|
||||
|
||||
//FatalMessageService.open($scope.device)
|
||||
|
||||
return device
|
||||
})
|
||||
.catch(function () {
|
||||
$timeout(function () {
|
||||
$location.path('/')
|
||||
})
|
||||
})
|
||||
|
||||
// TODO: WHAT???
|
||||
//$scope.$watch('device')
|
||||
|
||||
|
||||
|
||||
|
||||
$scope.$watch('device.state', function (newValue, oldValue) {
|
||||
|
||||
if (newValue !== oldValue) {
|
||||
if (oldValue === 'using') {
|
||||
FatalMessageService.open($scope.device)
|
||||
}
|
||||
} else if (typeof newValue === 'undefined' && typeof oldValue === 'undefined') {
|
||||
//FatalMessageService.open(angular.copy($scope.device))
|
||||
}
|
||||
}, true)
|
||||
}
|
||||
|
||||
$scope.installForced = function (options) {
|
||||
return $scope.control.install(options)
|
||||
.progressed(function (installResult) {
|
||||
$scope.$apply(function () {
|
||||
installResult.manifest = options.manifest
|
||||
$scope.installation = installResult
|
||||
})
|
||||
})
|
||||
.then(function (installResult) {
|
||||
$scope.$apply(function () {
|
||||
installResult.manifest = options.manifest
|
||||
$scope.treeData = installResult.manifest
|
||||
$scope.installation = installResult
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
DeviceService.get($routeParams.serial, $scope)
|
||||
.then(function (device) {
|
||||
return GroupService.invite(device)
|
||||
})
|
||||
.then(function (device) {
|
||||
$scope.device = device
|
||||
$scope.control = ControlService.create(device, device.channel)
|
||||
|
||||
//FatalMessageService.open($scope.device)
|
||||
|
||||
return device
|
||||
})
|
||||
.catch(function () {
|
||||
$timeout(function () {
|
||||
$location.path('/')
|
||||
})
|
||||
})
|
||||
|
||||
// TODO: WHAT???
|
||||
//$scope.$watch('device')
|
||||
|
||||
|
||||
$scope.$watch('device.state', function (newValue, oldValue) {
|
||||
if (newValue !== oldValue) {
|
||||
if (oldValue === 'using') {
|
||||
FatalMessageService.open($scope.device)
|
||||
}
|
||||
} else if (typeof newValue === 'undefined' &&
|
||||
typeof oldValue === 'undefined') {
|
||||
//FatalMessageService.open(angular.copy($scope.device))
|
||||
}
|
||||
}, true)
|
||||
|
||||
|
||||
function switchDeviceCharset() {
|
||||
$scope.control.keyPress('switch_charset')
|
||||
console.log('Switching charset')
|
||||
}
|
||||
|
||||
hotkeys.add({
|
||||
combo: 'shift+space',
|
||||
description: 'Selects next IME in the device',
|
||||
allowIn: ['textarea'],
|
||||
callback: function (event) {
|
||||
event.preventDefault()
|
||||
switchDeviceCharset()
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user