Skip to content
This repository has been archived by the owner on Jul 17, 2024. It is now read-only.

Catalogtree #126

Merged
merged 57 commits into from
Aug 16, 2013
Merged

Catalogtree #126

merged 57 commits into from
Aug 16, 2013

Conversation

procrastinatio
Copy link
Contributor

I think that this PR is now in a state where it makes sense to merge it into master.

What's done:

  • Load Catalogtree based on topic and language
  • Loads Catalogtree definition from catalog service
  • React on topic changes (reloads tree)
  • React on language changes (reloads tree)
  • On hover, a preview of the layer will be shown directly in the map (inspired by oteral's wms browser)
  • Add/remove layers to/from map by clicking checkbox in tree
  • Collaps/Expand catalog tree, initial state reflects data as returned by gaLayers layers definition initially
  • Integrated in accordion
  • Style more or less resembles what is specified
  • Working example

What's not done (to be done in future PR's):

  • React on info button (showing metadata -> which service do we use?)
  • Keep state of tree on language changes (this will not be easy as we load from server on language changes)
  • Probably more styling (didn't test on different browsers)
  • Tests
  • Once the layer selection component is in place, we need to synchronize with catalogtree component
  • other things...

Note:
CatalogService returns layers that are not defined in corresponding layers service. This means that certain layers are not addable from the catalogtree

Below is the original message of Marc

This is only to discuss:

There is a basic example in /ltmom/app/src/catalogtree/example/catalogtree.html

- Expandable/collapsible branches
- Configured with a json file (the equivalent service has to be merged  mf-chsdi3/pull/13)
- Opened/closed branch as defined
- I am not very happy with my template: I need two templates (branches/leafs), should I use two directives, or is there a way to use only parts of a template ?

@gjn
Copy link
Contributor

gjn commented Jul 19, 2013

Discussions went on in our mailing list:
https://groups.google.com/forum/#!topic/re3-dev/L_zjmnwRRGk

I think we should continue this here.

@gjn
Copy link
Contributor

gjn commented Jul 19, 2013

I've just added new commits. We are now using the approach found by Eric on jsfiddle. I think it's very similar to what Marc did to start with, but it looks a little more clean.

Also, the directive is now using a standard partial (templateUrl parameter) for all purposes. We are using ng-if statements to make sure the right stuff is created.

Examples as well as integration in accordion is done.

There's a couple of things still to be done (I'll work on that next week. Today no more time):

  1. First analysis shows that we create massive memory leaks. We need to get rid of those. ng-repeat obviously does not destroy all scopes. I verified this using chromes Profiles tab (Take Heap Snapshots), which increases constantly when changing topic on the tree.
  2. I don't understand why our ng-click functions from the template need to manually call preventDefault() and stopPropagation(). I thought this was part of ng-click? Does anyone has experience in that regard?
  3. Adding functionality (selection, etc) which have to wait on other components
  4. Lots of css (probably something for @tonio when functionality is there

Please review current code. I'm especially worried about 1 and 2.

@gjn
Copy link
Contributor

gjn commented Jul 19, 2013

I analysed a little further. Scopes are all destroyed via $destroy call on the parent element. Anyhow, memory consumption still grows contiually maybe because the GC didn't kick in yet. Any way to force that to happen?

@gjn
Copy link
Contributor

gjn commented Jul 23, 2013

I did some rough analysis on memory consumption:

  1. There seems to be a bug in Batarang (the chrome angularjs debug plugin) creating memory leaks, especially on ng-repeat directives. [1]
  2. There was a bug in angularjs creating memory leaks on chrome. This has been fixed in our current version, but who knows ([2] and [3]).
  3. I created a simple test app. This app changes catalogtree every 15 s (timeout triggered), switching between 400 node tree and 40 node tree. I let this run in Chrome and Firefox for 15 hours. In Chrome, there was an increase of 50kb of memory (might be causes by something else, as chrome has a very strange memory management model) and 10kb of memory increase in Firefox. So, this doesn't look as dramatic...

[1] angular/batarang#62
[2] angular/angular.js#1313 (comment)
[3] https://github.com/angular/angular.js/blob/master/src/ng/rootScope.js#L621

@@ -184,6 +185,8 @@
}
}
.accordion-inner {
max-height: 480px;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should probably be depending on screen-size (and orientation?). We'll let @tonio deal with this.

@gjn
Copy link
Contributor

gjn commented Jul 30, 2013

I thinks it would make sense to merge this into master, even though it's not fully complete.

Please review.

@tonio
Copy link
Contributor

tonio commented Jul 30, 2013

Just a detail, but there’s a mix between (2|4) spaces in your less files (app.less & catalogtree.less).

@gjn
Copy link
Contributor

gjn commented Jul 30, 2013

@tonio Good find.

Should be fixed now.

.ga-catalogtree-entry {
margin-top: 0px;
margin-bottom: 0px;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.ga-catalogtree-entry rule is defined twice.

@loicgasser
Copy link
Contributor

Since you're using the service CatalogServer you could remove the file src/components/catalogtree/example/tree.json

@gjn
Copy link
Contributor

gjn commented Aug 8, 2013

I think it makes sense to not have a dependency to some external service in examples.

@loicgasser
Copy link
Contributor

ok I get it

On Thu, Aug 8, 2013 at 2:33 PM, Gilbert Jeiziner
notifications@github.51.alwrote:

I think it makes sense to not have a dependency to some external service
in examples.


Reply to this email directly or view it on GitHubhttps://github.com//pull/126#issuecomment-22320150
.

map.removeLayer(layer);
}
};

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In order to avoid code duplication (search and catalog, probably layertree later), functions like removeLayerFromMap, addLayerToMap, getMapLayer could all in a service like gaMapUtils. What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Absolutely. This is on Eric's desk as part of the layer list component.

