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


TypeScript backend_srv.BackendSrv类代码示例

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


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

示例1: constructor

  /** @ngInject */
  constructor($scope: any, backendSrv: BackendSrv, navModelSrv: NavModelSrv) {
    this.navModel = navModelSrv.getNav('admin', 'server-settings');

    backendSrv.get('/api/admin/settings').then((settings: any) => {
      $scope.settings = settings;
    });
  }
开发者ID:grafana,项目名称:grafana,代码行数:8,代码来源:index.ts

示例2: describe

describe('backend_srv', () => {
  const _httpBackend = options => {
    if (options.url === 'gateway-error') {
      return Promise.reject({ status: 502 });
    }
    return Promise.resolve({});
  };

  const _backendSrv = new BackendSrv(
    _httpBackend,
    {} as angular.IQService,
    {} as angular.ITimeoutService,
    {} as ContextSrv
  );

  describe('when handling errors', () => {
    it('should return the http status code', async () => {
      try {
        await _backendSrv.datasourceRequest({
          url: 'gateway-error',
        });
      } catch (err) {
        expect(err.status).toBe(502);
      }
    });
  });
});
开发者ID:grafana,项目名称:grafana,代码行数:27,代码来源:backend_srv.test.ts

示例3:

 $scope.getUser = (id: number) => {
   backendSrv.get('/api/users/' + id).then((user: User) => {
     $scope.user = user;
     $scope.user_id = id;
     $scope.permissions.isGrafanaAdmin = user.isGrafanaAdmin;
   });
 };
开发者ID:grafana,项目名称:grafana,代码行数:7,代码来源:AdminEditUserCtrl.ts

示例4: getDefaultProject

 async getDefaultProject() {
   try {
     if (this.authenticationType === 'gce' || !this.projectName) {
       const { data } = await this.backendSrv.datasourceRequest({
         url: '/api/tsdb/query',
         method: 'POST',
         data: {
           queries: [
             {
               refId: 'ensureDefaultProjectQuery',
               type: 'ensureDefaultProjectQuery',
               datasourceId: this.id,
             },
           ],
         },
       });
       this.projectName = data.results.ensureDefaultProjectQuery.meta.defaultProject;
       return this.projectName;
     } else {
       return this.projectName;
     }
   } catch (error) {
     throw this.formatStackdriverError(error);
   }
 }
开发者ID:grafana,项目名称:grafana,代码行数:25,代码来源:datasource.ts

示例5: deleteNotification

 deleteNotification(id: number) {
   this.backendSrv.delete(`/api/alert-notifications/${id}`).then(() => {
     this.notifications = this.notifications.filter((notification: any) => {
       return notification.id !== id;
     });
   });
 }
开发者ID:grafana,项目名称:grafana,代码行数:7,代码来源:NotificationsListCtrl.ts

示例6:

    $scope.update = () => {
      if (!$scope.orgDetailsForm.$valid) {
        return;
      }

      backendSrv.put('/api/orgs/' + $scope.org.id, $scope.org).then(() => {
        $location.path('/admin/orgs');
      });
    };
开发者ID:grafana,项目名称:grafana,代码行数:9,代码来源:AdminEditOrgCtrl.ts

示例7: it

 it('should return the http status code', async () => {
   try {
     await _backendSrv.datasourceRequest({
       url: 'gateway-error',
     });
   } catch (err) {
     expect(err.status).toBe(502);
   }
 });
开发者ID:gzq0616,项目名称:grafana,代码行数:9,代码来源:backend_srv.test.ts


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