Commit 3dca194a authored by Sarun Mungthanya's avatar Sarun Mungthanya
Browse files

fix:after deploy production

parent 8f31e6c3
...@@ -120,6 +120,24 @@ class NewsIndex extends Component ...@@ -120,6 +120,24 @@ class NewsIndex extends Component
} }
public function deleteSelected($selectedNews)
{
if (!\Auth::user()->hasPermissions(['delete-news'])) {
$this->showNoPermissionModal = TRUE;
return;
}
$newsDeleted = Shippingnetnews::whereIn("id", $selectedNews)->pluck('topic')->toArray();
$newsStr = implode(",", $newsDeleted);
Shippingnetnews::destroy($selectedNews);
$message = "Deleted : (" . $newsStr . " )Successfully";
$this->message = $message;
$this->selectedNews = [];
if ($this->message) {
$this->dispatchBrowserEvent('show-message', ['message' => $this->message]);
}
}
public function render() public function render()
{ {
......
...@@ -72,7 +72,7 @@ class SendPatchEdit extends Component ...@@ -72,7 +72,7 @@ class SendPatchEdit extends Component
$this->searchInProgress = true; $this->searchInProgress = true;
$query = ConfServerLicense::query(); $query = ConfServerLicense::query();
if (!empty($this->serverkey)) { if (!empty($this->serverkey)) {
$query->where('SNKEY', 'LIKE', '%' . $this->serverkey . '%'); $query->where('SNKEY', 'LIKE', '' . $this->serverkey . '%');
} }
if (!empty($this->company)) { if (!empty($this->company)) {
$query->where('COMPANY', 'LIKE', '%' . $this->company . '%'); $query->where('COMPANY', 'LIKE', '%' . $this->company . '%');
...@@ -87,8 +87,9 @@ class SendPatchEdit extends Component ...@@ -87,8 +87,9 @@ class SendPatchEdit extends Component
if (!empty($this->selectedOwnerType)) { if (!empty($this->selectedOwnerType)) {
$query->where('OWNERTYPE', $this->selectedOwnerType); $query->where('OWNERTYPE', $this->selectedOwnerType);
} }
$this->resultsServerkey = $query->get(); $tmp = $query->get();
$this->resultsServerkeyArr = $query->get()->toArray(); $this->resultsServerkey = $tmp;
$this->resultsServerkeyArr = $tmp->toArray();
$this->showSearch = true; $this->showSearch = true;
$this->searchInProgress = false; $this->searchInProgress = false;
} }
......
...@@ -90,6 +90,8 @@ class ServerLicenseEdit extends Component ...@@ -90,6 +90,8 @@ class ServerLicenseEdit extends Component
{ {
$this->licenseId = $editId; $this->licenseId = $editId;
$this->loadData(); $this->loadData();
$this->fileDownloads = $this->info['FileDownload'] ?? [];
} }
...@@ -118,12 +120,15 @@ class ServerLicenseEdit extends Component ...@@ -118,12 +120,15 @@ class ServerLicenseEdit extends Component
$this->contactCustomerName = $license->CONTACTCUSTOMERNAME; $this->contactCustomerName = $license->CONTACTCUSTOMERNAME;
if ($license && !empty($license->BACKUP_FEEDBACK)) { if ($license && !empty($license->BACKUP_FEEDBACK)) {
$compressedData = gzuncompress(base64_decode($license->BACKUP_FEEDBACK)); $compressedData = gzuncompress(base64_decode($license->BACKUP_FEEDBACK));
$this->backupFeedback = $compressedData; $this->backupFeedback = $compressedData;
$currentEncoding = mb_detect_encoding($compressedData, mb_detect_order(), true); $currentEncoding = mb_detect_encoding($compressedData, mb_detect_order(), true);
$this->info = null; $this->info = null;
eval('$this->info = ' . trim($compressedData) . ';'); eval('$this->info = ' . trim($compressedData) . ';');
} }
} }
...@@ -634,13 +639,34 @@ class ServerLicenseEdit extends Component ...@@ -634,13 +639,34 @@ class ServerLicenseEdit extends Component
public function loadFileDownload() public function loadFileDownload()
{ {
$this->tab = 'fileDownload'; $this->tab = 'fileDownload';
if ($this->info && isset($this->info['FileDownload'])) { if ($this->info && isset($this->info['FileDownload'])) {
$this->fileDownloads = $this->info['FileDownload'] ?? [];
$this->fileNameList = $this->info['Filename'] ?? []; $this->fileNameList = $this->info['Filename'] ?? [];
} }
} }
public function downloadFile($index)
{
$this->loadData();
$codeFile =$this->info['FileDownload'][$index] ?? '';
$filename = $this->fileNameList[$index] ?? 'unknown_file' . $index . '.txt';
$codeFileUtf8 = iconv('TIS-620', 'UTF-8//IGNORE', $codeFile);
$filename = ltrim($filename, './');
$tempFilePath = storage_path('app/temp/' . $filename);
$dirname = dirname($tempFilePath);
if (!is_dir($dirname)) {
mkdir($dirname, 0777, true);
}
if (file_put_contents($tempFilePath, $codeFileUtf8) !== false) {
return response()->download($tempFilePath)->deleteFileAfterSend(true);
} else {
session()->flash('error', "Failed to create temporary file for $filename");
}
}
public function downloadAllFile() public function downloadAllFile()
{ {
$dateCurrent = now()->format('Y-m-d H:i:s'); $dateCurrent = now()->format('Y-m-d H:i:s');
...@@ -657,12 +683,15 @@ class ServerLicenseEdit extends Component ...@@ -657,12 +683,15 @@ class ServerLicenseEdit extends Component
if ($zip->open($zipFilePath, ZipArchive::CREATE) !== true) { if ($zip->open($zipFilePath, ZipArchive::CREATE) !== true) {
return response()->json(['error' => "Cannot open <$zipFilePath>"], 500); return response()->json(['error' => "Cannot open <$zipFilePath>"], 500);
} }
$this->loadData();
$fileDownloads = $this->info['FileDownload'] ?? []; $fileDownloads = $this->info['FileDownload'] ?? [];
$filenames = $this->info['Filename'] ?? []; $filenames = $this->info['Filename'] ?? [];
$textLog = "\n{$dateCurrent} {$this->SNKEY} ??TempUser?? [ "; $textLog = "\n{$dateCurrent} {$this->SNKEY} ??TempUser?? [ ";
foreach ($fileDownloads as $key => $codeFile) { foreach ($fileDownloads as $key => $codeFile) {
// Convert $codeFile from TIS-620 to UTF-8
$codeFileUtf8 = iconv('TIS-620', 'UTF-8//IGNORE', $codeFile);
$filename = $filenames[$key] ?? 'unknown_file' . $key . '.txt'; $filename = $filenames[$key] ?? 'unknown_file' . $key . '.txt';
$filename = ltrim($filename, './'); $filename = ltrim($filename, './');
$tempFilePath = storage_path('app/temp/' . $filename); $tempFilePath = storage_path('app/temp/' . $filename);
...@@ -672,7 +701,7 @@ class ServerLicenseEdit extends Component ...@@ -672,7 +701,7 @@ class ServerLicenseEdit extends Component
mkdir($dirname, 0777, true); mkdir($dirname, 0777, true);
} }
if (file_put_contents($tempFilePath, $codeFile) !== false) { if (file_put_contents($tempFilePath, $codeFileUtf8) !== false) {
$tempFiles[] = $tempFilePath; $tempFiles[] = $tempFilePath;
if (!$zip->addFile($tempFilePath, $filename)) { if (!$zip->addFile($tempFilePath, $filename)) {
session()->flash('error', "Failed to add $filename to ZIP"); session()->flash('error', "Failed to add $filename to ZIP");
...@@ -752,7 +781,6 @@ class ServerLicenseEdit extends Component ...@@ -752,7 +781,6 @@ class ServerLicenseEdit extends Component
public function render() public function render()
{ {
$this->loadHistoryPatchData(); $this->loadHistoryPatchData();
return view('livewire.pages.server-license.server-license-edit', [ return view('livewire.pages.server-license.server-license-edit', [
'historyPatchList' => $this->historyPatchList, 'historyPatchList' => $this->historyPatchList,
]); ]);
......
...@@ -28,7 +28,24 @@ ...@@ -28,7 +28,24 @@
</div> </div>
</div> </div>
@endif @endif
<div class="grid grid-cols-1 gap-4 sm:gap-5 lg:gap-6 bg-main-container rounded-md" x-data="{ showDeleteListModal : false}"> <div class="grid grid-cols-1 gap-4 sm:gap-5 lg:gap-6 bg-main-container rounded-md"
x-data="{
showDeleteListModal: @entangle('showDeleteListModal'),
showAlert: false,
toggleGroup(event) {
const groupId = event.target.value;
if (event.target.checked) {
if (!this.selectedNewsAlpine.includes(groupId)) {
this.selectedNewsAlpine.push(groupId);
}
} else {
this.selectedNewsAlpine = this.selectedNewsAlpine.filter(id => id !== groupId);
}
},
selectedNewsAlpine: [],
selectedNews: @entangle('selectedNews')
}"
>
<div class="pb-4 pt-5 bg-white rounded-lg shadow-lg"> <div class="pb-4 pt-5 bg-white rounded-lg shadow-lg">
<div class="flex justify-between"> <div class="flex justify-between">
......
<div> <div x-cloak>
@include('components.no-permission') @include('components.no-permission')
<div class="flex items-center space-x-4 py-5 lg:py-6 "> <div class="flex items-center space-x-4 py-5 lg:py-6 ">
......
...@@ -63,7 +63,8 @@ ...@@ -63,7 +63,8 @@
<div class="relative flex items-center w-full"> <div class="relative flex items-center w-full">
<input type="text" <input type="text"
class="form-input h-9 peer w-full rounded-lg border border-slate-300 bg-transparent px-3 py-2 placeholder:text-slate-400/70 hover:border-slate-400 focus:border-primary dark:border-navy-450 dark:hover:border-navy-400 dark:focus:border-accent" class="form-input h-9 peer w-full rounded-lg border border-slate-300 bg-transparent px-3 py-2 placeholder:text-slate-400/70 hover:border-slate-400 focus:border-primary dark:border-navy-450 dark:hover:border-navy-400 dark:focus:border-accent"
wire:model.debounce.100ms="serverkey" placeholder="Search for a server key">
wire:model.debounce.1000ms="serverkey" placeholder="Search for a server key">
<span wire:loading <span wire:loading
wire:target="serverkey, selectedOwnerType, company, db_type, cur_ver, selectAllResults" wire:target="serverkey, selectedOwnerType, company, db_type, cur_ver, selectAllResults"
class="absolute right-3"> class="absolute right-3">
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
console.log(show, message); console.log(show, message);
setTimeout(() => { show = false, console.log(show, message); }, 3000); setTimeout(() => { show = false, console.log(show, message); }, 3000);
});"> });">
<div x-show.transition.duration.500ms="show" <div x-show.transition.duration.500ms="show" x-cloak
class="fixed top-5 right-5 z-50 bg-green-500 text-white py-2 px-4 rounded-md shadow-lg"> class="fixed top-5 right-5 z-50 bg-green-500 text-white py-2 px-4 rounded-md shadow-lg">
{{ $message }} {{ $message }}
</div> </div>
......
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
<td class="whitespace-nowrap px-1 py-1 sm:px-2"> <td class="whitespace-nowrap px-1 py-1 sm:px-2">
<div class="flex justify-center space-x-2"> <div class="flex justify-center space-x-2">
<a <a wire:click="downloadFile('{{ $key }}')" href="javascript:void(0)"
class="btn h-8 w-8 p-0 hover:text-main-container active:text-main-container hover:primary-focus focus:primary-focus active:bg-info/25"> class="btn h-8 w-8 p-0 hover:text-main-container active:text-main-container hover:primary-focus focus:primary-focus active:bg-info/25">
<i aria-hidden="true" class="fa fa-download"></i> <i aria-hidden="true" class="fa fa-download"></i>
</a> </a>
......
...@@ -79,7 +79,9 @@ ...@@ -79,7 +79,9 @@
<div wire:ignore class="mb-2"> <div wire:ignore class="mb-2">
<label for="group" class="block text-sm font-medium text-gray-700">Add Groups:</label> <label for="group" class="block text-sm font-medium text-gray-700">Add Groups:</label>
<span class="relative flex w-full"> <span class="relative flex w-full">
<input class="mt-1.5 relative flex w-full" x-data="{ groupLists: @entangle('group_lists') }" x-init="groupLists = []; <input class="mt-1.5 relative flex w-full" wire:ignore
x-data="{ groupLists: @entangle('group_lists') }"
x-init="groupLists = [];
const tempGroup = pages.groupSelect; const tempGroup = pages.groupSelect;
pages.fetchGroups(tempGroup).then(() => { pages.fetchGroups(tempGroup).then(() => {
$el._x_tom = new Tom($el, { $el._x_tom = new Tom($el, {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment