Beispiel #1
0
  constructor($scope, $injector, $rootScope) {
    super($scope, $injector);
    this.$rootScope = $rootScope;

    _.defaults(this.panel, panelDefaults);
    _.defaults(this.panel.legend, panelDefaults.legend);

    this.events.on('data-received', this.onDataReceived.bind(this));
    this.events.on('data-error', this.onDataError.bind(this));
    this.events.on('data-snapshot-load', this.onDataReceived.bind(this));
    this.events.on('init-edit-mode', this.onInitEditMode.bind(this));
  }
Beispiel #2
0
  function addModels(kiln) {
    extensionA = _.defaults({name: 'A'}, extensionApi)
    const extensionB = _.defaults({name: 'B'}, extensionApi)
    const extensionC = _.defaults({name: 'C'}, extensionApi)
    jest.spyOn(extensionA, 'build').mockReturnValue({resultA: 'foo'})
    jest.spyOn(extensionB, 'build').mockReturnValue({resultB: 'bar'})
    jest.spyOn(extensionC, 'build').mockReturnValue({resultC: 'baz'})

    kiln
      .addModel({name: 'user', model})
      .addExtension({modelName: 'user', extension: extensionA})
      .addExtension({modelName: 'user', extension: extensionB})
      .addModel({name: 'photo', model})
      .addExtension({modelName: 'photo', extension: extensionC})
  }
Beispiel #3
0
export const shipOrder = async (transactionId: string, orderLines?: Array<IMollieOrderLine>, tracking?: IMollieTracking): Promise<any> => {
  const [
    { default: store },
  ] = await Promise.all([
    import(/* webpackPrefetch: true, webpackChunkName: "transaction" */ '@transaction/store'),
  ]);
  try {
    const ajaxEndpoint = store.getState().config.ajaxEndpoint;

    const { data } = await axios.post(ajaxEndpoint, {
      resource: 'orders',
      action: 'ship',
      transactionId,
      orderLines,
      tracking,
    });
    if (!data.success && typeof data.message === 'string') {
      throw data.detailed ? data.detailed : data.message;
    }

    return defaults(data, { success: false, order: null });
  } catch (e) {
    if (typeof e === 'string') {
      throw e;
    }
    console.error(e);

    return false;
  }
};
Beispiel #4
0
	constructor(config: IConfig) {
		this._config = _.defaults({}, config, {
			request: axiosAdapter({
				forceHttpAdaptor: config.environment === 'node',
			}),
			userAgent: 'anx-api/' + packageJson.version,
			timeout: 60 * 1000,
			headers: {},
			target: null,
			token: null,
			rateLimiting: true,
			chunkSize: DEFAULT_CHUNK_SIZE,
		});

		this.request = __request;

		// Install optional rate limiting adapter
		this.request = this._config.rateLimiting ? rateLimitAdapter(_.assign({}, config, {
			request: __request.bind(this),
		})) : __request.bind(this);

		// Install optional concurrency adapter
		this._config.request = this._config.concurrencyLimit ? concurrencyAdapter({
			limit: this._config.concurrencyLimit,
			request: this._config.request,
		}) : this._config.request;
	}
Beispiel #5
0
      .then(() => {
        _.each(datasources, (value, key) => {
          inputs.push(value);
        });

        // templatize constants
        for (let variable of saveModel.templating.list) {
          if (variable.type === 'constant') {
            var refName = 'VAR_' + variable.name.replace(' ', '_').toUpperCase();
            inputs.push({
              name: refName,
              type: 'constant',
              label: variable.label || variable.name,
              value: variable.current.value,
              description: '',
            });
            // update current and option
            variable.query = '${' + refName + '}';
            variable.options[0] = variable.current = {
              value: variable.query,
              text: variable.query,
            };
          }
        }

        // make inputs and requires a top thing
        var newObj = {};
        newObj['__inputs'] = inputs;
        newObj['__requires'] = _.sortBy(requires, ['id']);

        _.defaults(newObj, saveModel);
        return newObj;
      })
Beispiel #6
0
    test('TCP/HTTP RPC command', function (done) {
      var server = new stratum.RPCServer(_.defaults({ mode: 'both' }, this.opts)),
        exposed = {
          'func': function (args, opts, callback) {
            callback(null, args)
          }
        },
        spy = sinon.spy(exposed, 'func'),
        client = new rpc.Client(server.opts.port, 'localhost')

      server.expose('func', exposed.func, exposed).listen()

      client.connectSocket(function (err, conn) {
        conn.call('func', ['MTIz', 1, 2], function (err, result) {
          expect(result).to.eql([1, 2])
          expect(spy.calledWith([1, 2])).to.equal(true)

          client.call('func', ['MTIz', 1, 2], function (err, result) {
            expect(result).to.eql([1, 2])
            expect(spy.calledWith([1, 2])).to.equal(true)
            server.close()
            done()
          })
        })
      })
    })
Beispiel #7
0
function addParams(request: PathFindRequest, result: RippledPathsResponse
): RippledPathsResponse {
  return _.defaults(_.assign({}, result, {
    source_account: request.source_account,
    source_currencies: request.source_currencies
  }), {destination_amount: request.destination_amount})
}
	private setDefaults(): void {
		this.config = _.defaults<Partial<RouteActiveConfig>, RouteActiveConfig>({
			activeClass: this.activeClass,
			attribute: this.attribute,
			matchExact: this.matchExact
		}, routeActiveConfig);
	}
function buildSassFile (srcFile, dstFile) {
  let sassOptions = _.defaults({ file: srcFile }, sassDefaults)
  return sassRender(sassOptions)
    .then((result) => {
      return writeFile(dstFile, result.css)
    })
}
  public convertServerGroupCommandToDeployConfiguration(base: any): any {
    // use _.defaults to avoid copying the backingData, which is huge and expensive to copy over
    const command = defaults({ backingData: [], viewState: [] }, base);
    command.cloudProvider = 'aws';
    command.availabilityZones = {};
    command.availabilityZones[command.region] = base.availabilityZones;
    command.loadBalancers = (base.loadBalancers || []).concat(base.vpcLoadBalancers || []);
    command.targetGroups = base.targetGroups || [];
    command.account = command.credentials;
    command.subnetType = command.subnetType || '';

    if (base.viewState.mode !== 'clone') {
      delete command.source;
    }
    if (!command.ramdiskId) {
      delete command.ramdiskId; // TODO: clean up in kato? - should ignore if empty string
    }
    delete command.region;
    delete command.viewState;
    delete command.backingData;
    delete command.selectedProvider;
    delete command.instanceProfile;
    delete command.vpcId;

    return command;
  }