forked from openstf/stf
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #67 from tstolarik/master
ANDROID-4665 add environment switch UI
- Loading branch information
Showing
7 changed files
with
130 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
res/app/control-panes/dashboard/environment/environment-controller.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
module.exports = function EnvironmentCtrl($scope) { | ||
$scope.result = null | ||
|
||
$scope.run = function(command) { | ||
if (command === 'clear') { | ||
$scope.clear() | ||
return | ||
} | ||
|
||
$scope.command = '' | ||
|
||
return $scope.control.shell(command) | ||
.progressed(function(result) { | ||
$scope.result = result | ||
$scope.data = result.data.join('') | ||
$scope.$digest() | ||
}) | ||
.then(function(result) { | ||
$scope.result = result | ||
$scope.data = result.data.join('') | ||
$scope.$digest() | ||
}) | ||
} | ||
|
||
$scope.clear = function() { | ||
$scope.command = '' | ||
$scope.data = '' | ||
$scope.result = null | ||
} | ||
|
||
$scope.switchTo = function(string) { | ||
$scope.run('am start -a android.intent.action.VIEW -d \"wandera-dev://?action=set_environment&environment=' + string + '\"') | ||
} | ||
|
||
$scope.switchToCustom = function(string) { | ||
$scope.run('am start -a android.intent.action.VIEW -d \"wandera-dev://?action=set_environment&environment=CUSTOM\&url=' + string + '.fi2.wandera.cz\"') | ||
} | ||
|
||
} |
20 changes: 20 additions & 0 deletions
20
res/app/control-panes/dashboard/environment/environment-spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
describe('EnvironmentCtrl', function() { | ||
|
||
beforeEach(angular.mock.module(require('./').name)) | ||
|
||
var scope, ctrl | ||
|
||
beforeEach(inject(function($rootScope, $controller) { | ||
scope = $rootScope.$new() | ||
ctrl = $controller('EnvironmentCtrl', {$scope: scope}) | ||
})) | ||
|
||
it('should clear the results', inject(function() { | ||
scope.result = ['result'] | ||
scope.run('clear') | ||
expect(scope.result).toBe(null) | ||
expect(scope.data).toBe('') | ||
expect(scope.command).toBe('') | ||
})) | ||
|
||
}) |
19 changes: 19 additions & 0 deletions
19
res/app/control-panes/dashboard/environment/environment.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
.stf-environment .environment-results { | ||
font-size: 12px; | ||
color: #fefefe; | ||
background: #444; | ||
} | ||
|
||
.stf-environment .environment-results-empty { | ||
font-style: italic; | ||
} | ||
|
||
.stf-environment .environment-input { | ||
font-family: Monaco, Menlo, Consolas, "Courier New", monospace; | ||
font-size: 12px; | ||
width: 75%; | ||
} | ||
|
||
.stf-environment .url-suffix { | ||
margin-left: 16px; | ||
} |
35 changes: 35 additions & 0 deletions
35
res/app/control-panes/dashboard/environment/environment.pug
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
.widget-container.fluid-height.stf-environment(ng-controller='EnvironmentCtrl') | ||
.heading | ||
stacked-icon(icon='fa-exchange', color='color-yellow') | ||
span(translate) Switch enviroment | ||
clear-button(ng-click='clear()', ng-disabled='!command && !data').btn-xs | ||
help-icon(topic='Remote-Shell', uib-tooltip='{{"Switches Wandera\'s environment to DEV, QA, PROD or FI" | translate}}') | ||
|
||
|
||
.widget-content.padded | ||
button.btn.btn-xs.btn-info-outline(ng-click='switchTo("DEV")', | ||
uib-tooltip='{{ "Switch to DEV" | translate }}') | ||
i.fa.fa-exchange | ||
span(translate) DEV | ||
button.btn.btn-xs.btn-info-outline(ng-click='switchTo("QA")', | ||
uib-tooltip='{{ "Switch to QA" | translate }}') | ||
i.fa.fa-exchange | ||
span(translate) QA | ||
button.btn.btn-xs.btn-info-outline(ng-click='switchTo("PRODUCTION")', | ||
uib-tooltip='{{ "Switch to PRODUCTION" | translate }}') | ||
i.fa.fa-exchange | ||
span(translate) PRODUCTION | ||
// NOTE: autofill doesn't work here | ||
form(method='post', enable-autofill, ng-submit='run(command)') | ||
|
||
.widget-content.padded | ||
.input-group.form-inline | ||
input(type=text, ng-model='command', Xtext-focus-select, | ||
autocapitalize='off', spellcheck='false', | ||
tabindex='30', accesskey='S', autocomplete='on' placeholder='FI name').form-control.environment-input | ||
span.url-suffix .fi2.wandera.cz | ||
span.input-group-btn | ||
button.btn.btn-primary-outline(ng-click='switchToCustom(command)', ng-disabled='!command') | ||
i.fa.fa-play | ||
pre.environment-results.selectable(ng-show='data') {{data}} | ||
pre.environment-results.selectable.environment-results-empty(ng-show='result.settled && !data') No output |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
require('./environment.css') | ||
|
||
module.exports = angular.module('stf.environment', [ | ||
require('stf/common-ui').name, | ||
require('gettext').name | ||
]) | ||
.run(['$templateCache', function($templateCache) { | ||
$templateCache.put('control-panes/dashboard/environment/environment.pug', | ||
require('./environment.pug') | ||
) | ||
}]) | ||
.controller('EnvironmentCtrl', require('./environment-controller')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters