Initial commit

This commit is contained in:
jar3b 2016-04-25 18:31:43 +03:00
parent 53d15517f7
commit 9718584ced
28 changed files with 262 additions and 7 deletions

4
.idea/watcherTasks.xml generated Normal file
View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectTasksOptions" suppressed-tasks="Babel" />
</project>

View File

@ -0,0 +1,5 @@
import DS from 'ember-data';
export default DS.RESTAdapter.extend({
host: 'http://api.fias.hellotan.ru'
});

View 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);
});
});
}
});

View File

@ -0,0 +1,6 @@
import Ember from 'ember';
export default Ember.LinkComponent.extend({
tagName: 'a',
classNames: ['item']
});

View 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);
}
}
}
});

View File

@ -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">

View 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')
});

View File

@ -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
View 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
View File

@ -0,0 +1,4 @@
import Ember from 'ember';
export default Ember.Route.extend({
});

View File

@ -0,0 +1,5 @@
import DS from 'ember-data';
export default DS.JSONSerializer.extend({
primaryKey: 'aoid'
});

View File

@ -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;
}

View File

@ -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>

View File

@ -0,0 +1 @@
<a href="">{{ yield }}</a>

View 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
View File

@ -0,0 +1 @@
{{outlet}}

1
app/templates/search.hbs Normal file
View File

@ -0,0 +1 @@
{{#search-form}}PIDARAS{{/search-form}}

View File

@ -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"
}
}

View File

@ -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",

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

View 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');
});

View 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');
});

View 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);
});

View 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);
});

View 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);
});

View 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);
});

View 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);
});

View 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);
});