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