Example #1
0
 results.forEach(result => {
   if (result.value) {
     if (result.value.data.roles) {
       resp = Ember.assign({}, resp, { zero_address_roles: result.value.data.roles });
     } else {
       resp = Ember.assign({}, resp, result.value);
     }
   }
 });
Example #2
0
var all = ((state, action) => {
    if (action.type === 'DESERIALIZE_ALL') {
        return Ember.assign({}, state, deserialize(action.response));
    }
    if (action.type === 'SELECT_SPEAKER') {
        return Ember.assign({}, state, selectSpeaker(state.speakers, action.speaker));
    }
    if (action.type === 'SELECT_SESSION') {
        return Ember.assign({}, state, selectSession(state.sessions, action.session));
    }
    return state || initialState;
});
Example #3
0
export default function startApp(attrs) {
  let application

  let attributes = Ember.assign({}, config.APP)
  attributes = Ember.assign(attributes, attrs) // use defaults, but you can override;

  Ember.run(() => {
    application = Application.create(attributes)
    application.setupForTesting()
    application.injectTestHelpers()
  })

  return application
}
let setRecord = function (source, keyName, value) {
  // array of keys
  let keys = keyName.split('.');

  if (keys.length > 1) {
    // first object of path
    let result = source.get(keys[0]);

    for (let i = 1, len = keys.length; i < len; i++) {
      // needed for recognition if key is index
      let keyValue = parseInt(keys[i]);

      if (i === (len - 1)) {
        // if previous object is array and key is index
        if (Ember.isArray(result) && !isNaN(keyValue)) {
          return Ember.assign(result.objectAt(keys[i]), value);
        } else {
          return Ember.set(result, keys[i], value);
        }
      } else if (Ember.isArray(result) && !isNaN(keyValue)) {
        result = result.objectAt(keys[i]);
      } else {
        result = result.get(keys[i]);
      }
    }
  }

  // if key is lonely - directly set value for this property
  return Ember.set(source, keys[0] || keyName, value);
};
    serialize: function(snapshot, options = {}) {
        // Restore relationships to serialized data
        var serialized = this._super(snapshot, options);

        var opts = {};

        if (snapshot.record.get('isNew')) {
            opts = {
                includeUser: true
            };
        }
        Ember.assign(opts, options);

        // APIv2 expects contributor information to be nested under relationships.
        if (opts.includeUser) {
            serialized.data.relationships = {
                users: {
                    data: {
                        id: snapshot.record.get('userId'),
                        type: 'users'
                    }
                }
            };
        }
        return serialized;
    }
export function optionsForBackend([backend, tab]) {
  const selected = SECRET_BACKENDS[backend];
  let backendOptions;

  if (selected && selected.tabs) {
    let tabData =
      selected.tabs.findBy('name', tab) || selected.tabs.findBy('modelPrefix', tab) || selected.tabs[0];
    backendOptions = Ember.assign({}, selected, tabData);
  } else if (selected) {
    backendOptions = selected;
  } else {
    backendOptions = Ember.assign({}, DEFAULT_DISPLAY, {
      displayName: backend === 'kv' ? 'KV' : Ember.String.capitalize(backend),
    });
  }
  return backendOptions;
}
 stageStatusUpdater: task(function * (stage) {
   let b = this.get('model');
   Ember.assign(stage, { build: b });
   stage.save()
     .finally(() => {
       this.get('buildFetcher').cancelAll();
       this.get('buildFetcher').perform();
     });
 }).drop(),
export default function startApp(attrs) {
  const attributes = Ember.assign({}, config.APP, attrs);

  Ember.run(() => {
    const application = Application.create(attributes);
    application.setupForTesting();
    application.injectTestHelpers();
    return application;
  });
}
/**
 * Make share data look like apiv2 preprints data and pull out identifiers
 *
 * @private
 * @method transformShareData
 * @param {Object} result - hit from a SHARE ES
 * @return {Object}
 */
