Skip to content

Commit

Permalink
patch
Browse files Browse the repository at this point in the history
  • Loading branch information
lbr38 committed Nov 14, 2024
1 parent 4b79ddc commit fb69f98
Show file tree
Hide file tree
Showing 19 changed files with 611 additions and 413 deletions.
8 changes: 1 addition & 7 deletions Todolist
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,9 @@

[ IMPROVEMENTS / FEATURES ]

[ GENERAL ]

- (JS) Refactor and mutualize the ajax functions


[ REPOS ]

- Think about a way to publish debian repos in a more elegant way. Currently: https://<FQDN>/repo/debian/dists/buster/main_prod buster main_prod
- (RPM) See how to accelerate the rpm signing process by using multi-threading
- (Feature) Support Arch Linux packages
https://blog.desdelinux.net/en/create-your-local-arch-linux-repository/
https://wiki.archlinux.org/title/Pacman#Repositories_and_mirrors
Expand Down
2 changes: 1 addition & 1 deletion www/controllers/Browse.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public static function printSubDir($dir, $path)
{
?>
<li>
<div class="explorer-toggle header-blue pointer flex column-gap-5 align-item-center" title="Directory <?= $dir ?>">
<div class="explorer-toggle div-generic-blue pointer flex column-gap-5 align-item-center" title="Directory <?= $dir ?>">
<img src="/assets/icons/folder.svg" class="icon" />
<p><?= $dir ?></p>
</div>
Expand Down
17 changes: 14 additions & 3 deletions www/controllers/Layout/Container/vars/hosts/list.vars.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
$mygroup = new \Controllers\Group('host');
$myhost = new \Controllers\Host();
$hostDb = new \Controllers\Host();
$compactView = false;
$compactView = true;

/**
* Initializing counters for doughnut chart
Expand Down Expand Up @@ -35,6 +35,17 @@
*/
$packagesCountConsideredCritical = $hostsSettings['pkgs_count_considered_critical'];

if (isset($_COOKIE['hosts/compact-view']) and $_COOKIE['hosts/compact-view'] == true) {
$compactView = true;
if (isset($_COOKIE['hosts/compact-view']) and $_COOKIE['hosts/compact-view'] == false) {
$compactView = false;
}

/**
* Setting layout variables depending on the view mode
*/
if ($compactView) {
$layoutPackagesTitle = 'PKG.';
$layoutGridClass = 'grid-5';
} else {
$layoutPackagesTitle = 'PACKAGES';
$layoutGridClass = 'grid-4';
}
2 changes: 1 addition & 1 deletion www/controllers/Login.php
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ public function changePassword(string $username, string $actualPassword, string
* Check that new specified password and its retype are the same
*/
if ($newPassword !== $newPasswordRetype) {
throw new Exception('New password and password re-type are different');
throw new Exception('New password and password confirm are different');
}

/**
Expand Down
20 changes: 20 additions & 0 deletions www/controllers/ajax/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,24 @@
response(HTTP_OK, 'User has been deleted');
}

/**
* Get websocker server log content
*/
if ($action == 'get-wss-log' and !empty([$_POST['logfile']])) {
// Check if the log file exists
if (!file_exists(WS_LOGS_DIR . '/' . $_POST['logfile'])) {
response(HTTP_BAD_REQUEST, 'Log file not found');
}

// Get the log content
$content = file_get_contents(WS_LOGS_DIR . '/' . $_POST['logfile']);

// Check if the log content was read successfully
if ($content === false) {
response(HTTP_BAD_REQUEST, 'Unable to read log file');
}

response(HTTP_OK, $content);
}

response(HTTP_BAD_REQUEST, 'Invalid action');
108 changes: 108 additions & 0 deletions www/public/assets/icons/view.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
100 changes: 36 additions & 64 deletions www/public/resources/js/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,25 @@ $(document).on('submit','#user-edit-info',function () {
var lastName = $('#user-edit-info').find('input[type=text][name=last-name]').val();
var email = $('#user-edit-info').find('input[type=email][name=email]').val();

edit(username, firstName, lastName, email);
ajaxRequest(
// Controller:
'login',
// Action:
'edit',
// Data:
{
username: username,
firstName: firstName,
lastName: lastName,
email: email
},
// Print success alert:
true,
// Print error alert:
true,
// Reload containers:
[]
);

return false;
});
Expand All @@ -40,71 +58,25 @@ $(document).on('submit','#user-change-password',function () {
var newPassword = $('#user-change-password').find('input[type=password][name=new-password]').val();
var newPasswordConfirm = $('#user-change-password').find('input[type=password][name=new-password-confirm]').val();

changePassword(username, actualPassword, newPassword, newPasswordConfirm);

return false;
});

/**
* Ajax: edit personnal informations
* @param {*} username
* @param {*} firstName
* @param {*} lastName
* @param {*} email
*/
function edit(username, firstName, lastName, email)
{
$.ajax({
type: "POST",
url: "/ajax/controller.php",
data: {
controller: "login",
action: "edit",
username: username,
firstName: firstName,
lastName: lastName,
email: email
},
dataType: "json",
success: function (data, textStatus, jqXHR) {
jsonValue = jQuery.parseJSON(jqXHR.responseText);
printAlert(jsonValue.message, 'success');
},
error: function (jqXHR, ajaxOptions, thrownError) {
jsonValue = jQuery.parseJSON(jqXHR.responseText);
printAlert(jsonValue.message, 'error');
},
});
}

/**
* Ajax: edit password
* @param {*} username
* @param {*} actualPassword
* @param {*} newPassword
* @param {*} newPasswordConfirm
*/
function changePassword(username, actualPassword, newPassword, newPasswordConfirm)
{
$.ajax({
type: "POST",
url: "/ajax/controller.php",
data: {
controller: "login",
action: "changePassword",
ajaxRequest(
// Controller:
'login',
// Action:
'changePassword',
// Data:
{
username: username,
actualPassword: actualPassword,
newPassword: newPassword,
newPasswordConfirm: newPasswordConfirm
},
dataType: "json",
success: function (data, textStatus, jqXHR) {
jsonValue = jQuery.parseJSON(jqXHR.responseText);
printAlert(jsonValue.message, 'success');
},
error: function (jqXHR, ajaxOptions, thrownError) {
jsonValue = jQuery.parseJSON(jqXHR.responseText);
printAlert(jsonValue.message, 'error');
},
});
}
// Print success alert:
true,
// Print error alert:
true,
// Reload containers:
[]
);

return false;
});
29 changes: 29 additions & 0 deletions www/public/resources/js/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,3 +211,32 @@ $(document).on('click','.delete-user-btn',function () {
);
}, 'Delete');
});

/**
* Event: select and view websocket server log file
*/
$(document).on('click','#websocket-log-btn',function () {
// Retrieve log file name
var logfile = $('select#websocket-log-select').val();

ajaxRequest(
// Controller:
'settings',
// Action:
'get-wss-log',
// Data:
{
logfile: logfile
},
// Print success alert:
false,
// Print error alert:
true,
// Reload container:
[],
// Execute functions on success:
[
'printModalWindow(jsonValue.message, "' + logfile + '")'
]
);
});
4 changes: 4 additions & 0 deletions www/public/resources/styles/browse.css
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@
padding-left: 15px;
}

#explorer ul:first-child {
padding-left: 0;
}

#delete-packages-btn {
margin-left: 15px;
}
Expand Down
5 changes: 3 additions & 2 deletions www/public/resources/styles/common.css
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,9 @@ pre.codeblock {
.grid {display: grid}
.grid-2 {grid-template-columns: 1fr 1fr !important}
.grid-2-1 {grid-template-columns: 2fr 1fr !important}
.grid-3 {grid-template-columns: 1fr 1fr 1fr !important}
.grid-4 {grid-template-columns: 1fr 1fr 1fr 1fr !important}
.grid-3 {grid-template-columns: repeat(3, 1fr) !important}
.grid-4 {grid-template-columns: repeat(4, 1fr) !important}
.grid-5 {grid-template-columns: repeat(5, 1fr) !important}
.grid-fr-1-2 {grid-template-columns: 1fr 2fr !important}
.grid-fr-2-1 {grid-template-columns: 2fr 1fr !important}
.grid-fr-4-1 {grid-template-columns: 4fr 1fr !important}
Expand Down
6 changes: 0 additions & 6 deletions www/public/resources/styles/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -541,12 +541,6 @@ input::placeholder {
background-color: #F32F63;
}

.div-flex {
display: flex;
justify-content: space-between;
vertical-align: top;
}

footer {
display: flex;
flex-direction: column;
Expand Down
Loading

0 comments on commit fb69f98

Please sign in to comment.