Initial commit
This commit is contained in:
parent
53d15517f7
commit
9718584ced
4
.idea/watcherTasks.xml
generated
Normal file
4
.idea/watcherTasks.xml
generated
Normal file
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectTasksOptions" suppressed-tasks="Babel" />
|
||||
</project>
|
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')
|
||||
});
|
@ -5,7 +5,8 @@ const Router = Ember.Router.extend({
|
||||
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}}
|
@ -4,6 +4,7 @@
|
||||
"ember": "~2.5.0",
|
||||
"ember-cli-shims": "0.1.1",
|
||||
"ember-cli-test-loader": "0.2.2",
|
||||
"ember-qunit-notifications": "0.1.0"
|
||||
"ember-qunit-notifications": "0.1.0",
|
||||
"semantic-ui": "^2.1.8"
|
||||
}
|
||||
}
|
||||
|
@ -31,6 +31,7 @@
|
||||
"ember-cli-jshint": "^1.0.0",
|
||||
"ember-cli-qunit": "^1.4.0",
|
||||
"ember-cli-release": "0.2.8",
|
||||
"ember-cli-semantic-ui": "0.8.1",
|
||||
"ember-cli-sri": "^2.1.0",
|
||||
"ember-cli-uglify": "^1.2.0",
|
||||
"ember-data": "^2.5.0",
|
||||
|
BIN
public/assets/images/logo.png
Normal file
BIN
public/assets/images/logo.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 22 KiB |
24
tests/integration/components/nav-link-to-test.js
Normal file
24
tests/integration/components/nav-link-to-test.js
Normal file
@ -0,0 +1,24 @@
|
||||
import { moduleForComponent, test } from 'ember-qunit';
|
||||
import hbs from 'htmlbars-inline-precompile';
|
||||
|
||||
moduleForComponent('nav-link-to', 'Integration | Component | nav link to', {
|
||||
integration: true
|
||||
});
|
||||
|
||||
test('it renders', function(assert) {
|
||||
// Set any properties with this.set('myProperty', 'value');
|
||||
// Handle any actions with this.on('myAction', function(val) { ... });
|
||||
|
||||
this.render(hbs`{{nav-link-to}}`);
|
||||
|
||||
assert.equal(this.$().text().trim(), '');
|
||||
|
||||
// Template block usage:
|
||||
this.render(hbs`
|
||||
{{#nav-link-to}}
|
||||
template block text
|
||||
{{/nav-link-to}}
|
||||
`);
|
||||
|
||||
assert.equal(this.$().text().trim(), 'template block text');
|
||||
});
|
24
tests/integration/components/search-form-test.js
Normal file
24
tests/integration/components/search-form-test.js
Normal file
@ -0,0 +1,24 @@
|
||||
import { moduleForComponent, test } from 'ember-qunit';
|
||||
import hbs from 'htmlbars-inline-precompile';
|
||||
|
||||
moduleForComponent('search-form', 'Integration | Component | search form', {
|
||||
integration: true
|
||||
});
|
||||
|
||||
test('it renders', function(assert) {
|
||||
// Set any properties with this.set('myProperty', 'value');
|
||||
// Handle any actions with this.on('myAction', function(val) { ... });
|
||||
|
||||
this.render(hbs`{{search-form}}`);
|
||||
|
||||
assert.equal(this.$().text().trim(), '');
|
||||
|
||||
// Template block usage:
|
||||
this.render(hbs`
|
||||
{{#search-form}}
|
||||
template block text
|
||||
{{/search-form}}
|
||||
`);
|
||||
|
||||
assert.equal(this.$().text().trim(), 'template block text');
|
||||
});
|
12
tests/unit/adapters/application-test.js
Normal file
12
tests/unit/adapters/application-test.js
Normal file
@ -0,0 +1,12 @@
|
||||
import { moduleFor, test } from 'ember-qunit';
|
||||
|
||||
moduleFor('adapter:application', 'Unit | Adapter | application', {
|
||||
// Specify the other units that are required for this test.
|
||||
// needs: ['serializer:foo']
|
||||
});
|
||||
|
||||
// Replace this with your real tests.
|
||||
test('it exists', function(assert) {
|
||||
let adapter = this.subject();
|
||||
assert.ok(adapter);
|
||||
});
|
12
tests/unit/adapters/find-result-test.js
Normal file
12
tests/unit/adapters/find-result-test.js
Normal file
@ -0,0 +1,12 @@
|
||||
import { moduleFor, test } from 'ember-qunit';
|
||||
|
||||
moduleFor('adapter:find-result', 'Unit | Adapter | find result', {
|
||||
// Specify the other units that are required for this test.
|
||||
// needs: ['serializer:foo']
|
||||
});
|
||||
|
||||
// Replace this with your real tests.
|
||||
test('it exists', function(assert) {
|
||||
let adapter = this.subject();
|
||||
assert.ok(adapter);
|
||||
});
|
12
tests/unit/models/find-result-test.js
Normal file
12
tests/unit/models/find-result-test.js
Normal file
@ -0,0 +1,12 @@
|
||||
import { moduleForModel, test } from 'ember-qunit';
|
||||
|
||||
moduleForModel('find-result', 'Unit | Model | find result', {
|
||||
// Specify the other units that are required for this test.
|
||||
needs: []
|
||||
});
|
||||
|
||||
test('it exists', function(assert) {
|
||||
let model = this.subject();
|
||||
// let store = this.store();
|
||||
assert.ok(!!model);
|
||||
});
|
11
tests/unit/routes/index-test.js
Normal file
11
tests/unit/routes/index-test.js
Normal file
@ -0,0 +1,11 @@
|
||||
import { moduleFor, test } from 'ember-qunit';
|
||||
|
||||
moduleFor('route:index', 'Unit | Route | index', {
|
||||
// Specify the other units that are required for this test.
|
||||
// needs: ['controller:foo']
|
||||
});
|
||||
|
||||
test('it exists', function(assert) {
|
||||
let route = this.subject();
|
||||
assert.ok(route);
|
||||
});
|
11
tests/unit/routes/search-test.js
Normal file
11
tests/unit/routes/search-test.js
Normal file
@ -0,0 +1,11 @@
|
||||
import { moduleFor, test } from 'ember-qunit';
|
||||
|
||||
moduleFor('route:search', 'Unit | Route | search', {
|
||||
// Specify the other units that are required for this test.
|
||||
// needs: ['controller:foo']
|
||||
});
|
||||
|
||||
test('it exists', function(assert) {
|
||||
let route = this.subject();
|
||||
assert.ok(route);
|
||||
});
|
15
tests/unit/serializers/find-result-test.js
Normal file
15
tests/unit/serializers/find-result-test.js
Normal file
@ -0,0 +1,15 @@
|
||||
import { moduleForModel, test } from 'ember-qunit';
|
||||
|
||||
moduleForModel('find-result', 'Unit | Serializer | find result', {
|
||||
// Specify the other units that are required for this test.
|
||||
needs: ['serializer:find-result']
|
||||
});
|
||||
|
||||
// Replace this with your real tests.
|
||||
test('it serializes records', function(assert) {
|
||||
let record = this.subject();
|
||||
|
||||
let serializedRecord = record.serialize();
|
||||
|
||||
assert.ok(serializedRecord);
|
||||
});
|
Loading…
x
Reference in New Issue
Block a user