1
0
Fork 0
mirror of https://github.com/openstf/stf synced 2025-10-06 03:50:04 +02:00

- Improving the shell. Still not a real shell.

This commit is contained in:
Gunther Brunner 2014-04-01 22:04:36 +09:00
parent e17f306d30
commit af47e535e4
10 changed files with 95 additions and 13 deletions

View file

@ -5,5 +5,6 @@ module.exports = angular.module('stf/common-ui', [
require('./nothing-to-show').name,
require('./table').name,
require('./notifications').name,
require('./ng-enter').name
require('./ng-enter').name,
require('./tooltips').name
])

View file

@ -0,0 +1,16 @@
# stf-tooltips
Based on Angular Bootstrap.
Usage:
```html
help-title='{{"Run Command"|translate}}'
help-key='Enter'
```
Maps to:
```html
tooltip-html-unsafe='{{"Run Command<br /><br /><code>Enter</code>"|translate}}'
```

View file

@ -0,0 +1,4 @@
module.exports = angular.module('stf.tooltips', [
])
.directive('tooltips', require('./tooltips-directive'))

View file

@ -0,0 +1,8 @@
module.exports = function tooltipsDirective() {
return {
restrict: 'A',
link: function (scope, element, attrs) {
}
}
}

View file

@ -0,0 +1,23 @@
describe('tooltips', function () {
beforeEach(module('stf.tooltips'));
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 tooltips name="name">hi</div>')(scope);
expect(element.text()).toBe('hello, world');
*/
});
});

View file

@ -1,7 +1,7 @@
require('./shell.css')
module.exports = angular.module('stf.shell', [
require('stf/common-ui').name
])
.run(["$templateCache", function ($templateCache) {
$templateCache.put('control-panes/dashboard/shell/shell.jade',

View file

@ -1,16 +1,34 @@
module.exports = function ShellCtrl($scope, $rootScope) {
$scope.results = []
// TODO: implement multiple devices
// $scope.results = []
$scope.result = null
$scope.referenceUrl = 'https://github.com/jackpal/Android-Terminal-Emulator/wiki/Android-Shell-Command-Reference'
$scope.run = function(command) {
if (command === 'clear') {
$scope.clear()
return
}
var cmd = $rootScope.control.shell(command)
$scope.command = ''
return cmd.promise
.progressed(function(results) {
$scope.results = results
.progressed(function(result) {
//$scope.result = result
$scope.data = result.data.join('')
$scope.$digest()
})
.then(function(results) {
$scope.results = results
.then(function(result) {
$scope.data = result.data.join('')
// $scope.result = result
$scope.$digest()
})
}
$scope.clear = function () {
$scope.command = ''
$scope.data = ''
}
}

View file

@ -1,3 +1,5 @@
.stf-shell {
.stf-shell .shell-results {
font-size: 12px;
color: #fefefe;
background: #444;
}

View file

@ -2,14 +2,20 @@
.heading
i.fa.fa-terminal
span(translate) Shell
clear-button(ng-click='clear()', ng-disabled='!command && !data').btn-xs
a(ng-href='{{referenceUrl}}', target='_href').btn.btn-xs.btn-primary-outline.pull-right
i.fa.fa-book
span(translate) Reference
.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', ng-enter='run(command)').form-control
span.input-group-btn
button.btn.btn-primary-outline(ng-click='run(command)')
button.btn.btn-primary-outline(ng-click='run(command)', tooltip-html-unsafe='{{"Run Command"|translate}}<br /><br /><code>Enter</code>')
i.fa.fa-play
table
pre.shell-results(ng-show='data') {{data}}
// table
tr(ng-repeat='result in results track by result.device.serial')
td {{ result.device.serial }}
td {{ result.data }}

View file

@ -5,7 +5,11 @@
.stf-vnc-navbar.as-row
a.stf-vnc-device-name.cursor.dropdown-toggle
p {{ $root.device.serial }} {{ $root.device.present ? 'present' : 'absent' }}
button(ng-click='showScreen = !showScreen') Show/Hide
.pull-right
button(type='button', ng-model='showScreen', btn-checkbox).btn.btn-sm.btn-danger
i(ng-show='showScreen', tooltip-html-unsafe='{{"Just control device"|translate}}<br /><code>⌘-⇧-O</code>', tooltip-placement='left').fa.fa-eye
i(ng-show='!showScreen', tooltip-html-unsafe='{{"View device"|translate}}<br /><code>⌘-⇧-O</code>', tooltip-placement='left').fa.fa-eye-slash
//button(ng-click='showScreen = !showScreen') Show/Hide
button(ng-click='$root.control.identify()') Identify