diff --git a/lib/roles/device/plugins/screenshot.js b/lib/roles/device/plugins/screenshot.js index 1dd2e97a..533db64f 100644 --- a/lib/roles/device/plugins/screenshot.js +++ b/lib/roles/device/plugins/screenshot.js @@ -47,10 +47,10 @@ module.exports = syrup.serial() router.on(wire.ScreenCaptureMessage, function(channel) { var reply = wireutil.reply(options.serial) plugin.capture() - .then(function(url) { + .then(function(file) { push.send([ channel - , reply.okay(url) + , reply.okay('success', file) ]) }) .catch(function(err) { diff --git a/lib/roles/device/support/storage.js b/lib/roles/device/support/storage.js index 7009222b..492ea996 100644 --- a/lib/roles/device/support/storage.js +++ b/lib/roles/device/support/storage.js @@ -32,7 +32,7 @@ module.exports = syrup.serial() else { try { var result = JSON.parse(body) - log.info('Uploaded to %s', result.resources.file) + log.info('Uploaded to %s', result.resources.file.url) resolver.resolve(result.resources.file) } catch (err) { diff --git a/lib/roles/storage/temp.js b/lib/roles/storage/temp.js index 2454793e..297bf3e4 100644 --- a/lib/roles/storage/temp.js +++ b/lib/roles/storage/temp.js @@ -43,15 +43,18 @@ module.exports = function(options) { , resources: (function() { var mapped = Object.create(null) storedFiles.forEach(function(file) { - mapped[file.field] = util.format( - 'http://%s:%s/api/v1/resources/%s%s' - , options.publicIp - , options.port - , file.id - , file.name - ? util.format('/%s', path.basename(file.name)) - : '' - ) + mapped[file.field] = { + date: new Date() + , url: util.format( + 'http://%s:%s/api/v1/resources/%s%s' + , options.publicIp + , options.port + , file.id + , file.name + ? util.format('/%s', path.basename(file.name)) + : '' + ) + } }) return mapped })() diff --git a/res/app/control-panes/screenshots/screenshots-controller.js b/res/app/control-panes/screenshots/screenshots-controller.js index 71b51eef..18f7aa74 100644 --- a/res/app/control-panes/screenshots/screenshots-controller.js +++ b/res/app/control-panes/screenshots/screenshots-controller.js @@ -1,3 +1,31 @@ -module.exports = function ScreenshotsCtrl($scope) { - +module.exports = function ScreenshotsCtrl($scope, SettingsService) { + $scope.screenshots = [] + $scope.shotSize = 'original' + + $scope.clear = function () { + $scope.screenshots = [] + } + + SettingsService.bind($scope, { + key: 'shotSize' + , storeName: 'ScreenShots.shotSize' + }) + + $scope.shotSizeUrlParameter = function () { + var sizes = { + 'small': '?crop=100x', + 'medium': '?crop=320x', + 'large': '?crop=450x', + 'original': '' + } + return sizes[$scope.shotSize] + } + + $scope.takeScreenShot = function () { + $scope.control.screenshot().then(function(result) { + $scope.$apply(function() { + $scope.screenshots.push(result) + }) + }) + } } diff --git a/res/app/control-panes/screenshots/screenshots.jade b/res/app/control-panes/screenshots/screenshots.jade index aff7c630..74935255 100644 --- a/res/app/control-panes/screenshots/screenshots.jade +++ b/res/app/control-panes/screenshots/screenshots.jade @@ -24,9 +24,8 @@ nothing-to-show(message='{{"No screenshots taken"|translate}}', icon='fa-camera', ng-show='!screenshots.length') ul.screenshots-icon-view.clear-fix li(ng-repeat='shot in screenshots').cursor-select - h4 {{ shot.device.capabilities.info.name.id || shot.device.capabilities.model }} - h5 {{ shot.value.date | date:'yyyy/MM/dd HH:mm:ss' }} - a(ng-href='{{ shot.value.screenshotUrl }}', target='_blank') - img(ng-src='{{ shot.value.screenshotUrl + shotSizeUrlParameter() }}') + h5 {{ shot.body.date | date:'yyyy/MM/dd HH:mm:ss' }} + a(ng-href='{{ shot.body.url }}', target='_blank') + img(ng-src='{{ shot.body.url + shotSizeUrlParameter() }}') - .clearfix \ No newline at end of file + .clearfix