-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Search Schema model, associations, and views
- Loading branch information
1 parent
c0e3334
commit d501ad4
Showing
25 changed files
with
359 additions
and
60 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import DS from 'ember-data'; | ||
|
||
export default DS.Model.extend({ | ||
|
||
}); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import Ember from 'ember'; | ||
|
||
export default Ember.Route.extend({ | ||
model(params) { | ||
return this.explorer.getCluster(params.clusterId, this.store) | ||
.then(function(cluster){ | ||
return cluster.get('searchSchemas').findBy('name', params.searchSchemaId); | ||
}); | ||
}, | ||
|
||
afterModel(model, transition) { | ||
if (!model.get('content')) { | ||
return Ember.$.ajax({ | ||
type: 'GET', | ||
url: model.get('url'), | ||
dataType: 'xml' | ||
}).then(function(data) { | ||
let xmlString = (new XMLSerializer()).serializeToString(data); | ||
model.set('content', xmlString); | ||
}); | ||
} | ||
}, | ||
|
||
actions: { | ||
updateSchema: function(schema) { | ||
let xmlString = schema.get('content'); | ||
let self = this; | ||
let xmlDoc = null; | ||
let clusterId = schema.get('cluster').get('id'); | ||
let schemaId = schema.get('name'); | ||
|
||
try { | ||
xmlDoc = Ember.$.parseXML(xmlString); | ||
} catch(error) { | ||
// TODO: Put in proper error messaging | ||
alert('Invalid XML. Please check and make sure schema is valid xml.'); | ||
return; | ||
} | ||
|
||
return Ember.$.ajax({ | ||
type: 'PUT', | ||
url: schema.get('url'), | ||
contentType: 'application/xml', | ||
processData: false, | ||
data: xmlDoc | ||
}).then(function(data) { | ||
self.transitionTo('search-schema', clusterId, schemaId); | ||
}, function(error) { | ||
// TODO: Put in proper error messaging | ||
alert('Something went wrong, schema was not saved.'); | ||
self.transitionTo('search-schema', clusterId, schemaId); | ||
}); | ||
} | ||
} | ||
}); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<div class='view-header'> | ||
{{breadcrumb-component | ||
clusterId=model.cluster.id | ||
pageTitle=model.name | ||
}} | ||
{{view-label | ||
pre-label='Search Schema' | ||
label=model.name}} | ||
</div> | ||
|
||
{{#dashboard-module}} | ||
<div class="schema-actions"> | ||
<span class="update schema-action" {{action 'updateSchema' model}}> | ||
<span class="glyphicon glyphicon-pencil" aria-hidden="true"></span> | ||
Update Schema | ||
</span> | ||
|
||
{{#link-to 'search-schema' model.cluster.id model.name class='cancel schema-action' }} | ||
<span class="glyphicon glyphicon-remove" aria-hidden="true"></span> | ||
Cancel | ||
{{/link-to}} | ||
</div> | ||
|
||
{{content-editable | ||
value=model.content | ||
type="html" | ||
tagName="pre"}} | ||
{{/dashboard-module}} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import DS from 'ember-data'; | ||
|
||
export default DS.Model.extend({ | ||
/** | ||
* Riak cluster the search schema was created on | ||
* | ||
* @property cluster | ||
* @type {DS.Model} Cluster | ||
* @writeOnce | ||
*/ | ||
cluster: DS.belongsTo('cluster', { async: true }), | ||
|
||
name: DS.attr('string'), | ||
|
||
content: DS.attr(), | ||
|
||
/** | ||
* Returns a formatted schema url | ||
* @method url | ||
* @returns String | ||
*/ | ||
url: function() { | ||
let proxyURL = this.get('cluster').get('proxyUrl'); | ||
let name = this.get('name'); | ||
|
||
return `${proxyURL}/search/schema/${name}`; | ||
}.property('name', 'cluster.proxyUrl') | ||
}); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import Ember from 'ember'; | ||
import $ from 'jquery'; | ||
|
||
export default Ember.Route.extend({ | ||
model(params) { | ||
return this.explorer.getCluster(params.clusterId, this.store) | ||
.then(function(cluster){ | ||
return cluster.get('searchSchemas').findBy('name', params.searchSchemaId); | ||
}); | ||
}, | ||
|
||
// TODO: Move to init??? | ||
afterModel(model, transition) { | ||
return Ember.$.ajax({ | ||
type: 'GET', | ||
url: model.get('url'), | ||
dataType: 'xml' | ||
}).then(function(data) { | ||
let xmlString = (new XMLSerializer()).serializeToString(data); | ||
model.set('content', xmlString); | ||
}); | ||
} | ||
}); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<div class='view-header'> | ||
{{breadcrumb-component | ||
clusterId=model.cluster.id | ||
pageTitle=model.name | ||
}} | ||
{{view-label | ||
pre-label='Search Schema' | ||
label=model.name}} | ||
</div> | ||
|
||
{{#dashboard-module}} | ||
<div class="schema-actions"> | ||
{{#link-to 'search-schema.edit' model.cluster.id model.name class='edit schema-action' }} | ||
<span class="glyphicon glyphicon-pencil" aria-hidden="true"></span> | ||
Edit Schema | ||
{{/link-to}} | ||
</div> | ||
<pre> | ||
{{model.content}} | ||
</pre> | ||
{{/dashboard-module}} |
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.