Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 15 additions & 13 deletions app/Console/Commands/TranslationGenerateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
namespace App\Console\Commands;

use App\Console\LnmsCommand;
use Symfony\Component\Process\Process;

class TranslationGenerateCommand extends LnmsCommand
{
Expand All @@ -37,28 +36,31 @@
*
* @return mixed
*/
public function handle()
public function handle(): int

Check failure on line 39 in app/Console/Commands/TranslationGenerateCommand.php

View workflow job for this annotation

GitHub Actions / PHP Static Analysis (8.3)

PHPDoc tag @return with type mixed is not subtype of native type int.

Check failure on line 39 in app/Console/Commands/TranslationGenerateCommand.php

View workflow job for this annotation

GitHub Actions / PHP Static Analysis (8.3)

PHPDoc tag @return with type mixed is not subtype of native type int.
{
\Artisan::call('vue-i18n:generate', ['--multi-locales' => 'true', '--format' => 'umd']);

$npm = new Process(['npm', 'run', 'production']);
$npm->run();

if ($npm->getExitCode() !== 0) {
// npm failed, update hashes manually
$this->updateManifest();
}
// update hashes manually
$this->updateManifest();

return 0;
}

private function updateManifest()
private function updateManifest(): void
{
$manifest_file = public_path('mix-manifest.json');
$manifest = json_decode(file_get_contents($manifest_file), true);
$manifest_file = public_path('js/lang/manifest.json');

if (file_exists($manifest_file)) {
$manifest = json_decode(file_get_contents($manifest_file), true);
} else {
$manifest = [];
}


foreach (glob(public_path('js/lang/*.js')) as $file) {
$file_name = str_replace(public_path(), '', $file);
$manifest[$file_name] = $file_name . '?id=' . substr(md5(file_get_contents($file)), 0, 20);
$locale = basename(str_replace(('/js/lang/'), '', $file_name), '.js');
$manifest[$locale] = $file_name . '?id=' . substr(md5(file_get_contents($file)), 0, 20);
}

file_put_contents($manifest_file, json_encode($manifest, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES) . PHP_EOL);
Expand Down
9 changes: 9 additions & 0 deletions app/Providers/AppServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,15 @@ private function bootCustomBladeDirectives(): void
Blade::directive('graphImage', function ($vars, $flags = 0) {
return "<?php echo \LibreNMS\Util\Graph::getImageData($vars, $flags); ?>";
});

Blade::directive('vuei18n', function () {
$manifest_file = public_path('js/lang/manifest.json');
$manifest = is_readable($manifest_file) ? json_decode(file_get_contents($manifest_file), true) : [];
$locales = array_unique(['en', app()->getLocale()]);
$output = array_map(fn($locale) => '<script src="' . asset($manifest[$locale] ?? "/js/lang/$locale.js") . '"></script>', $locales);

return implode(PHP_EOL, $output);
});
}

private function configureMorphAliases()
Expand Down
308 changes: 308 additions & 0 deletions html/build/assets/app-A4obArBr.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions html/build/assets/app-Bijdu_je.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions html/build/assets/app-CrmpfpAb.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions html/build/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"resources/css/app.css": {
"file": "assets/app-Bijdu_je.css",
"src": "resources/css/app.css",
"isEntry": true
},
"resources/js/app.js": {
"file": "assets/app-A4obArBr.js",
"name": "app",
"src": "resources/js/app.js",
"isEntry": true,
"css": [
"assets/app-CrmpfpAb.css"
]
}
}
2 changes: 0 additions & 2 deletions html/css/app.css

This file was deleted.

1 change: 0 additions & 1 deletion html/css/tailwind.min.css

This file was deleted.

1 change: 0 additions & 1 deletion html/js/app.js

This file was deleted.

5 changes: 0 additions & 5 deletions html/js/boot.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,6 @@
* @author Tony Murray <[email protected]>
*/

// set CSRF for jquery ajax request
$.ajaxSetup({
headers:
{ 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') }
});

// toastr style to match php toasts
toastr.options = {
Expand Down
1 change: 0 additions & 1 deletion html/js/manifest.js

This file was deleted.

2 changes: 0 additions & 2 deletions html/js/vendor.js

This file was deleted.

61 changes: 0 additions & 61 deletions html/js/vendor.js.LICENSE.txt

This file was deleted.

17 changes: 0 additions & 17 deletions html/mix-manifest.json

This file was deleted.

Loading
Loading