Skip to content

Conversation

@GermanBluefox
Copy link
Contributor

Add .npmignore file

@sulkaharo
Copy link
Member

Not sure this needs a .npmignore? Also, see https://medium.com/@jdxcode/for-the-love-of-god-dont-use-npmignore-f93c08909d8d

@unsoluble
Copy link
Contributor

There are tons of changes in here — can you elaborate please on exactly what functionality has been added and/or altered?

language.set('en');

// detect browser language
var lang = (navigator.language || navigator.userLanguage).toLowerCase();
Copy link
Member

Choose a reason for hiding this comment

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

For language, you should check the client preferences on the language picked in the UI in the main view. Nightscout explicitly does not use the browser language detection

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@sulkaharo
Copy link
Member

@unsoluble I read through the changes and everything except for the language auto-detection and the .npmignore look like they're good to go. This fixes the clock views not working on instances that don't allow API reads without authentication.

And get suitable language for the very first auth dialog (before the settings were read from server or user can select language in the configuration)
language.set('en');

// detect browser language
var lang = Storages.localStorage.get('language') || (navigator.language || navigator.userLanguage).toLowerCase();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

So I changed it. Please don't forget that for the VERY FIRST authentication dialog it is better to show it in the browser language, than in english.
E.g. my browser language is german and I would like to see the auth dialog in german.

@GermanBluefox
Copy link
Contributor Author

Will it be merged or I should split it? (what will costs me time :) )

@nightscout nightscout deleted a comment Aug 10, 2019
@GermanBluefox
Copy link
Contributor Author

Not sure this needs a .npmignore? Also, see https://medium.com/@jdxcode/for-the-love-of-god-dont-use-npmignore-f93c08909d8d

The author forgot to write ".npmrc" into .npmignore and wrote the whole article about it on medium. Don't believe in everything what is written in internet. The authors there are just like you and me. :)


// Insert the trend arrow.
$('#arrow').attr('src', '/images/' + rec.direction + '.svg');
$('#arrow').attr('src', '/images/' + (!rec.direction || rec.direction === 'NOT COMPUTABLE' ? 'NONE' : rec.direction) + '.svg');
Copy link
Contributor Author

Choose a reason for hiding this comment

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

If calculation cannot be done, so invalid icon was shown. This will fix the icon.


// Generate and insert the clock.
let timeDivisor = (client.settings.timeFormat) ? client.settings.timeFormat : 12;
let timeDivisor = parseInt(client.settings.timeFormat ? client.settings.timeFormat : 12, 10);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just number validation.

