Skip to content

Commit

Permalink
server changes
Browse files Browse the repository at this point in the history
  • Loading branch information
andreyfoggy committed Apr 1, 2020
1 parent 7b9f627 commit fe03ee8
Show file tree
Hide file tree
Showing 37 changed files with 56 additions and 839 deletions.
395 changes: 0 additions & 395 deletions dist/3rdpartylicenses.txt

This file was deleted.

Binary file removed dist/assets/icons/circle-orange.png
Binary file not shown.
Binary file removed dist/assets/icons/circle-purple.png
Binary file not shown.
Binary file removed dist/assets/icons/circle-red.png
Binary file not shown.
Binary file removed dist/assets/icons/diamond-orange.png
Binary file not shown.
Binary file removed dist/assets/icons/diamond-purple.png
Binary file not shown.
Binary file removed dist/assets/icons/diamond-red.png
Binary file not shown.
395 changes: 0 additions & 395 deletions dist/corona-map/3rdpartylicenses.txt

This file was deleted.

Binary file removed dist/corona-map/assets/icons/circle-orange.png
Binary file not shown.
Binary file removed dist/corona-map/assets/icons/circle-purple.png
Binary file not shown.
Binary file removed dist/corona-map/assets/icons/circle-red.png
Binary file not shown.
Binary file removed dist/corona-map/assets/icons/diamond-orange.png
Binary file not shown.
Binary file removed dist/corona-map/assets/icons/diamond-purple.png
Binary file not shown.
Binary file removed dist/corona-map/assets/icons/diamond-red.png
Binary file not shown.
Binary file removed dist/corona-map/favicon.ico
Binary file not shown.
13 changes: 0 additions & 13 deletions dist/corona-map/index.html

This file was deleted.

1 change: 0 additions & 1 deletion dist/corona-map/main-es2015.181aedd2bdeacc562b88.js

This file was deleted.

1 change: 0 additions & 1 deletion dist/corona-map/main-es5.181aedd2bdeacc562b88.js

This file was deleted.

1 change: 0 additions & 1 deletion dist/corona-map/polyfills-es2015.5b10b8fd823b6392f1fd.js

This file was deleted.

1 change: 0 additions & 1 deletion dist/corona-map/polyfills-es5.3e8196928d184a6e5319.js

This file was deleted.

1 change: 0 additions & 1 deletion dist/corona-map/runtime-es2015.c5fa8325f89fc516600b.js

This file was deleted.

1 change: 0 additions & 1 deletion dist/corona-map/runtime-es5.c5fa8325f89fc516600b.js

This file was deleted.

Empty file.
Binary file removed dist/favicon.ico
Binary file not shown.
13 changes: 0 additions & 13 deletions dist/index.html

This file was deleted.

1 change: 0 additions & 1 deletion dist/main-es2015.1df3d47b14bbfa1d14c9.js

This file was deleted.

1 change: 0 additions & 1 deletion dist/main-es5.1df3d47b14bbfa1d14c9.js

This file was deleted.

1 change: 0 additions & 1 deletion dist/polyfills-es2015.3fd94ed6a324eee92aec.js

This file was deleted.

1 change: 0 additions & 1 deletion dist/polyfills-es5.1a32a062f6d1a267bbc0.js

This file was deleted.

1 change: 0 additions & 1 deletion dist/runtime-es2015.0811dcefd377500b5b1a.js

This file was deleted.

1 change: 0 additions & 1 deletion dist/runtime-es5.0811dcefd377500b5b1a.js

This file was deleted.

Empty file.
36 changes: 33 additions & 3 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const path = require('path');
const request = require('request');

const app = express();

let savedData;
initAPI()
initAngularApp();

Expand All @@ -14,7 +14,7 @@ function initAPI() {
app.get('/regions', (req, serverResponse) => {
request('https://cdn.pravda.com/cdn/covid-19/ukraine.json', { json: true }, (err, res, body) => {
serverResponse.status(200)
.json({ regions: body });
.json(Array.isArray(body.regions) ? body.regions : JSON.parse(savedData));
});
});
}
Expand All @@ -27,4 +27,34 @@ function initAngularApp() {
});

app.listen(process.env.PORT || 8080);
}
}

savedData = `[
{"name":"vinnytsya","confirmed":49,"recovered":0,"deaths":0},
{"name":"volyn","confirmed":7,"recovered":0,"deaths":0},
{"name":"dnipropetrovsk","confirmed":9,"recovered":1,"deaths":0},
{"name":"donetsk","confirmed":6,"recovered":0,"deaths":0},
{"name":"zhytomyr","confirmed":5,"recovered":0,"deaths":1},
{"name":"transcarpathia","confirmed":1,"recovered":0,"deaths":0},
{"name":"zaporizhzhya","confirmed":13,"recovered":1,"deaths":0},
{"name":"ivanofrankivsk","confirmed":64,"recovered":0,"deaths":3},
{"name":"kiev","confirmed":57,"recovered":1,"deaths":3},
{"name":"kirovohrad","confirmed":6,"recovered":0,"deaths":0},
{"name":"luhansk","confirmed":3,"recovered":0,"deaths":0},
{"name":"lviv","confirmed":6,"recovered":0,"deaths":0},
{"name":"mykolayiv","confirmed":0,"recovered":0,"deaths":0},
{"name":"odessa","confirmed":12,"recovered":0,"deaths":0},
{"name":"poltava","confirmed":2,"recovered":0,"deaths":0},
{"name":"rivne","confirmed":15,"recovered":0,"deaths":3},
{"name":"sumy","confirmed":19,"recovered":0,"deaths":2},
{"name":"ternopil","confirmed":98,"recovered":0,"deaths":1},
{"name":"kharkiv","confirmed":1,"recovered":0,"deaths":0},
{"name":"kherson","confirmed":1,"recovered":0,"deaths":0},
{"name":"khmelnytskyy","confirmed":3,"recovered":0,"deaths":0},
{"name":"cherkasy","confirmed":52,"recovered":0,"deaths":0},
{"name":"chernivtsi","confirmed":90,"recovered":7,"deaths":4},
{"name":"chernihiv","confirmed":2,"recovered":0,"deaths":0},
{"name":"kievcity","confirmed":134,"recovered":0,"deaths":0},
{"name":"crimea","confirmed":16,"recovered":0,"deaths":0},
{"name":"sevastopol","confirmed":0,"recovered":0,"deaths":0}
]`
1 change: 0 additions & 1 deletion src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ export class AppComponent implements OnInit {
private setMarkers(regionCasesCollection: Array<any>) {
this.markers = regions.map(region => {
const regionCasesElem = regionCasesCollection.find(item => item.name === region.name);
console.log(regionCasesElem.name);
return {
...region,
cases: regionCasesElem.confirmed,
Expand Down
20 changes: 19 additions & 1 deletion src/app/app.constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const regions = [
},
{
name: 'ivanofrankivsk',
title: 'Івано-Франковська область',
title: 'Івано-Франківська область',
lat: 48.87,
lng: 24.66,
},
Expand Down Expand Up @@ -131,4 +131,22 @@ export const regions = [
lat: 49.24,
lng: 27.00,
},
{
name: 'poltava',
title: 'Полтавська область',
lat: 49.36,
lng: 34.34,
},
{
name: 'kirovohrad',
title: 'Кіровоградська область',
lat: 48.30,
lng: 32.15,
},
{
name: 'kharkiv',
title: 'Харківська область',
lat: 49.90,
lng: 36.20,
},
];
8 changes: 3 additions & 5 deletions src/app/services/http.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,12 @@ export class HttpService {
}

getCasesData() {
return this.http.get('https://cdn.pravda.com/cdn/covid-19/ukraine.json')
.pipe(map((res: any) => {
console.log(res);
const regions = res.regions.regions;
return this.http.get('/regions')
.pipe(map((regions: any) => {
const kyivRegion = regions[regions.findIndex(region => region.name === 'kiev')];
const kyivCity = regions[regions.findIndex(region => region.name === 'kievcity')];
kyivRegion.confirmed += kyivCity.confirmed;

return regions;
}))
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/services/map.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { MarkerManager } from '@agm/core';
export class MapService {

constructor(private markerManager: MarkerManager) {

}

public addMarker(params) {
Expand Down

0 comments on commit fe03ee8

Please sign in to comment.