function transformShareData(result) {
    const transformedResult = Ember.assign(result._source, {
        id: result._id,
        type: 'elastic-search-result',
        workType: result._source['@type'],
        abstract: result._source.description,
        subjects: result._source.subjects.map(each => ({ text: each })),
        subject_synonyms: result._source.subject_synonyms.map(each => ({ text: each })),
        providers: result._source.sources.map(item => ({
            name: item,
        })),
        hyperLinks: [ // Links that are hyperlinks from hit._source.lists.links
            {
                type: 'share',
                url: `${config.OSF.shareBaseUrl}${result._source.type.replace(/ /g, '')}/${result._id}`,
            },
        ],
        infoLinks: [], // Links that are not hyperlinks  hit._source.lists.links
        registrationType: result._source.registration_type, // for registries
    });

    result._source.identifiers.forEach(function(identifier) {
        if (identifier.startsWith('http://')) {
            transformedResult.hyperLinks.push({ url: identifier });
        } else {
            const spl = identifier.split('://');
            const [type, uri] = spl;
            transformedResult.infoLinks.push({ type, uri });
        }
    });

    transformedResult.contributors = transformedResult.lists.contributors ?
        sortContributors(transformedResult.lists.contributors) :
        [];

    // Temporary fix to handle half way migrated SHARE ES
    // Only false will result in a false here.
    transformedResult.contributors.map((contributor) => {
        const contrib = contributor;
        contrib.users.bibliographic = !(contributor.users.bibliographic === false);
        return contrib;
    });

    return transformedResult;
}
Example #10
0
function filterByQuery (array, propertyKeys, query, options) {
  if (!query) {
    return Ember.A(array);
  }
  
  // options = Ember.typeOf(options) === 'undefined' ? {} : options;
  options = Ember.assign({sort: true}, options);
  
  propertyKeys = Ember.makeArray(propertyKeys);
  var input, sifter, result, sort;
  sort = options.sort;//'sort' in options ? options.sort : true;
  delete options['sort'];
  
  input = array.map(function (item) {
    var hash = {};
    propertyKeys.forEach(function (key) {
      hash[key.replace(/\$$/, '')] = Ember.get(item, key);
    });
    return hash;
  });
  
  options.fields = options.fields || propertyKeys.map(function (key) {
      return key.replace(/\$$/, '')
    });
  options.limit = options.limit || array.length;
  options.limit = array.length || array.get('length');
  if (sort) {
    options.sort = propertyKeys.map(function (key) {
      return {field: key.replace(/\$$/, ''), direction: 'asc'};
    });
  }
  
  sifter = new Sifter(input);
  if (!sort) {
    sifter.getSortFunction = function () {
      return null;
    };
  }
  
  result = sifter.search(query, options);
  
  return Ember.A(result.items.map(function (item) {
    return Ember.A(array).objectAt(item.id);
  }));
}
Example #11
0
export default function startApp(attrs) {
  let application, attributes;

  // use defaults, but you can override
  if (Ember.assign) {
    attributes = Ember.assign({}, config.APP, attrs);
  } else {
    attributes = Ember.merge({}, config.APP);
    attributes = Ember.merge(attributes, attrs);
  }

  Ember.run(() => {
    application = Application.create(attributes);
    application.setupForTesting();
    application.injectTestHelpers();
  });

  return application;
}
export function loadPage(model, relationship, pageSize, page, options = {}) {
    let query = {
        'page[size]': pageSize || 10,
        page: page || 1
    };
    query = Ember.assign(query, options || {});
    Ember.set(model, 'query-params', query);

    return model.queryHasMany(relationship, query).then(results => {
        var remaining = 0;
        if (results.meta) {
            var total = results.meta.total;
            var pageSize = results.meta.per_page;
            remaining = total - (page * pageSize);
        }
        return {
            results: results.toArray(),
            hasRemaining: remaining > 0,
            remaining: remaining,
        };
    });
}
  definitionUpdater: task(function*(ajaxOptions) {
    Ember.assign(ajaxOptions, {
      type: 'POST',
      data: JSON.stringify({
        definition: {
          content: btoa(this.get('definition.content')),
          sha: this.get('definition.sha')
        },
        commit: this.get('commitOption')
      }),
      contentType: 'application/json;chartset=UTF-8'
    });

    let action = this.get('editorAction').toLowerCase();
    yield Ember.$.ajax(ajaxOptions)
      .then((definition) => {
        this.get('model').reload();
        this.get('notify').success(`Successfully ${action}d the definition file for the pipeline`);
        this.serializeDefinition(definition);
      }, (res) => {
        this.get('notify').error(res.responseJSON.Message || `Failed to ${action} the definition file for the pipeline`);
      });
  }).drop(),
export default function loadAll(model, relationship, dest, options = {}) {
    var page = options.page || 1;
    var query = {
        'page[size]': 10,
        page: page
    };
    query = Ember.assign(query, options || {});
    Ember.set(model, 'query-params', query);

    return model.queryHasMany(relationship, query).then(results => {
        dest.pushObjects(results.toArray());
        if (results.meta) {
            var total = results.meta.total;
            var pageSize = results.meta.per_page;
            var remaining = total - (page * pageSize);
            if (remaining > 0) {
                query.page = page + 1;
                query['page[size]'] = pageSize;
                return loadAll(model, relationship, dest, query);
            }
        }
    });
}
            headers[headerName] = content;
        });
        dropzoneOptions.headers = headers;
        dropzoneOptions.withCredentials = (config.authorizationType === 'cookie');

        // Attach preUpload to addedfile event
        drop.on('addedfile', file => {
            if (preUpload) {
                preUpload(this, drop, file).then(() => drop.processFile(file));
            } else {
                drop.processFile(file);
            }
        });

        // Set dropzone options
        drop.options = Ember.assign(drop.options, dropzoneOptions);

        // Attach dropzone event listeners: http://www.dropzonejs.com/#events
        drop.events.forEach(event => {
            if (typeof this.get(event) === 'function') {
                drop.on(event, (...args) => this.get(event)(this, drop, ...args));
            }
        });
    },
    destroyDropzone() {
        if (this.get('dropzoneElement')) {
            this.get('dropzoneElement').destroy();
        }
    },
    didReceiveAttrs: diffAttrs('enable', 'clickable', function(changedAttrs, ...args) {
        this._super(...args);
Example #16
0
  alignItems: 'center',
  alignContent: 'flex-start',
  justifyContent: 'space-between',
  padding: '0'
}

const UiGridComponent = Ember.Component.extend(GridElement, {
  layout,
  tagName: 'ui-grid',

  gridableCSS: `flex-direction: {{direction}};align-items: {{alignItems}};align-content: {{alignContent}};justify-content: {{justifyContent}}; padding: {{padding}}`,

  init(){
    this._super(...arguments);

    Ember.assign(this, defaults);

    this.updateStylesRenderPersist([
      { declaration: 'sizeable', property: 'size.width', value: 100 },
      { declaration: 'sizeable', property: 'size.height', value: 100 },
      { declaration: 'sizeable', property: 'size.widthUnit', value: '%' },
      { declaration: 'sizeable', property: 'size.heightUnit', value: '%' },
      { declaration: 'gridable', property: 'direction', value: defaults.direction },
      { declaration: 'gridable', property: 'alignItems', value: defaults.alignItems },
      { declaration: 'gridable', property: 'alignContent', value: defaults.alignContent },
      { declaration: 'gridable', property: 'justifyContent', value: defaults.justifyContent },
      { declaration: 'gridable', property: 'padding', value: defaults.padding },
    ]);
  }

});
Example #17
0
  type: 'text',
  date: null,
  picker: null,

  didRender() {
    this.updateInputText();
    this.toggleInputDisabled();
  },

  getOptions() {
    const defaults = {
      'date': {},
      'time': {}
    };
    const appOptions = config['ember-cli-pickadate'];
    return Ember.assign(defaults, appOptions);
  },

  toggleInputDisabled: function() {
    if(this.get('disabled')) {
      this.get('picker').stop();
      this.$().prop('disabled', true); // pick-a-date is doing funny things with the disabled attribute
    } else {
      this.get('picker').start();
      this.$().prop('disabled', false);
    }
  },

  dateChanged: observer('date', function() {
    this.updateInputText()
  }),
Example #18
0
  },

  normalizeItems(payload) {
    if (payload.data.keys && Array.isArray(payload.data.keys)) {
      let ret = payload.data.keys.map(key => {
        let model = {
          id: key,
        };
        if (payload.backend) {
          model.backend = payload.backend;
        }
        return model;
      });
      return ret;
    }
    Ember.assign(payload, payload.data);
    delete payload.data;
    return [payload];
  },
  modelNameFromPayloadKey(payloadType) {
    return payloadType;
  },

  normalizeResponse(store, primaryModelClass, payload, id, requestType) {
    const nullResponses = ['updateRecord', 'createRecord', 'deleteRecord'];
    const responseJSON = nullResponses.includes(requestType) ? { id } : this.normalizeItems(payload);
    const { modelName } = primaryModelClass;
    let transformedPayload = { [modelName]: responseJSON };
    // just return the single object because ember is picky
    if (requestType === 'queryRecord') {
      transformedPayload = { [modelName]: responseJSON[0] };
Example #19
0
    return true;
  },

  shouldReloadRecord() {
    return true;
  },

  shouldBackgroundReloadRecord() {
    return false;
  },

  _preRequest(url, options) {
    const token = this.get('auth.currentToken');
    if (token && !options.unauthenticated) {
      options.headers = Ember.assign(options.headers || {}, {
        'X-Vault-Token': token,
      });
      if (options.wrapTTL) {
        Ember.assign(options.headers, { 'X-Vault-Wrap-TTL': options.wrapTTL });
      }
    }
    const isPolling = POLLING_URL_PATTERNS.some(str => url.includes(str));
    if (!isPolling) {
      this.get('auth').setLastFetch(Date.now());
    }
    if (this.get('auth.shouldRenew')) {
      this.get('auth').renew();
    }
    options.timeout = 60000;
    return options;
  },
Example #20
0
const { computed } = Ember;  

import layout from '../templates/components/name-input';
import ddau from '../mixins/input-ddau';
import { v4 } from 'ember-uuid';

export default Ember.Component.extend(ddau, {
  layout,
  tagName: '',
  id: computed(() => v4()),
  name: computed(() => ({})),
  previous: computed(() => ({})),
  actions: {
    firstName(first) {
      const oldValue = this.get('name');
      const name = Ember.assign({}, oldValue);
      name.first = first;
      this.set('name', name);
      this.handleDDAU('onChange', name, {
        oldValue,
        type: 'object'
      });
    },
    lastName(last) {
      const oldValue = this.get('name');
      const name = Ember.assign({}, oldValue);
      name.last = last;
      this.set('name', name);
      this.handleDDAU('onChange', name, {
        oldValue,
        type: 'object'
Example #21
0
      this.setExportKeyDefaults();
    }
  },

  handleError(e) {
    this.set('errors', e.errors);
  },

  handleSuccess(resp, options, action) {
    let props = {};
    if (resp && resp.data) {
      if (action === 'export' && resp.data.keys) {
        const { keys, type, name } = resp.data;
        resp.data.keys = { keys, type, name };
      }
      props = Ember.assign({}, props, resp.data);
    }
    if (options.wrapTTL) {
      props = Ember.assign({}, props, { wrappedToken: resp.wrap_info.token });
    }
    this.setProperties(props);
    if (action === 'rotate') {
      this.sendAction('refresh');
    }
  },

  compactData(data) {
    let type = get(this, 'key.type');
    let isRSA = type === 'rsa-2048' || type === 'rsa-4096';
    return Object.keys(data).reduce((result, key) => {
      if (key === 'signature_algorithm' && !isRSA) {
    this.get('session').authorize('authorizer:kontinuous', (headerName, headerValue) => {
      let api = Configuration.APP.kontinuousAPI;
      let params = this.get('model').getProperties('owner', 'repo');
      let headers = {};
      headers[headerName] = headerValue;
      let url = `${api.host}/api/${api.version}/pipelines/${params.owner}/${params.repo}/definition`;
      task.perform({headers: headers, url: url});
    });
  },

  serializeDefinition(res) {
    let currentDefinition = this.get('definition') || {};
    if (res && res.content) {
      res.content = atob(res.content);
    }
    Ember.assign(currentDefinition, res);
    this.set('definition', currentDefinition);
    this.notifyPropertyChange('definition');
  },

  definitionFetcher: task(function*(ajaxOptions) {
    let definition = yield Ember.$.ajax(ajaxOptions);
    this.serializeDefinition(definition);
  }).drop(),

  definitionUpdater: task(function*(ajaxOptions) {
    Ember.assign(ajaxOptions, {
      type: 'POST',
      data: JSON.stringify({
        definition: {
          content: btoa(this.get('definition.content')),
export default function (defaultOptions) {
  const options = {
    title: {
      text: '',
    },
    chart: {
      type: 'area',
    },
    legend: {
      enabled: false,
    },
    credits: {
      enabled: false,
    },
    xAxis: {
      title: {
        text: '',
      },
      type: 'datetime',
      labels: {
        enabled: false,
      },
    },
    yAxis: {
      title: {
        text: '',
      },
    },
    tooltip: {
      // Mostly the dates are formatted as hours,
      // but better safe than sorry.
      dateTimeLabelFormats: {
        second: '%b %e, %Y',
        minute: '%b %e, %Y',
        hour: '%b %e, %Y',
        day: '%b %e, %Y',
        week: '%b %e, %Y',
        month: '%b %e, %Y',
        year: '%b %e, %Y',
      },
    },
    plotOptions: {
      series: {
        marker: {
          fillColor: '#518fc9',
          radius: 0,
          states: {
            hover: {
              enabled: true,
              radius: 5,
            },
          },
        },
        shadow: false,
        states: {
          hover: {
            lineWidth: 3,
          },
        },
      },
    },
  };
  Ember.assign(defaultOptions, options);
  return defaultOptions;
}
    const lastBuild = branch.createBuild({
      state: 'passed',
      number: '1919',
      finished_at: oneYearAgo,
      started_at: beforeOneYearAgo,
      event_type: 'cron',
      repository_id: repoId
    });

    const commitAttributes = {
      sha: '1234567890',
      author_name: currentUser.name
    };

    lastBuild.createCommit(Ember.assign({
      branch: 'successful-cron-branch'
    }, commitAttributes));
    lastBuild.save();

    const failedBuild = branch.createBuild({
      state: 'failed',
      event_type: 'push',
      repository_id: repoId
    });

    failedBuild.createCommit(commitAttributes);
    failedBuild.save();

    const erroredBuild = branch.createBuild({
      state: 'errored',
      event_type: 'push',
 (acc, key) => Ember.assign(acc, { [Ember.String.camelize(key)]: contributor[key] }),
Example #26
0
 *
 * @param disabled - (boolean) Disable the timepicker
 * @param placeholder - (string) The text to display in the input when nothing is selected
 * @param options - (object) Options available via the pick-a-date API
 * @param date - (Date) The inital date to display
 * @param on-selected - (function) Called when a time is selected and passed the new date as the first argument.
 * @param nulls-date - (boolean) If true, will set the date to null when the clear button is pressed.
 *                               If false, will set the time part to 0 only when the clear button is pressed, the date part is unaffected.
 */
export default Picker.extend({
  placeholder: "Select a time",
  classNames: ['ember-pick-a-time'],

  didInsertElement() {
    const defaults = this.getOptions().date;
    const options = Ember.assign(defaults, this.attrs.options);
    options.onClose = options.onClose || this.onClose;
    options.onSet = () => {
      this.onSelected();
    };
    this.$().pickatime(options);
    this.set('picker', this.$().pickatime('picker'));
  },

  updateInputText() {
    const date = this.get('date');
    const options = this.attrs.options || {};
    const format = options.format || DEFAULT_TIME_FORMAT;
    const picker = this.get('picker');

    if (!picker.get('open')) {
Example #27
0
import Ember from 'ember';

export default Ember.Route.extend({
    redirect(model, {queryParams}) {
        this.transitionTo('projects.project.spider.action.data', {
            /* The queryParams in the transition object have been processed and keys with empty
               values have been removed. If we use the same object for the new transition the
               unspecified values will keep their current values. This means we can't automatically
               pass through query parameters that have intentionally been emptied. */
            queryParams: Ember.assign({
                url: null,
                baseurl: null
            }, queryParams)
        });
    }
});