yarn-container.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import DS from 'ember-data';
  2. import Converter from 'yarn-ui/utils/converter';
  3. import Config from 'yarn-ui/config';
  4. export default DS.JSONAPIAdapter.extend({
  5. headers: {
  6. Accept: 'application/json'
  7. },
  8. rmHost: 'http://localhost:1337/' + Config.RM_HOST + ':' + Config.RM_PORT,
  9. tsHost: 'http://localhost:1337/' + Config.TS_HOST + ':' + Config.TS_PORT,
  10. host: function() {
  11. return undefined
  12. }.property(),
  13. rmNamespace: 'ws/v1/cluster',
  14. tsNamespace: 'ws/v1/applicationhistory',
  15. namespace: function() {
  16. return undefined
  17. }.property(),
  18. urlForQuery(query, modelName) {
  19. if (query.is_rm) {
  20. this.set("host", this.rmHost);
  21. this.set("namespace", this.rmNamespace);
  22. } else {
  23. this.set("host", this.tsHost);
  24. this.set("namespace", this.tsNamespace);
  25. }
  26. var url = this._buildURL();
  27. url = url + '/apps/' + Converter.attemptIdToAppId(query.app_attempt_id)
  28. + "/appattempts/" + query.app_attempt_id + "/containers";
  29. console.log(url);
  30. return url;
  31. },
  32. ajax(url, method, hash) {
  33. hash = {};
  34. hash.crossDomain = true;
  35. hash.xhrFields = {withCredentials: true};
  36. hash.targetServer = "RM";
  37. return this._super(url, method, hash);
  38. }
  39. });