Skip to content

Commit

Permalink
fix(nav-bar): fixed current page highlight, rework perms
Browse files Browse the repository at this point in the history
  • Loading branch information
mwfarb committed Apr 21, 2022
1 parent 1a76e61 commit 373c51a
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 18 deletions.
20 changes: 12 additions & 8 deletions navbar-auth-state-old.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,16 @@ $(document).ready(function() {
$('#auth-dropdown').after(
'<ul class=\'dropdown-menu\' role=\'menu\' aria-labelledby=\'dropdownMenu\'></ul>');
$('ul .dropdown-menu').append(`<li><a href="${host}/user/profile">Profile</a></li>`);
if (typeof window.showPerms !== 'undefined') {
$('ul .dropdown-menu').append(`<li><a id="show_perms" href="#">MQTT Permissions</a></li>`);
$('#show_perms').on('click', function() {
window.showPerms();
});
}
$('ul .dropdown-menu').append(`<li><a id="show_perms" href="#">MQTT Permissions</a></li>`);
$('#show_perms').on('click', function() {
const frame = document.getElementsByTagName('iframe');
const win = (frame && frame.length > 0) ? frame[0].contentWindow : window;
if (typeof win.showPerms !== 'undefined') {
win.showPerms();
} else {
alert('No MQTT permissions');
}
});
$('ul .dropdown-menu').append(`<li><a href="${host}/user/logout">Logout</a></li>`);
} else {
$('#auth-dropdown').html('Login').on('click', function(e) {
Expand Down Expand Up @@ -46,9 +50,9 @@ $(document).ready(function() {
storePath = storePath.replace('/storemng/files', '/store');
const fullPath = `${window.location.protocol}//${window.location.host}${storePath}`;
navigator.clipboard.writeText(fullPath);
Swal.fire( 'Copied!', fullPath, 'success' );
Swal.fire('Copied!', fullPath, 'success');
} else {
Swal.fire( 'Invalid path', 'Please navigate to another File Store file or folder', 'warning' );
Swal.fire('Invalid path', 'Please navigate to another File Store file or folder', 'warning');
}
});

Expand Down
24 changes: 14 additions & 10 deletions navbar-auth-state.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,18 @@ $(document).ready(function() {
authDrop.attr('aria-haspopup', 'true');
authDrop.attr('aria-expanded', 'false');
$('#auth-dropdown').after(
'<ul class=\'dropdown-menu dropdown-menu-end\' role=\'menu\' aria-labelledby=\'auth-dropdow\'></ul>');
'<ul class=\'dropdown-menu dropdown-menu-end\' role=\'menu\' aria-labelledby=\'auth-dropdown\'></ul>');
$('ul .dropdown-menu').append(`<li><a class="dropdown-item" href="${host}/user/profile">Profile</a></li>`);
if (typeof window.showPerms !== 'undefined') {
$('ul .dropdown-menu').append(`<li><a class="dropdown-item" id="show_perms" href="#">MQTT Permissions</a></li>`);
$('#show_perms').on('click', function() {
window.showPerms();
});
}
$('ul .dropdown-menu').append(`<li><a class="dropdown-item" id="show_perms" href="#">MQTT Permissions</a></li>`);
$('#show_perms').on('click', function() {
const frame = document.getElementsByTagName('iframe');
const win = (frame && frame.length > 0) ? frame[0].contentWindow : window;
if (typeof win.showPerms !== 'undefined') {
win.showPerms();
} else {
alert('No MQTT permissions');
}
});
$('ul .dropdown-menu').append(`<li><a class="dropdown-item" href="${host}/user/logout">Logout</a></li>`);
} else {
$('#auth-dropdown').html('Login').on('click', function(e) {
Expand All @@ -39,7 +43,7 @@ $(document).ready(function() {
$('#btn-copy-store-path').hide();
}
return link == loc;
}).parent().addClass('active');
}).addClass('active');

// copy the file store public path
$('#btn-copy-store-path').on('click', function(e) {
Expand All @@ -49,9 +53,9 @@ $(document).ready(function() {
storePath = storePath.replace('/storemng/files', '/store');
const fullPath = `${window.location.protocol}//${window.location.host}${storePath}`;
navigator.clipboard.writeText(fullPath);
Swal.fire( 'Copied!', fullPath, 'success' );
Swal.fire('Copied!', fullPath, 'success');
} else {
Swal.fire( 'Invalid path', 'Please navigate to another File Store file or folder', 'warning' );
Swal.fire('Invalid path', 'Please navigate to another File Store file or folder', 'warning');
}
});

Expand Down

0 comments on commit 373c51a

Please sign in to comment.