Skip to content

Commit 7c98f70

Browse files
authored
Merge pull request #67 from tstolarik/master
ANDROID-4665 add environment switch UI
2 parents d7d84be + cad4a31 commit 7c98f70

File tree

7 files changed

+130
-2
lines changed

7 files changed

+130
-2
lines changed

res/app/control-panes/dashboard/dashboard.pug

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
div(ng-include='"control-panes/dashboard/apps/apps.pug"')
66
.col-md-12
77
div(ng-include='"control-panes/dashboard/install/install.pug"')
8-
8+
.col-md-12
9+
div(ng-include='"control-panes/dashboard/environment/environment.pug"')
10+
911
.col-md-6
1012
.col-md-12
1113
div(ng-include='"control-panes/dashboard/clipboard/clipboard.pug"')
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
module.exports = function EnvironmentCtrl($scope) {
2+
$scope.result = null
3+
4+
$scope.run = function(command) {
5+
if (command === 'clear') {
6+
$scope.clear()
7+
return
8+
}
9+
10+
$scope.command = ''
11+
12+
return $scope.control.shell(command)
13+
.progressed(function(result) {
14+
$scope.result = result
15+
$scope.data = result.data.join('')
16+
$scope.$digest()
17+
})
18+
.then(function(result) {
19+
$scope.result = result
20+
$scope.data = result.data.join('')
21+
$scope.$digest()
22+
})
23+
}
24+
25+
$scope.clear = function() {
26+
$scope.command = ''
27+
$scope.data = ''
28+
$scope.result = null
29+
}
30+
31+
$scope.switchTo = function(string) {
32+
$scope.run('am start -a android.intent.action.VIEW -d \"wandera-dev://?action=set_environment&environment=' + string + '\"')
33+
}
34+
35+
$scope.switchToCustom = function(string) {
36+
$scope.run('am start -a android.intent.action.VIEW -d \"wandera-dev://?action=set_environment&environment=CUSTOM\&url=' + string + '.fi2.wandera.cz\"')
37+
}
38+
39+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
describe('EnvironmentCtrl', function() {
2+
3+
beforeEach(angular.mock.module(require('./').name))
4+
5+
var scope, ctrl
6+
7+
beforeEach(inject(function($rootScope, $controller) {
8+
scope = $rootScope.$new()
9+
ctrl = $controller('EnvironmentCtrl', {$scope: scope})
10+
}))
11+
12+
it('should clear the results', inject(function() {
13+
scope.result = ['result']
14+
scope.run('clear')
15+
expect(scope.result).toBe(null)
16+
expect(scope.data).toBe('')
17+
expect(scope.command).toBe('')
18+
}))
19+
20+
})
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
.stf-environment .environment-results {
2+
font-size: 12px;
3+
color: #fefefe;
4+
background: #444;
5+
}
6+
7+
.stf-environment .environment-results-empty {
8+
font-style: italic;
9+
}
10+
11+
.stf-environment .environment-input {
12+
font-family: Monaco, Menlo, Consolas, "Courier New", monospace;
13+
font-size: 12px;
14+
width: 75%;
15+
}
16+
17+
.stf-environment .url-suffix {
18+
margin-left: 16px;
19+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
.widget-container.fluid-height.stf-environment(ng-controller='EnvironmentCtrl')
2+
.heading
3+
stacked-icon(icon='fa-exchange', color='color-yellow')
4+
span(translate) Switch enviroment
5+
clear-button(ng-click='clear()', ng-disabled='!command && !data').btn-xs
6+
help-icon(topic='Remote-Shell', uib-tooltip='{{"Switches Wandera\'s environment to DEV, QA, PROD or FI" | translate}}')
7+
8+
9+
.widget-content.padded
10+
button.btn.btn-xs.btn-info-outline(ng-click='switchTo("DEV")',
11+
uib-tooltip='{{ "Switch to DEV" | translate }}')
12+
i.fa.fa-exchange
13+
span(translate) DEV
14+
button.btn.btn-xs.btn-info-outline(ng-click='switchTo("QA")',
15+
uib-tooltip='{{ "Switch to QA" | translate }}')
16+
i.fa.fa-exchange
17+
span(translate) QA
18+
button.btn.btn-xs.btn-info-outline(ng-click='switchTo("PRODUCTION")',
19+
uib-tooltip='{{ "Switch to PRODUCTION" | translate }}')
20+
i.fa.fa-exchange
21+
span(translate) PRODUCTION
22+
// NOTE: autofill doesn't work here
23+
form(method='post', enable-autofill, ng-submit='run(command)')
24+
25+
.widget-content.padded
26+
.input-group.form-inline
27+
input(type=text, ng-model='command', Xtext-focus-select,
28+
autocapitalize='off', spellcheck='false',
29+
tabindex='30', accesskey='S', autocomplete='on' placeholder='FI name').form-control.environment-input
30+
span.url-suffix .fi2.wandera.cz
31+
span.input-group-btn
32+
button.btn.btn-primary-outline(ng-click='switchToCustom(command)', ng-disabled='!command')
33+
i.fa.fa-play
34+
pre.environment-results.selectable(ng-show='data') {{data}}
35+
pre.environment-results.selectable.environment-results-empty(ng-show='result.settled && !data') No output
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
require('./environment.css')
2+
3+
module.exports = angular.module('stf.environment', [
4+
require('stf/common-ui').name,
5+
require('gettext').name
6+
])
7+
.run(['$templateCache', function($templateCache) {
8+
$templateCache.put('control-panes/dashboard/environment/environment.pug',
9+
require('./environment.pug')
10+
)
11+
}])
12+
.controller('EnvironmentCtrl', require('./environment-controller'))

res/app/control-panes/dashboard/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ module.exports = angular.module('stf.dashboard', [
55
require('./apps/index').name,
66
require('./clipboard/index').name,
77
require('./remote-debug/index').name,
8-
require('./enrollment/index').name
8+
require('./enrollment/index').name,
9+
require('./environment/index').name
910
])
1011
.run(['$templateCache', function($templateCache) {
1112
$templateCache.put(

0 commit comments

Comments
 (0)