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

View File

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

View File

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

View File

@ -4,12 +4,8 @@
<td data-title="{{dt.state}}">
{{badge-state model=model}}
</td>
<td data-title="{{dt.name}}">
{{#copy-to-clipboard clipboardText=model.displayName size="small"}}
<span class="clip vertical-middle" style="max-width:100px">
{{model.displayName}}
</span>
{{/copy-to-clipboard}}
<td class="force-wrap" data-title="{{dt.name}}">
{{model.displayName}}
</td>
<td data-title="{{dt.description}}">
{{#if model.description}}
@ -19,13 +15,13 @@
{{/if}}
</td>
<td data-title="{{dt.created}}">
{{date-calendar model.created}}
{{date-from-now model.created}}
</td>
<td data-title="{{dt.expires}}">
{{#if model.expiresAt}}
{{date-calendar model.expiresAt}}
{{date-from-now model.expiresAt}}
{{else}}
<span class="text-muted">{{t 'generic.none'}}</span>
<span class="text-muted">{{t 'generic.never'}}</span>
{{/if}}
</td>
<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}}
</td>
<td data-title="{{dt.provider}}">
{{model.displayProvider}}
{{#if model.version.gitVersion}}
<small>{{model.displayProvider}}</small>
<p class="text-small text-muted m-0">{{model.version.gitVersion}}</p>
{{else}}
{{model.displayProvider}}
{{/if}}
</td>
{{#if (eq model.state "inactive")}}
<td colspan="4" class="text-center">
@ -21,7 +26,8 @@
</td>
<td data-title="{{dt.cpu}}">
{{#if model.cpuUsage}}
{{model.cpuUsage}}
<small>{{model.cpuUsage}}</small>
<p class="text-small text-muted m-0">{{model.cpuPercent}}</p>
{{else}}
<span class="text-muted">
{{t 'generic.na'}}
@ -31,7 +37,8 @@
<td data-title="{{dt.memory}}">
{{#if model.memoryUsage}}
{{model.memoryUsage}}
<small>{{model.memoryUsage}}</small>
<p class="text-small text-muted m-0">{{model.memoryPercent}}</p>
{{else}}
<span class="text-muted">
{{t 'generic.na'}}

View File

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

View File

@ -1,7 +1,7 @@
const UNITS = ['','K','M','G','T','P'];
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 exp = startingExponent;
@ -11,9 +11,9 @@ export function formatSi(inValue, increment=1000, suffix=null, firstSuffix=null,
}
var out = '';
if ( (val < 1) || ( val < 10 ) ) {
if ( val < 10 && maxPrecision >= 2 ) {
out = Math.round(val*100)/100;
} else if ( val < 100 ) {
} else if ( val < 100 && maxPrecision >= 1) {
out = Math.round(val*10)/10;
} else {
out = Math.round(val);

View File

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

View File

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