mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-15 18:56:22 +00:00
add planet create modal & switching func
This commit is contained in:
@@ -8,6 +8,7 @@ var apiUrl = 'http://localhost:8000/'
|
||||
|
||||
var PlanetStore = Reflux.createStore({
|
||||
init: function () {
|
||||
this.listenTo(PlanetActions.createPlanet, this.createPlanet)
|
||||
this.listenTo(PlanetActions.fetchPlanet, this.fetchPlanet)
|
||||
this.listenTo(PlanetActions.createSnippet, this.createSnippet)
|
||||
this.listenTo(PlanetActions.updateSnippet, this.updateSnippet)
|
||||
@@ -16,6 +17,31 @@ var PlanetStore = Reflux.createStore({
|
||||
this.listenTo(PlanetActions.updateBlueprint, this.updateBlueprint)
|
||||
this.listenTo(PlanetActions.deleteBlueprint, this.deleteBlueprint)
|
||||
},
|
||||
createPlanet: function (input) {
|
||||
request
|
||||
.post(apiUrl + 'planets/create')
|
||||
.set({
|
||||
Authorization: 'Bearer ' + localStorage.getItem('token')
|
||||
})
|
||||
.send(input)
|
||||
.end(function (err, res) {
|
||||
if (err) {
|
||||
console.error(err)
|
||||
this.trigger(null)
|
||||
return
|
||||
}
|
||||
|
||||
var planet = res.body
|
||||
planet.Snippets = []
|
||||
planet.Blueprints = []
|
||||
planet.Articles = []
|
||||
|
||||
this.trigger({
|
||||
status: 'planetCreated',
|
||||
data: planet
|
||||
})
|
||||
}.bind(this))
|
||||
},
|
||||
fetchPlanet: function (planetName) {
|
||||
request
|
||||
.get(apiUrl + planetName)
|
||||
|
||||
Reference in New Issue
Block a user