当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript core_module.service函数代码示例

本文整理汇总了TypeScript中app/core/core_module.service函数的典型用法代码示例。如果您正苦于以下问题:TypeScript service函数的具体用法?TypeScript service怎么用?TypeScript service使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了service函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: zoomOut

      from: dateMath.parse(raw.from, false, timezone),
      to: dateMath.parse(raw.to, true, timezone),
      raw: raw,
    };
  }

  zoomOut(e, factor) {
    const range = this.timeRange();

    const timespan = range.to.valueOf() - range.from.valueOf();
    const center = range.to.valueOf() - timespan / 2;

    const to = center + timespan * factor / 2;
    const from = center - timespan * factor / 2;

    this.setTime({ from: moment.utc(from), to: moment.utc(to) });
  }
}

let singleton;

export function setTimeSrv(srv: TimeSrv) {
  singleton = srv;
}

export function getTimeSrv(): TimeSrv {
  return singleton;
}

coreModule.service('timeSrv', TimeSrv);
开发者ID:CorpGlory,项目名称:grafana,代码行数:30,代码来源:TimeSrv.ts

示例2: create

      for (i = 0; i < this.rows.length; i++) {
        var row = this.rows[i];
        for (j = 0; j < row.panels.length; j++) {
          for (k = 0; k < panelUpgrades.length; k++) {
            panelUpgrades[k].call(this, row.panels[j]);
          }
        }
      }
    }
}


export class DashboardSrv {
  currentDashboard: any;

  create(dashboard, meta) {
    return new DashboardModel(dashboard, meta);
  }

  setCurrent(dashboard) {
    this.currentDashboard = dashboard;
  }

  getCurrent() {
    return this.currentDashboard;
  }
}

coreModule.service('dashboardSrv', DashboardSrv);

开发者ID:sis-labs,项目名称:grafana,代码行数:29,代码来源:dashboard_srv.ts

示例3:

    this.bind('d s', () => {
      this.showDashEditView('settings');
    });

    this.bind('d k', () => {
      appEvents.emit('toggle-kiosk-mode');
    });

    this.bind('d v', () => {
      appEvents.emit('toggle-view-mode');
    });

    this.bind('esc', () => {
      var popups = $('.popover.in');
      if (popups.length > 0) {
        return;
      }
      // close modals
      var modalData = $(".modal").data();
      if (modalData && modalData.$scope && modalData.$scope.dismiss) {
        modalData.$scope.dismiss();
      }

      scope.appEvent('hide-dash-editor');
      scope.exitFullscreen();
    });
  }
}

coreModule.service('keybindingSrv', KeybindingSrv);
开发者ID:navedalam,项目名称:grafana,代码行数:30,代码来源:keybindingSrv.ts

示例4: repeatPanel

    // restore id
    clone.id = tmpId;
    clone.repeatIteration = this.iteration;
    clone.repeatPanelId = sourcePanel.id;
    clone.repeat = null;
    return clone;
  }

  repeatPanel(panel, row) {
    var variable = _.find(this.variables, {name: panel.repeat});
    if (!variable) { return; }

    var selected;
    if (variable.current.text === 'All') {
      selected = variable.options.slice(1, variable.options.length);
    } else {
      selected = _.filter(variable.options, {selected: true});
    }

    _.each(selected, (option, index) => {
      var copy = this.getPanelClone(panel, row, index);
      copy.span = Math.max(12 / selected.length, panel.minSpan || 4);
      copy.scopedVars = copy.scopedVars || {};
      copy.scopedVars[variable.name] = option;
    });
  }
}

coreModule.service('dynamicDashboardSrv', DynamicDashboardSrv);

开发者ID:PaulMest,项目名称:grafana,代码行数:29,代码来源:dynamic_dashboard_srv.ts

示例5:

import './editor_ctrl';
import coreModule from 'app/core/core_module';

import { TemplateSrv } from './template_srv';
import { VariableSrv } from './variable_srv';
import { IntervalVariable } from './interval_variable';
import { QueryVariable } from './query_variable';
import { DatasourceVariable } from './datasource_variable';
import { CustomVariable } from './custom_variable';
import { ConstantVariable } from './constant_variable';
import { AdhocVariable } from './adhoc_variable';

coreModule.service('templateSrv', TemplateSrv);

export {
  TemplateSrv,
  VariableSrv,
  IntervalVariable,
  QueryVariable,
  DatasourceVariable,
  CustomVariable,
  ConstantVariable,
  AdhocVariable,
};
开发者ID:connection-reset,项目名称:grafana,代码行数:24,代码来源:all.ts

