Example #1
0
  static FromXML(el: Element): [GF, undefined] | [undefined, Error] {
    const table: typeof GFDefaults = Object.assign({}, GFDefaults);
    let err: Error | undefined;

    for (let i = 0; i < el.attributes.length; i++) {
      const attr = el.attributes.item(i);
      if (!attr) {
        continue;
      }
      switch (attr.name.toLowerCase()) {
        case 'type':
          const kind = attr.value.toLowerCase();
          if (kind === 'discrete' || kind === 'continuous' || kind === 'extrapolate') {
            table.type = kind;
          } else {
            return [undefined, new Error(`bad GF type: ${kind}`)];
          }
          break;
      }
    }

    for (let i = 0; i < el.childNodes.length; i++) {
      const child = el.childNodes.item(i) as Element;
      if (child.nodeType !== 1) {
        // Element
        continue;
      }
      switch (child.nodeName.toLowerCase()) {
        case 'xscale':
          [table.xScale, err] = Scale.FromXML(child);
          if (err) {
            return [undefined, new Error(`xscale: ${err}`)];
          }
          break;
        case 'yscale':
          [table.yScale, err] = Scale.FromXML(child);
          if (err) {
            return [undefined, new Error(`yscale: ${err}`)];
          }
          break;
        case 'xpts':
          table.xPoints = numberize(splitOnComma(content(child)));
          break;
        case 'ypts':
          table.yPoints = numberize(splitOnComma(content(child)));
          break;
      }
    }

    if (table.yPoints === undefined) {
      return [undefined, new Error('table missing ypts')];
    }

    // FIXME: handle
    if (table.type && table.type !== 'continuous') {
      console.log('WARN: unimplemented table type: ' + table.type);
    }

    return [new GF(table), undefined];
  }
Example #2
0
    const deployRefsPromise = deploysPromise.then(([ codeDeploys, prodDeploys ]) => {
        const currentCodeDeploys = getMostRecentDeploys(codeDeploys);
        const currentProdDeploys = getMostRecentDeploys(prodDeploys);

        const latestCodeDeploy = currentCodeDeploys
            .sortBy(deploy => deploy.build)
            .last();
        const oldestProdDeploy = currentProdDeploys
            .sortBy(deploy => deploy.build)
            .first();

        return [ latestCodeDeploy, oldestProdDeploy ];
    });
Example #3
0
  static FromXML(el: Element): [Options, undefined] | [undefined, Error] {
    const options = Object.assign({}, OptionsDefaults);

    for (let i = 0; i < el.attributes.length; i++) {
      const attr = el.attributes.item(i);
      if (!attr) {
        continue;
      }
      switch (attr.name.toLowerCase()) {
        case 'namespace':
          options.namespaces = splitOnComma(attr.value);
          break;
      }
    }

    for (let i = 0; i < el.childNodes.length; i++) {
      const child = el.childNodes.item(i) as Element;
      if (child.nodeType !== 1) {
        // Element
        continue;
      }
      let name = child.nodeName.toLowerCase();
      let plen: number | undefined;
      if (name.slice(0, 5) === 'uses_') {
        plen = 4;
      } else if (name.substring(0, 4) !== 'has_') {
        plen = 3;
      }
      if (!plen) {
        continue;
      }
      // use slice here even for the single char we
      // are camel-casing to avoid having to check
      // the length of the string
      name = camelCase(name);
      if (!options.hasOwnProperty(name)) {
        continue;
      }

      (options as any)[name] = true;

      if (name === 'usesArrays') {
        let val: string | undefined;
        val = attr(child, 'maximum_dimensions');
        if (val) {
          const [n, err] = num(val);
          if (err || !n) {
            // FIXME: real logging
            console.log('bad max_dimensions( ' + val + '): ' + err);
            options.maximumDimensions = 1;
          } else {
            if (n !== i32(n)) {
              console.log('non-int max_dimensions: ' + val);
            }
            options.maximumDimensions = i32(n);
          }
        }
        val = attr(child, 'invalid_index_value');
        if (val === 'NaN') {
          options.invalidIndexValue = NaN;
        }
      }
    }
    return [new Options(options), undefined];
  }
Example #4
0
const renderGroupDeployListNode = (deploys: List<DeployRecord>) => {
    const previousDeploysMap =
        Map<DeployRecord, DeployRecord>(
            deploys.map(deploy =>
                [deploy, getStartedDeploysFor(deploy.projectName, deploys)
                    .filterNot(d => d.uuid === deploy.uuid)
                    .last()
                ]
            )
        );

    const currentDeploys = getMostRecentDeploys(deploys);
    const notRunningDeploys = deploys.filter(deploy => !hasDeployStarted(deploy)).toList();

    const renderGroupDeployNodes = (groupDeploys: List<DeployRecord>, deployGroup: DeployGroupRecord) => {
        const shouldShowProjectNames = !groupDeploys.equals(currentDeploys);

        return h(
            'li',
            { className: `deploy deploy--${deployGroup.status.split(' ').join('-').toLowerCase()}` },
            [
                h('h2', [
                    h('a', { href: createBuildLink(deployGroup.build) }, `${deployGroup.build}`)
                ]),
                // Only show project names if we have multiple deployed groups
                exp(shouldShowProjectNames) && ih('ul', {}, groupDeploys
                    .sortBy(build => build.projectName)
                    .map(deploy => {
                        const previousBuild = previousDeploysMap.get(deploy);
                        return h('li', [
                            h('a', {
                                href: createRiffRaffDeployLink(deploy.uuid),
                                title: previousBuild ? `Previous build: ${previousBuild.build}` : ''
                            }, deploy.projectName)
                        ]);
                    })
                    .toList()
                )
            ]
        );
    };

    const createDeployGroup = (deploys: List<DeployRecord>) => (
        deploys.groupBy(deploy => (
            createDeployGroupRecord({
                status: deploy.status,
                build: deploy.build
            })
        ))
    );

    const currentDeployGroupNodes = createDeployGroup(currentDeploys)
        .map(renderGroupDeployNodes)
        .toList();

    return h('div', {}, [
        ih('ul', { className: 'deploys' }, currentDeployGroupNodes),
        exp(notRunningDeploys.size > 0) && [
            h('h2', 'Queue'),
            ih('ul', {}, createDeployGroup(notRunningDeploys)
                .map((groupDeploys, deployGroup) => (
                    h('li', [
                        h('strong', [
                            h('a', { href: createBuildLink(deployGroup.build) }, deployGroup.build.toString())
                        ]),
                        ih('ul', {}, (
                            groupDeploys
                                .sortBy(build => build.projectName)
                                .map(deploy => {
                                    const previousBuild = previousDeploysMap.get(deploy);
                                    return h('li', [
                                        h('a', {
                                            href: createRiffRaffDeployLink(deploy.uuid),
                                            title: previousBuild ? `Previous build: ${previousBuild.build}` : ''

                                        }, deploy.projectName)
                                    ]);
                                })
                                .toList()
                        ))
                    ])
                ))
                .toList()
            )
        ]
    ]);
};