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

CLOSED - TP: Adds Server Capabilities UI #3977

Closed
wants to merge 21 commits into from

Conversation

mitchell852
Copy link
Member

@mitchell852 mitchell852 commented Oct 10, 2019

What does this PR (Pull Request) do?

DO NOT MERGE UNTIL #3966 is merged

This PR enhances TP to support the creation, viewing and deletion of server capabilities. See blueprint for a better explanation of server capabilities.

It also includes UI tests to view, create and delete a server capability
It also includes some documentation under the quick how to section. Note: the docs are a little light at the moment but will fill in as the other feature are complete (assigning a server capability to a server and delivery service).

  • This PR is not related to any Issue

Which Traffic Control components are affected by this PR?

  • Traffic Portal

What is the best way to verify this PR?

  • Launch TP
  • Navigate to Configure > Server Capabilities
  • Create, view and delete a server capability

The following criteria are ALL met by this PR

  • This PR includes tests OR I have explained why tests are unnecessary
  • This PR includes documentation OR I have explained why documentation is unnecessary
  • This PR includes an update to CHANGELOG.md OR such an update is not necessary
  • This PR includes any and all required license headers
  • This PR ensures that database migration sequence is correct OR this PR does not include a database migration
  • This PR DOES NOT FIX A SERIOUS SECURITY VULNERABILITY (see the Apache Software Foundation's security guidelines for details)

@mitchell852 mitchell852 added Traffic Portal related to Traffic Portal new feature A new feature, capability or behavior labels Oct 10, 2019
@asf-ci
Copy link
Contributor

asf-ci commented Oct 10, 2019

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/trafficcontrol-PR/4441/

Copy link
Contributor

@mhoppa mhoppa left a comment

Choose a reason for hiding this comment

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

Pulled and tested this locally it works as expected. Can view/remove/create server capabilities and it correctly handles errors. On the code side havent been in the TP code much so I'll defer to others but I did not personally see any issues with it.

@lbathina
Copy link

leading and trailing spaces are ignore and doesn't throw errors.

@lbathina
Copy link

lbathina commented Oct 10, 2019

I guess we do not have requirement on what the values in Server capabilities can be. However, the UI indicates that Must be alphamumeric with no spaces. Dash, dot and underscore also allowed. given that, the system accepts when only numbers are entered.
Also there should be a check on only special characters - system should not accept only special characters.

@rob05c
Copy link
Member

rob05c commented Oct 10, 2019

I'd like to remove allowing dot, if no one objects. While it's valid in most parts of a URL, if we limit to alpha/digit/_/-, it can be exactly the set of characters in Base64 encoding (RFC 4648). Which seems like it might come in handy. And adding allowed things later is easier than removing them.

@mitchell852
Copy link
Member Author

leading and trailing spaces are ignore and doesn't throw errors.

i think that's fine. the api strips them out.

@mitchell852
Copy link
Member Author

mitchell852 commented Oct 11, 2019

I'd like to remove allowing dot, if no one objects.

I'm good with that. Is this a good UI error message?

Must be alphanumeric with no spaces. Dash and underscore are also allowed.

based on that. This is fine:

-------
-_-_-_
222222

not really sure anyone would do that....but they could...

@mitchell852
Copy link
Member Author

Also there should be a check on only special characters - system should not accept only special characters.

define special

@asf-ci
Copy link
Contributor

asf-ci commented Oct 11, 2019

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/trafficcontrol-PR/4461/

@asf-ci
Copy link
Contributor

asf-ci commented Oct 11, 2019

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/trafficcontrol-PR/4463/

@mitchell852 mitchell852 marked this pull request as ready for review October 11, 2019 19:28
@lbathina
Copy link

lbathina commented Oct 11, 2019

Also there should be a check on only special characters - system should not accept only special characters.

define special

for example following names for server capabilities doesn't make sense.
-------
-_-_-_

@lbathina
Copy link

I'd like to remove allowing dot, if no one objects.

I'm good with that. Is this a good UI error message?

Must be alphanumeric with no spaces. Dash and underscore are also allowed.
Name may contain alphabets, numbers, special character Dash and underscore.
I guess Alphanumberic is different than saying can contain numbers, alphabets.

based on that. This is fine:

-------
-_-_-_
222222

not really sure anyone would do that....but they could...

@asf-ci
Copy link
Contributor

asf-ci commented Oct 11, 2019

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/trafficcontrol-PR/4466/

@asf-ci
Copy link
Contributor

asf-ci commented Oct 12, 2019

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/trafficcontrol-PR/4471/

@asf-ci
Copy link
Contributor

asf-ci commented Oct 12, 2019

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/trafficcontrol-PR/4472/

};

this.getServerCapability = function(name) {
return $http.get(ENV.api['root'] + 'server_capabilities?name=' + name).then(
Copy link
Contributor

Choose a reason for hiding this comment

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

instead of string concatenation, use the params key of the optional args object, like you do above in getServerCapabilty. This ensures proper URI Encoding.

return $http.get(ENV.api['root'] + 'server_capabilities', {params: {"name": name}}).then(r=>r.data.response[0],e=>{throw e;})

};

this.deleteServerCapability = function(name) {
return $http.delete(ENV.api['root'] + 'server_capabilities?name=' + name).then(
Copy link
Contributor

Choose a reason for hiding this comment

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

same as above RE: proper query param usage

<div class="x_title">
<ol class="breadcrumb pull-left">
<li><a ng-click="navigateToPath('/server-capabilities')">Server Capabilities</a></li>
<li class="active">{{serverCapabilityName}}</li>
Copy link
Contributor

Choose a reason for hiding this comment

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

:: for one-time binding?

Copy link
Member Author

Choose a reason for hiding this comment

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

true. i forgot you can't change the name on a server cap

});
};

$scope.serverCapabilityName = angular.copy(serverCapability.name);
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think you need to use angular.copy here.

Copy link
Member Author

Choose a reason for hiding this comment

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

yep i think you are right because you can't change a server cap name even if you wanted to

modalInstance.result.then(function() {
deleteServerCapability(serverCapability);
}, function () {
// do nothing
Copy link
Contributor

Choose a reason for hiding this comment

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

Please don't do nothing; at least log the error

Copy link
Member Author

Choose a reason for hiding this comment

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

it's not an error but i can log something like "action cancelled". actually maybe i just kill this handler.

modalInstance.result.then(function() {
deleteServerCapability(serverCapability);
}, function () {
// do nothing
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above, RE doing nothing.

</ol>
<div class="pull-right">
<button name="createServerCapabilityButton" class="btn btn-primary" title="Create Server Capability" ng-click="createServerCapability()"><i class="fa fa-plus"></i></button>
<button class="btn btn-default" title="Refresh" ng-click="refresh()"><i class="fa fa-refresh"></i></button>
Copy link
Contributor

Choose a reason for hiding this comment

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

The types of these buttons are both submit, and I don't think they ought to be

<br>
<table id="serverCapabilitiesTable" class="table responsive-utilities jambo_table">
<thead>
<tr class="headings">
Copy link
Contributor

Choose a reason for hiding this comment

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

what's this class do? couldn't you just use the selector: thead tr?

Copy link
Member Author

Choose a reason for hiding this comment

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

this is a jquery datatables thing. i'll see if it's not needed.

Copy link
Member Author

Choose a reason for hiding this comment

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

i took it out. seems to have not changed anything.

**************************
Manage Server Capabilities
**************************
Server capabilities are designed to enable system operators to control the flow of delivery service traffic through caches (Edges or Mids) with ONLY the required capabilities. For example, delivery services that serve large binary files should only be routed to caches with sufficient disk cache. Currently, this can be controlled at the Edge tier where system operators can explicitly assign only Edge caches with sufficient disk cache to the delivery service. However, the system operators do not have control of the Mid tier and cannot dictate which Mid caches are qualified to serve these large binary files. This will cause a problem if a Mid cache with insufficient disk cache is asked to serve the large binary files.
Copy link
Contributor

Choose a reason for hiding this comment

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

You've got a bunch of unlinked terms in here: "delivery service", "cache" (should be "cache server" in many cases), maybe a couple of others.
Verbal stress on a word in a sentence should be indicated with emphasis roles. Typically you'd do that with asterisks:

*this text is emphasized*

What's an "operator"? I think you mean

... users with the "operator" :term:`Role` ("operators") ...

this.name=element(by.name('name'));
this.createButton=element(by.buttonText('Create'));
this.deleteButton=element(by.buttonText('Delete'));
this.searchFilter=element(by.id('serverCapabilitiesTable_filter')).element(by.css('label')).element(by.css('input'));
Copy link
Contributor

Choose a reason for hiding this comment

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

can't you combine this into one by.css? by.css('label input')?

Copy link
Member Author

Choose a reason for hiding this comment

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

maybe but they seem fine separate to me. i'm sure all of this UI test framework could be cleaned up.

@asf-ci
Copy link
Contributor

asf-ci commented Oct 15, 2019

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/trafficcontrol-PR/4515/

@mitchell852
Copy link
Member Author

I got into rebase hell so I'm closing this PR and opened #3993

@mitchell852 mitchell852 changed the title TP: Adds Server Capabilities UI CLOSED - TP: Adds Server Capabilities UI Oct 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
abandoned new feature A new feature, capability or behavior Traffic Portal related to Traffic Portal
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants