Skip to content
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

Make search boxes not usable and visually show this while fetching orgs and spaces #1287

Merged
merged 1 commit into from
Oct 6, 2017
Merged
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
3 changes: 3 additions & 0 deletions components/app-framework/i18n/en_US/app-framework.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,8 @@
},
"code-block": {
"copied-msg": "Copied to clipboard"
},
"search-box": {
"busy": "Loading ..."
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@
placeholder: '@?',
searchIcon: '@?',
disabled: '=?',
translateOptionLabels: '=?'
translateOptionLabels: '=?',
busy: '=?'
},
controller: SearchBoxController,
controllerAs: 'searchBoxCtrl',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
<div ng-click="searchBoxCtrl.openIt()" class="search-box" ng-class="{ open: searchBoxCtrl.open, disabled: searchBoxCtrl.disabled}">
<div ng-click="!searchBoxCtrl.busy && searchBoxCtrl.openIt()" class="search-box" ng-class="{ open: searchBoxCtrl.open, disabled: searchBoxCtrl.disabled || searchBoxCtrl.busy}">
<div class="search-box-busy" ng-if="searchBoxCtrl.busy" translate>search-box.busy</div>
<input type="text"
ng-change="searchBoxCtrl.onChange()"
ng-model="searchBoxCtrl.searchText"
ng-keydown="searchBoxCtrl.onKeyDown($event)"
ng-show="!searchBoxCtrl.busy"
placeholder="{{ searchBoxCtrl.placeholder }}" ng-disabled="searchBoxCtrl.disabled"/>
<i class="search-icon material-icons"
ng-show="!searchBoxCtrl.busy"
ng-class="searchBoxCtrl.searchIcon || 'search-icon-icon'"></i>

<ul ng-show="searchBoxCtrl.open" class="dropdown-menu">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,14 @@ search-box {
}
}
}

.search-box-busy {
padding: 0;
margin-bottom: $padding-base-vertical;
height: $line-height-computed;
line-height: $line-height-computed;
margin-top: $console-form-margin-top;
}
}

.form-group-large {
Expand Down
4 changes: 4 additions & 0 deletions components/app-theme/src/scss/style/components/_forms.scss
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ form, [ng-form] {
width: $console-input-width * 1.25;
}

&.form-group-busy {
background-color: $gray-lighter;
}

label {
color: $console-input-label-fg;
font-weight: normal;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@
vm.organizations = [];
vm.spaces = [];

vm.loadingOrganizations = true;
vm.loadingSpaces = true;

if (initialServiceInstance && initialServiceInstance !== 'all') {
// Find the option to set. If the user has no permissions this may be null
var preSelectedService = _.find(vm.serviceInstances, {value: {guid: initialServiceInstance}}) || {};
Expand Down Expand Up @@ -91,6 +94,8 @@
function getOrganizations() {
var cnsiGuid = vm.serviceInstance.guid;
vm.organizations.length = 0;
vm.loadingOrganizations = true;
vm.loadingSpaces = true;

return cfOrganizationModel.listAllOrganizations(cnsiGuid)
.then(function (organizations) {
Expand All @@ -115,6 +120,9 @@
var preSelectedOrg = _.find(vm.organizations, {value: {metadata: {guid: initialOrganization}}}) || {};
vm.organization = preSelectedOrg.value;
}
})
.finally(function () {
vm.loadingOrganizations = false;
});
}

Expand All @@ -128,6 +136,7 @@
function getSpacesForOrganization(guid) {
var cnsiGuid = vm.serviceInstance.guid;
vm.spaces.length = 0;
vm.loadingSpaces = true;

return cfOrganizationModel.listAllSpacesForOrganization(cnsiGuid, guid)
.then(function (spaces) {
Expand All @@ -145,6 +154,9 @@
var preSelectedOrg = _.find(vm.spaces, {value: {metadata: {guid: initialSpace}}}) || {};
vm.space = preSelectedOrg.value;
}
})
.finally(function () {
vm.loadingSpaces = false;
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,24 @@
</search-box>
</div>

<div class="form-group form-group-large">
<div class="form-group form-group-large" ng-class="{'form-group-busy': deployLocation.loadingOrganizations}">
<label class="control-label" required translate>app.deploy-location.org-label</label>
<search-box
ng-model="deployLocation.organization"
input-options="deployLocation.organizations"
placeholder="{{'app.deploy-location.org-placeholder' | translate}}"
busy="deployLocation.loadingOrganizations"
tabindex="0" required>
</search-box>
</div>

<div class="form-group form-group-large">
<div class="form-group form-group-large" ng-class="{'form-group-busy': deployLocation.loadingSpaces}">
<label class="control-label" required translate>app.deploy-location.space-label</label>
<search-box
ng-model="deployLocation.space"
input-options="deployLocation.spaces"
placeholder="{{'app.deploy-location.space-placeholder' | translate}}"
busy="deployLocation.loadingSpaces"
tabindex="0" required>
</search-box>
</div>