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

Fixes #10017: Improve data sources UI #1460

Conversation

RaphaelGauthier
Copy link
Member

@RaphaelGauthier RaphaelGauthier force-pushed the ust_10017/improve_data_sources_ui branch from 57ad4d0 to 7f47351 Compare January 24, 2017 16:54
@RaphaelGauthier
Copy link
Member Author

Commit modified

@RaphaelGauthier RaphaelGauthier force-pushed the ust_10017/improve_data_sources_ui branch from 7f47351 to 355d906 Compare January 24, 2017 16:58
@RaphaelGauthier
Copy link
Member Author

PR rebased

@RaphaelGauthier RaphaelGauthier force-pushed the ust_10017/improve_data_sources_ui branch from 355d906 to 152151f Compare January 24, 2017 17:04
r = r.replace(new RegExp("[ùúûü]", 'g'),"u");
r = r.replace(new RegExp("[ýÿ]", 'g'),"y");
r = r.replace(new RegExp("\\W", 'g'),"_");
$scope.selectedDatasource.id = r;
Copy link
Member

Choose a reason for hiding this comment

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

Isn't their a function in JS to map UTF-8 space to ascii? (+take care of ascii space, at least this one is enumerable).
Because, we could do nothing, it would be least surprising than here (for ex, what about the "ğ" ?
And why limit key space? It could be full UTF-8 chars (trimed), no?

Copy link
Member

Choose a reason for hiding this comment

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

OK, js is just a ridiculus language. But that requirement should appear in a lot of place in our code, no?
If so, having an external function like: https://github.com/backbone-paginator/backbone.paginator/blob/a579796a30e583c4dfa09e0a86e4abd21e0b5b56/plugins/diacritic.js would be better.

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 don't find any Javascript native function to map UTF-8 space to ASCII.. But maybe we can use a more complete solution like this ?
https://github.com/Kepro/angular-remove-diacritics

Copy link
Member

Choose a reason for hiding this comment

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

@VinceMacBuche what do you think?

Copy link
Member Author

Choose a reason for hiding this comment

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

Oops I didn't see your previous answer. The Angular Service I linked is precisely based on this function :)

Copy link
Member

Choose a reason for hiding this comment

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

Some more thinking: there is no other keys in Rudder that are not UTF-8 ;
Other node properties can be UTF-8 ;
It is not enforced by API (so that we can add data sources with utf-8 id in all case);.
So I'm really not sure that we want to enforce that only in the web UI (I'm pretty sure of the opposite).
@jooooooon @VinceMacBuche what do you think?

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 @fanf, did some research too, and found the same library ... we should not do ourselves something someone else already did !!

Copy link
Member

Choose a reason for hiding this comment

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

if some validation needs to be done on keys/id we need to do them in backend (prevent invalid characters, being valid identifier ...)

checking on UI side gives a better UX but validating on backend side seems more important

Copy link
Member

Choose a reason for hiding this comment

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

Policy generation fails when you use a property based on utf8 characters

error_properties_utf8

Indeed cfengine arrays does only support cfengine valid ([a-zA-Z_]+) keys, we should valideate properties keys likweise

Copy link
Member

Choose a reason for hiding this comment

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

Replacing invalid key characters (not "[-_a-zA-Z0-9]") by _, is a better solution

@VinceMacBuche
Copy link
Member

apart utf8 remparks this is all good

@RaphaelGauthier
Copy link
Member Author

PR rebased

@RaphaelGauthier RaphaelGauthier force-pushed the ust_10017/improve_data_sources_ui branch from ede3c74 to d301912 Compare January 25, 2017 09:12
@RaphaelGauthier
Copy link
Member Author

Commit modified

@RaphaelGauthier RaphaelGauthier force-pushed the ust_10017/improve_data_sources_ui branch 2 times, most recently from 65d8283 to 5da01c3 Compare January 25, 2017 10:42
@RaphaelGauthier
Copy link
Member Author

Commit modified

<form class="bloc-body show-details" name="forms.datasourceForm">
<div class="form-group">
<label for="name">Name</label>
<input type="text" class="form-control input-sm" id="name" ng-value="selectedDatasource.name" name="datasourceName" required ng-model="selectedDatasource.name" >
<input type="text" class="form-control" id="name" ng-value="selectedDatasource.name" name="datasourceName" required ng-model="selectedDatasource.name" ng-change="updateKeyName(selectedDatasource.name)">
Copy link
Member

Choose a reason for hiding this comment

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

You may want this to be trimmed (using ng-trim)

Copy link
Member Author

Choose a reason for hiding this comment

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

By default, this option is activated. ng-trim allows us to set it to false if necessary but it is not our case :)

Copy link
Member

Choose a reason for hiding this comment

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

Ok :D

@RaphaelGauthier RaphaelGauthier force-pushed the ust_10017/improve_data_sources_ui branch from 5da01c3 to 23c5724 Compare January 25, 2017 12:06
@RaphaelGauthier
Copy link
Member Author

PR rebased

"updateTimeout":{"day":0,"hour":0,"minute":5},
"requestTimeout":{"day":0,"hour":0,"minute":5}
"schedule":{"second":0,"minute":5},
"updateTimeout":{"second":0,"minute":5},
Copy link
Member

Choose a reason for hiding this comment

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

Should be 30s

"requestTimeout":{"day":0,"hour":0,"minute":5}
"schedule":{"second":0,"minute":5},
"updateTimeout":{"second":0,"minute":5},
"requestTimeout":{"second":0,"minute":5}
Copy link
Member

Choose a reason for hiding this comment

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

Same here: 30s

"modifiedTimes":{
"schedule":{"day":0,"hour":0,"minute":5},
Copy link
Member

Choose a reason for hiding this comment

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

Here, by default, every hour is OK.

Copy link
Member

Choose a reason for hiding this comment

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

6h, even

@RaphaelGauthier
Copy link
Member Author

Commit modified

@Normation-Quality-Assistant
Copy link
Contributor

OK, merging this PR

@Normation-Quality-Assistant Normation-Quality-Assistant merged commit 4826f2c into Normation:branches/rudder/4.1 Jan 26, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants