Last active
May 19, 2017 18:33
-
-
Save foxnewsnetwork/858b28f3a4dc4816f9c5afb8a3bddc00 to your computer and use it in GitHub Desktop.
Apollo Catalog Linker
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
import ajax from 'ember-ajax/request'; | |
import { task } from 'ember-concurrency'; | |
const { isPresent, get, set } = Ember; | |
export default Ember.Component.extend({ | |
loadTask: task(function*(uri) { | |
const { links } = yield ajax(uri); | |
return links; | |
}).drop(), | |
didInsertElement() { | |
this.sendAction('ready'); | |
}, | |
didReceiveAttrs() { | |
const { uri, loadTask } = this.getProperties('uri', 'loadTask'); | |
if (isPresent(uri)) { | |
loadTask.perform(uri).then((products) => { | |
this.setProperties({ products }); | |
}); | |
} | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
appName: 'Apollo Catalog Linker' | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
const { computed } = Ember; | |
export default Ember.Controller.extend({ | |
queryParams: ['line', 'vType'], | |
vType: 'transit', | |
gbp: 'https://tips.fedora.milady?u=mirin', | |
pgbp: computed('gbp', { | |
get() { | |
return encodeURIComponent(this.get('gbp')); | |
} | |
}), | |
actions: { | |
pageDidRender() { | |
Ember.run.later(() => { | |
this.set('fakeUser', 'Matthew Wilson'); | |
}, 1000) | |
} | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
import config from './config/environment'; | |
const Router = Ember.Router.extend({ | |
location: 'none', | |
rootURL: config.rootURL | |
}); | |
Router.map(function() { | |
this.route('categories', { path: '/' }, function() { | |
this.route('category', { path: 'category/:id' }, function() { | |
this.route('products'); | |
}); | |
}); | |
}); | |
export default Router; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Route.extend({ | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
import ajax from 'ember-ajax/request'; | |
const URI_BY_LINE = { | |
'mgmt': 'https://psnow.e1-np.playstation.com/store/api/ps4now/00_09_000/container/US/en/19/STORE-MSF192018-APOLLOROOT/1491319284?start=0&size=1000', | |
'e1-np': 'https://commerce1.api.e1-np.km.playstation.net/store/api/ps4now/00_09_000/container/US/en/19/STORE-MSF4103535-APOLLO' | |
}; | |
class Request { | |
static uri(line) { | |
return URI_BY_LINE[line] | |
} | |
constructor(line) { | |
this.line = line; | |
} | |
run() { | |
return ajax(this.constructor.uri(this.line)); | |
} | |
} | |
const getLinks = ({ links }) => links.map(({url, name}) => ({ name, url}) ); | |
export default Ember.Route.extend({ | |
queryParams: { | |
line: { | |
refreshModel: true | |
}, | |
vType: { | |
refreshModel: false | |
} | |
}, | |
model() { | |
const request = new Request('e1-np'); | |
return request.run().then(getLinks); | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"version": "0.12.1", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js", | |
"ember": "2.12.0", | |
"ember-template-compiler": "2.12.0", | |
"ember-testing": "2.12.0" | |
}, | |
"addons": { | |
"ember-data": "2.12.1", | |
"ember-one-way-controls": "2.0.0", | |
"ember-ajax": "3.0.0", | |
"ember-concurrency": "0.8.3", | |
"ember-truth-helpers": "1.3.0", | |
"ember-composable-helpers": "2.0.1" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment