diff --git a/res/app/components/stf/common-ui/index.js b/res/app/components/stf/common-ui/index.js index 9f8c3d2a..40b382a8 100644 --- a/res/app/components/stf/common-ui/index.js +++ b/res/app/components/stf/common-ui/index.js @@ -4,5 +4,6 @@ module.exports = angular.module('stf/common-ui', [ require('./filter-button').name, require('./nothing-to-show').name, require('./table').name, - require('./notifications').name + require('./notifications').name, + require('./ng-enter').name ]) \ No newline at end of file diff --git a/res/app/components/stf/common-ui/ng-enter/index.js b/res/app/components/stf/common-ui/ng-enter/index.js new file mode 100644 index 00000000..609d2b60 --- /dev/null +++ b/res/app/components/stf/common-ui/ng-enter/index.js @@ -0,0 +1,4 @@ +module.exports = angular.module('stf.ng-enter', [ + +]) + .directive('ngEnter', require('./ng-enter-directive')) diff --git a/res/app/components/stf/common-ui/ng-enter/ng-enter-directive.js b/res/app/components/stf/common-ui/ng-enter/ng-enter-directive.js new file mode 100644 index 00000000..276a31a2 --- /dev/null +++ b/res/app/components/stf/common-ui/ng-enter/ng-enter-directive.js @@ -0,0 +1,12 @@ +module.exports = function ngEnterDirective() { + return function (scope, element, attrs) { + element.bind("keydown keypress", function (event) { + if (event.which === 13) { + scope.$apply(function () { + scope.$eval(attrs.ngEnter, {'event': event}) + }) + event.preventDefault() + } + }) + } +} \ No newline at end of file diff --git a/res/app/components/stf/common-ui/ng-enter/ng-enter-spec.js b/res/app/components/stf/common-ui/ng-enter/ng-enter-spec.js new file mode 100644 index 00000000..951993e3 --- /dev/null +++ b/res/app/components/stf/common-ui/ng-enter/ng-enter-spec.js @@ -0,0 +1,23 @@ +describe('ngEnter', function () { + + beforeEach(module('stf.ng-enter')); + + 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('
hi
')(scope); + expect(element.text()).toBe('hello, world'); + */ + + }); +}); \ No newline at end of file diff --git a/res/app/control-panes/control-panes-controller.js b/res/app/control-panes/control-panes-controller.js index dada1667..42b26cc3 100644 --- a/res/app/control-panes/control-panes-controller.js +++ b/res/app/control-panes/control-panes-controller.js @@ -1,4 +1,5 @@ -module.exports = function ($scope, gettext, $routeParams, $location, DeviceService, GroupService, ControlService) { +module.exports = function ($scope, gettext, $rootScope, $routeParams, $location, + DeviceService, GroupService, ControlService) { var sharedTabs = [ { @@ -52,17 +53,17 @@ module.exports = function ($scope, gettext, $routeParams, $location, DeviceServi ].concat(angular.copy(sharedTabs)) - $scope.device = null - $scope.control = null + $rootScope.device = null + $rootScope.control = null - DeviceService.get($routeParams.serial, $scope) + DeviceService.get($routeParams.serial, $rootScope) .then(function (device) { return GroupService.invite(device) }) .then(function (device) { - $scope.device = device - $scope.control = ControlService.create(device, device.channel) + $rootScope.device = device + $rootScope.control = ControlService.create(device, device.channel) return device }) .catch(function () { diff --git a/res/app/control-panes/dashboard/shell/shell-controller.js b/res/app/control-panes/dashboard/shell/shell-controller.js index 05a1d9fb..f29406de 100644 --- a/res/app/control-panes/dashboard/shell/shell-controller.js +++ b/res/app/control-panes/dashboard/shell/shell-controller.js @@ -1,8 +1,8 @@ -module.exports = function ShellCtrl($scope) { +module.exports = function ShellCtrl($scope, $rootScope) { $scope.results = [] $scope.run = function(command) { - var cmd = $scope.control.shell(command) + var cmd = $rootScope.control.shell(command) return cmd.promise .progressed(function(results) { $scope.results = results diff --git a/res/app/control-panes/dashboard/shell/shell.jade b/res/app/control-panes/dashboard/shell/shell.jade index 91f0885c..214338e8 100644 --- a/res/app/control-panes/dashboard/shell/shell.jade +++ b/res/app/control-panes/dashboard/shell/shell.jade @@ -5,7 +5,7 @@ .widget-content.padded a(href='https://github.com/jackpal/Android-Terminal-Emulator/wiki/Android-Shell-Command-Reference', target='_href') Reference .input-group.form-inline - input(type=text, ng-model='command').form-control + input(type=text, ng-model='command', ng-enter='run(command)').form-control span.input-group-btn button.btn.btn-primary-outline(ng-click='run(command)') i.fa.fa-play diff --git a/res/app/control-panes/device-control/device-control.jade b/res/app/control-panes/device-control/device-control.jade index 6b572d51..9812d7af 100644 --- a/res/app/control-panes/device-control/device-control.jade +++ b/res/app/control-panes/device-control/device-control.jade @@ -4,9 +4,9 @@ .as-table.fill-height .stf-vnc-navbar.as-row a.stf-vnc-device-name.cursor.dropdown-toggle - p {{ device.serial }} {{ device.present ? 'present' : 'absent' }} + p {{ $root.device.serial }} {{ $root.device.present ? 'present' : 'absent' }} button(ng-click='showScreen = !showScreen') Show/Hide - button(ng-click='control.identify()') Identify + button(ng-click='$root.control.identify()') Identify @@ -14,15 +14,15 @@ strong Installation status: {{ installation.progress}}% ({{ installation.lastData }}) .as-row.fill-height - div(ng-controller='DeviceScreenCtrl', ng-file-drop='install($files)') + div(ng-controller='DeviceScreenCtrl', ng-file-drop='$root.install($files)') device-screen(style='width: 400px; height: 600px; background: gray') .stf-vnc-bottom.as-row .controls .btn-group.btn-group-justified - a(ng-click='control.menu()', title='{{"Menu"|translate}}').btn.btn-primary.btn-lg + a(ng-click='$root.control.menu()', title='{{"Menu"|translate}}').btn.btn-primary.btn-lg i.fa.fa-bars - a(ng-click='control.home()', title='{{"Home"|translate}}').btn.btn-primary.btn-lg + a(ng-click='$root.control.home()', title='{{"Home"|translate}}').btn.btn-primary.btn-lg i.fa.fa-home - a(ng-click='control.back()', title='{{"Back"|translate}}').btn.btn-primary.btn-lg + a(ng-click='$root.control.back()', title='{{"Back"|translate}}').btn.btn-primary.btn-lg i.fa.fa-mail-reply