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

#833 feat(service-details): add quick navigation menu anchors #875

Conversation

eliat123
Copy link
Contributor

@eliat123 eliat123 commented May 23, 2017

Signed-off-by: Eli Atzaba eliat123@gmail.com
Fix #833

@thojkooi
Copy link
Contributor

Doesn't this result in a page refresh of the service details? Which means that if you are editing some fields and click a link in the nav menu, you will lose your changes?

@deviantony
Copy link
Member

Indeed, as @Glowbal stated, this introduces loss in the changes you bring in the form if you click on a menu link.

I think that this should be done differently, maybe if you keep using the goToItem method on each link, but set the anchor in that method?

@deviantony deviantony added changes-required Waiting for an update of the contributor and removed contrib/tech-review-in-progress labels May 23, 2017
@eliat123 eliat123 force-pushed the fix833-Quick-navigation-menu-with-anchors branch from 144d00f to 05f487a Compare May 23, 2017 20:39
@@ -39,6 +39,8 @@ function ($scope, $stateParams, $state, $location, $anchorScroll, Service, Servi
};

$scope.goToItem = function(hash) {
$state.params.page_anchor = hash;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

a hack to avoid full page refresh when changing $location.path

@eliat123
Copy link
Contributor Author

@Glowbal @deviantony updated without full page refresh, please review.

@deviantony deviantony added rebase-required Indicates that the PR must be rebased on the latest development branch and removed changes-required Waiting for an update of the contributor labels May 24, 2017
@deviantony
Copy link
Member

@eliat123 could you rebase your changes? 1.13.0 was released yesterday and #868 introduced a lot of changes.

@eliat123 eliat123 force-pushed the fix833-Quick-navigation-menu-with-anchors branch from 05f487a to 7b02958 Compare May 24, 2017 14:15
@eliat123
Copy link
Contributor Author

@deviantony rebased to latest develop, please review.

@deviantony deviantony added contrib/tech-review-in-progress and removed rebase-required Indicates that the PR must be rebased on the latest development branch labels May 24, 2017
Copy link
Member

@deviantony deviantony left a comment

Choose a reason for hiding this comment

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

I don't like the current implementation, can you have a look at my comments?

app/app.js Outdated
@@ -428,7 +428,7 @@ angular.module('portainer', [
}
})
.state('service', {
url: '^/service/:id/',
url: '^/service/:id/:page_anchor',
Copy link
Member

Choose a reason for hiding this comment

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

I'm not fond of having to add an extra :page_anchor parameter here.

Copy link
Contributor Author

@eliat123 eliat123 May 25, 2017

Choose a reason for hiding this comment

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

@deviantony In my implementation you can have a direct access to a page anchor.

What would be the url format without an additional parameter?

Copy link
Member

Choose a reason for hiding this comment

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

Sorry for my late response.

I don't think there is a need for a direct access to a page anchor, what would be the goal here? Who's going to type the full URL to a service (including the service ID) ?

I also think that location.hash(hash) set the hash in the URL, we might need to add id on elements in the page though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@deviantony I think that users can use this url as a bookmark or as #833 requested.

Why would we want to prevent this usage from users?

Copy link
Member

Choose a reason for hiding this comment

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

@eliat123 yes I agree but you do not need to add this as a state parameter. You can set the hash in the URL with $location.hash(<HASH>) and then call $anchorScroll() to automatically scroll to that hash.

Note that we will need to add id= on each HTML component that we want to be able to scroll to (e.g. networks, ports, etc...)

See my comment below for a code example.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@deviantony I do not fully understand what you mean, just as an example, the url might be:
http://127.0.0.1:9000/#/service/m132l2db91jg31txe9i8s6f1u-service-tasks
If not, please provide an example.

Copy link
Member

Choose a reason for hiding this comment

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

Ok have a look at b42272c

This is an example on how to use $anchorScroll() to automatically scrolls to element with IDs.

This way you can use: http://portainer.domain:9000/#/service/ID/#networks to access networks for example.

And then you can use $location.hash('networks') to scroll to the network element programmatically.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, I will try to find time to work on it.

Copy link
Member

Choose a reason for hiding this comment

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

So I've been able to test it again, it's working well. But could you remove the :page_anchor parameter from the service state?

@@ -37,6 +37,8 @@ function ($q, $scope, $stateParams, $state, $location, $anchorScroll, ServiceSer
};

$scope.goToItem = function(hash) {
$state.params.page_anchor = hash;
$location.path('/service/'+$scope.service.Id+'/'+hash);
Copy link
Member

Choose a reason for hiding this comment

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

Instead of using this hack and $location.path could we use $location.hash and $anchorScroll ?

Something like:

$scope.goToItem = function(hash) {
  var newHash = hash;
  if ($location.hash() !== newHash) {
    $location.hash(hash);
  } else {
    $anchorScroll();
  }
};

As presented in the second example here: https://docs.angularjs.org/api/ng/service/$anchorScroll

@@ -269,6 +272,10 @@ function ($q, $scope, $stateParams, $state, $location, $anchorScroll, ServiceSer
$scope.service = service;
ControllerDataPipeline.setAccessControlData('service', $stateParams.id, service.ResourceControl);
originalService = angular.copy(service);

if(page_anchor) {
Copy link
Member

Choose a reason for hiding this comment

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

Then just call $anchorScroll() here instead of that condition, and it should automatically scroll the hash when the page is refreshed.

@deviantony deviantony added changes-required Waiting for an update of the contributor and removed contrib/tech-review-in-progress labels May 25, 2017
@deviantony
Copy link
Member

ping @eliat123

@eliat123 eliat123 force-pushed the fix833-Quick-navigation-menu-with-anchors branch 4 times, most recently from d94c3a7 to a4a0079 Compare May 29, 2017 07:37
$scope.secrets = data.secrets.map(function (secret) {
return new SecretViewModel(secret);
});

$timeout(function() {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

the $anchorScroll has to occur after the page has been fully rendered, (otherwise the anchor doesn't exist). This can be achieved using $timeout()

Copy link
Member

Choose a reason for hiding this comment

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

I agree with that.

@eliat123
Copy link
Contributor Author

@deviantony I have rebased and added the changes, please review.

@deviantony deviantony added contrib/tech-review-in-progress and removed changes-required Waiting for an update of the contributor labels May 29, 2017
Copy link
Member

@deviantony deviantony left a comment

Choose a reason for hiding this comment

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

Hi @eliat123

Sorry for the late update !

I did another review and some testing. Overall LGTM but you need to remove that page_anchor parameter from the service state as well as fix an identifier.

See my comments.

app/app.js Outdated
@@ -428,7 +428,7 @@ angular.module('portainer', [
}
})
.state('service', {
url: '^/service/:id/',
url: '^/service/:id/:page_anchor',
Copy link
Member

Choose a reason for hiding this comment

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

So I've been able to test it again, it's working well. But could you remove the :page_anchor parameter from the service state?

$scope.secrets = data.secrets.map(function (secret) {
return new SecretViewModel(secret);
});

$timeout(function() {
Copy link
Member

Choose a reason for hiding this comment

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

I agree with that.

@@ -1,4 +1,4 @@
<div>
<div id="service-resources">
Copy link
Member

Choose a reason for hiding this comment

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

The service-resources id should be placed on the service specification panel located in app/components/service/includes/resources.html instead of container-specs.html.

@deviantony deviantony added changes-required Waiting for an update of the contributor and removed contrib/tech-review-in-progress labels Jun 17, 2017
Signed-off-by: Eli Atzaba <eliat123@gmail.com>
@eliat123 eliat123 force-pushed the fix833-Quick-navigation-menu-with-anchors branch from a4a0079 to 485e6b4 Compare June 18, 2017 06:31
@eliat123
Copy link
Contributor Author

@deviantony - I have fixed the requested changes, please review.

Copy link
Member

@deviantony deviantony left a comment

Choose a reason for hiding this comment

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

LGTM

@deviantony deviantony merged commit 9360f24 into portainer:develop Jun 20, 2017
@deviantony
Copy link
Member

Thanks @eliat123 👍

xAt0mZ pushed a commit that referenced this pull request Aug 25, 2022
* fix(helm-rbac) check rbac on helm install

* Use correct auth check
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants