Merge pull request #1790 from vincent99/master

Tables
This commit is contained in:
Vincent Fiduccia 2018-04-02 23:41:18 -07:00 committed by GitHub
commit b9229edf2c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 39 additions and 39 deletions

View File

@ -22,13 +22,12 @@ export default Controller.extend({
name: 'state', name: 'state',
sort: ['sortState','name','id'], sort: ['sortState','name','id'],
translationKey: 'apiPage.table.state', translationKey: 'apiPage.table.state',
width: 125, width: 80,
}, },
{ {
name: 'name', name: 'name',
sort: ['name','id'], sort: ['name','id'],
translationKey: 'apiPage.table.name', translationKey: 'apiPage.table.name',
width: 150,
}, },
{ {
name: 'description', name: 'description',
@ -39,13 +38,13 @@ export default Controller.extend({
name: 'created', name: 'created',
sort: ['created','name','id'], sort: ['created','name','id'],
translationKey: 'apiPage.table.created', translationKey: 'apiPage.table.created',
width: 200, width: 150,
}, },
{ {
name: 'expires', name: 'expires',
sort: ['expiresAt','name','id'], sort: ['expiresAt','name','id'],
translationKey: 'apiPage.table.expires.label', translationKey: 'apiPage.table.expires.label',
width: 200, width: 150,
}, },
], ],

View File

@ -18,13 +18,7 @@ const headers = [
name: 'provider', name: 'provider',
sort: ['displayProvider','name','id'], sort: ['displayProvider','name','id'],
translationKey: 'clustersPage.provider.label', translationKey: 'clustersPage.provider.label',
width: 125, width: 150,
},
{
name: 'version',
sort: ['displayProvider','name','id'],
translationKey: 'clustersPage.provider.label',
width: 125,
}, },
{ {
name: 'nodes', name: 'nodes',
@ -57,6 +51,7 @@ export default Controller.extend({
application: controller(), application: controller(),
headers: headers, headers: headers,
extraSearchFields: ['version.gitVersion'],
sortBy: 'name', sortBy: 'name',
searchText: null, searchText: null,
bulkActions: true, bulkActions: true,

View File

@ -15,6 +15,7 @@
searchText=searchText searchText=searchText
sortBy=sortBy sortBy=sortBy
bulkActions=true bulkActions=true
extraSearchFields=extraSearchFields
pagingLabel="pagination.cluster" pagingLabel="pagination.cluster"
headers=headers as |sortable kind inst dt| headers=headers as |sortable kind inst dt|
}} }}

View File

