Skip to content

Commit

Permalink
fix for #16, #15, #10, css fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
kostistr committed Jul 24, 2018
1 parent 5006caf commit 67232ce
Show file tree
Hide file tree
Showing 41 changed files with 1,430 additions and 929 deletions.
4 changes: 2 additions & 2 deletions src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import { EnvironmentSpecificService } from './envSpecific/environment-specific-s

const appRoutes: Routes = [
{ path: '', component: AppBootStrapComponent, resolve: { envSpecific: EnvironmentSpecificResolver }, children:[
{ path: 'welcome', component: WelcomeComponent},
{ path: '', component: WelcomeComponent},
{ path: 'signup', component: SignupComponent},
{ path: 'login', component: LoginComponent},
{ path: 'dashboard', component: DashboardComponent, canActivate:[AuthGuardService], children:[
Expand Down Expand Up @@ -64,7 +64,7 @@ const appRoutes: Routes = [
{path: 'statistics', component: StatisticsComponent},
{path: '**', redirectTo: 'home', pathMatch: 'full'}
]},
{ path: '**', redirectTo: 'welcome', pathMatch: 'full'}
{ path: '**', redirectTo: '', pathMatch: 'full'}
]}
];

Expand Down
4 changes: 3 additions & 1 deletion src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ import { ListIssuesComponent } from './dashboard/issues/list-issues/list-issues.
import { DisplayIssueComponent } from './dashboard/issues/display-issue/display-issue.component';
import { StatisticsComponent } from './dashboard/statistics/statistics.component';
import { SearchIssueComponent } from './dashboard/issues/search-issue/search-issue.component';
import { LocalizedDatePipe } from './shared/localized-date.pipe';



Expand Down Expand Up @@ -120,7 +121,8 @@ registerLocaleData(localeEl);
ListIssuesComponent,
DisplayIssueComponent,
StatisticsComponent,
SearchIssueComponent
SearchIssueComponent,
LocalizedDatePipe
],
imports: [
BrowserModule,
Expand Down
4 changes: 2 additions & 2 deletions src/app/dashboard/boundaries/boundaries.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ <h5 class="title">{{ 'DASHBOARD.BOUNDARIES' | translate }}</h5>
<div class="row">
<div class="col-xl-8">
<div class="card no-margin-top">
<div class="card-header-bootstrap text-center">
<div class="card-header-bootstrap">
{{ 'DASHBOARD.CITY_BOUNDARIES_OVERVIEW' | translate }}
</div>
<div style="min-height:500px; height:65vh"
Expand All @@ -22,7 +22,7 @@ <h5 class="title">{{ 'DASHBOARD.BOUNDARIES' | translate }}</h5>
</div>
<div class="col-xl-4">
<div class="card no-margin-top">
<div class="card-header-bootstrap text-center">
<div class="card-header-bootstrap">
{{ 'DASHBOARD.CITY_BOUNDARIES_CONFIG' | translate }}
</div>

Expand Down
50 changes: 12 additions & 38 deletions src/app/dashboard/boundaries/boundaries.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,19 @@ export class BoundariesComponent implements OnInit {
zoom: 6,
center: latLng(38.074208 , 22.824312)
};

this.returnBoundaries()
}

returnBoundaries() {
this.municService.get_boundaries()
.subscribe(
data => {
console.log(data)
if (data.length == 0) {
this.toastr.error(this.translationService.get_instant('DASHBOARD.CITY_BOUNDARIES_ERROR'), this.translationService.get_instant('ERROR'), {timeOut:8000, progressBar:true, enableHtml:true})
} else {
this.geojsonFeature.features[0].geometry = {"type": data[0].boundaries.type, "coordinates": data[0].boundaries.coordinates};

this.geoJSON = geoJSON(this.geojsonFeature);

this.boundaryLayer = [
this.geoJSON
];
Expand All @@ -77,7 +79,6 @@ export class BoundariesComponent implements OnInit {
},
() => {}
);

}

onMapReady(map: Map){
Expand All @@ -91,58 +92,39 @@ export class BoundariesComponent implements OnInit {
}

submitBoundaries() {
console.log(this.boundariesObj)
this.municService.update_municipality(this.boundariesObj)
this.municService.update_municipality_boundaries({"boundaries":this.boundariesObj})
.subscribe(
data => console.log(data),
error => console.error(error)
data => this.toastr.success(this.translationService.get_instant('DASHBOARD.BOUNDARIES_CHANGED_MSG'), this.translationService.get_instant('SUCCESS'), {timeOut:8000, progressBar:true, enableHtml:true}),
error => {
this.toastr.error(this.translationService.get_instant('DASHBOARD.BOUNDARIES_CHANGED_ERROR'), this.translationService.get_instant('ERROR'), {timeOut:8000, progressBar:true, enableHtml:true})
this.returnBoundaries()
},
() => {this.returnBoundaries()}
)
}

displayCityOnMap(boundaries) {
console.log('displayCityOnMap')
this.boundaryLayer = []

// this.validateJSON(boundaries)
this.boundariesObj = boundaries

console.log(this.boundariesObj)


this.geojsonFeature.features[0].geometry = {"type": boundaries.type, "coordinates": boundaries.coordinates}

this.geoJSON = geoJSON(this.geojsonFeature);
console.log(this.geoJSON)

this.boundaryLayer = [
this.geoJSON
];

this.submitButtonEnabled = true;

}

validateJSON(boundaries) {
console.log(boundaries)
let valid:boolean = false;
let poly = boundaries.coordinates[0]
if (boundaries.type == 'Polygon') {
console.log(poly)
console.log(poly[0])
console.log(poly[poly.length - 1])
valid = arraysEqual(poly[0], poly[poly.length - 1])
}

else if (boundaries.type == 'MultiPolygon') {
console.log(poly)
for (let polygon of poly) {
console.log(polygon)
console.log(polygon[0])
console.log(polygon[polygon.length - 1])

valid = arraysEqual(polygon[0], polygon[polygon.length - 1])
if (valid == false) break;

}
}

Expand All @@ -153,13 +135,10 @@ export class BoundariesComponent implements OnInit {
if(arr1[i] !== arr2[i])
return false;
}

return true;
}

console.log(valid)
return valid

}

fileName = ""
Expand All @@ -178,23 +157,18 @@ export class BoundariesComponent implements OnInit {
let json = {}
reader.onload = () => {
text = reader.result
console.log(text)
try {
json = JSON.parse(text)
console.log(json)
if (this.validateJSON(json)) {
this.displayCityOnMap(json)
} else {
this.toastr.error(this.translationService.get_instant('DASHBOARD.INVALID_BOUNDARIES_FILE_ERROR'), this.translationService.get_instant('ERROR'), {timeOut:4000, progressBar:true, enableHtml:true})
}

} catch (ex) {
console.error(ex)
this.toastr.error(this.translationService.get_instant('DASHBOARD.INVALID_BOUNDARIES_FILE_ERROR'), this.translationService.get_instant('ERROR'), {timeOut:4000, progressBar:true, enableHtml:true})
}
}
reader.readAsText(files[0])

} else {
this.toastr.error(this.translationService.get_instant('DASHBOARD.INVALID_BOUNDARIES_FILE_ERROR'), this.translationService.get_instant('ERROR'), {timeOut:4000, progressBar:true, enableHtml:true})
}
Expand Down
4 changes: 3 additions & 1 deletion src/app/dashboard/dashboard.component.css
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ i, span {
}

.navbar-btn {
box-shadow: none;
-webkit-box-shadow: 0 1px 4px 0 rgba(0,0,0,.14);
box-shadow: 0 1px 4px 0 rgba(0,0,0,.14);
background-color: #eee;
outline: none !important;
border: none;
}
Expand Down
4 changes: 3 additions & 1 deletion src/app/dashboard/dashboard.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,12 @@ export class DashboardComponent implements OnInit {
this.issuesService.API = this.bootstrapComp.API;
this.issuesService.statisticsUrl = this.bootstrapComp.STATISTICS_URL;
this.issuesService.googleKey = this.bootstrapComp.GOOGLE_KEY;
this.issuesService.cityCenter = this.bootstrapComp.CITY_CENTERS[this.city]
this.bootstrapComp.CITY_CENTERS[this.city] ? this.issuesService.cityCenter = this.bootstrapComp.CITY_CENTERS[this.city] : this.issuesService.cityCenter = {"lat":38.074208, "lng":22.824312, "zoom":6}

this.municService.API = this.bootstrapComp.API
this.municService.city = this.city
this.municService.uuid = this.uuid
this.bootstrapComp.CITY_CENTERS[this.city] ? this.municService.cityCenter = this.bootstrapComp.CITY_CENTERS[this.city] : this.municService.cityCenter = {"lat":38.074208, "lng":22.824312, "zoom":6}


this.subscription.add(this.usersServ.usersChanged.subscribe(
Expand Down
Loading

0 comments on commit 67232ce

Please sign in to comment.