Skip to content

Commit

Permalink
Merged in DoanQuangDuc/mini-project/LIM2018-143 (pull request #39)
Browse files Browse the repository at this point in the history
LIM2018-143
  • Loading branch information
Doan Quang Duc authored and dinhnguyen-groove committed Jul 9, 2018
2 parents 0d75531 + d98d0cd commit e4320b5
Show file tree
Hide file tree
Showing 11 changed files with 794 additions and 86 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ public async Task<IActionResult> UpdateShipment(string id, FormShipmentModel mod

//DUC
[Route("{shipmentCode}/deliverydetail")]
[Authorize(Roles = "Driver,Coordinator")]
[HttpGet]
public async Task<IActionResult> GetShipmentDetailAsync(string shipmentCode)
{
Expand All @@ -128,42 +129,47 @@ public async Task<IActionResult> ChangeDeliveryStatus([FromBody]string requestCo
}

[Route("{shipmentCode}/locationpicking")]
[Authorize(Roles = "Driver,Coordinator")]
[HttpGet]
public async Task<IActionResult> GetLocationPicking(string shipmentCode)
{
return Ok(await _shipmentRequestService.GetPositionPicking(shipmentCode));
}

[Route("request/{requestCode}")]
//[Authorize(Roles = "Driver,Coordinator")]
[Authorize(Roles = "Driver,Coordinator")]
[HttpGet]
public async Task<IActionResult> GetRequestDetailAsync(string requestCode)
{
return Ok(await _shipmentRequestService.GetCurrentRequestAsync(requestCode));
}

[Route("{shipmentCode}/requestList")]
[Authorize(Roles = "Driver,Coordinator")]
[HttpGet]
public async Task<IActionResult> GetRequestList(string shipmentCode)
{
return Ok(await _shipmentRequestService.GetRequestListAsync(shipmentCode));
}

[Route("{shipmentCode}/changestatus/{status}")]
[Authorize(Roles = "Driver")]
[HttpPut]
public async Task<IActionResult> ShipmentFeedback(string shipmentCode, string status)
{
string code = await _Shipmentservice.ChangeDeliveryStatus(shipmentCode, status);
return Ok(await _Shipmentservice.GetShipmentAsync(code));
}
[Route("request/{requestCode}/changestatus/{status}")]
[Authorize(Roles = "Driver")]
[HttpPut]
public async Task<IActionResult> ChangeStatusRequest(string requestCode, string status)
{
string code = await _shipmentRequestService.ChangeStatusRequestAsync(requestCode, status);
return Ok(await _shipmentRequestService.GetCurrentRequestAsync(code));
}
[Route("request/{requestCode}/sendproblem")]
[Authorize(Roles = "Driver")]
[HttpPost]
public async Task<IActionResult> SaveProblem(string requestCode, [FromBody]Message message)
{
Expand All @@ -172,6 +178,7 @@ public async Task<IActionResult> SaveProblem(string requestCode, [FromBody]Messa
return Ok(await _shipmentRequestService.GetCurrentRequestAsync(code));
}
[Route("request/{requestCode}/resolveproblem")]
[Authorize(Roles = "Driver")]
[HttpPut]
public async Task<IActionResult> ResolveProblem (string requestCode)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, OnInit, NgZone, Input, OnDestroy } from '@angular/core';
import { Component, OnInit, NgZone, Input, OnDestroy, Output, EventEmitter } from '@angular/core';
import { LatLng } from '@agm/core';
import { Marker } from '@agm/core/services/google-maps-types';
import { ShipmentService } from '../shipment/shipment.service';
Expand All @@ -23,12 +23,14 @@ export class GgmapComponent implements OnInit, OnDestroy {
private intervalDisposer: any;
@Input('isRoute') isRoute: boolean;
@Input('marker') marker: string;
@Input('addressWarehouse') addressWarehouse: string;
@Input('addressDelivery') addressDelivery: string;
@Input('addressWarehouse') addressWarehouse: BehaviorSubject<string>;
@Input('addressDelivery') addressDelivery: BehaviorSubject<string>;
//@Input('Origin') Origin: any; // TODO: first letter of property must be lowercase
//@Input('Destination') Destination: LatLng; // TODO: first letter of property must be lowercase
private Waypts: infoMarker[] = [];
@Input('waypts') wayptsSubject: BehaviorSubject<infoMarker[]>;

@Output() addressDeliveryLocated = new EventEmitter();
// @Input('Markers') Markers: any[] = [];

//parameter
Expand All @@ -42,6 +44,7 @@ export class GgmapComponent implements OnInit, OnDestroy {

oldMarkerOrigin = new google.maps.Marker();
oldMarker = new google.maps.Marker();
oldMarkerDelivery = new google.maps.Marker();

markersClean: any[] = [];
// //The location of you
Expand All @@ -60,18 +63,24 @@ export class GgmapComponent implements OnInit, OnDestroy {
private shipmentService: ShipmentService,
private saveService: SaveService
) {

}

ngOnInit() {
console.log(this.isRoute)
this.initMap(this.latcenter, this.lngcenter);
if (this.addressDelivery != '') {
console.log(this.addressDelivery)
this.geocodeAddress(this.addressDelivery, this.iconNext, this.map);
}
if (this.addressWarehouse != '') {
console.log(this.addressWarehouse)
this.geocodeAddress(this.addressWarehouse, this.iconWarehouse, this.map)
if (this.isRoute == false) {
console.log(1);
var addressDeliveryValue: string;
var addressWarehouseValue: string;
this.addressDelivery.subscribe(result => {
console.log(this.oldMarkerDelivery)
addressDeliveryValue = result
if (addressDeliveryValue != '') {
this.geocodeAddress(addressDeliveryValue, this.iconNext, this.map);
}
})

}
if (this.isRoute == true) {
if (APP_SETTINGS.shipmentMap.locationUpdateIntervalMilisec > 0) {
Expand All @@ -96,7 +105,7 @@ export class GgmapComponent implements OnInit, OnDestroy {

ngOnDestroy(): void {
clearInterval(this.intervalDisposer);

}

// TODO: first letter of function must be lowercase
Expand Down Expand Up @@ -201,7 +210,7 @@ export class GgmapComponent implements OnInit, OnDestroy {
var route = response.routes[0];
}
else {
window.alert('Directions request failed due to ' + status);
//window.alert('Directions request failed due to ' + status);
}
});

Expand All @@ -220,47 +229,44 @@ export class GgmapComponent implements OnInit, OnDestroy {
});
}

// TODO: first letter of function must be lowercase
//Convert the address to the latitude and longitude
//Geocoding(address, urlIcon) {
// var geocoder = new google.maps.Geocoder();
// geocoder.geocode({ 'address': address }, function (results, status) {

// if (status == google.maps.GeocoderStatus.OK) {
// this.ngZone.run(() => {
// var latitude = results[0].geometry.location.lat();
// var longitude = results[0].geometry.location.lng();

// var marker = new google.maps.Marker({
// position: { lat: latitude, lng: longitude },
// icon: urlIcon,
// map: this.map
// });

// })
// }
// });
//}
geocodeAddress(address,urlIcon,map) {

geocodeAddress(address, urlIcon, map) {
var geocoder = new google.maps.Geocoder();
this.oldMarkerDelivery.setMap(null);
var marker = new google.maps.Marker();
this.oldMarkerDelivery = marker;
var infoWindow = new google.maps.InfoWindow();
this.openInfoWindow(marker, address, infoWindow);
this.closeInfoWindow(marker, address, infoWindow);
geocoder = new google.maps.Geocoder();

let $self = this;
if (geocoder) {
geocoder.geocode({
'address': address
}, function (results, status) {
if (status == google.maps.GeocoderStatus.OK) {
console.log(results)
var lat = results[0].geometry.location.lat();
var lng = results[0].geometry.location.lng();
let latlng = new google.maps.LatLng(lat, lng)
var marker = new google.maps.Marker({
position: latlng,
icon: urlIcon,
map: map

$self.addressDeliveryLocated.emit({
lat: lat,
lng: lng
});
//marker = new google.maps.Marker({
// position: latlng,
// icon: urlIcon,
// map: map
//});
marker.setPosition(latlng);
marker.setIcon(urlIcon);
marker.setMap(map);
map.setCenter(latlng);

}
});
}
);
}
}

Expand Down Expand Up @@ -293,7 +299,7 @@ export class GgmapComponent implements OnInit, OnDestroy {
}

// TODO: first letter of function must be lowercase
getMarkerDelivery(lat,lng, urlIcon, map) {
getMarkerDelivery(lat, lng, urlIcon, map) {
var marker = new google.maps.Marker({
position: this.getLatlng(lat, lng),
icon: urlIcon,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,32 +135,32 @@ <h1 [hidden]="!isViewFormMode" class="heading">Request Detail</h1>
</div>
</div>

<!--<div class="form-group">
<label for="deliveryLatitude">Delivery Latitude</label>
<input type="text" class="form-control" value="110" [(ngModel)]="formData.deliveryLatitude" name="deliveryLatitude" #deliveryLatitude="ngModel" required [readonly]="isViewFormMode">
<div *ngIf="deliveryLatitude.invalid && (deliveryLatitude.dirty || deliveryLatitude.touched)"
class="alert alert-danger">
<div *ngIf="deliveryLatitude.errors.required">
Delivery Latitude is required.
</div>
</div>
</div>-->
<!--<div class="form-group ">
<label for="deliveryLongitude">Delivery Longitude</label>
<input type="text" class="form-control" value="110" [(ngModel)]="formData.deliveryLongitude" name="deliveryLongitude" #deliveryLongitude="ngModel" required [readonly]="isViewFormMode">
<div *ngIf="deliveryLongitude.invalid && (deliveryLongitude.dirty || deliveryLongitude.touched)"
class="alert alert-danger">
<div *ngIf="deliveryLongitude.errors.required">
Delivery Longitude is required.
</div>
</div>
</div>-->
<div class="form-group">
<label for="deliveryLatitude">Delivery Latitude</label>
<input type="text" class="form-control" value="110" [(ngModel)]="formData.deliveryLatitude" name="deliveryLatitude" #deliveryLatitude="ngModel" readonly="readonly">
<!--<div *ngIf="deliveryLatitude.invalid && (deliveryLatitude.dirty || deliveryLatitude.touched)"
class="alert alert-danger">
<div *ngIf="deliveryLatitude.errors.required">
Delivery Latitude is required.
</div>
</div>-->
</div>
<div class="form-group ">
<label for="deliveryLongitude">Delivery Longitude</label>
<input type="text" class="form-control" value="110" [(ngModel)]="formData.deliveryLongitude" name="deliveryLongitude" #deliveryLongitude="ngModel" readonly="readonly">
<!--<div *ngIf="deliveryLongitude.invalid && (deliveryLongitude.dirty || deliveryLongitude.touched)"
class="alert alert-danger">
<div *ngIf="deliveryLongitude.errors.required">
Delivery Longitude is required.
</div>
</div>-->
</div>
</fieldset>
</form>
</div>
</div>
<div class="col-lg-8 col-md-6 col-sm-12" id="map">
<app-ggmap [addressDelivery]="addDelivery" [addressWarehouse]="addWarehouse" [isRoute]="false"></app-ggmap>
<div class="col-lg-8 col-md-6 col-sm-12" id="map">
<app-ggmap [addressDelivery]="addDelivery" (addressDeliveryLocated)="onAddressDeliveryLocated($event)" [isRoute]="isRoute"></app-ggmap>
</div>

</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,24 @@ import { ActivatedRoute, Router } from '@angular/router';
import { NotificationService } from '../../../shared/component/dialog/notification.service';
import { RequestService } from '../request.service';
import { DatePipe } from '@angular/common';
import { Observable } from 'rxjs';
import { Observable, BehaviorSubject } from 'rxjs';
import { SharingService } from '../../../shared/sevices/sharing-service.service';


@Component({
selector: 'app-request-form',
templateUrl: './request-form.component.html',
styleUrls: ['./request-form.component.scss']
})

export class RequestFormComponent extends FormBaseComponent implements OnInit {
public warehouseList: Array<any> = [];
public warehouseList: Array<any> = [];
public vehicleFeatureList: Array<any> = [];
public requestStatus: string = '';
private isCustomer: boolean;
public addDelivery: string = this.formData.address;
public addDelivery: BehaviorSubject<string> = new BehaviorSubject<string>(this.formData.address);
public message: string = '';

public isRoute: boolean;
constructor(protected route: ActivatedRoute,
protected router: Router,
protected requestService: RequestService,
Expand All @@ -34,11 +35,11 @@ export class RequestFormComponent extends FormBaseComponent implements OnInit {
(this._sharingService.getRole() == "Customer") ? this.isCustomer = true : this.isCustomer = false;
//this.canAccess = (formMode) => { this.canAccessUpdate(formMode) };
this.canAccess = this.canAccessUpdate;
this.formConfiguration.events.onAfterInitFormData = (data)=> {
this.formConfiguration.events.onAfterInitFormData = (data) => {
this.onBeforeInitFormData(data);
};
super.formOnInit("Request", {});

this.isRoute = false;
}

public canAccessUpdate(formMode) {
Expand Down Expand Up @@ -127,7 +128,7 @@ export class RequestFormComponent extends FormBaseComponent implements OnInit {
this.warehouseList = data;
}
});

}
}

Expand All @@ -143,10 +144,16 @@ export class RequestFormComponent extends FormBaseComponent implements OnInit {
}

public onChangeAddress(data) {
this.addDelivery = data;
console.log(1);
this.addDelivery.next(data);
console.log(this.addDelivery)
}

public onAddressDeliveryLocated(location) {
console.log(location);
this.formData.deliveryLatitude = location.lat;
this.formData.deliveryLongitude = location.lng;
}
ngOnInit() {
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ <h1 class="heading">Request Management</h1>
</div>

<kendo-grid [data]="view"
[filter]="true"
[pageable]="true"
filterable="menu"

[sortable]="true"
[pageSize]="state.take"
[skip]="state.skip"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,15 @@ <h1 *ngIf="isCreateForm">Create Shipment</h1>

</fieldset>
<kendo-grid [data]="gridData"
[skip]="state.skip"

[pageSize]="state.take"
[skip]="state.skip"
[sort]="state.sort"
[scrollable]="'scrollable'"
[height]="350"

[sortable]="true"
[group]="state.group"
filterable="menu"
[filter]="state.filter"
[height]="350"
(remove)="removeHandler($event)"
required>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export class ShipmentFormComponent implements OnInit, OnDestroy {

public state: DataSourceRequestState = {
skip: 0,
take: 4
take: 9
};

public active: boolean;
Expand Down
Loading

0 comments on commit e4320b5

Please sign in to comment.