@ -4,12 +4,8 @@
<td data-title="{{dt.state}}"> <td data-title="{{dt.state}}">
{{badge-state model=model}} {{badge-state model=model}}
</td> </td>
<td data-title="{{dt.name}}"> <td class="force-wrap" data-title="{{dt.name}}">
{{#copy-to-clipboard clipboardText=model.displayName size="small"}}
<span class="clip vertical-middle" style="max-width:100px">
{{model.displayName}} {{model.displayName}}
</span>
{{/copy-to-clipboard}}
</td> </td>
<td data-title="{{dt.description}}"> <td data-title="{{dt.description}}">
{{#if model.description}} {{#if model.description}}
@ -19,13 +15,13 @@
{{/if}} {{/if}}
</td> </td>
<td data-title="{{dt.created}}"> <td data-title="{{dt.created}}">
{{date-calendar model.created}} {{date-from-now model.created}}
</td> </td>
<td data-title="{{dt.expires}}"> <td data-title="{{dt.expires}}">
{{#if model.expiresAt}} {{#if model.expiresAt}}
{{date-calendar model.expiresAt}} {{date-from-now model.expiresAt}}
{{else}} {{else}}
<span class="text-muted">{{t 'generic.none'}}</span> <span class="text-muted">{{t 'generic.never'}}</span>
{{/if}} {{/if}}
</td> </td>
<td data-title="{{dt.actions}}" class="actions"> <td data-title="{{dt.actions}}" class="actions">

View File

@ -9,7 +9,12 @@
{{#link-to-external 'authenticated.cluster' model.id}}{{model.displayName}}{{/link-to-external}} {{#link-to-external 'authenticated.cluster' model.id}}{{model.displayName}}{{/link-to-external}}
</td> </td>
<td data-title="{{dt.provider}}"> <td data-title="{{dt.provider}}">
{{#if model.version.gitVersion}}
<small>{{model.displayProvider}}</small>
<p class="text-small text-muted m-0">{{model.version.gitVersion}}</p>
{{else}}
{{model.displayProvider}} {{model.displayProvider}}
{{/if}}
</td> </td>
{{#if (eq model.state "inactive")}} {{#if (eq model.state "inactive")}}
<td colspan="4" class="text-center"> <td colspan="4" class="text-center">
@ -21,7 +26,8 @@
</td> </td>
<td data-title="{{dt.cpu}}"> <td data-title="{{dt.cpu}}">
{{#if model.cpuUsage}} {{#if model.cpuUsage}}
{{model.cpuUsage}} <small>{{model.cpuUsage}}</small>
<p class="text-small text-muted m-0">{{model.cpuPercent}}</p>
{{else}} {{else}}
<span class="text-muted"> <span class="text-muted">
{{t 'generic.na'}} {{t 'generic.na'}}
@ -31,7 +37,8 @@
<td data-title="{{dt.memory}}"> <td data-title="{{dt.memory}}">
{{#if model.memoryUsage}} {{#if model.memoryUsage}}
{{model.memoryUsage}} <small>{{model.memoryUsage}}</small>
<p class="text-small text-muted m-0">{{model.memoryPercent}}</p>
{{else}} {{else}}
<span class="text-muted"> <span class="text-muted">
{{t 'generic.na'}} {{t 'generic.na'}}

View File

@ -12,10 +12,10 @@ export default Mixin.create({
const total = parseSi(get(this,'allocatable.cpu')); const total = parseSi(get(this,'allocatable.cpu'));
if ( total ) { if ( total ) {
const minExp = exponentNeeded(total); const minExp = exponentNeeded(total);
const usedStr = formatSi(used, 1000, '', '', 0, minExp).replace(/\s.*$/,''); const usedStr = formatSi(used, 1000, '', '', 0, minExp, 1).replace(/\s.*$/,'');
const totalStr = formatSi(total, 1000, '', '', 0, minExp); const totalStr = formatSi(total, 1000, '', '', 0, minExp, 1);
return `${usedStr}/${totalStr}` return `${usedStr}/${totalStr} Core` + (totalStr === '1' ? '' : 's');
} else { } else {
return null; return null;
} }
@ -25,7 +25,7 @@ export default Mixin.create({
const used = parseSi(get(this,'requested.cpu'))||0; const used = parseSi(get(this,'requested.cpu'))||0;
const total = parseSi(get(this,'allocatable.cpu')); const total = parseSi(get(this,'allocatable.cpu'));
if ( total ) { if ( total ) {
return formatPercent(100*used/total); return formatPercent(100*used/total, 0);
} else { } else {
return null; return null;
} }
@ -36,8 +36,8 @@ export default Mixin.create({
const total = parseSi(get(this,'allocatable.memory')); const total = parseSi(get(this,'allocatable.memory'));
if ( total ) { if ( total ) {
const minExp = exponentNeeded(total); const minExp = exponentNeeded(total);
const usedStr = formatSi(used, 1024, '', '', 0, minExp).replace(/\s.*/,''); const usedStr = formatSi(used, 1024, '', '', 0, minExp, 1).replace(/\s.*/,'');
const totalStr = formatSi(total, 1024, 'iB', 'B', 0, minExp); const totalStr = formatSi(total, 1024, 'iB', 'B', 0, minExp, 1);
return `${usedStr}/${totalStr}` return `${usedStr}/${totalStr}`
} else { } else {
@ -49,7 +49,7 @@ export default Mixin.create({
const used = parseSi(get(this,'requested.memory'))||0; const used = parseSi(get(this,'requested.memory'))||0;
const total = parseSi(get(this,'allocatable.memory')); const total = parseSi(get(this,'allocatable.memory'));
if ( total ) { if ( total ) {
return formatPercent(100*used/total); return formatPercent(100*used/total, 0);
} else { } else {
return null; return null;
} }
@ -60,8 +60,8 @@ export default Mixin.create({
const total = parseSi(get(this,'allocatable.pods')); const total = parseSi(get(this,'allocatable.pods'));
if ( total ) { if ( total ) {
const minExp = exponentNeeded(total); const minExp = exponentNeeded(total);
const usedStr = formatSi(used, 1000, '', '', 0, minExp).replace(/\s.*$/,''); const usedStr = formatSi(used, 1000, '', '', 0, minExp, 1).replace(/\s.*$/,'');
const totalStr = formatSi(total, 1000, '', '', 0, minExp); const totalStr = formatSi(total, 1000, '', '', 0, minExp, 1);
return `${usedStr}/${totalStr}` return `${usedStr}/${totalStr}`
} else { } else {
@ -73,7 +73,7 @@ export default Mixin.create({
const used = parseSi(get(this,'requested.pods'))||0; const used = parseSi(get(this,'requested.pods'))||0;
const total = parseSi(get(this,'allocatable.pods')); const total = parseSi(get(this,'allocatable.pods'));
if ( total ) { if ( total ) {
return formatPercent(100*used/total); return formatPercent(100*used/total, 0);
} else { } else {
return null; return null;
} }

View File

@ -1,7 +1,7 @@
const UNITS = ['','K','M','G','T','P']; const UNITS = ['','K','M','G','T','P'];
const FRACTIONAL = ['','m','u','n','p','f']; // milli micro nano pico femto const FRACTIONAL = ['','m','u','n','p','f']; // milli micro nano pico femto
export function formatSi(inValue, increment=1000, suffix=null, firstSuffix=null, startingExponent=0, minExponent=0) export function formatSi(inValue, increment=1000, suffix=null, firstSuffix=null, startingExponent=0, minExponent=0, maxPrecision=2)
{ {
var val = inValue; var val = inValue;
var exp = startingExponent; var exp = startingExponent;
@ -11,9 +11,9 @@ export function formatSi(inValue, increment=1000, suffix=null, firstSuffix=null,
} }
var out = ''; var out = '';
if ( (val < 1) || ( val < 10 ) ) { if ( val < 10 && maxPrecision >= 2 ) {
out = Math.round(val*100)/100; out = Math.round(val*100)/100;
} else if ( val < 100 ) { } else if ( val < 100 && maxPrecision >= 1) {
out = Math.round(val*10)/10; out = Math.round(val*10)/10;
} else { } else {
out = Math.round(val); out = Math.round(val);

View File

@ -232,12 +232,12 @@ export function randomStr(length=16, charset='alphanum')
}).join(''); }).join('');
} }
export function formatPercent(value) { export function formatPercent(value, maxPrecision=2) {
if ( value < 1 ) if ( value < 1 && maxPrecision >= 2 )
{ {
return Math.round(value*100)/100 + '%'; return Math.round(value*100)/100 + '%';
} }
else if ( value < 10 ) else if ( value < 10 && maxPrecision >= 1 )
{ {
return Math.round(value*10)/10 + '%'; return Math.round(value*10)/10 + '%';
} }

View File

@ -635,6 +635,8 @@ clustersPage:
label: Cluster Name label: Cluster Name
provider: provider:
label: Provider label: Provider
version:
label: Version
nodes: nodes:
label: Nodes label: Nodes
cpu: cpu: