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


TypeScript URLExt.join方法代码示例

本文整理汇总了TypeScript中@jupyterlab/coreutils.URLExt.join方法的典型用法代码示例。如果您正苦于以下问题:TypeScript URLExt.join方法的具体用法?TypeScript URLExt.join怎么用?TypeScript URLExt.join使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在@jupyterlab/coreutils.URLExt的用法示例。


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

示例1: makeSettings

 export function makeSettings(
   options: Partial<ServerConnection.ISettings> = {}
 ): ServerConnection.ISettings {
   let extra: Partial<ServerConnection.ISettings> = {};
   if (options.baseUrl && !options.wsUrl) {
     // Setting baseUrl to https://host... sets wsUrl to wss://host...
     let baseUrl = options.baseUrl;
     if (baseUrl.indexOf('http') !== 0) {
       if (typeof location !== 'undefined') {
         baseUrl = URLExt.join(location.origin, baseUrl);
       } else {
         // TODO: Why are we hardcoding localhost and 8888? That doesn't seem
         // good. See https://github.com/jupyterlab/jupyterlab/issues/4761
         baseUrl = URLExt.join('http://localhost:8888/', baseUrl);
       }
     }
     extra = {
       wsUrl: 'ws' + baseUrl.slice(4)
     };
   }
   return {
     ...ServerConnection.defaultSettings,
     ...options,
     ...extra
   };
 }
开发者ID:dalejung,项目名称:jupyterlab,代码行数:26,代码来源:serverconnection.ts

示例2: getCurrent

    execute: args => {
      const current = getCurrent(args);

      if (!current) {
        return;
      }

      const notebookPath = URLExt.encodeParts(current.context.path);
      const url = URLExt.join(
        services.serverSettings.baseUrl,
        'nbconvert',
        (args['format']) as string,
        notebookPath
      ) + '?download=true';
      const child = window.open('', '_blank');
      const { context } = current;

      if (context.model.dirty && !context.model.readOnly) {
        return context.save().then(() => { child.location.assign(url); });
      }

      return new Promise<void>((resolve) => {
        child.location.assign(url);
        resolve(undefined);
      });
    },
开发者ID:SimonBiggs,项目名称:jupyterlab,代码行数:26,代码来源:index.ts

示例3: showDialog

 }).then(result => {
   if (result.button.accept) {
     let setting = ServerConnection.makeSettings();
     let apiURL = URLExt.join(setting.baseUrl, 'api/shutdown');
     ServerConnection.makeRequest(apiURL, { method: 'POST' }, setting)
       .then(result => {
         if (result.ok) {
           // Close this window if the shutdown request has been successful
           let body = document.createElement('div');
           body.innerHTML = `<p>You have shut down the Jupyter server. You can now close this tab.</p>
             <p>To use JupyterLab again, you will need to relaunch it.</p>`;
           showDialog({
             title: 'Server stopped',
             body: new Widget({ node: body }),
             buttons: []
           });
           window.close();
         } else {
           throw new ServerConnection.ResponseError(result);
         }
       })
       .catch(data => {
         throw new ServerConnection.NetworkError(data);
       });
   }
 });
开发者ID:SylvainCorlay,项目名称:jupyterlab,代码行数:26,代码来源:index.ts

示例4: redirect

  export async function redirect(
    router: IRouter,
    paths: JupyterFrontEnd.IPaths,
    workspace: string,
    warn = false
  ): Promise<void> {
    const form = createRedirectForm(warn);
    const dialog = new Dialog({
      title: 'Please use a different workspace.',
      body: form,
      focusNodeSelector: 'input',
      buttons: [Dialog.okButton({ label: 'Switch Workspace' })]
    });
    const result = await dialog.launch();

    dialog.dispose();
    if (!result.value) {
      return redirect(router, paths, workspace, true);
    }

    // Navigate to a new workspace URL and abandon this session altogether.
    const page = paths.urls.page;
    const workspaces = paths.urls.workspaces;
    const prefix = (workspace ? workspaces : page).length + workspace.length;
    const rest = router.current.request.substring(prefix);
    const url = URLExt.join(workspaces, result.value, rest);

    router.navigate(url, { hard: true, silent: true });

    // This promise will never resolve because the application navigates
    // away to a new location. It only exists to satisfy the return type
    // of the `redirect` function.
    return new Promise<void>(() => undefined);
  }
开发者ID:afshin,项目名称:jupyterlab,代码行数:34,代码来源:index.ts

示例5: async

  activate: async (app: JupyterLab, router: IRouter) => {
    const resolver = new WindowResolver();
    const match = router.current.path.match(Patterns.workspace);
    const workspace = (match && decodeURIComponent(match[1])) || '';
    const candidate = workspace
      ? URLExt.join(
          PageConfig.getOption('baseUrl'),
          PageConfig.getOption('workspacesUrl'),
          workspace
        )
      : app.info.defaultWorkspace;

    try {
      await resolver.resolve(candidate);
    } catch (error) {
      console.warn('Window resolution failed:', error);

      // Return a promise that never resolves.
      return new Promise<IWindowResolver>(() => {
        Private.redirect(router);
      });
    }

    PageConfig.setOption('workspace', resolver.name);

    return resolver;
  }
开发者ID:willingc,项目名称:jupyterlab,代码行数:27,代码来源:index.ts

示例6: getCurrent

    execute: args => {
      let current = getCurrent(args);
      if (!current) {
        return;
      }

      let notebookPath = URLExt.encodeParts(current.context.path);
      let url = URLExt.join(
        services.serverSettings.baseUrl,
        'nbconvert',
        (args['format']) as string,
        notebookPath
      ) + '?download=true';

      let w = window.open('', '_blank');
      if (current.context.model.dirty && !current.context.model.readOnly) {
        return current.context.save().then(() => {
          w.location.assign(url);
        });
      } else {
        return new Promise((resolve, reject) => {
          w.location.assign(url);
        });
      }
    },
开发者ID:charnpreetsingh185,项目名称:jupyterlab,代码行数:25,代码来源:index.ts

示例7: redirect

  export async function redirect(router: IRouter, warn = false): Promise<void> {
    const form = createRedirectForm(warn);
    const dialog = new Dialog({
      title: 'Please use a different workspace.',
      body: form,
      focusNodeSelector: 'input',
      buttons: [Dialog.okButton({ label: 'Switch Workspace' })]
    });

    const result = await dialog.launch();

    dialog.dispose();
    if (!result.value) {
      return redirect(router, true);
    }

    // Navigate to a new workspace URL and abandon this session altogether.
    const workspaces = PageConfig.getOption('workspacesUrl');
    const url = URLExt.join(workspaces, result.value);

    router.navigate(url, { hard: true, silent: true });

    // This promise will never resolve because the application navigates
    // away to a new location. It only exists to satisfy the return type
    // of the `redirect` function.
    return new Promise<void>(() => undefined);
  }
开发者ID:willingc,项目名称:jupyterlab,代码行数:27,代码来源:index.ts

示例8: getStatus

  /**
   * Get whether the application should be built.
   */
  getStatus(): Promise<BuildManager.IStatus> {
    const base = this.serverSettings.baseUrl;
    const url = URLExt.join(base, BUILD_SETTINGS_URL);
    const request = { method: 'GET', url };
    const { serverSettings } = this;
    const promise = ServerConnection.makeRequest(request, serverSettings);

    return promise.then(response => {
      const { status } = response.xhr;

      if (status !== 200) {
        throw ServerConnection.makeError(response);
      }

      let data = response.data as BuildManager.IStatus;
      if (typeof data.status !== 'string') {
        throw ServerConnection.makeError(response, 'Invalid data');
      }
      if (typeof data.message !== 'string') {
        throw ServerConnection.makeError(response, 'Invalid data');
      }
      return data;

    }).catch(reason => { throw ServerConnection.makeError(reason); });
  }
开发者ID:cameronoelsen,项目名称:jupyterlab,代码行数:28,代码来源:index.ts

示例9: encodeURI

 execute: () => {
   const widget = tracker.currentWidget;
   if (!widget) {
     return;
   }
   const path = encodeURI(widget.selectedItems().next().path);
   Clipboard.copyToSystem(URLExt.join(PageConfig.getTreeUrl(), path));
 },
开发者ID:jupyter,项目名称:jupyterlab,代码行数:8,代码来源:index.ts

示例10: candidate

 export function candidate(
   paths: JupyterFrontEnd.IPaths,
   workspace = ''
 ): string {
   return workspace
     ? URLExt.join(paths.urls.base, paths.urls.workspaces, workspace)
     : paths.urls.defaultWorkspace;
 }
开发者ID:jupyter,项目名称:jupyterlab,代码行数:8,代码来源:index.ts


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