Skip to content

Commit

Permalink
refactor(*): code cleanup
Browse files Browse the repository at this point in the history
- removing dead code, comments, etc.
- added a few scss lines that should not have been removed from a previous version
  • Loading branch information
matt-litwiller committed Aug 21, 2023
1 parent 379a042 commit aa6c89b
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 57 deletions.
28 changes: 4 additions & 24 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ import { AuthOptions } from '@igo2/auth';
import { PwaService } from './services/pwa.service';
import { Workspace } from '@igo2/common';
import { WorkspaceState } from '@igo2/integration';
import { Feature, LayerService, WMSDataSource } from '@igo2/geo';
import { Feature, LayerService } from '@igo2/geo';
import { HttpClient } from '@angular/common/http';
import { map } from 'rxjs/operators';
import { FeatureCollection } from 'geojson';
import { Option } from './pages/filters/simple-filters.interface';
import { FiltersAdditionalPropertiesService } from './pages/filters/filterServices/filters-additional-properties.service';
import { ContextService, DetailedContext } from '@igo2/context';
import { ContextService } from '@igo2/context';


@Component({
Expand Down Expand Up @@ -49,7 +49,6 @@ export class AppComponent implements OnInit {
private promptEvent: any;
public hasMenu: boolean = false;
public workspace = undefined;
public workspaceEnabled = false;
public additionalProperties: Map<string, Map<string,string>> = new Map<string, Map<string, string>>();
public additionalTypes: Array<string>;
public properties: Array<string>; //array of properties (the keys in the propertiesMap)
Expand Down Expand Up @@ -93,30 +92,14 @@ export class AppComponent implements OnInit {
this.hasMenu = this.configService.getConfig('hasMenu') === undefined ? false :
this.configService.getConfig('hasMenu');

this.showMap = this.configService.getConfig('useEmbeddedVersion.showMap') !== undefined ? this.configService.getConfig('useEmbeddedVersion.showMap') : false;
this.showMap = this.configService.getConfig('useEmbeddedVersion.showMap') !== undefined ?
this.configService.getConfig('useEmbeddedVersion.showMap') : false;

this.useEmbeddedVersion = this.configService.getConfig('useEmbeddedVersion') === undefined ?
false : this.showMap || this.showSimpleFeatureList || this.showSimpleFilters;

this.layerId = this.configService.getConfig('useEmbeddedVersion.layerId');

this.workspaceEnabled = this.configService.getConfig('layers.workspace');
console.log("workspaceEnabled ", this.workspaceEnabled);
this.contextService.contexts$.subscribe( context => {
console.log("context ", context);
context.ours.forEach(c => {
console.log("id ", c.id);
})
})

// this.contextService.showContext("_default").subscribe(c => console.log("c ", c));
// this.contextService.getDefault().subscribe( c => console.log("c ", c));
// this.contextService.getById(this.layerId).forEach(context => {
// console.log("context ", context);
// })

console.log("useEmbeddedVersion ", this.useEmbeddedVersion);

this.setManifest();
this.installPrompt();
this.pwaService.checkForUpdates();
Expand Down Expand Up @@ -218,8 +201,6 @@ export class AppComponent implements OnInit {
this.entitiesAll = this.workspace.entityStore.entities$.getValue() as Array<Feature>;
this.entitiesList = this.workspace.entityStore.entities$.getValue() as Array<Feature>;

console.log("entitiesAll ", this.entitiesAll);

this.properties = Object.keys(this.entitiesAll[0]["properties"]);
for(let property of this.properties){
let values: Array<Option> = [];
Expand All @@ -239,7 +220,6 @@ export class AppComponent implements OnInit {
}

setClickedEntities(features: Feature[]) {
console.log("clicked entities");
this.clickedEntities = features;
}

Expand Down
10 changes: 0 additions & 10 deletions src/app/pages/list/simple-feature-list.component.scss
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
.entities-container {
// overflow-y: auto;
// height: 100%;
// width: 100%
}

.entity, .selectedEntity {
border-bottom: 1px solid #C5CAD2;
padding: 20px 0px 20px 0px;
Expand Down Expand Up @@ -32,8 +26,6 @@

.standard {
font-size: 16px;
// line-height: 24px;
// margin-top: 16px;
}

.small {
Expand All @@ -43,8 +35,6 @@

.attribute, .description {
font-family: "Open Sans", sans-serif;
// font-size: 16px;
// line-height: 24px;
}

.selectButton, .unselectButton {
Expand Down
4 changes: 0 additions & 4 deletions src/app/pages/list/simple-feature-list.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,13 +190,9 @@ export class SimpleFeatureListComponent implements OnInit, OnChanges, OnDestroy
let propA: Map<string, string> = this.additionalProperties.get(coordsA);
let propB: Map<string, string> = this.additionalProperties.get(coordsB);

console.log("propA ", propA, " propB ", propB);

let typeA = propA.get(sortBy);
let typeB = propB.get(sortBy);

console.log("typeA ", typeA, " typeB ", typeB);

return typeA > typeB ? 1 : typeA < typeB ? -1 : 0;
} catch (error){
//the only error that can occur is if the data is not initialized (from additionalProperties)
Expand Down
3 changes: 2 additions & 1 deletion src/app/pages/menu/menu-pages/map/map.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ export class MapComponent {

constructor(private configService: ConfigService) {

this.showMap = this.configService.getConfig('useEmbeddedVersion.showMap') === undefined ? false : this.configService.getConfig('useEmbeddedVersion.showMap');
this.showMap = this.configService.getConfig('useEmbeddedVersion.showMap') === undefined ?
false : this.configService.getConfig('useEmbeddedVersion.showMap');
this.showSimpleFilters = this.configService.getConfig('useEmbeddedVersion.simpleFilters') === undefined ? false : true;
this.showSimpleFeatureList = this.configService.getConfig('useEmbeddedVersion.simpleFeatureList') === undefined ? false : true;

Expand Down
2 changes: 1 addition & 1 deletion src/app/pages/portal/portal.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
<igo-geolocate-button *ngIf="hasGeolocateButton" [map]="map" color="primary"></igo-geolocate-button>
<igo-zoom-button [map]="map" color="primary"></igo-zoom-button>
<igo-rotation-button *ngIf="!useEmbeddedVersion" [showIfNoRotation]="showRotationButtonIfNoRotation" [map]="map" color="primary"></igo-rotation-button>
<app-legend-button *ngIf= "hasLegendButton" (toggleLegend)= "toggleLegend()" [legendInPanel]= "legendInPanel" [tooltipDisabled]="mobile" [legendButtonTooltip]="legendButtonTooltip" color= "primary"></app-legend-button>
<app-legend-button *ngIf="hasLegendButton && !useEmbeddedVersion" (toggleLegend)= "toggleLegend()" [legendInPanel]= "legendInPanel" [tooltipDisabled]="mobile" [legendButtonTooltip]="legendButtonTooltip" color= "primary"></app-legend-button>
</div>

<app-bottompanel
Expand Down
6 changes: 6 additions & 0 deletions src/app/pages/portal/portal.component.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
@import './portal.variables';

/*** Main ***/
:host {
width: 100%;
height: 100%;
display: block;
}

$right-min-width : 400px;
$map-min-height: 400px;
$left-min-width : 400px;
Expand Down
19 changes: 3 additions & 16 deletions src/app/pages/portal/portal.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,8 @@ export class PortalComponent implements OnInit, AfterContentInit, OnDestroy, OnC
this.configService.getConfig('legendInPanel');
this.useEmbeddedVersion = this.configService.getConfig('useEmbeddedVersion') === undefined ?
false : this.showMap || this.showSimpleFeatureList || this.showSimpleFilters;

console.log("condition ", this.hasFooter && !this.mobile && !this.useEmbeddedVersion);
}

ngOnInit() {
Expand Down Expand Up @@ -472,7 +474,7 @@ export class PortalComponent implements OnInit, AfterContentInit, OnDestroy, OnC
this.entitiesAllService.onEvent().subscribe(entitiesAll => this.entitiesAll = entitiesAll);
this.entitiesListService.onEvent().subscribe(entitiesList => {
this.entitiesList = entitiesList;
this.fitFeatures();
// this.fitFeatures();
});

// RESPONSIVE BREAKPOINTS
Expand Down Expand Up @@ -522,7 +524,6 @@ export class PortalComponent implements OnInit, AfterContentInit, OnDestroy, OnC
}

mapQuery(event) {
console.log("mapquery ", event);
this.mapQueryClick = event;
}

Expand Down Expand Up @@ -663,8 +664,6 @@ export class PortalComponent implements OnInit, AfterContentInit, OnDestroy, OnC
}

onMapQuery(event: { features: Feature[]; event: MapBrowserEvent<any> }) {
console.log("event ", event);
// console.log("entitiesListttt ", this.entitiesList);
if(this.useEmbeddedVersion) {
if (event.features.length === 0) return;
if (!this.dataInitialized) {
Expand All @@ -673,20 +672,14 @@ export class PortalComponent implements OnInit, AfterContentInit, OnDestroy, OnC
}
//all entities that appear in entitiesList will be returned
let entities: Array<Feature> = [];
// console.log("event.features[0] ", event.features[0]);
for(let entity of event.features){
// console.log("entity ", entity)
let id = entity.ol.getId();
// console.log("coords ", id);
for(let entityEntry of this.entitiesList){
// console.log("entityEntry ", entityEntry)
if(entityEntry.meta.id === id){
// console.log("FOUND ", entityEntry);
entities.push(entity);
}
}
}
// this.mapQueryEvent.emit(event.features);
if (entities.length > 0) this.mapQueryEvent.emit(entities);
}else {
if(this.configService.getConfig('queryOnlyOne')){
Expand Down Expand Up @@ -959,7 +952,6 @@ export class PortalComponent implements OnInit, AfterContentInit, OnDestroy, OnC
'EPSG:4326',
this.map.projection
);
console.log("computezoomtoextent extent1 ", olExtent);
this.map.viewController.zoomToExtent(olExtent as [number, number, number, number]);
}
}
Expand Down Expand Up @@ -1023,7 +1015,6 @@ export class PortalComponent implements OnInit, AfterContentInit, OnDestroy, OnC
})
);
const totalExtent = computeOlFeaturesExtent(this.map, searchResultsOlFeatures);
console.log("readSearchParams extent2 ", totalExtent);
this.map.viewController.zoomToExtent(totalExtent);
});
}
Expand Down Expand Up @@ -1281,7 +1272,6 @@ export class PortalComponent implements OnInit, AfterContentInit, OnDestroy, OnC
olFeaturesSelected.push(localOlFeature);
}
const totalExtent = computeOlFeaturesExtent(this.map, olFeaturesSelected);
console.log("zoomToSelectedFeature extent3 ", totalExtent);
this.map.viewController.zoomToExtent(totalExtent);
}

Expand All @@ -1292,7 +1282,6 @@ export class PortalComponent implements OnInit, AfterContentInit, OnDestroy, OnC
*/
public filterByOgc(wmsDatasource: WMSDataSource, filterString: string) {
const appliedFilter = new OgcFilterWriter().formatProcessedOgcFilter(filterString, wmsDatasource.options.params.LAYERS);
if(appliedFilter) console.log("length ", appliedFilter.length, ": ", appliedFilter);
wmsDatasource.ol.updateParams({ FILTER: appliedFilter });
}

Expand All @@ -1316,7 +1305,6 @@ export class PortalComponent implements OnInit, AfterContentInit, OnDestroy, OnC
if (category[0] === undefined) return;
let bundleConditions = [];
let lastFilterType = category[0];
console.log("lastfiltertype ", lastFilterType);
for(let filter of category[1]){
if(this.additionalTypes.includes(filter.type) && uniqueKey){
//create idMap, where it stores the keys (coords) of all entities which match the requested terrapi filter
Expand Down Expand Up @@ -1425,7 +1413,6 @@ export class PortalComponent implements OnInit, AfterContentInit, OnDestroy, OnC
});

let mapExtent: MapExtent = [minX, minY, maxX, maxY];
console.log("fitFeatures extent4 ", mapExtent);
this.map.viewController.zoomToExtent(mapExtent);
}

Expand Down
2 changes: 1 addition & 1 deletion src/config/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"logo": "assets/images/signature-PIV.svg",
"logoPrint": "assets/images/signature-PIV.svg"
},
"hasMenu": false,
"hasMenu": true,
"hasFooter": true,
"hasLegendButton": true,
"legendInPanel": true,
Expand Down

0 comments on commit aa6c89b

Please sign in to comment.