Skip to content

Commit 486aa5d

Browse files
authored
Merge pull request #4 from yarl/dev
version 0.4
2 parents 7a01ea9 + c837196 commit 486aa5d

11 files changed

Lines changed: 128 additions & 11 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "monumental",
3-
"version": "0.3.0",
3+
"version": "0.4.0",
44
"private": true,
55
"description": "Monumental app",
66
"main": "src/index.js",

src/components/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import main from './main/main';
22
import dashboard from './main/dashboard/dashboard';
3+
import list from './main/list/list';
34
import monument from './main/monument/monument';
45

56
export default () => {
67
main();
78
dashboard();
9+
list();
810
monument();
911
};
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1-
<md-content layout="column" layout-gt-sm="row" layout-align="start stretch" flex>
2-
<a ui-sref="main.object({id: 'Q765569'})">Zamek Gryf (Q765569)<a/>
1+
<md-content layout="column" layout-align="start center" flex>
2+
<div class="dashboard">
3+
<a ui-sref="main.object({id: '765569'})">Zamek Gryf<a/><br />
4+
<a ui-sref="main.list({id: '16970-in-54181'})">churches in silesian voivodeship<a/>
5+
</div>
36
</md-content>

src/components/main/dashboard/dashboard.scss

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,8 @@
22
@import '../../../styles/responsive';
33

44
mo-dashboard {
5-
5+
.dashboard {
6+
width: 980px;
7+
max-width: 100%;
8+
}
69
}

src/components/main/list/list.html

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<md-content layout="column" layout-align="start center" flex>
2+
<div class="list" layout="row" layout-align="start stretch">
3+
<div class="list__container" flex>
4+
<md-subheader class="md-no-sticky">List</md-subheader>
5+
<md-list-item ng-repeat="item in $ctrl.list | orderBy: 'value'"
6+
ui-sref="main.object({id: item.name.value_id.substring(1)})">
7+
<p>{{item.name.value}} <span class="muted">{{item.admin.value}}</span></p>
8+
</md-list-item>
9+
</div>
10+
<leaflet ng-if="$ctrl.showMap" markers="$ctrl.map.markers" center="$ctrl.map.center" flex></leaflet>
11+
</div>
12+
</md-content>

src/components/main/list/list.js

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
import _ from 'lodash';
2+
3+
import './list.scss';
4+
import template from './list.html';
5+
import '../../../images/marker.png';
6+
7+
const ListComponent = {
8+
controller: controller,
9+
template: template
10+
};
11+
12+
function controller($stateParams, $timeout, wikidata) {
13+
let vm = this;
14+
vm.map = {};
15+
16+
const ids = $stateParams.id.split('-in-').map(id => id[0] === 'Q' ? id : 'Q' + id);
17+
const icon = {
18+
iconUrl: 'assets/images/marker.png',
19+
shadowUrl: undefined,
20+
iconSize: [40, 40],
21+
shadowSize: [0, 0],
22+
iconAnchor: [20, 20],
23+
shadowAnchor: [0, 0]
24+
};
25+
26+
vm.map = {
27+
center: {
28+
lat: 51.686,
29+
lng: 19.545,
30+
zoom: 7
31+
},
32+
markers: {}
33+
};
34+
35+
wikidata.getSPARQL(`SELECT ?item ?itemLabel ?admin ?adminLabel ?coord WHERE {
36+
?item wdt:P31 wd:`+ ids[0] + ` .
37+
?item wdt:P131* wd:`+ ids[1] + ` .
38+
?item wdt:P131 ?admin .
39+
?item wdt:P625 ?coord .
40+
SERVICE wikibase:label { bd:serviceParam wikibase:language "pl,en" }
41+
}`).then(data => {
42+
console.log(data)
43+
vm.list = data.map(element => ({
44+
name: {
45+
value_id: element.item.value.substring(element.item.value.indexOf('/Q') + 1),
46+
value: element.itemLabel.value
47+
},
48+
admin: {
49+
value_id: element.admin.value.substring(element.admin.value.indexOf('/Q') + 1),
50+
value: element.adminLabel.value
51+
},
52+
coord: element.coord.value ? element.coord.value.replace('Point(', '').replace(')', '').split(' ') : false
53+
}));
54+
return vm.list;
55+
}).then(list => {
56+
list.forEach(element => {
57+
if(element.coord) {
58+
vm.map.markers[element.name.value_id] = {
59+
lat: +element.coord[1],
60+
lng: +element.coord[0],
61+
icon: icon
62+
};
63+
}
64+
});
65+
$timeout(() => {
66+
vm.showMap = true;
67+
});
68+
});
69+
}
70+
71+
export default () => {
72+
angular
73+
.module('monumental')
74+
.component('moList', ListComponent);
75+
};

src/components/main/list/list.scss

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
mo-list {
2+
.list {
3+
width: 980px;
4+
max-width: 100%;
5+
}
6+
7+
.list__container {
8+
max-height: calc(100vh - 110px);
9+
overflow-y: scroll;
10+
overflow-x: hidden;
11+
}
12+
}

src/components/main/main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const MainComponent = {
1010
function controller(wikidata, $state) {
1111
let vm = this;
1212

13-
vm.goToItem = (item) => $state.go('main.object', {id: item.title});
13+
vm.goToItem = (item) => $state.go('main.object', {id: item.title.substring(1)});
1414
vm.querySearch = (text) => wikidata.getSearch(text);
1515
vm.search = {};
1616

src/components/main/monument/monument.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const MonumentComponent = {
1111

1212
function controller($http, $q, $sce, $stateParams, $timeout, $window, WikiService, wikidata) {
1313
let vm = this;
14-
const id = $stateParams.id;
14+
const id = $stateParams.id[0] === 'Q' ? $stateParams.id : 'Q' + $stateParams.id;
1515

1616
vm.getCommonsLink = getCommonsLink;
1717
vm.image = [];

src/index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ function stateConfig($stateProvider, $urlRouterProvider) {
5555
template: `<mo-dashboard></mo-dashboard>`,
5656
resolve: {}
5757
})
58+
.state('main.list', {
59+
url: '/list/:id',
60+
template: `<mo-list></mo-list>`,
61+
resolve: {}
62+
})
5863
.state('main.object', {
5964
url: '/object/:id?lang',
6065
template: `<mo-monument></mo-monument>`,

0 commit comments

Comments
 (0)