Commit 681d2cd0 authored by Sarun Mungthanya's avatar Sarun Mungthanya
Browse files

update validate patch

parent 6ea37075
......@@ -23,13 +23,15 @@ class PatchCreate extends Component
public $fileChanges = [], $filePathChanges = [];
public $searchProject = 'SPN64Bits';
public $UNINSTALL = '$b=1';
public $PATCHNAME, $PDATE, $PHP_VERSION, $PLEVEL, $PCODE, $MAJOR_VERSION, $PDESC, $Remark, $POWNER, $PAPPROVEDATE, $PTYPE, $SPECIFIC_CUSTOMER, $PATCHCODE, $PATCHCODE_SERVER;
public $PATCHNAME, $PDATE, $PHP_VERSION = 0, $PLEVEL, $PCODE, $MAJOR_VERSION, $PDESC, $Remark, $POWNER,$POWNERNAME, $PAPPROVEDATE, $PTYPE, $SPECIFIC_CUSTOMER, $PATCHCODE, $PATCHCODE_SERVER;
public function mount()
{
$this->PDATE = date("Y-m-d H:i:s");
$this->PAPPROVEDATE = date("Y-m-d H:i:s");
$this->PLEVEL = 'High';
$this->POWNERNAME = auth()->user()->username??'';
$this->PATCHCODE = 'function updatePatchFile($PATH_APP,$content){
$handle = fopen($PATH_APP, "w");
fputs($handle,base64_decode($content));
......@@ -164,35 +166,33 @@ class PatchCreate extends Component
public function save()
{
// $this->validate([
// 'PATCHNAME' => 'required|string|max:255',
// 'PDATE' => 'required|date',
// 'PHP_VERSION' => 'required|integer',
// 'PLEVEL' => 'required|string|max:255',
// 'PCODE' => 'required|string|max:255',
// 'MAJOR_VERSION' => 'required|string|max:255',
// 'PDESC' => 'required|string|max:255',
// 'Remark' => 'required|string|max:255',
$this->validate([
'PATCHNAME' => 'required|string|max:255',
'PHP_VERSION' => 'required|in:0,1,2,3',
'PLEVEL' => 'required|string|max:255',
'MAJOR_VERSION' => 'required|string|max:255',
'PDESC' => 'required|string|max:255',
// 'POWNER' => 'required|string|max:255',
// 'PAPPROVEDATE' => 'required|date',
// 'PTYPE' => 'required|string|max:255',
'PAPPROVEDATE' => 'required|date',
'PTYPE' => 'required|string|max:255',
// 'PATCHCODE' => 'required|string',
// 'UNINSTALL' => 'required|string|max:255',
// 'PATCHCODE_SERVER' => 'required|string',
// ]);
]);
$codePhpVersion = MasterPhpVer::find($this->PHP_VERSION);
$confSmartUpdate = new ConfSmartUpdate();
$confSmartUpdate->PATCHNAME = $this->PATCHNAME;
$confSmartUpdate->PDATE = $this->PDATE;
$confSmartUpdate->PDATE = date("Y-m-d H:i:s");
$confSmartUpdate->PHP_VERSION_ID = $this->PHP_VERSION;
$confSmartUpdate->PLEVEL = $this->PLEVEL;
$confSmartUpdate->PCODE = $this->PCODE;
$confSmartUpdate->MAJOR_VERSION = $this->MAJOR_VERSION;
$confSmartUpdate->PDESC = $this->PDESC;
$confSmartUpdate->Remark = $this->Remark;
$confSmartUpdate->POWNER = $this->POWNER;
$confSmartUpdate->POWNER = auth()->user()->id;
$confSmartUpdate->PAPPROVEDATE = $this->PAPPROVEDATE;
$confSmartUpdate->PTYPE = $this->PTYPE;
$confSmartUpdate->PATCHCODE = ($codePhpVersion->check_code ?? '') . " " . $this->PATCHCODE;
......
......@@ -5,6 +5,7 @@ namespace App\Http\Livewire\Pages\Patch;
use Livewire\Component;
use App\Models\ConfSmartUpdate;
use App\Models\TabPatchFile;
use App\Models\User;
use GuzzleHttp\Client;
use GuzzleHttp\Exception\RequestException;
use Illuminate\Support\Facades\Cache;
......@@ -145,6 +146,13 @@ class PatchEdit extends Component
{
$patch = ConfSmartUpdate::findOrFail($this->patchId);
if(!isset($patch->user)) {
$owner = User::where('id', $patch->POWNER)->first();
$this->POWNERNAME = $owner->username;
}else{
$this->POWNERNAME = $patch->user->username;
}
$this->PATCHNAME = $patch->PATCHNAME;
$this->PDATE = $patch->PDATE;
$this->PHP_VERSION = $patch->PHP_VERSION;
......@@ -154,7 +162,7 @@ class PatchEdit extends Component
$this->PDESC = $patch->PDESC;
$this->Remark = $patch->Remark;
$this->POWNER = $patch->POWNER;
$this->POWNERNAME = $patch->user->first_name ?? '';
$this->PAPPROVEDATE = $patch->PAPPROVEDATE;
$this->PTYPE = $patch->PTYPE;
$this->PATCHCODE = $patch->PATCHCODE;
......
......@@ -45,11 +45,11 @@ class ConfSmartupdate extends Model
}
public function servers()
{
{
return $this->hasMany(ConfServerPendding::class, 'PatchID', 'PID');
}
public function user()
{
return $this->belongsTo(User::class, 'POWNER', 'uid');
}
}
public function user()
{
return $this->belongsTo(User::class, 'POWNER' , 'uid');
}
}
......@@ -20,11 +20,11 @@ class User extends Authenticatable
* @var array<int, string>
*/
protected $fillable = [
'uid',
'username',
'first_name',
'last_name',
'phone',
'uid',
'email',
'password',
];
......@@ -52,7 +52,10 @@ class User extends Authenticatable
{
return $this->belongsToMany(Group::class);
}
public function patches()
{
return $this->hasMany(ConfSmartupdate::class , 'uid', 'POWNER');
}
public function permissions()
{
......
......@@ -28,6 +28,7 @@
branches: @entangle('branches').defer,
fileChanges: @entangle('fileChanges').defer,
isLoading: false,
showChangeFile : false
fetchProjects() {
this.isLoading = true;
this.selectedProject = '60';
......@@ -79,7 +80,7 @@
<input type="text" value="254e87" wire:model.defer="endCommit" placeholder="End Commit"
class="placeholder:text-sm text-lg mb-2 form-input rounded-lg border border-slate-300 px-2">
<div class="text-center">
<button type="button" wire:click="getChangedFiles"
<button type="button" wire:click="getChangedFiles" @click="showChangeFile = true"
class="btn mx-auto mt-3 text-white bg-primary px-3 py-2">Get
Changed
Files</button>
......@@ -99,7 +100,7 @@
</div>
</div>
</template> --}}
<div class="mt-5 bg-gray-100 p-4 rounded-lg shadow">
<div class="mt-5 bg-gray-100 p-4 rounded-lg shadow" x-show="showChangeFile">
<h3 class="text-lg mb-3">Changed Files</h3>
<div class="file-tree">
<ul class='pl-4 mt-1'>
......@@ -121,13 +122,29 @@
<label for="patch_name" class="block text-gray-700">Patch name</label>
<input type="text" id="patch_name" class="w-full mt-1 p-2 border border-gray-300 rounded-md"
wire:model.defer="PATCHNAME">
@error('PATCHNAME')
<span class="text-tiny+ text-error">{{ $message }}</span>
@enderror
</div>
<div class="mb-4">
{{-- <div class="mb-4">
<label for="patch_date" class="block text-gray-700">Patch date</label>
<input type="datetime-local" id="patch_date"
class="w-full mt-1 p-2 border border-gray-300 rounded-md" wire:model.defer="PDATE">
@error('PDATE')
<span class="text-tiny+ text-error">{{ $message }}</span>
@enderror
</div> --}}
<div class="grid grid-cols-6 space-x-2 mb-4">
<div class="col-span-2">
<label for="major_version" class="block text-gray-700">Major version</label>
<input type="text" id="major_version"
class="w-full mt-1 p-2 border border-gray-300 rounded-md"
wire:model.defer="MAJOR_VERSION">
@error('MAJOR_VERSION')
<span class="text-tiny+ text-error">{{ $message }}</span>
@enderror
</div>
<div class="mb-4">
<div class="col-span-2">
<label for="php_version" class="block text-gray-700">PHP Version</label>
<select id="php_version" wire:model.defer="PHP_VERSION"
class="w-full mt-1 p-2 border border-gray-300 rounded-md">
......@@ -136,43 +153,74 @@
<option value="2">64Bits (PHP 5.6)</option>
<option value="3">64Bits (PHP 8.0)</option>
</select>
@error('PHP_VERSION')
<span class="text-tiny+ text-error">{{ $message }}</span>
@enderror
</div>
<div class="mb-4">
<div class="col-span-2">
<label for="patch_level" class="block text-gray-700">Patch level</label>
<input type="text" id="patch_level"
class="w-full mt-1 p-2 border border-gray-300 rounded-md" wire:model.defer="PLEVEL">
</div>
<div class="mb-4">
<label for="code" class="block text-gray-700">Patch Code</label>
<input type="text" id="code" wire:model.defer="PCODE"
<select id="patch_level" wire:model.defer="PLEVEL"
class="w-full mt-1 p-2 border border-gray-300 rounded-md">
<option value="High">High</option>
<option value="Auto">Auto</option>
<option value="Critical">Critical</option>
</select>
@error('PLEVEL')
<span class="text-tiny+ text-error">{{ $message }}</span>
@enderror
</div>
<div class="mb-4">
<label for="major_version" class="block text-gray-700">Major version</label>
<input type="text" id="major_version"
class="w-full mt-1 p-2 border border-gray-300 rounded-md"
wire:model.defer="MAJOR_VERSION">
</div>
<div class="mb-4">
<label for="pdesc" class="block text-gray-700">Patch Desciption</label>
<textarea id="pdesc" wire:model.defer="PDESC" class="w-full mt-1 p-2 border border-gray-300 rounded-md"
rows="3"></textarea>
@error('PDESC')
<span class="text-tiny+ text-error">{{ $message }}</span>
@enderror
</div>
<div class="mb-4">
<label for="remark" class="block text-gray-700">Remark</label>
<input type="text" id="remark" wire:model.defer="Remark"
class="w-full mt-1 p-2 border border-gray-300 rounded-md">
@error('Remark')
<span class="text-tiny+ text-error">{{ $message }}</span>
@enderror
</div>
<div class="mb-4">
<label for="owner" class="block text-gray-700">Owner</label>
<input type="text" id="owner" wire:model.defer="POWNER"
class="w-full mt-1 p-2 border border-gray-300 rounded-md" value="aom">
<label for="owner" class="block text-gray-700 ">Owner</label>
<input type="text" id="owner" wire:model.defer="POWNERNAME"
class="w-full mt-1 p-2 border border-gray-300 rounded-md bg-gray-300" readonly>
</div>
<div class="mb-4">
<label for="papprovedate" class="block text-gray-700">Papprovedate</label>
<input type="datetime-local" id="papprovedate" wire:model.defer="PAPPROVEDATE"
class="w-full mt-1 p-2 border border-gray-300 rounded-md" value="2024-03-27T15:00">
</div>
<div x-data="{ isOpen: false }" class="mb-4">
<button @click="isOpen = !isOpen"
class="flex items-center space-x-2 bg-primary text-white px-4 py-2 rounded hover:bg-primary-focus justify-self-end">
<span x-text="isOpen ? 'Hide Details' : 'More Details'"></span>
<svg x-show="!isOpen" xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" fill="none"
viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
d="M12 4v16m8-8H4" />
</svg>
<svg x-show="isOpen" xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" fill="none"
viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M20 12H4" />
</svg>
</button>
<div id="specialBox" x-show="isOpen" x-transition:enter="transition ease-out duration-300"
x-transition:enter-start="opacity-0 transform scale-90"
x-transition:enter-end="opacity-100 transform scale-100"
x-transition:leave="transition ease-in duration-100"
x-transition:leave-start="opacity-100 transform scale-100"
x-transition:leave-end="opacity-0 transform scale-90" class="">
<div class="mb-4">
<label for="code" class="block text-gray-700">Patch Code</label>
<input type="text" id="code" wire:model.defer="PCODE"
class="w-full mt-1 p-2 border border-gray-300 rounded-md">
</div>
<div class="mb-4">
<label for="ptype" class="block text-gray-700">Ptype</label>
<input type="text" id="ptype" wire:model.defer="PTYPE"
......@@ -183,6 +231,9 @@
<input type="text" id="specific_customer"
class="w-full mt-1 p-2 border border-gray-300 rounded-md">
</div>
</div>
</div>
<div class="mb-4">
<label for="patchcode" class="block text-gray-700">Patchcode</label>
<textarea id="patchcode" @click="showModal = true" x-model="tempPathCode" wire:model.defer="PATCHCODE"
......@@ -200,7 +251,7 @@
</div>
<div class="flex justify-center">
<button type="button" wire:click="save"
class="bg-stone-700 text-white px-4 py-2 rounded-md hover:bg-blue-600">Save</button>
class="bg-primary text-white px-4 py-2 rounded-md hover:bg-primary-focus">Save</button>
</div>
<div x-show="showModal" class="fixed inset-0 z-50 bg-gray-800/40 overflow-auto">
<div class="bg-white rounded-lg w-4/5 mx-auto mt-10 mb-10 pb-4">
......
......@@ -27,7 +27,7 @@
transition: width 0.5s;
}
</style>
<a href="/patch" type="button" class="btn mx-auto m-3 text-white bg-primary px-3 py-2">Back</a>
<a href="/patch" type="button" class="btn mx-auto m-1 text-white bg-primary px-3 py-2">Back</a>
<div x-show="progress > 0" x-text="progress + '%'"></div>
......@@ -152,10 +152,10 @@
<div x-show="activeTab === 'tab2'" class="" x-data="{ selectedDeleteFiles: [], showDeleteListModal: false }">
<div class="py-2 ">
<button type="button"
class="py-2 px-3 bg-white border border-primary text-primary rounded-md hover:text-main-container hover:bg-primary-focus"
class="py-2 px-3 bg-primary border border-primary text-white rounded-md hover:bg-primary-focus"
wire:click="$emit('openModalFormPatchFile', '', '{{ $patchId }}')">Add</button>
<button type="button"
class="py-2 px-3 bg-white border-error border rounded-md text-error hover:text-main-container hover:bg-error-focus"
class="py-2 px-3 bg-error border-error border rounded-md text-white hover:bg-error-focus"
@click="showDeleteListModal = true">Delete</button>
</div>
<div x-show="showDeleteListModal"
......@@ -239,13 +239,27 @@
<label for="patch_name" class="block text-gray-700">Patch name</label>
<input type="text" id="patch_name"
class="w-full mt-1 p-2 border border-gray-300 rounded-md" wire:model.defer="PATCHNAME">
@error('PATCHNAME')
<span class="text-tiny+ text-error">{{ $message }}</span>
@enderror
</div>
<div class="mb-4">
<label for="patch_date" class="block text-gray-700">Patch date</label>
<input type="datetime-local" id="patch_date"
class="w-full mt-1 p-2 border border-gray-300 rounded-md" wire:model.defer="PDATE">
</div>
<div class="mb-4">
<div class="grid grid-cols-6 space-x-2 mb-4">
<div class="col-span-2">
<label for="major_version" class="block text-gray-700">Major version</label>
<input type="text" id="major_version"
class="w-full mt-1 p-2 border border-gray-300 rounded-md"
wire:model.defer="MAJOR_VERSION">
@error('MAJOR_VERSION')
<span class="text-tiny+ text-error">{{ $message }}</span>
@enderror
</div>
<div class="col-span-2">
<label for="php_version" class="block text-gray-700">PHP Version</label>
<select id="php_version" wire:model.defer="PHP_VERSION"
class="w-full mt-1 p-2 border border-gray-300 rounded-md">
......@@ -254,27 +268,31 @@
<option value="2">64Bits (PHP 5.6)</option>
<option value="3">64Bits (PHP 8.0)</option>
</select>
@error('PHP_VERSION')
<span class="text-tiny+ text-error">{{ $message }}</span>
@enderror
</div>
<div class="mb-4">
<div class="col-span-2">
<label for="patch_level" class="block text-gray-700">Patch level</label>
<input type="text" id="patch_level"
class="w-full mt-1 p-2 border border-gray-300 rounded-md" wire:model.defer="PLEVEL">
</div>
<div class="mb-4">
<label for="code" class="block text-gray-700">Patch Code</label>
<input type="text" id="code" wire:model.defer="PCODE"
<select id="patch_level" wire:model.defer="PLEVEL"
class="w-full mt-1 p-2 border border-gray-300 rounded-md">
<option value="High">High</option>
<option value="Auto">Auto</option>
<option value="Critical">Critical</option>
</select>
@error('PLEVEL')
<span class="text-tiny+ text-error">{{ $message }}</span>
@enderror
</div>
<div class="mb-4">
<label for="major_version" class="block text-gray-700">Major version</label>
<input type="text" id="major_version"
class="w-full mt-1 p-2 border border-gray-300 rounded-md"
wire:model.defer="MAJOR_VERSION">
</div>
<div class="mb-4">
<label for="pdesc" class="block text-gray-700">Patch Description</label>
<textarea id="pdesc" wire:model.defer="PDESC" class="w-full mt-1 p-2 border border-gray-300 rounded-md"
rows="3"></textarea>
@error('PDESC')
<span class="text-tiny+ text-error">{{ $message }}</span>
@enderror
</div>
<div class="mb-4">
<label for="remark" class="block text-gray-700">Remark</label>
......@@ -284,13 +302,38 @@
<div class="mb-4">
<label for="owner" class="block text-gray-700 ">Owner</label>
<input type="text" id="owner" wire:model.defer="POWNERNAME" readonly
class="w-full mt-1 p-2 border border-gray-300 rounded-md bg-slate-300">
class="w-full mt-1 p-2 border border-gray-300 rounded-md bg-gray-300">
</div>
<div class="mb-4">
<label for="papprovedate" class="block text-gray-700">Papprovedate</label>
<input type="datetime-local" id="papprovedate" wire:model.defer="PAPPROVEDATE"
class="w-full mt-1 p-2 border border-gray-300 rounded-md" value="2024-03-27T15:00">
</div>
<div x-data="{ isOpen: false }" class="mb-4">
<button @click="isOpen = !isOpen"
class="flex items-center space-x-2 bg-primary text-white px-4 py-2 rounded hover:bg-primary-focus justify-self-end">
<span x-text="isOpen ? 'Hide Details' : 'More Details'"></span>
<svg x-show="!isOpen" xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" fill="none"
viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
d="M12 4v16m8-8H4" />
</svg>
<svg x-show="isOpen" xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" fill="none"
viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M20 12H4" />
</svg>
</button>
<div id="specialBox" x-show="isOpen" x-transition:enter="transition ease-out duration-300"
x-transition:enter-start="opacity-0 transform scale-90"
x-transition:enter-end="opacity-100 transform scale-100"
x-transition:leave="transition ease-in duration-100"
x-transition:leave-start="opacity-100 transform scale-100"
x-transition:leave-end="opacity-0 transform scale-90" class="">
<div class="mb-4">
<label for="code" class="block text-gray-700">Patch Code</label>
<input type="text" id="code" wire:model.defer="PCODE"
class="w-full mt-1 p-2 border border-gray-300 rounded-md">
</div>
<div class="mb-4">
<label for="ptype" class="block text-gray-700">Ptype</label>
<input type="text" id="ptype" wire:model.defer="PTYPE"
......@@ -301,6 +344,8 @@
<input type="text" id="specific_customer"
class="w-full mt-1 p-2 border border-gray-300 rounded-md">
</div>
</div>
</div>
<div class="mb-4">
<label for="patchcode" class="block text-gray-700">Patchcode</label>
<textarea id="patchcode" @click="showModal = true" x-model="tempPathCode" wire:model.defer="PATCHCODE"
......@@ -313,8 +358,8 @@
</div>
<div class="mb-4">
<label for="patchcode_server" class="block text-gray-700">Patchcode_server</label>
<textarea id="patchcode_server" @click="showModal2 = true" x-model="tempPathCodeServer" wire:model.defer="PATCHCODE_SERVER"
class="w-full mt-1 p-2 border border-gray-300 rounded-md" rows="5"></textarea>
<textarea id="patchcode_server" @click="showModal2 = true" x-model="tempPathCodeServer"
wire:model.defer="PATCHCODE_SERVER" class="w-full mt-1 p-2 border border-gray-300 rounded-md" rows="5"></textarea>
</div>
<div class="flex justify-center">
<button type="button" @click="$wire.call('startProcess')"
......@@ -322,7 +367,8 @@
</div>
<div x-show="showModal" class="fixed inset-0 z-50 bg-gray-800/40 overflow-auto">
<div class="bg-white rounded-lg w-4/5 mx-auto mt-10 mb-10 pb-4"><div class="w-full p-4">
<div class="bg-white rounded-lg w-4/5 mx-auto mt-10 mb-10 pb-4">
<div class="w-full p-4">
<h2 class="text-xl font-semibold mb-4">Edit Patch Code</h2>
<textarea x-model="tempPathCode" class="w-full h-full p-2 bg-white rounded border border-gray-300" rows="30"
style="font-family: monospace; white-space: pre; overflow-wrap: normal; overflow-x: auto;">></textarea>
......@@ -335,10 +381,11 @@
</div>
</div>
<div x-show="showModal2" class="fixed inset-0 z-50 bg-gray-800/40 overflow-auto">
<div class="bg-white rounded-lg w-4/5 mx-auto mt-10 mb-10 pb-4"><div class="w-full p-4">
<div class="bg-white rounded-lg w-4/5 mx-auto mt-10 mb-10 pb-4">
<div class="w-full p-4">
<h2 class="text-xl font-semibold mb-4">Edit Patch Code Server</h2>
<textarea x-model="tempPathCodeServer" class="w-full h-full p-2 bg-white rounded border border-gray-300" rows="30"
style="font-family: monospace; white-space: pre; overflow-wrap: normal; overflow-x: auto;">></textarea>
<textarea x-model="tempPathCodeServer" class="w-full h-full p-2 bg-white rounded border border-gray-300"
rows="30" style="font-family: monospace; white-space: pre; overflow-wrap: normal; overflow-x: auto;">></textarea>
<div class="mt-4 flex justify-end space-x-2">
<button @click="showModal2 = false"
class="bg-red-500 text-white px-4 py-2 rounded hover:bg-red-600">Close</button>
......
......@@ -17,7 +17,7 @@
wire:model.debounce.500ms="serverkey" placeholder="Search for a server key">
@if (!empty($serverkey) && $showSearch)
<ul class="mt-2 border border-gray-200 rounded-md max-h-64 overflow-auto">
<ul class="border border-gray-200 rounded-md max-h-64 overflow-auto">
@forelse($results as $result)
<li class="p-2 hover:bg-gray-100 cursor-pointer"
wire:click="selectResult('{{ $result->SNKEY }}')">
......
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