當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。