Other existing directives will need to be changed once this components will
be ready.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or the gaLayers could provide convenience functions to add and remove layers to maps.

gaLayers.addToMap(layerId, map);
gaLayers.removeFromMap(layerId, map);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be added to gaLayers. Right now, this service is map agnostic.

Also, I think this new component will need to take care of other things as well. We have different kinds of layers: background, cataloglayers* (wms, wmts, aggregate), kml import layers_, wms import layers_, preview layers (in search, catalogtree, wms import), feature layers for redlining, feature layers for measurements, etc. Those denoted with * are part of the layer list. For all of these, order needs to be managed and maintained by this service.

@cedricmoullet
Copy link
Contributor

I have a strange behaviour on Chrome/Mac -> I can't click on the radiobutton (but can click on the layer name) in order to add the layer. Is it on all plattform ?

@cedricmoullet
Copy link
Contributor

The hover effect is active on the whole line, but the possibility to add the layer works only if the mouse is over the layer name. Is it possible to make that the possibilty to add a layer works like the hover effect ?

@cedricmoullet
Copy link
Contributor

Regarding design:
image
Would it be possible to follow the spec ?

@gjn
Copy link
Contributor

gjn commented Aug 15, 2013

Regarding the icons (category icons, checkbox), I'm using Font Awsome, which don't have round category icons (folded, unfolded) and don't have squared checkbox icons (checked, unchecked). They have what's currently visible. I've discussed it with Dave and he's ok with it.

Regarding colors: yes, I'll need to adapt those.

@gjn
Copy link
Contributor

gjn commented Aug 15, 2013

Regarding hover: on my machine, it works as you wish to have it. I've tested on Chrome, FF and IE9.

Also, adding layers by clicking work in all 3.

Apparently, it's a problem on Mac/Chrome

@gjn
Copy link
Contributor

gjn commented Aug 15, 2013

Addressed all problems with latest commit.

There's still the question about the lines going all the way to the left. But before we hack something, I'd like to discuss this with Dave.

@gjn
Copy link
Contributor

gjn commented Aug 15, 2013

Another rebase done to have popup service.

@gjn
Copy link
Contributor

gjn commented Aug 15, 2013

Added usage of popup service to display metadata information when clicking on the information button.

Note: showing of metadata information will likely be refactored into a seperate service/directive, which can be used in other components (I think search component will also need it)

But I would like to have those merged first before doing the refactoring.

Please review and merge.

return 'http://mf-chsdi30t.bgdi.admin.ch/rest/services/' +
topicId + '/MapServer/' +
layerId + '/getlegend?lang=' +
lang + '&callback=JSON_CALLBACK';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could be updated thanks to f520973

procrastinatio and others added 5 commits August 16, 2013 11:40
We took out modifications of 'val' inside watch function for 'val'
which resulted in infite loops (which were gracefully treated by
angular until now, but it was still bad). In place, we put the
corresponding variables to the scope.

We put the node and leaf html snippets in partials. To load this
partials, we use ng-include snippets at runtime (they are hard
coded in js, which will still changes), which are global to
the directive module.
@gjn
Copy link
Contributor

gjn commented Aug 16, 2013

Took responsibility to update the tree on language/topic change out of controller and put it into a new container directive. Thanks to @elemoine for this input.

Changes based on other comments and did a new rebase.

Ready to be reviewed again and merged.

},
link: function(scope, element, attrs) {
var currentTopic;
scope.updateCatalogTree = function() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need a reference to the updateCatalogTree function in the scope? Instead, can't updateCatalogTree just be local to the link function?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Absolutely. I'll adapt.

@elemoine
Copy link
Contributor

In the example I see the catalog tree twice in the page? Is it expected?

@elemoine
Copy link
Contributor

I'm seeing bugs related to the voidLayer:

  • select the swissALTI3D Hillshade layer in the catalog
  • then select the voidLayer using the background layer selector
  • select the color map background layer again using the background layer selector
  • BUG the swissALTI3D Hillshade layer is not visible anymore

This can be addressed with a separate PR, but I think an issue should be created right after merging this PR.

@gjn
Copy link
Contributor

gjn commented Aug 16, 2013

Regarding example: yes, it is expected.

Regarding bugs: there are quite a few other similar bugs too (for example, hovering over a background layer in the tree will remove it from the map). This is because we don't have a central instance doing our layer management (the layer manager we were speaking on Tuesday).

I take responsibility to update catalog_tree once we have the layer manager in place.

@elemoine
Copy link
Contributor

Something I don't like in the catalog tree UI: after selecting a layer in the catalog the layer gets displayed in the map but it disappears when I start moving my mouse. I know it reappears when the mouse goes out of the layer tree item, but I still find it quite confusing. Can be addressed later as well I think.

@gjn
Copy link
Contributor

gjn commented Aug 16, 2013

This can easily be fixed.

(function() {
goog.provide('ga_catalogtree_directive');

var module = angular.module('ga_catalogtree_directive', [
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your module should depend on ga_translation.

@elemoine
Copy link
Contributor

Regarding example: yes, it is expected.

My apologies. I had missed that.

@elemoine
Copy link
Contributor

This is super impressive work! I'll merge this PR when you tell me again it's ready for merging.

@gjn
Copy link
Contributor

gjn commented Aug 16, 2013

Thanks for the review and compliments.

I adapted based on your recent comments. I think it can be merged....and I'm off to Gampel Open Air!

elemoine pushed a commit that referenced this pull request Aug 16, 2013
@elemoine elemoine merged commit b28789b into master Aug 16, 2013
@elemoine elemoine deleted the dev_catalogtree branch August 16, 2013 11:46
@elemoine
Copy link
Contributor

Merged. Again, fantastic work!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants