mirror of
https://github.com/DeviceFarmer/stf.git
synced 2026-04-20 00:53:26 +02:00
Merge branch 'feature/screenshot' into develop
Conflicts: res/app/control-panes/dashboard/upload/upload.jade
This commit is contained in:
@@ -111,49 +111,8 @@ module.exports = function ControlServiceFactory(
|
||||
return sendTwoWay('device.identify')
|
||||
}
|
||||
|
||||
this.uploadUrl = function(url) {
|
||||
var tx = TransactionService.create({
|
||||
id: 'storage'
|
||||
})
|
||||
socket.emit('storage.upload', channel, tx.channel, {
|
||||
url: url
|
||||
})
|
||||
return tx.promise
|
||||
}
|
||||
|
||||
this.uploadFile = function(files) {
|
||||
if (files.length !== 1) {
|
||||
throw new Error('Can only upload one file')
|
||||
}
|
||||
var tx = TransactionService.create({
|
||||
id: 'storage'
|
||||
})
|
||||
TransactionService.punch(tx.channel)
|
||||
.then(function() {
|
||||
$upload.upload({
|
||||
url: '/api/v1/resources?channel=' + tx.channel
|
||||
, method: 'POST'
|
||||
, file: files[0]
|
||||
})
|
||||
})
|
||||
return tx.promise
|
||||
}
|
||||
|
||||
this.install = function(options) {
|
||||
var app = options.manifest.application
|
||||
var params = {
|
||||
url: options.url
|
||||
}
|
||||
if (app.launcherActivities.length) {
|
||||
var activity = app.launcherActivities[0]
|
||||
params.launchActivity = {
|
||||
action: 'android.intent.action.MAIN'
|
||||
, component: options.manifest.package + '/' + activity.name
|
||||
, category: ['android.intent.category.LAUNCHER']
|
||||
, flags: 0x10200000
|
||||
}
|
||||
}
|
||||
return sendTwoWay('device.install', params)
|
||||
return sendTwoWay('device.install', options)
|
||||
}
|
||||
|
||||
this.uninstall = function(pkg) {
|
||||
@@ -216,6 +175,10 @@ module.exports = function ControlServiceFactory(
|
||||
return sendTwoWay('store.open')
|
||||
}
|
||||
|
||||
this.screenshot = function() {
|
||||
return sendTwoWay('screen.capture')
|
||||
}
|
||||
|
||||
window.cc = this
|
||||
}
|
||||
|
||||
|
||||
@@ -3,3 +3,4 @@ module.exports = angular.module('stf/control', [
|
||||
])
|
||||
.factory('TransactionService', require('./transaction-service'))
|
||||
.factory('ControlService', require('./control-service'))
|
||||
.factory('StorageService', require('./storage-service'))
|
||||
|
||||
40
res/app/components/stf/control/storage-service.js
Normal file
40
res/app/components/stf/control/storage-service.js
Normal file
@@ -0,0 +1,40 @@
|
||||
var Promise = require('bluebird')
|
||||
|
||||
module.exports = function StorageServiceFactory($http, $upload) {
|
||||
var service = {}
|
||||
|
||||
service.storeUrl = function(type, url) {
|
||||
return $http({
|
||||
url: '/api/v1/s/' + type + '/download'
|
||||
, method: 'POST'
|
||||
, data: {
|
||||
url: url
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
service.storeFile = function(type, files) {
|
||||
var resolver = Promise.defer()
|
||||
|
||||
$upload.upload({
|
||||
url: '/api/v1/s/' + type
|
||||
, method: 'POST'
|
||||
, file: files
|
||||
})
|
||||
.then(
|
||||
function(value) {
|
||||
resolver.resolve(value)
|
||||
}
|
||||
, function(err) {
|
||||
resolver.reject(err)
|
||||
}
|
||||
, function(progressEvent) {
|
||||
resolver.progress(progressEvent)
|
||||
}
|
||||
)
|
||||
|
||||
return resolver.promise
|
||||
}
|
||||
|
||||
return service
|
||||
}
|
||||
Reference in New Issue
Block a user