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


TypeScript chrome.addBasePath函数代码示例

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


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

示例1: requestFile

export async function requestFile(
  payload: FetchFilePayload,
  line?: string
): Promise<FetchFileResponse> {
  const { uri, revision, path } = payload;
  const url = `/api/code/repo/${uri}/blob/${encodeURIComponent(revision)}/${path}`;
  const query: any = {};
  if (line) {
    query.line = line;
  }
  const response: Response = await fetch(chrome.addBasePath(Url.format({ pathname: url, query })));

  if (response.status >= 200 && response.status < 300) {
    const contentType = response.headers.get('Content-Type');

    if (contentType && contentType.startsWith('text/')) {
      const lang = contentType.split(';')[0].substring('text/'.length);
      if (lang === 'big') {
        return {
          payload,
          content: '',
          isOversize: true,
        };
      }
      return {
        payload,
        lang,
        content: await response.text(),
        isUnsupported: false,
      };
    } else if (contentType && contentType.startsWith('image/')) {
      return {
        payload,
        isImage: true,
        content: '',
        url,
        isUnsupported: false,
      };
    } else {
      return {
        payload,
        isImage: false,
        content: '',
        url,
        isUnsupported: true,
      };
    }
  } else if (response.status === 404) {
    return {
      payload,
      isNotFound: true,
    };
  }
  throw new Error('invalid file type');
}
开发者ID:elastic,项目名称:kibana,代码行数:55,代码来源:file.ts

示例2: get

  (uiCapabilities: UICapabilities, kbnBaseUrl: string, $route: any, kbnUrl: any) => {
    const route = get($route, 'current.$$route') as any;
    if (!route.requireUICapability) {
      return;
    }

    if (!get(uiCapabilities, route.requireUICapability)) {
      const url = chrome.addBasePath(`${kbnBaseUrl}#/home`);
      kbnUrl.redirect(url);
      throw uiRoutes.WAIT_FOR_URL_CHANGE_TOKEN;
    }
  }
开发者ID:elastic,项目名称:kibana,代码行数:12,代码来源:route_setup.ts

示例3: moveToDiscover

export function moveToDiscover(indexPatternId: string, kbnBaseUrl: string) {
  const _g = rison.encode({});

  // Add the index pattern ID to the appState part of the URL.
  const _a = rison.encode({
    index: indexPatternId,
  });

  const baseUrl = chrome.addBasePath(kbnBaseUrl);
  const hash = `#/discover?_g=${_g}&_a=${_a}`;

  window.location.href = `${baseUrl}${hash}`;
}
开发者ID:elastic,项目名称:kibana,代码行数:13,代码来源:navigation.ts

示例4: getKibanaHref

export function getKibanaHref({
  location,
  pathname = '',
  hash,
  query = {}
}: KibanaHrefArgs): string {
  const search = getSearchString(location, pathname, query);
  const href = url.format({
    pathname: chrome.addBasePath(pathname),
    hash: `${hash}?${search}`
  });
  return href;
}
开发者ID:njd5475,项目名称:kibana,代码行数:13,代码来源:url_helpers.ts

示例5: getKibanaHref

export function getKibanaHref({
  location,
  pathname = '',
  hash,
  query = {}
}: KibanaHrefArgs): string {
  const queryWithRisonParams = getQueryWithRisonParams(location, query);
  const search = stringifyWithoutEncoding(queryWithRisonParams);
  const href = url.format({
    pathname: chrome.addBasePath(pathname),
    hash: `${hash}?${search}`
  });
  return href;
}
开发者ID:liuyepiaoxiang,项目名称:kibana,代码行数:14,代码来源:url_helpers.ts

示例6: trackUiMetric

export function trackUiMetric(appName: string, metricType: string | string[]) {
  if (!getCanTrackUiMetrics()) {
    return;
  }

  if (appName.includes(':')) {
    throw createErrorMessage(`app name '${appName}'`);
  }

  if (metricType.includes(':')) {
    throw createErrorMessage(`metric type ${metricType}`);
  }

  const metricTypes = Array.isArray(metricType) ? metricType.join(',') : metricType;
  const uri = chrome.addBasePath(`${API_BASE_PATH}/${appName}/${metricTypes}`);
  _http.post(uri);
}
开发者ID:elastic,项目名称:kibana,代码行数:17,代码来源:index.ts

示例7: fetchText

  private async fetchText(resource: Uri) {
    const repo = `${resource.authority}${resource.path}`;
    const revision = resource.query;
    const file = resource.fragment;
    const response = await fetch(
      chrome.addBasePath(`/api/code/repo/${repo}/blob/${revision}/${file}`)
    );
    if (response.status === 200) {
      const contentType = response.headers.get('Content-Type');

      if (contentType && contentType.startsWith('text/')) {
        const lang = contentType.split(';')[0].substring('text/'.length);
        const text = await response.text();
        return { text, lang };
      }
    } else {
      return null;
    }
  }
开发者ID:elastic,项目名称:kibana,代码行数:19,代码来源:textmodel_resolver.ts

示例8: getRisonHref

export function getRisonHref({
  location,
  pathname,
  hash,
  query = {}
}: RisonHrefArgs) {
  const currentQuery = toQuery(location.search);
  const nextQuery = {
    ...TIMEPICKER_DEFAULTS,
    ...pick(currentQuery, PERSISTENT_APM_PARAMS),
    ...query
  };

  // Create _g value for non-apm links
  const g = createG(nextQuery);
  const encodedG = rison.encode(g);
  const encodedA = query._a ? rison.encode(query._a) : ''; // TODO: Do we need to url-encode the _a values before rison encoding _a?
  const risonQuery: RisonEncoded = {
    _g: encodedG
  };

  if (encodedA) {
    risonQuery._a = encodedA;
  }

  // don't URI-encode the already-encoded rison
  const search = qs.stringify(risonQuery, undefined, undefined, {
    encodeURIComponent: (v: string) => v
  });

  const href = url.format({
    pathname: chrome.addBasePath(pathname),
    hash: `${hash}?${search}`
  });

  return href;
}
开发者ID:njd5475,项目名称:kibana,代码行数:37,代码来源:rison_helpers.ts

示例9: saveRole

/*
 * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
 * or more contributor license agreements. Licensed under the Elastic License;
 * you may not use this file except in compliance with the Elastic License.
 */
import { omit } from 'lodash';
import chrome from 'ui/chrome';
import { Role } from '../../../common/model/role';

const apiBase = chrome.addBasePath(`/api/security/role`);

export async function saveRole($http: any, role: Role) {
  const data = omit(role, 'name', 'transient_metadata', '_unrecognized_applications');
  return await $http.put(`${apiBase}/${role.name}`, data);
}

export async function deleteRole($http: any, name: string) {
  return await $http.delete(`${apiBase}/${name}`);
}
开发者ID:gingerwizard,项目名称:kibana,代码行数:19,代码来源:roles.ts

示例10: createUserActionUri

export function createUserActionUri(appName: string, actionType: string): string {
  return chrome.addBasePath(`/api/user_action/${appName}/${actionType}`);
}
开发者ID:njd5475,项目名称:kibana,代码行数:3,代码来源:user_action.ts


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