File

src/app/shared/model/about/feature-info.model.ts

Description

Contains meta data about the supported features.

Implements

Serializable

Example

Index

Properties
Methods

Methods

Public deserialize
deserialize(input: )
Parameters :
Name Type Optional Description
input
Returns : this
Public isFeatureEnabled
isFeatureEnabled(feature: string)

Perform a check of the passed in string whether it matches any of the supported and set features.

Parameters :
Name Type Optional Description
feature string
Returns : boolean
Public reset
reset()

Set the FeatureInfo object to default values.

Returns : void

Properties

Public grafanaEnabled
grafanaEnabled:
Default value : false
Public schedulesEnabled
schedulesEnabled:
Default value : false
Public streamsEnabled
streamsEnabled:
Default value : false
Public tasksEnabled
tasksEnabled:
Default value : false
import { Serializable } from '../serialization/serializable.model';
import { LoggerService } from '../../services/logger.service';

/**
 * Contains meta data about the supported features.
 *
 * @author Gunnar Hillert
 * @author Damien Vitrac
 */
export class FeatureInfo implements Serializable<FeatureInfo> {

  public streamsEnabled = false;
  public tasksEnabled = false;
  public schedulesEnabled = false;
  public grafanaEnabled = false;


  /**
   * Set the FeatureInfo object to default values.
   */
  public reset() {
    this.streamsEnabled = false;
    this.tasksEnabled = false;
    this.schedulesEnabled = false;
    this.grafanaEnabled = false;
  }

  public deserialize(input) {
    this.streamsEnabled = input['streamsEnabled'] === true;
    this.tasksEnabled = input['tasksEnabled'] === true;
    this.schedulesEnabled = input['schedulesEnabled'] === true;
    this.grafanaEnabled = input['grafanaEnabled'] === true;
    return this;
  }

  /**
   * Perform a check of the passed in string
   * whether it matches any of the supported and set features.
   *
   * @param feature
   */
  public isFeatureEnabled(feature: string): boolean {
    if (feature) {
      switch (feature) {
        case 'streamsEnabled': {
          return this.streamsEnabled;
        }
        case 'tasksEnabled': {
          return this.tasksEnabled;
        }
        case 'schedulesEnabled': {
          return this.schedulesEnabled;
        }
        case 'grafanaEnabled': {
          return this.grafanaEnabled;
        }
        default: {
          LoggerService.error(`Unsupported feature parameter '${feature}'.`);
          return false;
        }
      }
    } else {
      LoggerService.error('Feature string parameter was not there.');
      return false;
    }
  }
}

results matching ""

    No results matching ""