How to use the ember-data-model-fragments/attributes.fragmentOwner function in ember-data-model-fragments

To help you get started, we’ve selected a few ember-data-model-fragments 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 jelhan / croodle / app / models / option.js View on Github external
allowEmpty: true
    }),
    // alias title validation especially for unique validation
    validator('alias', {
      alias: 'title',
      firstMessageOnly: true
    }),
    // alias is partially filled validation as that's part of time validation
    validator('alias', {
      alias: 'isPartiallyFilled',
    }),
  ]
});

export default Fragment.extend(Validations, {
  poll: fragmentOwner(),
  title: attr('string'),

  date: computed('title', function() {
    const allowedFormats = [
      'YYYY-MM-DD',
      'YYYY-MM-DDTHH:mm:ss.SSSZ'
    ];
    const value = this.title;
    if (isEmpty(value)) {
      return;
    }

    const format = allowedFormats.find((f) => {
      // if format length does not match value length
      // string can't be in this format
      return f.length === value.length && moment(value, f, true).isValid();
github hashicorp / levant / vendor / github.com / hashicorp / nomad / ui / app / models / task-group.js View on Github external
import { computed } from '@ember/object';
import Fragment from 'ember-data-model-fragments/fragment';
import attr from 'ember-data/attr';
import { fragmentOwner, fragmentArray } from 'ember-data-model-fragments/attributes';
import sumAggregation from '../utils/properties/sum-aggregation';

const maybe = arr => arr || [];

export default Fragment.extend({
  job: fragmentOwner(),

  name: attr('string'),
  count: attr('number'),

  tasks: fragmentArray('task'),

  allocations: computed('job.allocations.@each.taskGroup', function() {
    return maybe(this.get('job.allocations')).filterBy('taskGroupName', this.get('name'));
  }),

  reservedCPU: sumAggregation('tasks', 'reservedCPU'),
  reservedMemory: sumAggregation('tasks', 'reservedMemory'),
  reservedDisk: sumAggregation('tasks', 'reservedDisk'),

  reservedEphemeralDisk: attr('number'),
github hashicorp / levant / vendor / github.com / hashicorp / nomad / ui / app / models / task-event.js View on Github external
import Fragment from 'ember-data-model-fragments/fragment';
import attr from 'ember-data/attr';
import { fragmentOwner } from 'ember-data-model-fragments/attributes';

export default Fragment.extend({
  state: fragmentOwner(),

  type: attr('string'),
  signal: attr('number'),
  exitCode: attr('number'),

  time: attr('date'),
  timeNanos: attr('number'),

  message: attr('string'),
});
github hashicorp / levant / vendor / github.com / hashicorp / nomad / ui / app / models / task-state.js View on Github external
import { computed } from '@ember/object';
import { alias, none, and } from '@ember/object/computed';
import Fragment from 'ember-data-model-fragments/fragment';
import attr from 'ember-data/attr';
import { fragment, fragmentOwner, fragmentArray } from 'ember-data-model-fragments/attributes';

export default Fragment.extend({
  allocation: fragmentOwner(),

  name: attr('string'),
  state: attr('string'),
  startedAt: attr('date'),
  finishedAt: attr('date'),
  failed: attr('boolean'),

  isActive: none('finishedAt'),
  isRunning: and('isActive', 'allocation.isRunning'),

  task: computed('allocation.taskGroup.tasks.[]', function() {
    const tasks = this.get('allocation.taskGroup.tasks');
    return tasks && tasks.findBy('name', this.name);
  }),

  driver: alias('task.driver'),