diff --git a/res/app/components/stf/device-context-menu/device-context-menu-directive.js b/res/app/components/stf/device-context-menu/device-context-menu-directive.js index 80e3e85b..f2995eb3 100644 --- a/res/app/components/stf/device-context-menu/device-context-menu-directive.js +++ b/res/app/components/stf/device-context-menu/device-context-menu-directive.js @@ -15,6 +15,35 @@ module.exports = function deviceContextMenuDirective($window) { $window.close() } + function saveToDisk(fileURL, fileName) { + // for non-IE + if (!window.ActiveXObject) { + var save = document.createElement('a') + save.href = fileURL + save.target = '_blank' + save.download = fileName || 'unknown' + + var event = document.createEvent('Event') + event.initEvent('click', true, true) + save.dispatchEvent(event) + (window.URL || window.webkitURL).revokeObjectURL(save.href) + } + + // for IE + else if (!!window.ActiveXObject && document.execCommand) { + var _window = window.open(fileURL, '_blank') + _window.document.close() + _window.document.execCommand('SaveAs', true, fileName || fileURL) + _window.close() + } + } + + scope.saveScreenShot = function () { + scope.control.screenshot().then(function (result) { + saveToDisk(result.body.href, result.body.name) + }) + } + } } } diff --git a/res/app/components/stf/device-context-menu/device-context-menu.jade b/res/app/components/stf/device-context-menu/device-context-menu.jade index 305c63a4..b9b8b321 100644 --- a/res/app/components/stf/device-context-menu/device-context-menu.jade +++ b/res/app/components/stf/device-context-menu/device-context-menu.jade @@ -18,6 +18,11 @@ i.fa.fa-rotate-right.fa-fw span(translate) Rotate Right li.divider + li + a.pointer(role='menuitem', ng-click='saveScreenShot(); $event.preventDefault()') + i.fa.fa-camera.fa-fw + span(translate) Save ScreenShot + li.divider li a.pointer(role='menuitem', ng-click='$root.standalone ? windowClose() : kickDevice(device); $event.preventDefault()') i.fa.fa-sign-out.fa-fw