mirror of
https://github.com/status-im/consul.git
synced 2025-01-10 13:55:55 +00:00
5fb9df1640
* Adding explicit MPL license for sub-package This directory and its subdirectories (packages) contain files licensed with the MPLv2 `LICENSE` file in this directory and are intentionally licensed separately from the BSL `LICENSE` file at the root of this repository. * Adding explicit MPL license for sub-package This directory and its subdirectories (packages) contain files licensed with the MPLv2 `LICENSE` file in this directory and are intentionally licensed separately from the BSL `LICENSE` file at the root of this repository. * Updating the license from MPL to Business Source License Going forward, this project will be licensed under the Business Source License v1.1. Please see our blog post for more details at <Blog URL>, FAQ at www.hashicorp.com/licensing-faq, and details of the license at www.hashicorp.com/bsl. * add missing license headers * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 --------- Co-authored-by: hashicorp-copywrite[bot] <110428419+hashicorp-copywrite[bot]@users.noreply.github.com>
76 lines
2.3 KiB
JavaScript
76 lines
2.3 KiB
JavaScript
/**
|
|
* Copyright (c) HashiCorp, Inc.
|
|
* SPDX-License-Identifier: BUSL-1.1
|
|
*/
|
|
|
|
import Model, { attr, hasMany } from '@ember-data/model';
|
|
import { computed } from '@ember/object';
|
|
import { filter } from '@ember/object/computed';
|
|
import { fragmentArray } from 'ember-data-model-fragments/attributes';
|
|
|
|
export const PRIMARY_KEY = 'uid';
|
|
export const SLUG_KEY = 'ID';
|
|
|
|
export default class Node extends Model {
|
|
@attr('string') uid;
|
|
@attr('string') ID;
|
|
|
|
@attr('string') Datacenter;
|
|
@attr('string') PeerName;
|
|
@attr('string') Partition;
|
|
@attr('string') Address;
|
|
@attr('string') Node;
|
|
@attr('number') SyncTime;
|
|
@attr('number') CreateIndex;
|
|
@attr('number') ModifyIndex;
|
|
@attr() meta; // {}
|
|
@attr() Meta; // {}
|
|
@attr() TaggedAddresses; // {lan, wan}
|
|
@attr({ defaultValue: () => [] }) Resources; // []
|
|
// Services are reshaped to a different shape to what you sometimes get from
|
|
// the response, see models/node.js
|
|
@hasMany('service-instance') Services; // TODO: Rename to ServiceInstances
|
|
@fragmentArray('health-check') Checks;
|
|
// MeshServiceInstances are all instances that aren't connect-proxies this
|
|
// currently includes gateways as these need to show up in listings
|
|
@filter('Services', (item) => item.Service.Kind !== 'connect-proxy') MeshServiceInstances;
|
|
// ProxyServiceInstances are all instances that are connect-proxies
|
|
@filter('Services', (item) => item.Service.Kind === 'connect-proxy') ProxyServiceInstances;
|
|
|
|
@filter('Checks', (item) => item.ServiceID === '') NodeChecks;
|
|
|
|
@computed('ChecksCritical', 'ChecksPassing', 'ChecksWarning')
|
|
get Status() {
|
|
switch (true) {
|
|
case this.ChecksCritical !== 0:
|
|
return 'critical';
|
|
case this.ChecksWarning !== 0:
|
|
return 'warning';
|
|
case this.ChecksPassing !== 0:
|
|
return 'passing';
|
|
default:
|
|
return 'empty';
|
|
}
|
|
}
|
|
|
|
@computed('NodeChecks.[]')
|
|
get ChecksCritical() {
|
|
return this.NodeChecks.filter((item) => item.Status === 'critical').length;
|
|
}
|
|
|
|
@computed('NodeChecks.[]')
|
|
get ChecksPassing() {
|
|
return this.NodeChecks.filter((item) => item.Status === 'passing').length;
|
|
}
|
|
|
|
@computed('NodeChecks.[]')
|
|
get ChecksWarning() {
|
|
return this.NodeChecks.filter((item) => item.Status === 'warning').length;
|
|
}
|
|
|
|
@computed('Meta')
|
|
get Version() {
|
|
return this.Meta?.['consul-version'] ?? '';
|
|
}
|
|
}
|