mirror of
https://github.com/openstf/stf
synced 2025-10-05 10:39:25 +02:00
Refactored device context menu to its own directive.
Now works in standalone also.
This commit is contained in:
parent
f705cd60a7
commit
c81cd75a50
10 changed files with 86 additions and 30 deletions
|
@ -40,7 +40,8 @@
|
|||
"angular-borderlayout": "https://github.com/filearts/angular-borderlayout.git",
|
||||
"angular-ui-bootstrap": "~0.11.0",
|
||||
"angular-ladda": "~0.1.6",
|
||||
"ng-context-menu": "~1.0.0"
|
||||
"ng-context-menu": "~1.0.0",
|
||||
"stats.js": "*"
|
||||
},
|
||||
"private": true,
|
||||
"resolutions": {
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
module.exports = function deviceContextMenuDirective($window) {
|
||||
return {
|
||||
restrict: 'EA',
|
||||
replace: false,
|
||||
//scope: {
|
||||
// control: '&',
|
||||
// device: '&'
|
||||
//},
|
||||
transclude: true,
|
||||
template: require('./device-context-menu.jade'),
|
||||
link: function (scope, element, attrs) {
|
||||
//var device = scope.device()
|
||||
//var control = scope.control()
|
||||
scope.windowClose = function () {
|
||||
$window.close()
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
describe('deviceContextMenu', function () {
|
||||
|
||||
beforeEach(angular.mock.module(require('./').name))
|
||||
|
||||
var scope, compile
|
||||
|
||||
beforeEach(inject(function ($rootScope, $compile) {
|
||||
scope = $rootScope.$new()
|
||||
compile = $compile
|
||||
}))
|
||||
|
||||
it('should ...', function () {
|
||||
|
||||
/*
|
||||
To test your directive, you need to create some html that would use your directive,
|
||||
send that through compile() then compare the results.
|
||||
|
||||
var element = compile('<div device-context-menu name="name">hi</div>')(scope)
|
||||
expect(element.text()).toBe('hello, world')
|
||||
*/
|
||||
|
||||
})
|
||||
})
|
|
@ -0,0 +1,3 @@
|
|||
.stf-device-context-menu {
|
||||
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
.dropdown.context-menu(id='context-menu-{{ $index }}')
|
||||
ul.dropdown-menu(role='menu')
|
||||
li
|
||||
a.pointer(role='menuitem', ng-click='control.back(); $event.preventDefault()')
|
||||
i.fa.fa-mail-reply.fa-fw
|
||||
span(translate) Back
|
||||
li
|
||||
a.pointer(role='menuitem', ng-click='control.home(); $event.preventDefault()')
|
||||
i.fa.fa-home.fa-fw
|
||||
span(translate) Home
|
||||
li.divider
|
||||
li
|
||||
a.pointer(role='menuitem', ng-click='rotateRight(); $event.preventDefault()')
|
||||
i.fa.fa-rotate-left.fa-fw
|
||||
span(translate) Rotate Left
|
||||
li
|
||||
a.pointer(role='menuitem', ng-click='rotateLeft(); $event.preventDefault()')
|
||||
i.fa.fa-rotate-right.fa-fw
|
||||
span(translate) Rotate Right
|
||||
li.divider
|
||||
li
|
||||
a.pointer(role='menuitem', ng-click='$root.standalone ? windowClose() : kickDevice(device); $event.preventDefault()')
|
||||
i.fa.fa-sign-out.fa-fw
|
||||
span(translate) Stop Using
|
||||
|
||||
.stf-device-context-menu(ng-transclude, context-menu, data-target='context-menu-{{ $index }}').fill-height
|
6
res/app/components/stf/device-context-menu/index.js
Normal file
6
res/app/components/stf/device-context-menu/index.js
Normal file
|
@ -0,0 +1,6 @@
|
|||
require('./device-context-menu.css')
|
||||
|
||||
module.exports = angular.module('stf.device-context-menu', [
|
||||
require('ng-context-menu').name
|
||||
])
|
||||
.directive('deviceContextMenu', require('./device-context-menu-directive'))
|
|
@ -62,7 +62,7 @@ module.exports =
|
|||
'resizable=yes'
|
||||
].join(',')
|
||||
|
||||
var newWindow = $window.open(url, 'STFNewWindow' + Date.now(), features)
|
||||
var newWindow = $window.open(url, 'STF-' + device.serial, features)
|
||||
|
||||
newWindow.onbeforeunload = function () {
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
.interact-control.fill-height.stf-device-control(ng-controller='DeviceControlCtrl').fill-height.fill-width
|
||||
div(ng-controller='DeviceScreenCtrl', ng-if='device', ng-file-drop='installFile($files)', ng-file-drag-over-class='dragover').fill-height.fill-width
|
||||
device-screen(device='device', control='control').fill-height.fill-width
|
||||
device-context-menu(device='device', control='control')
|
||||
device-screen(device='device', control='control').fill-height.fill-width
|
||||
|
|
|
@ -37,34 +37,9 @@
|
|||
|
||||
.as-row.fill-height
|
||||
|
||||
.dropdown.context-menu(id='context-menu-{{ $index }}')
|
||||
ul.dropdown-menu(role='menu')
|
||||
li
|
||||
a.pointer(role='menuitem', ng-click='control.back(); $event.preventDefault()')
|
||||
i.fa.fa-mail-reply.fa-fw
|
||||
span(translate) Back
|
||||
li
|
||||
a.pointer(role='menuitem', ng-click='control.home(); $event.preventDefault()')
|
||||
i.fa.fa-home.fa-fw
|
||||
span(translate) Home
|
||||
li.divider
|
||||
li
|
||||
a.pointer(role='menuitem', ng-click='rotateRight(); $event.preventDefault()')
|
||||
i.fa.fa-rotate-left.fa-fw
|
||||
span(translate) Rotate Left
|
||||
li
|
||||
a.pointer(role='menuitem', ng-click='rotateLeft(); $event.preventDefault()')
|
||||
i.fa.fa-rotate-right.fa-fw
|
||||
span(translate) Rotate Right
|
||||
li.divider
|
||||
li
|
||||
a.pointer(role='menuitem', ng-click='kickDevice(device); $event.preventDefault()')
|
||||
i.fa.fa-sign-out.fa-fw
|
||||
span(translate) Stop Using
|
||||
|
||||
div(ng-controller='DeviceScreenCtrl', ng-if='device',
|
||||
ng-file-drop='installFile($files)', ng-file-drag-over-class='dragover').fill-height
|
||||
div(context-menu, data-target='context-menu-{{ $index }}').fill-height
|
||||
device-context-menu(device='device', control='control')
|
||||
device-screen(device='device', control='control')
|
||||
|
||||
.stf-vnc-bottom.as-row(ng-hide='$root.standalone')
|
||||
|
|
|
@ -4,7 +4,8 @@ module.exports = angular.module('device-control', [
|
|||
require('stf/device').name,
|
||||
require('stf/control').name,
|
||||
require('stf/screen').name,
|
||||
require('ng-context-menu').name
|
||||
require('ng-context-menu').name,
|
||||
require('stf/device-context-menu').name
|
||||
])
|
||||
.run(["$templateCache", function ($templateCache) {
|
||||
$templateCache.put('control-panes/device-control/device-control.jade',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue