Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ACRFD-13: feature model update, code cleanup, rotating refresh button support new refresh response type. #361

Merged
merged 1 commit into from
Jun 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,6 @@ export class ApplicationAsideComponent implements OnInit, OnDestroy {
try {
_.each(features, feature => {
const f = JSON.parse(JSON.stringify(feature));
// needs to be valid GeoJSON
delete f.geometryName;
const featureObj: GeoJSON.Feature<any> = f;
const layer = L.geoJSON(featureObj);
this.fg.addLayer(layer);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ <h1>Crown land File: {{application.clFile}}</h1>
<button class="btn btn-icon" title="Refresh this application with the latest data from Tantalis"
(click)="refreshApplication()"
[disabled]="isRefreshing">
<i class="material-icons">
<i class="material-icons" [ngClass]="{'rotating': isRefreshing}">
refresh
</i>
</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,14 @@ export class ApplicationDetailComponent implements OnInit, OnDestroy {
.refreshApplication(this.application)
.pipe(takeUntil(this.ngUnsubscribe))
.subscribe(
updatedApplication => {
// updated the application with the latest data
this.application = { ...this.application, ...updatedApplication };
updatedApplicationAndFeatures => {
// update the application with the latest data
this.application = {
...this.application,
...updatedApplicationAndFeatures.application
};
// update the features with the latest data
this.application.features = updatedApplicationAndFeatures.features;
},
error => {
this.isRefreshing = false;
Expand Down
17 changes: 10 additions & 7 deletions src/app/models/feature.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
export class Feature {
_id: string;
type: string;
applicationID: string;
isDeleted: boolean;
geometry: {
type: string;
coordinates: any;
geometries: [
{
type: string;
coordinates: any;
}
];
};
properties: {
INTRID_SID: number;
Expand All @@ -31,15 +34,15 @@ export class Feature {
OBJECTID: number;
SW_ANNO_CAD_DATA: any; // TODO: what type is this?
};
geometryName: string;
isDeleted: boolean;
applicationID: string;

constructor(obj?: any) {
this._id = (obj && obj._id) || null;
this.type = (obj && obj.type) || null;
this.applicationID = (obj && obj.type) || null;
this.isDeleted = (obj && obj.isDeleted) || null;
this.geometry = (obj && obj.geometry) || null;
this.properties = (obj && obj.properties) || null;
this.geometryName = (obj && obj.geometryName) || null;
this.isDeleted = (obj && obj.isDeleted) || null;
this.applicationID = (obj && obj.type) || null;
}
}
18 changes: 14 additions & 4 deletions src/app/services/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,16 @@ interface ILocalLoginResponse {
accessToken: string;
}

/**
* refreshApplication response type.
*
* @interface IRefreshApplicationResponse
*/
interface IRefreshApplicationResponse {
application: Application;
features: Feature[];
}

@Injectable()
export class ApiService {
public token: string;
Expand Down Expand Up @@ -282,9 +292,9 @@ export class ApiService {
return this.http.delete<Application>(`${this.pathAPI}/${queryString}`, {});
}

refreshApplication(app: Application): Observable<Application> {
refreshApplication(app: Application): Observable<IRefreshApplicationResponse> {
const queryString = `application/${app._id}/refresh`;
return this.http.put<Application>(`${this.pathAPI}/${queryString}`, {});
return this.http.put<IRefreshApplicationResponse>(`${this.pathAPI}/${queryString}`, {});
}

saveApplication(app: Application): Observable<Application> {
Expand All @@ -296,13 +306,13 @@ export class ApiService {
// Features
//
getFeaturesByTantalisId(tantalisId: number): Observable<Feature[]> {
const fields = ['type', 'tags', 'geometry', 'geometryName', 'properties', 'isDeleted', 'applicationID'];
const fields = ['type', 'tags', 'geometry', 'properties', 'isDeleted', 'applicationID'];
const queryString = `feature?isDeleted=false&tantalisId=${tantalisId}&fields=${this.buildValues(fields)}`;
return this.http.get<Feature[]>(`${this.pathAPI}/${queryString}`, {});
}

getFeaturesByApplicationId(applicationId: string): Observable<Feature[]> {
const fields = ['type', 'tags', 'geometry', 'geometryName', 'properties', 'isDeleted', 'applicationID'];
const fields = ['type', 'tags', 'geometry', 'properties', 'isDeleted', 'applicationID'];
const queryString = `feature?isDeleted=false&applicationId=${applicationId}&fields=${this.buildValues(fields)}`;
return this.http.get<Feature[]>(`${this.pathAPI}/${queryString}`, {});
}
Expand Down