Hide the namespace selector when on swarm or <2 K8s ns

We now hide the new namespace dropdown selector when
there is only 1 namespace, or when we are on swarm
This is also hidden in the function create page and
the function detail page

Signed-off-by: Alistair Hey <alistair@heyal.co.uk>
This commit is contained in:
Alistair Hey
2019-12-15 16:23:26 +00:00
committed by Alex Ellis
parent d90288143d
commit 04fead5eab
3 changed files with 12 additions and 7 deletions

View File

@ -54,9 +54,9 @@
</md-list-item>
</md-list>
<md-input-container>
<md-input-container ng-show="allNamespaces.length > 1">
<label>Namespace</label>
<md-select ng-model="namespaceSelect" placeholder="Select a Namespace">
<md-select ng-model="namespaceSelectDropdown" placeholder="Select a Namespace">
<md-option ng-click="setNamespace(namespace)" ng-value="namespace" ng-repeat="namespace in allNamespaces">
{{ namespace }}
</md-option>
@ -127,7 +127,7 @@
<input ng-model="function.invocationCount" type="text" readonly="readonly">
</md-input-container>
<md-input-container class="md-block" flex-gt-sm>
<md-input-container class="md-block" flex-gt-sm ng-show="allNamespaces.length > 1">
<label>Namespace</label>
<input ng-model="function.namespace" type="text" readonly="readonly">
</md-input-container>

View File

@ -23,7 +23,6 @@ app.controller("home", ['$scope', '$log', '$http', '$location', '$interval', '$f
contentType: "text"
};
$scope.namespaceSelect = $scope.selectedNamespace;
$scope.baseUrl = $location.absUrl().replace(/\ui\/$/, '');
try {
$scope.canCopyToClipboard = document.queryCommandSupported('copy');
@ -43,6 +42,8 @@ app.controller("home", ['$scope', '$log', '$http', '$location', '$interval', '$f
showPostInvokedToast(msg);
}
$scope.toggleSideNav = function() {
$mdSidenav('left').toggle();
};
@ -310,7 +311,7 @@ app.controller("home", ['$scope', '$log', '$http', '$location', '$interval', '$f
$scope.labelsToLabelInputs(func.labels);
$scope.annotationsToAnnotationInputs(func.annotations);
$scope.secretsToSecretInputs(func.secrets);
$scope.item.namespace = func.selectedNamespace;
$scope.item.namespace = $scope.namespaceSelected();
$scope.selectedFunc = func;
@ -365,6 +366,10 @@ app.controller("home", ['$scope', '$log', '$http', '$location', '$interval', '$f
});
};
$scope.fnNamespaceSelected = function(inputNamespace) {
$scope.namespaceSelect = inputNamespace;
}
$scope.onEnvInputExpand = function() {
$scope.envFieldsVisible = !$scope.envFieldsVisible;
}

View File

@ -58,12 +58,12 @@
<input name="network" ng-model="item.network" md-maxlength="200" minlength="0">
</md-input-container>
</div>
<div layout-gt-xs="row">
<div layout-gt-xs="row" ng-if="allNamespaces.length > 1">
<md-input-container class="md-block" flex-gt-sm>
<md-tooltip md-direction="bottom">Namespace your function runs in i.e. 'openfaas-fn'. Only namespaces OpenFaaS can manage will show here</md-tooltip>
<label>Namespace</label>
<md-select name="namespace" ng-model="namespaceSelect" placeholder="Select a Namespace">
<md-option ng-value="namespace" ng-repeat="namespace in allNamespaces">
<md-option ng-click="fnNamespaceSelected(namespace)" ng-value="namespace" ng-repeat="namespace in allNamespaces">
{{ namespace }}
</md-option>
</md-select>