-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
#833 feat(service-details): add quick navigation menu anchors #875
Conversation
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? |
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 |
144d00f
to
05f487a
Compare
@@ -39,6 +39,8 @@ function ($scope, $stateParams, $state, $location, $anchorScroll, Service, Servi | |||
}; | |||
|
|||
$scope.goToItem = function(hash) { | |||
$state.params.page_anchor = hash; |
There was a problem hiding this comment.
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
@Glowbal @deviantony updated without full page refresh, please review. |
05f487a
to
7b02958
Compare
@deviantony rebased to latest develop, please review. |
There was a problem hiding this 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', |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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.
ping @eliat123 |
d94c3a7
to
a4a0079
Compare
$scope.secrets = data.secrets.map(function (secret) { | ||
return new SecretViewModel(secret); | ||
}); | ||
|
||
$timeout(function() { |
There was a problem hiding this comment.
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()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with that.
@deviantony I have rebased and added the changes, please review. |
There was a problem hiding this 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', |
There was a problem hiding this comment.
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() { |
There was a problem hiding this comment.
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"> |
There was a problem hiding this comment.
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
.
Signed-off-by: Eli Atzaba <eliat123@gmail.com>
a4a0079
to
485e6b4
Compare
@deviantony - I have fixed the requested changes, please review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Thanks @eliat123 👍 |
* fix(helm-rbac) check rbac on helm install * Use correct auth check
Signed-off-by: Eli Atzaba eliat123@gmail.com
Fix #833