github.com/manicqin/nomad@v0.9.5/ui/app/serializers/evaluation.js (about)

     1  import { inject as service } from '@ember/service';
     2  import { get } from '@ember/object';
     3  import { assign } from '@ember/polyfills';
     4  import ApplicationSerializer from './application';
     5  
     6  export default ApplicationSerializer.extend({
     7    system: service(),
     8  
     9    normalize(typeHash, hash) {
    10      const failures = hash.FailedTGAllocs || {};
    11      hash.FailedTGAllocs = Object.keys(failures).map(key => {
    12        const propertiesForKey = failures[key] || {};
    13        return assign({ Name: key }, propertiesForKey);
    14      });
    15  
    16      hash.PlainJobId = hash.JobID;
    17      hash.Namespace =
    18        hash.Namespace ||
    19        get(hash, 'Job.Namespace') ||
    20        this.get('system.activeNamespace.id') ||
    21        'default';
    22      hash.JobID = JSON.stringify([hash.JobID, hash.Namespace]);
    23  
    24      hash.ModifyTimeNanos = hash.ModifyTime % 1000000;
    25      hash.ModifyTime = Math.floor(hash.ModifyTime / 1000000);
    26  
    27      hash.CreateTimeNanos = hash.CreateTime % 1000000;
    28      hash.CreateTime = Math.floor(hash.CreateTime / 1000000);
    29  
    30      return this._super(typeHash, hash);
    31    },
    32  });