Initial commit
This commit is contained in:
5
app/adapters/application.js
Normal file
5
app/adapters/application.js
Normal file
@@ -0,0 +1,5 @@
|
||||
import DS from 'ember-data';
|
||||
|
||||
export default DS.RESTAdapter.extend({
|
||||
host: 'http://api.fias.hellotan.ru'
|
||||
});
|
||||
18
app/adapters/find-result.js
Normal file
18
app/adapters/find-result.js
Normal file
@@ -0,0 +1,18 @@
|
||||
import ApplicationAdapter from './application';
|
||||
import Ember from 'ember';
|
||||
|
||||
export default ApplicationAdapter.extend({
|
||||
query: function(store, type, query) {
|
||||
var url = this.get('host')+'/find/'+query.text;
|
||||
Ember.Logger.log('url:', url);
|
||||
|
||||
return new Ember.RSVP.Promise(function(resolve, reject) {
|
||||
Ember.$.getJSON(url, query).then(function(data) {
|
||||
Ember.run(null, resolve, data);
|
||||
}, function(jqXHR) {
|
||||
jqXHR.then = null; // tame jQuery's ill mannered promises
|
||||
Ember.run(null, reject, jqXHR);
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
6
app/components/nav-link-to.js
Normal file
6
app/components/nav-link-to.js
Normal file
@@ -0,0 +1,6 @@
|
||||
import Ember from 'ember';
|
||||
|
||||
export default Ember.LinkComponent.extend({
|
||||
tagName: 'a',
|
||||
classNames: ['item']
|
||||
});
|
||||
19
app/components/search-form.js
Normal file
19
app/components/search-form.js
Normal file
@@ -0,0 +1,19 @@
|
||||
import Ember from 'ember';
|
||||
|
||||
export default Ember.Component.extend({
|
||||
placeholder: "Ввведите название населенного пункта",
|
||||
searchText: "",
|
||||
store: Ember.inject.service('store'),
|
||||
|
||||
actions: {
|
||||
search(param) {
|
||||
if (param !== '') {
|
||||
this.get('store').query('find-result', {text: param}).then((result) => {
|
||||
this.set('model', result);
|
||||
});
|
||||
} else {
|
||||
this.set('model', null);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -3,7 +3,7 @@
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<title>FiasFace</title>
|
||||
<title>Hellotan's FIAS API</title>
|
||||
<meta name="description" content="">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
|
||||
|
||||
9
app/models/find-result.js
Normal file
9
app/models/find-result.js
Normal file
@@ -0,0 +1,9 @@
|
||||
import Model from 'ember-data/model';
|
||||
import attr from 'ember-data/attr';
|
||||
|
||||
export default Model.extend({
|
||||
text: attr('string'),
|
||||
cort: attr('number'),
|
||||
ratio: attr('number'),
|
||||
aoid: attr('string')
|
||||
});
|
||||
@@ -2,10 +2,11 @@ import Ember from 'ember';
|
||||
import config from './config/environment';
|
||||
|
||||
const Router = Ember.Router.extend({
|
||||
location: config.locationType
|
||||
location: config.locationType
|
||||
});
|
||||
|
||||
Router.map(function() {
|
||||
Router.map(function () {
|
||||
this.route('search');
|
||||
});
|
||||
|
||||
export default Router;
|
||||
|
||||
7
app/routes/index.js
Normal file
7
app/routes/index.js
Normal file
@@ -0,0 +1,7 @@
|
||||
import Ember from 'ember';
|
||||
|
||||
export default Ember.Route.extend({
|
||||
beforeModel() {
|
||||
this.transitionTo('search');
|
||||
}
|
||||
});
|
||||
4
app/routes/search.js
Normal file
4
app/routes/search.js
Normal file
@@ -0,0 +1,4 @@
|
||||
import Ember from 'ember';
|
||||
|
||||
export default Ember.Route.extend({
|
||||
});
|
||||
5
app/serializers/find-result.js
Normal file
5
app/serializers/find-result.js
Normal file
@@ -0,0 +1,5 @@
|
||||
import DS from 'ember-data';
|
||||
|
||||
export default DS.JSONSerializer.extend({
|
||||
primaryKey: 'aoid'
|
||||
});
|
||||
@@ -0,0 +1,12 @@
|
||||
body {
|
||||
background-color: #FFFFFF;
|
||||
}
|
||||
.ui.menu .item img.logo {
|
||||
margin-right: 1.5em;
|
||||
}
|
||||
.main.container {
|
||||
margin-top: 7em;
|
||||
}
|
||||
.wireframe {
|
||||
margin-top: 2em;
|
||||
}
|
||||
@@ -1,3 +1,21 @@
|
||||
<h2 id="title">Welcome to Ember</h2>
|
||||
|
||||
{{outlet}}
|
||||
<div class="ui container">
|
||||
<div class="ui fixed inverted menu">
|
||||
<div class="ui container">
|
||||
<a href="#" class="header item">
|
||||
<img class="logo" src="assets/images/logo.png">
|
||||
FIAS API
|
||||
</a>
|
||||
{{#nav-link-to 'search'}}Search{{/nav-link-to}}
|
||||
<div class="ui simple dropdown item">
|
||||
Follow <i class="dropdown icon"></i>
|
||||
<div class="menu">
|
||||
<a class="item" href="https://github.com/jar3b/py-phias">Github</a>
|
||||
<div class="divider"></div>
|
||||
<a class="item" href="#">Facebook</a>
|
||||
<a class="item" href="#">Twitter</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{ outlet }}
|
||||
</div>
|
||||
|
||||
1
app/templates/components/nav-link-to.hbs
Normal file
1
app/templates/components/nav-link-to.hbs
Normal file
@@ -0,0 +1 @@
|
||||
<a href="">{{ yield }}</a>
|
||||
21
app/templates/components/search-form.hbs
Normal file
21
app/templates/components/search-form.hbs
Normal file
@@ -0,0 +1,21 @@
|
||||
<div class="ui main text container">
|
||||
<div class="ui piled segment">
|
||||
<div class="ui fluid action input">
|
||||
{{input type="text" placeholder=placeholder value=searchText action="search" on="key-up"}}
|
||||
<button {{action 'search' searchText}} class="ui icon button">
|
||||
<i class="search icon"></i>
|
||||
</button>
|
||||
</div>
|
||||
{{#if model}}
|
||||
<div class="ui divider"></div>
|
||||
|
||||
{{#ui-accordion class='styled fluid'}}
|
||||
{{#each model as |aoitem|}}
|
||||
{{#ui-popup content=(concat "Ratio: " aoitem.ratio) position='right center'}}
|
||||
{{#ui-accordion-section title=aoitem.text}}<p>AOID: {{ aoitem.aoid }} </p>{{/ui-accordion-section}}
|
||||
{{/ui-popup}}
|
||||
{{/each}}
|
||||
{{/ui-accordion}}
|
||||
{{/if}}
|
||||
</div>
|
||||
</div>
|
||||
1
app/templates/index.hbs
Normal file
1
app/templates/index.hbs
Normal file
@@ -0,0 +1 @@
|
||||
{{outlet}}
|
||||
1
app/templates/search.hbs
Normal file
1
app/templates/search.hbs
Normal file
@@ -0,0 +1 @@
|
||||
{{#search-form}}PIDARAS{{/search-form}}
|
||||
Reference in New Issue
Block a user