How to use the opennms.Model.Severities function in opennms

To help you get started, we’ve selected a few opennms examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github OpenNMS / opennms-helm / src / datasources / entity-ds / Examples.js View on Github external
export class Example {
    constructor(description, apiFilter) {
        this.apiFilter = apiFilter;
        this.description = description;
    }
}

// Some examples to use
export const Examples = [
    new Example("Show all alarms", new API.Filter()),
    new Example("Show all alarms for location 'Default'",
        new API.Filter().withAndRestriction(new API.Restriction("node.location.locationName", API.Comparators.EQ, 'Default'))),
    new Example("Show all alarms with a severity between 'Warning' and 'Major'",
        new API.Filter()
            .withAndRestriction(new API.Restriction("alarm.severity", API.Comparators.GE, Model.Severities.WARNING.label))
            .withAndRestriction(new API.Restriction("alarm.severity", API.Comparators.LE, Model.Severities.MAJOR.label))),
    new Example("Show all alarms for nodes in category 'Servers'",
        new API.Filter().withAndRestriction(new API.Restriction("category.name", API.Comparators.EQ, 'Severs'))),
    new Example("Show all unacknowledged alarms",
        new API.Filter().withAndRestriction(new API.Restriction("alarmAckTime", API.Comparators.EQ, 'null'))),
    new Example("Show all acknowledged alarms",
        new API.Filter().withAndRestriction(new API.Restriction("alarmAckTime", API.Comparators.NE, 'null'))),

];
github OpenNMS / opennms-helm / src / datasources / entity-ds / Examples.js View on Github external
export class Example {
    constructor(description, apiFilter) {
        this.apiFilter = apiFilter;
        this.description = description;
    }
}

// Some examples to use
export const Examples = [
    new Example("Show all alarms", new API.Filter()),
    new Example("Show all alarms for location 'Default'",
        new API.Filter().withAndRestriction(new API.Restriction("node.location.locationName", API.Comparators.EQ, 'Default'))),
    new Example("Show all alarms with a severity between 'Warning' and 'Major'",
        new API.Filter()
            .withAndRestriction(new API.Restriction("alarm.severity", API.Comparators.GE, Model.Severities.WARNING.label))
            .withAndRestriction(new API.Restriction("alarm.severity", API.Comparators.LE, Model.Severities.MAJOR.label))),
    new Example("Show all alarms for nodes in category 'Servers'",
        new API.Filter().withAndRestriction(new API.Restriction("category.name", API.Comparators.EQ, 'Severs'))),
    new Example("Show all unacknowledged alarms",
        new API.Filter().withAndRestriction(new API.Restriction("alarmAckTime", API.Comparators.EQ, 'null'))),
    new Example("Show all acknowledged alarms",
        new API.Filter().withAndRestriction(new API.Restriction("alarmAckTime", API.Comparators.NE, 'null'))),

];
github OpenNMS / opennms-helm / src / datasources / entity-ds / datasource.js View on Github external
.then(property => {
              if (!property) {
                  return this.q.when([]);
              }
              // Special handling for properties
              switch(property.id) {
                  // Severity is handled separately as otherwise the severity ordinal vs the severity label would be
                  // used, but that may not be ideal for the user
                  case 'severity':
                      return this.q.when(_.map(Model.Severities, severity => {
                          return {
                              id: severity.id,
                              label: severity.label
                          }
                      }));
              }
              return property.findValues({limit: 1000}).then(values => {
                  return values.filter(value => value !== null).map(value => {
                      return {id: value, label: value, text: value ? String(value) : value, value: value}
                  });
              });
          });
    }
github OpenNMS / opennms-helm / src / spec / lib_custom_action_spec.js View on Github external
it('should interpolate a variable that refers to an object', () => {
      const ca = new CustomAction('foo', 'http://bar/$severity');
      const alarm = new Model.OnmsAlarm();
      alarm.severity = Model.Severities.NORMAL;
      expect(ca.interpolate(alarm)).to.equal('http://bar/NORMAL');
    });
    it('should validate a variable with a number index', () => {
github OpenNMS / opennms-helm / src / panels / alarm-table / table_model.js View on Github external
severityForLabel(label) {
    const sev = Model.Severities[label];
    if (sev) {
      return sev.id;
    } else {
      console.warn('Unable to determine severity for "' + label + '".');
      return -1;
    }
  }
github OpenNMS / opennms-helm / src / spec / lib_custom_action_spec.js View on Github external
it('should validate a variable that refers to an object', () => {
      const ca = new CustomAction('foo', 'http://bar/$severity');
      const alarm = new Model.OnmsAlarm();
      alarm.severity = Model.Severities.NORMAL;
      expect(ca.validate(alarm)).to.be.true;
    });
    it('should interpolate a variable that refers to an object', () => {
github OpenNMS / opennms-helm / src / panels / alarm-table / action_mgr.js View on Github external
let escalatableRows = _.filter(this.rows, row => {
      let severity = row.alarm.severity;
      return severity.index >= Model.Severities.CLEARED.index && severity.index < Model.Severities.CRITICAL.index;
    });
    this.addOptionToContextMenu('General', 'Escalate', escalatableRows,
github OpenNMS / opennms-helm / src / panels / alarm-table / renderer.js View on Github external
return v => {
        if (v === null || v === void 0) {
          return '-';
        }

        if (column.style.displayAs === 'label') {
          return Model.Severities[v].toDisplayString();
        } else if (column.style.displayAs === 'labelCaps') {
          return v;
        } else {
          var icon = TableRenderer.getIconForSeverity(v.toLowerCase());
          return `<i title="${v}" class="icon severity-icon fa ${icon}"></i>`;
        }
      };
    }