Commit d2755a5d authored by Jochen Kressin's avatar Jochen Kressin
Browse files

sort tenants alphabetically, closes #13

parent 47d2e2aa
......@@ -39,17 +39,17 @@
</td>
</tr>
<tr ng-repeat="(tenant, rw) in ctrl.tenants" ng-class="{'active': tenant == ctrl.currentTenant}">
<tr ng-repeat="tenantkey in ctrl.tenantkeys" ng-class="{'active': tenantkey == ctrl.currentTenant}">
<td>
{{tenant}}
{{tenantkey}}
</td>
<td>
<div ng-if="rw">read/write</div>
<div ng-if="!rw">read only</div>
<div ng-if="ctrl.alltenants[tenantkey] == 'rw'">read/write</div>
<div ng-if="ctrl.alltenants[tenantkey] == 'ro'">read only</div>
</td>
<td></td>
<td class="actions">
<button class="btn-primary" ng-disabled="ctrl.currentTenant == tenant" ng-click="ctrl.selectTenant(tenant, tenant)">Choose</button>
<button class="btn-primary" ng-disabled="ctrl.currentTenant == tenantkey" ng-click="ctrl.selectTenant(tenantkey, tenantkey)">Choose</button>
</td>
</tr>
</tbody>
......
......@@ -52,7 +52,21 @@ uiModules
this.username = response.data.user_name;
var allTenants = response.data.sg_tenants;
delete allTenants[this.username];
// sort tenants by putting the keys in an array first
var tenantkeys = [];
var k;
for (k in allTenants) {
if (allTenants.hasOwnProperty(k)) {
tenantkeys.push(k);
}
}
tenantkeys.sort();
this.tenants = allTenants;
this.tenantkeys = tenantkeys;
$http.get(`${API_ROOT}/tenant`)
.then(
(response) => {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment