How to use the ember-data.JSONAPISerializer function in ember-data

To help you get started, we’ve selected a few ember-data 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 Nanocloud / community / webapp / app / serializers / application.js View on Github external
import Ember from 'ember';
import DS from 'ember-data';

var underscore = Ember.String.underscore;

// Allow to have underscore in JSONAPI keys
export default DS.JSONAPISerializer.extend({
  keyForAttribute: function(attr) {
    return underscore(attr);
  },

  keyForRelationship: function(rawKey) {
    return underscore(rawKey);
  }
});
github apache / hadoop / hadoop-yarn-project / hadoop-yarn / hadoop-yarn-ui / src / main / webapp / app / serializers / yarn-container-log.js View on Github external
* "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import DS from 'ember-data';
import Converter from 'yarn-ui/utils/converter';

export default DS.JSONAPISerializer.extend({
  normalizeSingleResponse(store, primaryModelClass, payload, id/*, requestType*/) {
    // Convert plain text response into JSON.
    // ID is of the form nodeAddress!containerId!fileName
    var splits = Converter.splitForContainerLogs(id);
    var convertedPayload = {
      id: id,
      type: primaryModelClass.modelName,
      attributes: {
        logs: payload,
        containerID: splits[1],
        logFileName: splits[2]
      }
    };
    return { data: convertedPayload };
  },
});
github danielspaniel / ember-data-change-tracker / tests / dummy / app / serializers / user.js View on Github external
import DS from 'ember-data';

export default DS.JSONAPISerializer.extend();
github html-next / vertical-collection / tests / dummy / app / serializers / application.js View on Github external
import DS from 'ember-data';

export default DS.JSONAPISerializer.extend({
  normalizeResponse(_, __, payload) {
    return payload;
  }
});
github raido / ember-json-serializer-meta / tests / helpers / store.js View on Github external
registry.register('service:store', DS.Store.extend({
    adapter
  }));

  registry.optionsForType('serializer', { singleton: false });
  registry.optionsForType('adapter', { singleton: false });
  registry.register('adapter:-default', DS.Adapter);

  registry.register('serializer:-default', DS.JSONSerializer);
  registry.register('serializer:-rest', DS.RESTSerializer);

  registry.register('adapter:-rest', DS.RESTAdapter);

  registry.register('adapter:-json-api', DS.JSONAPIAdapter);
  registry.register('serializer:-json-api', DS.JSONAPISerializer);

  env.restSerializer = container.lookup('serializer:-rest');
  env.store = container.lookup('service:store');
  env.serializer = env.store.serializerFor('-default');
  env.adapter = env.store.get('defaultAdapter');

  return env;
}
github linkedin / WhereHows / wherehows-web / app / serializers / application.js View on Github external
import DS from 'ember-data';
import DataTableSerializerMixin from 'ember-data-table/mixins/serializer';

export default DS.JSONAPISerializer.extend(DataTableSerializerMixin, {});
github apache / incubator-pinot / thirdeye / thirdeye-frontend / app / serializers / base.js View on Github external
import DS from 'ember-data';

export default DS.JSONAPISerializer.extend({
  /*
   * @summary normalizing the payload from api response with array type ([{},{}..]) to correct json-api format spec. See  http://jsonapi.org/
   */
  normalizeArrayResponse(store, primaryModelClass, payload, id, requestType) {
    //we are kind of doing the job of the this._super(...) here to convert a 'classic JSON' payload into JSON API.
    let data = payload.map((resourcePayload) => {
      let attributes = {};
      primaryModelClass.eachAttribute(key => {
        attributes[key] = resourcePayload[key];
      });

      return {
        id: resourcePayload.id,
        type: primaryModelClass.modelName,
        attributes
      };
github NYCPlanning / labs-zap-search / app / serializers / milestone.js View on Github external
import DS from 'ember-data';

export default class MilestoneSerializer extends DS.JSONAPISerializer {
  attrs = { displayDate2: 'display-date-2' };
}
github apache / hadoop / hadoop-yarn-project / hadoop-yarn / hadoop-yarn-ui / src / main / webapp / app / serializers / yarn-app.js View on Github external
* "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import DS from 'ember-data';
import Converter from 'yarn-ui/utils/converter';

export default DS.JSONAPISerializer.extend({
    internalNormalizeSingleResponse(store, primaryModelClass, payload, id) {
      if (payload.app) {
        payload = payload.app;
      }

      var timeoutInSecs = -1;
      var appExpiryTime = Converter.timeStampToDate(payload.finishedTime);
      if (payload.timeouts && payload.timeouts.timeout && payload.timeouts.timeout[0]) {
        timeoutInSecs = payload.timeouts.timeout[0].remainingTimeInSeconds;
        if (timeoutInSecs > -1) {
          appExpiryTime = Converter.isoDateToDate(payload.timeouts.timeout[0].expiryTime);
        }
      }

      var fixedPayload = {
        id: id,