示例6: init

///<reference path="../../headers/common.d.ts" />

import coreModule from 'app/core/core_module';

export class AlertingSrv {
  dashboard: any;
  alerts: any[];

  init(dashboard, alerts) {
    this.dashboard = dashboard;
    this.alerts = alerts || [];
  }
}

coreModule.service('alertingSrv', AlertingSrv);
开发者ID:arcolife,项目名称:grafana,代码行数:15,代码来源:alerting_srv.ts

示例7: constructor

}

export interface DiffTarget {
  dashboardId: number;
  version: number;
  unsavedDashboard?: DashboardModel; // when doing diffs against unsaved dashboard version
}

export class HistorySrv {
  /** @ngInject */
  constructor(private backendSrv) {}

  getHistoryList(dashboard: DashboardModel, options: HistoryListOpts) {
    const id = dashboard && dashboard.id ? dashboard.id : void 0;
    return id ? this.backendSrv.get(`api/dashboards/id/${id}/versions`, options) : Promise.resolve([]);
  }

  calculateDiff(options: CalculateDiffOptions) {
    return this.backendSrv.post('api/dashboards/calculate-diff', options);
  }

  restoreDashboard(dashboard: DashboardModel, version: number) {
    const id = dashboard && dashboard.id ? dashboard.id : void 0;
    const url = `api/dashboards/id/${id}/restore`;

    return id && _.isNumber(version) ? this.backendSrv.post(url, { version }) : Promise.resolve({});
  }
}

coreModule.service('historySrv', HistorySrv);
开发者ID:CorpGlory,项目名称:grafana,代码行数:30,代码来源:HistorySrv.ts

示例8: setAdhocFilter

    });

    // add new values
    this.templateSrv.fillVariableValuesForUrl(params);
    // update url
    this.$location.search(params);
  }

  setAdhocFilter(options) {
    var variable = _.find(this.variables, {type: 'adhoc', datasource: options.datasource});
    if (!variable) {
      variable = this.createVariableFromModel({name: 'Filters', type: 'adhoc', datasource: options.datasource});
      this.addVariable(variable);
    }

    let filters = variable.filters;
    let filter =  _.find(filters, {key: options.key, value: options.value});

    if (!filter) {
      filter = {key: options.key, value: options.value};
      filters.push(filter);
    }

    filter.operator = options.operator;
    this.variableUpdated(variable, true);
  }

}

coreModule.service('variableSrv', VariableSrv);
开发者ID:shirish87,项目名称:grafana,代码行数:30,代码来源:variable_srv.ts

示例9:

      const angularUrl = this.$location.url();
      const url = locationUtil.stripBaseFromUrl(state.location.url);
      if (angularUrl !== url) {
        this.$timeout(() => {
          this.$location.url(url);
          // some state changes should not trigger new browser history
          if (state.location.replace) {
            this.$location.replace();
          }
        });
        console.log('store updating angular $location.url', url);
      }
    });

    appEvents.on('location-change', (payload: any) => {
      const urlWithoutBase = locationUtil.stripBaseFromUrl(payload.href);
      if (this.fullPageReloadRoutes.indexOf(urlWithoutBase) > -1) {
        this.$window.location.href = payload.href;
        return;
      }

      this.$timeout(() => {
        // A hack to use timeout when we're changing things (in this case the url) from outside of Angular.
        this.$location.url(urlWithoutBase);
      });
    });
  }
}

coreModule.service('bridgeSrv', BridgeSrv);
开发者ID:grafana,项目名称:grafana,代码行数:30,代码来源:bridge_srv.ts

示例10: destroy

import coreModule from 'app/core/core_module';

export interface AttachedPanel {
  destroy();
}

export class PanelLoader {
  /** @ngInject */
  constructor(private $compile, private $rootScope) {}

  load(elem, panel, dashboard): AttachedPanel {
    var template = '<plugin-component type="panel" class="panel-height-helper"></plugin-component>';
    var panelScope = this.$rootScope.$new();
    panelScope.panel = panel;
    panelScope.dashboard = dashboard;

    const compiledElem = this.$compile(template)(panelScope);
    const rootNode = angular.element(elem);
    rootNode.append(compiledElem);

    return {
      destroy: () => {
        panelScope.$destroy();
        compiledElem.remove();
      },
    };
  }
}

coreModule.service('panelLoader', PanelLoader);
开发者ID:GPegel,项目名称:grafana,代码行数:30,代码来源:PanelLoader.ts


注:本文中的app/core/core_module.service函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。