github.com/outbrain/consul@v1.4.5/ui-v2/app/models/node.js (about)

     1  import Model from 'ember-data/model';
     2  import attr from 'ember-data/attr';
     3  import { computed, get } from '@ember/object';
     4  import sumOfUnhealthy from 'consul-ui/utils/sumOfUnhealthy';
     5  import hasStatus from 'consul-ui/utils/hasStatus';
     6  
     7  export const PRIMARY_KEY = 'uid';
     8  export const SLUG_KEY = 'ID';
     9  
    10  export default Model.extend({
    11    [PRIMARY_KEY]: attr('string'),
    12    [SLUG_KEY]: attr('string'),
    13    Address: attr('string'),
    14    Node: attr('string'),
    15    Meta: attr(),
    16    Services: attr(),
    17    Checks: attr(),
    18    CreateIndex: attr('number'),
    19    ModifyIndex: attr('number'),
    20    TaggedAddresses: attr(),
    21    Datacenter: attr('string'),
    22    Segment: attr(),
    23    Coord: attr(),
    24    hasStatus: function(status) {
    25      return hasStatus(get(this, 'Checks'), status);
    26    },
    27    isHealthy: computed('Checks', function() {
    28      return sumOfUnhealthy(get(this, 'Checks')) === 0;
    29    }),
    30    isUnhealthy: computed('Checks', function() {
    31      return sumOfUnhealthy(get(this, 'Checks')) > 0;
    32    }),
    33  });