Skip to content

Add select picker to env tab on pod page #674

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion app/scripts/controllers/pod.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,14 @@ angular.module('openshiftConsole')

// Must always be initialized so we can watch selectedTab
$scope.selectedTab = {};

// we might want to start structuring this data more?
$scope.tabs = {
env: {
selected: {
container: null
}
}
};
var watches = [];

// Check if the metrics service is available so we know when to show the tab.
Expand Down Expand Up @@ -217,6 +224,7 @@ angular.module('openshiftConsole')
function(pod) {
$scope.loaded = true;
$scope.pod = pod;
$scope.tabs.env.selected.container = pod.spec.containers[0].name;
setLogVars(pod);
setContainerVars();
var pods = {};
Expand Down
52 changes: 41 additions & 11 deletions app/views/browse/pod.html
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,46 @@ <h1>
</uib-tab>
<uib-tab heading="Environment" active="selectedTab.environment">
<uib-tab-heading>Environment</uib-tab-heading>
<div ng-repeat="container in pod.spec.containers">
<h3>Container {{container.name}} Environment Variables</h3>
<key-value-editor
entries="container.env"
is-readonly
cannot-add
cannot-sort
cannot-delete
ng-if="container.env.length"></key-value-editor>
<em ng-if="!container.env.length">The container specification has no environment variables set.</em>

<div class="row">
<div class="col-sm-6 col-lg-4">
<span ng-if="pod.spec.containers.length === 1">
<label for="selectLogContainer">Container:</label>
{{pod.spec.containers[0].name}}
</span>
<ui-select
ng-if="pod.spec.containers.length > 1"
ng-model="tabs.env.selected.container">
<ui-select-match
class="truncate"
placeholder="Container Name">
<span ng-bind="tabs.env.selected.container"></span>
</ui-select-match>
<ui-select-choices
repeat="container.name as container in pod.spec.containers">
{{container.name}}
</ui-select-choices>
</ui-select>
</div>
</div>

<div
class="row"
ng-repeat="container in pod.spec.containers"
ng-show="tabs.env.selected.container === container.name">
<div class="col-sm-12">
<h3>Container {{container.name}} Environment Variables</h3>
<key-value-editor
entries="container.env"
is-readonly
cannot-add
cannot-sort
cannot-delete
ng-if="container.env.length"></key-value-editor>
<em ng-if="!container.env.length">The container specification has no environment variables set.</em>
</div>
</div>

</uib-tab>
<uib-tab ng-if="metricsAvailable" heading="Metrics" active="selectedTab.metrics">
<!-- Use ng-if to remove the metrics directive when the tab is not active so
Expand Down Expand Up @@ -146,11 +175,12 @@ <h2>
<div class="row">
<div class="pad-left-none pad-bottom-md col-sm-6 col-lg-4">
<span ng-if="pod.spec.containers.length === 1">
<label for="selectLogContainer">Container:</label>
<label for="selectEnvContainer">Container:</label>
{{pod.spec.containers[0].name}}
</span>

<ui-select
id="selectEnvContainer"
ng-model="selectedTerminalContainer"
on-select="onTerminalSelectChange(selectedTerminalContainer)"
ng-if="pod.spec.containers.length > 1"
Expand Down
10 changes: 8 additions & 2 deletions dist/scripts/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -3440,7 +3440,13 @@ title:c.pod
} ], a.terminalDisconnectAlert.disconnect = {
type:"warning",
message:"This terminal has been disconnected. If you reconnect, your terminal history will be lost."
}, a.noContainersYet = !0, a.selectedTab = {};
}, a.noContainersYet = !0, a.selectedTab = {}, a.tabs = {
env:{
selected:{
container:null
}
}
};
var k = [];
h.isAvailable().then(function(b) {
a.metricsAvailable = b;
Expand Down Expand Up @@ -3519,7 +3525,7 @@ b.containerState = d;
};
j.get(c.project).then(_.spread(function(d, h) {
a.project = d, a.projectContext = h, f.get("pods", c.pod, h).then(function(b) {
a.loaded = !0, a.pod = b, l(b), m();
a.loaded = !0, a.pod = b, a.tabs.env.selected.container = b.spec.containers[0].name, l(b), m();
var d = {};
d[b.metadata.name] = b, g.fetchReferencedImageStreamImages(d, a.imagesByDockerReference, a.imageStreamImageRefByDockerReference, h), a.containerTerminals = s(), t(b), k.push(f.watchObject("pods", c.pod, h, function(b, c) {
"DELETED" === c && (a.alerts.deleted = {
Expand Down
24 changes: 21 additions & 3 deletions dist/scripts/templates.js
Original file line number Diff line number Diff line change
Expand Up @@ -2745,11 +2745,29 @@ angular.module('openshiftConsoleTemplates', []).run(['$templateCache', function(
"</uib-tab>\n" +
"<uib-tab heading=\"Environment\" active=\"selectedTab.environment\">\n" +
"<uib-tab-heading>Environment</uib-tab-heading>\n" +
"<div ng-repeat=\"container in pod.spec.containers\">\n" +
"<div class=\"row\">\n" +
"<div class=\"col-sm-6 col-lg-4\">\n" +
"<span ng-if=\"pod.spec.containers.length === 1\">\n" +
"<label for=\"selectLogContainer\">Container:</label>\n" +
"{{pod.spec.containers[0].name}}\n" +
"</span>\n" +
"<ui-select ng-if=\"pod.spec.containers.length > 1\" ng-model=\"tabs.env.selected.container\">\n" +
"<ui-select-match class=\"truncate\" placeholder=\"Container Name\">\n" +
"<span ng-bind=\"tabs.env.selected.container\"></span>\n" +
"</ui-select-match>\n" +
"<ui-select-choices repeat=\"container.name as container in pod.spec.containers\">\n" +
"{{container.name}}\n" +
"</ui-select-choices>\n" +
"</ui-select>\n" +
"</div>\n" +
"</div>\n" +
"<div class=\"row\" ng-repeat=\"container in pod.spec.containers\" ng-show=\"tabs.env.selected.container === container.name\">\n" +
"<div class=\"col-sm-12\">\n" +
"<h3>Container {{container.name}} Environment Variables</h3>\n" +
"<key-value-editor entries=\"container.env\" is-readonly cannot-add cannot-sort cannot-delete ng-if=\"container.env.length\"></key-value-editor>\n" +
"<em ng-if=\"!container.env.length\">The container specification has no environment variables set.</em>\n" +
"</div>\n" +
"</div>\n" +
"</uib-tab>\n" +
"<uib-tab ng-if=\"metricsAvailable\" heading=\"Metrics\" active=\"selectedTab.metrics\">\n" +
"\n" +
Expand Down Expand Up @@ -2792,10 +2810,10 @@ angular.module('openshiftConsoleTemplates', []).run(['$templateCache', function(
"<div class=\"row\">\n" +
"<div class=\"pad-left-none pad-bottom-md col-sm-6 col-lg-4\">\n" +
"<span ng-if=\"pod.spec.containers.length === 1\">\n" +
"<label for=\"selectLogContainer\">Container:</label>\n" +
"<label for=\"selectEnvContainer\">Container:</label>\n" +
"{{pod.spec.containers[0].name}}\n" +
"</span>\n" +
"<ui-select ng-model=\"selectedTerminalContainer\" on-select=\"onTerminalSelectChange(selectedTerminalContainer)\" ng-if=\"pod.spec.containers.length > 1\" class=\"mar-left-none pad-left-none pad-right-none\">\n" +
"<ui-select id=\"selectEnvContainer\" ng-model=\"selectedTerminalContainer\" on-select=\"onTerminalSelectChange(selectedTerminalContainer)\" ng-if=\"pod.spec.containers.length > 1\" class=\"mar-left-none pad-left-none pad-right-none\">\n" +
"<ui-select-match class=\"truncate\" placeholder=\"Container Name\">\n" +
"<span class=\"pad-left-md\">\n" +
"{{selectedTerminalContainer.containerName}}\n" +
Expand Down