if (timeDivisor == 12) {
h = (h == 0) ? 12 : h; // In the case of 00:xx, change to 12:xx for 12h time
if (timeDivisor === 12) {
h = h || 12; // In the case of 00:xx, change to 12:xx for 12h time
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Formatting

Copy link
Contributor

Choose a reason for hiding this comment

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

This is not only formatting. For h == 4 this will be changed to h==12. Please restore old behaviour, perhaps with === instead of ==

Copy link
Contributor

Choose a reason for hiding this comment

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

fixed on my branch

// defined in the template this is loaded into
// eslint-disable-next-line no-undef
if (clockFace == 'clock-color') {
if (clockFace === 'clock-color') {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Formatting

, height: 240
width: 400
, height: 270
, closeText: ''
Copy link
Contributor Author

@GermanBluefox GermanBluefox Aug 10, 2019

Choose a reason for hiding this comment

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

Make an auth dialog a little bit bigger, because in other languages the text is longer and scroll bars appear.

, buttons: [
{
text: translate('Update')
id: 'requestauthenticationdialog-btn'
Copy link
Contributor Author

@GermanBluefox GermanBluefox Aug 10, 2019

Choose a reason for hiding this comment

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

Search is better by ID than $(this).parent().find('button.ui-button-text-only')

]
, open: function open ( ) {
$('#requestauthenticationdialog').keypress(function pressed (e) {
$('#apisecret').off('keyup').on('keyup' ,function pressed (e) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Install handler only on INPUT element and not on the whole dialog.

'<div id="requestauthenticationdialog" style="display:none" title="'+translate('Device authentication')+'">'+
'<label for="apisecret">'+translate('Your API secret')+': </label>'+
'<input type="password" id="apisecret" size="20" />'+
'<input type="password" id="apisecret" size="20" style="width: 100%;"/>'+
Copy link
Contributor Author

Choose a reason for hiding this comment

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

make a secret input element to be a full width, because the secret could be longer than 20 chars.


language.languages.forEach(function (l) {
if (l.code == language.lang && l.speechCode) language.speechCode = l.speechCode;
if (l.code === language.lang && l.speechCode) language.speechCode = l.speechCode;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Formatting

<div id="trend">
<div id="bgnow"></div>
<div id="arrowDiv"><img id="arrow" src=""/></div>
<div id="arrowDiv"><img id="arrow" src="" alt="arrow"/></div>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just a HTML w3c requirement. Alt should be in every "img"

};
script.src = src;

document.head.appendChild(script); //or something of the likes
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Load JSON with token or secret for the case that authentication is enabled.

There is still an open case if the user starts directly to work with clock view without calling the index.html. In this case no authentication dialog will be shown. But I don't know such a use case. In this case the user can use token.

@unsoluble
Copy link
Contributor

Thanks for all the notes. Was really just wanting to know if any other functionality was affected, but appreciate the details. :)

<script src="/api/v1/status.js"></script>
<script src="<%= locals.bundle %>/js/bundle.clock.js?v=<%= locals.cachebuster %>"></script>

<script src="/<%= locals.bundle %>/js/bundle.clock.js?v=<%= locals.cachebuster %>"></script>
Copy link
Contributor

Choose a reason for hiding this comment

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

locals.bundle is /bundle by default, so I get error:
image
remove / in front of it to make it work

Copy link
Contributor

Choose a reason for hiding this comment

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

please cherry pick PieterGit@e143142

@PieterGit
Copy link
Contributor

PieterGit commented Aug 20, 2019

@GermanBluefox Thanks for your contributions. I tested this and did a code review of the changes. I don't understand how you have managed to test this ok, without removing the extra / because with the / it didn't work for me. I'm fine with merging this if you cherry pick or remove the /. I'm now able to use the clock and the implementation LGTM.

I'm sure you and @sulkaharo can find a solution on whether to keep or remove the .npmignore. I think I would advice not to merge it because I don't see the benefits of it. If the discussion about that single file is persistent, I would suggest to open an extra PR for that and merge this without .npmignore. You can just delete it from the PR, because we squash merge commits to dev when we approve them.

@sulkaharo
Copy link
Member

Weird, I thought I posted a long piece here about the .npmignore. The main reason I'd prefer not having it is, given it's a file blacklist, the package maintainers will have to remember to consider the blacklist for every commit to the repository, while a whitelist approach would mean we detect something breaks if a mistake is made. As someone who's been looking after this repo for some years, I really want to reduce the maintenance effort as much as possible, so any new code that comes in should do everything possible to the least additional effort on maintenance.

(Related - we should talk about how / where / when / why to release nightscout as a npm package. If it's done, it should be done from the original repo using the Nightscout org.

@PieterGit
Copy link
Contributor

merged with #4914 (without npmignore)

@PieterGit PieterGit added this to the 0.12.4 milestone Aug 22, 2019
@PieterGit
Copy link
Contributor

@sulkaharo Your reaction on npmignore is #4860 (comment) here. Based on the article I wrote #4860 (comment)

@GermanBluefox @sulkaharo agree to close this issue?

@GermanBluefox
Copy link
Contributor Author

GermanBluefox commented Aug 23, 2019

agree to close this issue?

It is Ok.

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.

4 participants