How to use the @jupyterlab/services.ServerConnection.makeSettings function in @jupyterlab/services

To help you get started, we’ve selected a few @jupyterlab/services examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github hadim / jupyter-archive / src / index.ts View on Github external
function downloadArchiveRequest(
  path: string,
  archiveFormat: ArchiveFormat
): Promise {
  const settings = ServerConnection.makeSettings();

  let baseUrl = settings.baseUrl;
  let url = URLExt.join(baseUrl, DIRECTORIES_URL, URLExt.encodeParts(path));

  const fullurl = new URL(url);

  // Generate a random token.
  const rand = () =>
    Math.random()
      .toString(36)
      .substr(2);
  const token = (length: number) =>
    (rand() + rand() + rand() + rand()).substr(0, length);

  fullurl.searchParams.append("archiveToken", token(20));
  fullurl.searchParams.append("archiveFormat", archiveFormat);
github minrk / thebelab / src / thebelab.js View on Github external
export function requestKernel(kernelOptions) {
  // request a new Kernel
  kernelOptions = mergeOptions({ kernelOptions }).kernelOptions;
  if (kernelOptions.serverSettings) {
    let ss = kernelOptions.serverSettings;
    // workaround bug in jupyterlab where wsUrl and baseUrl must both be set
    // https://github.com/jupyterlab/jupyterlab/pull/4427
    if (ss.baseUrl && !ss.wsUrl) {
      ss.wsUrl = "ws" + ss.baseUrl.slice(4);
    }
    kernelOptions.serverSettings = ServerConnection.makeSettings(
      kernelOptions.serverSettings
    );
  }
  events.trigger("status", {
    status: "starting",
    message: "Starting Kernel",
  });
  let p = Session.startNew(kernelOptions);
  p.then(session => {
    events.trigger("status", {
      status: "ready",
      message: "Kernel is ready",
    });
    let k = session.kernel;
    return k;
  });
github jupyterlab / jupyterlab / tests / test-services / src / serverconnection.spec.ts View on Github external
it('should handle overrides', () => {
        const defaults: Partial = {
          baseUrl: 'foo',
          wsUrl: 'bar',
          init: {
            credentials: 'same-origin'
          },
          token: 'baz'
        };
        const settings = ServerConnection.makeSettings(defaults);
        expect(settings.baseUrl).to.equal(defaults.baseUrl);
        expect(settings.wsUrl).to.equal(defaults.wsUrl);
        expect(settings.token).to.equal(defaults.token);
        expect(settings.init.credentials).to.equal(defaults.init!.credentials);
      });
    });
github jupyterlab / jupyterlab-data-explorer / tests / test-services / src / setting / manager.spec.ts View on Github external
it('should accept options', () => {
        const manager = new SettingManager({
          serverSettings: ServerConnection.makeSettings()
        });
        expect(manager).to.be.an.instanceof(SettingManager);
      });
    });
github jupyter / nbdime / packages / labextension / src / actions.ts View on Github external
function isNbInGit(args: {readonly path: string}): Promise {
  let request = {
      method: 'POST',
      body: JSON.stringify(args),
    };
  let settings = ServerConnection.makeSettings();
  return ServerConnection.makeRequest(
    URLExt.join(urlRStrip(settings.baseUrl), '/nbdime/api/isgit'),
    request, settings).then((response) => {
      if (!response.ok) {
        return Promise.reject(response);
      }
      return response.json() as Promise;
    }).then((data) => {
      return data['is_git'];
    });
}
github jupyter / nbdime / packages / nbdime / src / request / index.ts View on Github external
function requestApiPromise(
    baseUrl: string,
    apiPath: string,
    argument: any): Promise {
  const url = URLExt.join(urlRStrip(baseUrl), apiPath);
  let request = {
    method: 'POST',
    body: JSON.stringify(argument),
  };
  let settings = ServerConnection.makeSettings();
  return ServerConnection.makeRequest(url, request, settings)
    .then(handleError);
}
github ines / juniper / src / index.js View on Github external
requestKernel(settings) {
        if (this.useStorage && typeof window !== 'undefined') {
            const timestamp = new Date().getTime() + this.storageExpire * 60 * 1000;
            const json = JSON.stringify({ settings, timestamp });
            window.localStorage.setItem(this.storageKey, json);
        }
        const serverSettings = ServerConnection.makeSettings(settings);
        return Kernel.startNew({ type: this.kernelType, name: this.kernelType, serverSettings })
            .then(kernel => {
                this._event('ready');
                return kernel;
            });
    }