+
+
+
+
+
+ [[_formatInboundBytesValue(totalInboundBytes, language)]]
+
+
+ [[_formatInboundBytesUnit(totalInboundBytes, language)]]
+
+
+
[[localize('server-data-transfer')]]
-
-
- [[_computeManagedServerUtilizationPercentage(totalInboundBytes,
- monthlyOutboundTransferBytes)]]
-
-
- /[[_formatBytesTransferred(monthlyOutboundTransferBytes,
- language)]]
-
+
+
+
![]([[getCloudIcon(cloudId)]])
+
+
+
+ [[_computeManagedServerUtilizationPercentage(totalInboundBytes,
+ monthlyOutboundTransferBytes)]]
+
+
+ /[[_formatBytesTransferred(monthlyOutboundTransferBytes,
+ language)]]
+
+
+
[[localize('server-data-used')]]
-
[[localize('server-data-used')]]
-
-
-
-
-
[[accessKeyRows.length]]
-
[[localize('server-keys')]]
+
+
+
+
[[accessKeyRows.length]]
+
[[localize('server-keys')]]
+
+
[[localize('server-access')]]
-
[[localize('server-access')]]
-
+
@@ -727,7 +748,13 @@ export class ServerView extends DirMixin(PolymerElement) {
-
+
+
+
void = null;
totalInboundBytes = 0;
+ totalUserHours = 0;
+ totalAverageDevices = 0;
/** The number to which access key transfer amounts are compared for progress bar display */
baselineDataTransfer = Number.POSITIVE_INFINITY;
accessKeyRows: DisplayAccessKey[] = [];
@@ -922,6 +958,33 @@ export class ServerView extends DirMixin(PolymerElement) {
return this.accessKeyRows.find(key => key.id === id);
}
+ _computeServerMetrics(
+ totalAverageDevices: number,
+ totalUserHours: number,
+ totalInboundBytes: number,
+ language: string
+ ) {
+ return [
+ {
+ icon: 'devices',
+ name: this.localize('server-metrics-average-devices'),
+ value: totalAverageDevices.toFixed(2),
+ },
+ {
+ icon: 'timer',
+ name: this.localize('server-metrics-user-hours'),
+ units: this._formatHourUnits(totalUserHours, language),
+ value: this._formatHourValue(totalUserHours, language),
+ },
+ {
+ icon: 'swap_horiz',
+ name: this.localize('server-metrics-data-transferred'),
+ units: this._formatInboundBytesUnit(totalInboundBytes, language),
+ value: this._formatInboundBytesValue(totalInboundBytes, language),
+ },
+ ];
+ }
+
_closeAddAccessKeyHelpBubble() {
(this.$.addAccessKeyHelpBubble as OutlineHelpBubble).hide();
}
@@ -1066,6 +1129,35 @@ export class ServerView extends DirMixin(PolymerElement) {
return formatting.formatBytesParts(totalBytes, language).value;
}
+ _formatHourUnits(hours: number, language: string) {
+ // This happens during app startup before we set the language
+ if (!language) {
+ return '';
+ }
+
+ const formattedValue = this._formatHourValue(hours, language);
+ const formattedValueAndUnit = new Intl.NumberFormat(language, {
+ style: 'unit',
+ unit: 'hour',
+ unitDisplay: 'long',
+ }).format(hours);
+
+ return formattedValueAndUnit
+ .split(formattedValue)
+ .find(_ => _)
+ .trim();
+ }
+
+ _formatHourValue(hours: number, language: string) {
+ // This happens during app startup before we set the language
+ if (!language) {
+ return '';
+ }
+ return new Intl.NumberFormat(language, {
+ unit: 'hour',
+ }).format(hours);
+ }
+
_formatBytesTransferred(numBytes: number, language: string, emptyValue = '') {
if (!numBytes) {
// numBytes may not be set for manual servers, or may be 0 for