Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Sarun Mungthanya
SpnPatch-Laravel
Commits
00cf7ee2
Commit
00cf7ee2
authored
Jul 16, 2024
by
Thidaporn Laisan
Browse files
update edit parameter
parent
e0a5c0be
Changes
7
Hide whitespace changes
Inline
Side-by-side
app/Http/Livewire/Pages/Parameter/ParameterCreate.php
View file @
00cf7ee2
...
@@ -9,9 +9,8 @@ use App\Models\TabSpnpage;
...
@@ -9,9 +9,8 @@ use App\Models\TabSpnpage;
class
ParameterCreate
extends
Component
class
ParameterCreate
extends
Component
{
{
public
$name
,
$message
,
$value
,
$description
,
$active
=
'Y'
,
$pageCode
;
public
$name
,
$message
,
$value
,
$description
,
$active
=
'Y'
,
$detail
,
$pageCode
=
[]
;
public
$searchByPage
=
[];
public
$searchByPage
=
[];
public
function
mount
()
public
function
mount
()
{
{
...
@@ -25,7 +24,8 @@ class ParameterCreate extends Component
...
@@ -25,7 +24,8 @@ class ParameterCreate extends Component
'value'
=>
'required|string|max:50'
,
'value'
=>
'required|string|max:50'
,
'description'
=>
'required|string|max:100'
,
'description'
=>
'required|string|max:100'
,
'active'
=>
'required'
,
'active'
=>
'required'
,
'pageCode'
=>
'required'
,
'detail'
=>
'required|string'
,
'pageCode'
=>
'required|array|min:1'
,
]);
]);
ConfParameter
::
create
([
ConfParameter
::
create
([
...
@@ -35,13 +35,16 @@ class ParameterCreate extends Component
...
@@ -35,13 +35,16 @@ class ParameterCreate extends Component
'active'
=>
$this
->
active
,
'active'
=>
$this
->
active
,
]);
]);
$pageCodesString
=
implode
(
','
,
$this
->
pageCode
);
TabParameterInfo
::
create
([
TabParameterInfo
::
create
([
'parameterName'
=>
$this
->
name
,
'parameterName'
=>
$this
->
name
,
'pageCode'
=>
$this
->
pageCode
,
'pageCode'
=>
$pageCodesString
,
'detail'
=>
$this
->
detail
,
]);
]);
$this
->
reset
([
'name'
,
'value'
,
'description'
,
'active'
,
'pageCode'
]);
$this
->
reset
([
'name'
,
'value'
,
'description'
,
'active'
,
'pageCode'
,
'detail'
]);
$this
->
emit
(
'showparameterListForm'
);
$this
->
emit
(
'showparameterListForm'
);
session
()
->
flash
(
'message'
,
'Parameter added successfully!'
);
session
()
->
flash
(
'message'
,
'Parameter added successfully!'
);
}
}
...
@@ -49,4 +52,11 @@ class ParameterCreate extends Component
...
@@ -49,4 +52,11 @@ class ParameterCreate extends Component
{
{
return
view
(
'livewire.pages.parameter.parameter-create'
);
return
view
(
'livewire.pages.parameter.parameter-create'
);
}
}
public
function
loadPage
(
$page
)
{
$this
->
action
=
$page
;
$this
->
parameters
=
ConfParameter
::
all
();
}
}
}
app/Http/Livewire/Pages/Parameter/ParameterEdit.php
View file @
00cf7ee2
<?php
<?php
namespace
App\Http\Livewire\Pages\Pa
tch
;
namespace
App\Http\Livewire\Pages\Pa
rameter
;
use
Livewire\Component
;
use
Livewire\Component
;
use
App\Models\ConfParameter
;
use
App\Models\ConfParameter
;
use
App\Models\TabPatchFile
;
use
App\Models\TabParameterInfo
;
use
GuzzleHttp\Client
;
use
App\Models\TabSpnpage
;
use
GuzzleHttp\Exception\RequestException
;
class
Pa
tch
Edit
extends
Component
class
Pa
rameter
Edit
extends
Component
{
{
public
$patchId
;
public
$parameterId
;
public
$name
,
$value
,
$description
,
$active
,
$detail
,
$pageCode
=
[];
public
$searchProject
=
''
;
public
$searchByPage
=
[];
public
$selectedBranch
,
$selectedPatch
;
public
$selectedProject
;
protected
$rules
=
[
public
$projects
=
[];
'name'
=>
'required|string|max:30'
,
public
$branches
=
[];
'value'
=>
'required|string|max:50'
,
public
$fileChanges
=
[];
'description'
=>
'required|string|max:100'
,
public
$startCommit
;
'active'
=>
'required'
,
public
$endCommit
;
'detail'
=>
'required'
,
public
$PATCHNAME
;
'pageCode'
=>
'required|array|min:1'
,
public
$PDATE
;
];
public
$PHP_VERSION
;
public
$PLEVEL
;
public
$PCODE
;
public
$MAJOR_VERSION
;
public
$PDESC
;
public
$Remark
;
public
$POWNER
;
public
$PAPPROVEDATE
;
public
$PTYPE
;
public
$PATCHCODE
;
public
$UNINSTALL
;
public
$PATCHCODE_SERVER
;
public
$filePathChanges
=
[];
protected
$listeners
=
[
'gotoModal'
];
public
function
mount
(
$editPid
)
public
function
mount
(
$editPid
)
{
{
$this
->
patchId
=
$editPid
;
$parameter
=
ConfParameter
::
where
(
'PID'
,
$editPid
)
->
firstOrFail
();
$this
->
loadPatchData
();
$this
->
parameterId
=
$parameter
->
PID
;
$this
->
name
=
$parameter
->
name
;
$this
->
value
=
$parameter
->
value
;
$this
->
description
=
$parameter
->
description
;
$this
->
active
=
$parameter
->
active
;
$parameterInfo
=
TabParameterInfo
::
where
(
'parameterName'
,
$parameter
->
name
)
->
first
();
if
(
$parameterInfo
)
{
$this
->
detail
=
$parameterInfo
->
detail
;
$this
->
pageCode
=
explode
(
','
,
$parameterInfo
->
pageCode
);
}
else
{
$this
->
detail
=
''
;
$this
->
pageCode
=
[];
}
$this
->
searchByPage
=
TabSpnpage
::
select
(
'pagecode'
,
'pagename'
)
->
get
()
->
toArray
();
}
}
public
function
loadPatchData
()
public
function
updateParameter
()
{
{
$patch
=
ConfSmartUpdate
::
findOrFail
(
$this
->
patchId
);
$this
->
validate
();
$this
->
PATCHNAME
=
$patch
->
PATCHNAME
;
$this
->
PDATE
=
$patch
->
PDATE
;
$this
->
PHP_VERSION
=
$patch
->
PHP_VERSION
;
$this
->
PLEVEL
=
$patch
->
PLEVEL
;
$this
->
PCODE
=
$patch
->
PCODE
;
$this
->
MAJOR_VERSION
=
$patch
->
MAJOR_VERSION
;
$this
->
PDESC
=
$patch
->
PDESC
;
$this
->
Remark
=
$patch
->
Remark
;
$this
->
POWNER
=
$patch
->
POWNER
;
$this
->
PAPPROVEDATE
=
$patch
->
PAPPROVEDATE
;
$this
->
PTYPE
=
$patch
->
PTYPE
;
$this
->
PATCHCODE
=
$patch
->
PATCHCODE
;
$this
->
UNINSTALL
=
$patch
->
UNINSTALL
;
$this
->
PATCHCODE_SERVER
=
$patch
->
PATCHCODE_SERVER
;
$filePath
=
TabPatchFile
::
where
(
"ptid"
,
$this
->
patchId
)
->
get
()
->
toArray
();
$filePath
=
$this
->
buildTree
(
$filePath
);
$this
->
fileChanges
=
$filePath
;
}
public
function
save
()
ConfParameter
::
where
(
'PID'
,
$this
->
parameterId
)
->
update
([
{
'name'
=>
$this
->
name
,
'value'
=>
$this
->
value
,
$this
->
validate
([
'description'
=>
$this
->
description
,
'PATCHNAME'
=>
'required|string|max:255'
,
'active'
=>
$this
->
active
,
'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'
,
'POWNER'
=>
'required|string|max:255'
,
'PAPPROVEDATE'
=>
'required|date'
,
'PTYPE'
=>
'required|string|max:255'
,
'PATCHCODE'
=>
'required|string'
,
'UNINSTALL'
=>
'required|string|max:255'
,
'PATCHCODE_SERVER'
=>
'required|string'
,
]);
]);
$confSmartUpdate
=
ConfSmartUpdate
::
findOrFail
(
$this
->
patchId
);
$pageCodesString
=
implode
(
','
,
$this
->
pageCode
);
$confSmartUpdate
->
PATCHNAME
=
$this
->
PATCHNAME
;
$confSmartUpdate
->
PDATE
=
$this
->
PDATE
;
$confSmartUpdate
->
PHP_VERSION
=
$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
->
PAPPROVEDATE
=
$this
->
PAPPROVEDATE
;
$confSmartUpdate
->
PTYPE
=
$this
->
PTYPE
;
$confSmartUpdate
->
PATCHCODE
=
$this
->
PATCHCODE
;
$confSmartUpdate
->
UNINSTALL
=
$this
->
UNINSTALL
;
$confSmartUpdate
->
PATCHCODE_SERVER
=
$this
->
PATCHCODE_SERVER
;
$confSmartUpdate
->
save
();
if
(
count
(
$this
->
filePathChanges
)
>
0
)
{
foreach
(
$this
->
filePathChanges
as
$file
)
{
$filePath
=
str_replace
(
"IE5DEV.shippingnet"
,
"."
,
$file
);
$filedata
=
$this
->
getFileContentFromGit
(
$filePath
,
$this
->
endCommit
);
$filepath
=
new
TabPatchFile
;
$filepath
->
ptid
=
$confSmartUpdate
->
PID
;
$filepath
->
file_name
=
$filePath
;
$filepath
->
file_data
=
base64_encode
(
$filedata
);
$filepath
->
save
();
}
}
session
()
->
flash
(
'message'
,
'Patch details and file changes updated successfully.'
);
}
private
function
getFileContentFromGit
(
$filePath
,
$commit
)
{
$token
=
env
(
'GITLAB_API_TOKEN'
);
$client
=
new
Client
([
'base_uri'
=>
'https://idemo.netbay.co.th/gitlab/api/v4/'
,
'headers'
=>
[
'Authorization'
=>
"Bearer
$token
"
,
'Accept'
=>
'application/json'
,
],
'verify'
=>
false
,
]);
try
{
$parameterInfo
=
TabParameterInfo
::
where
(
'parameterName'
,
ConfParameter
::
where
(
'PID'
,
$this
->
parameterId
)
->
value
(
'name'
))
->
first
();
$response
=
$client
->
get
(
"projects/
$this->selectedProject
/repository/files/"
.
urlencode
(
$filePath
)
.
"/raw"
,
[
if
(
$parameterInfo
)
{
'query'
=>
[
'ref'
=>
$commit
]
$parameterInfo
->
update
([
'parameterName'
=>
$this
->
name
,
// อัปเดตชื่อด้วย
'pageCode'
=>
$pageCodesString
,
'detail'
=>
$this
->
detail
,
]);
}
else
{
TabParameterInfo
::
create
([
'parameterName'
=>
$this
->
name
,
'pageCode'
=>
$pageCodesString
,
'detail'
=>
$this
->
detail
,
]);
]);
$statusCode
=
$response
->
getStatusCode
();
$content
=
$response
->
getBody
()
->
getContents
();
if
(
$statusCode
==
200
)
{
return
$content
;
}
else
{
throw
new
\
Exception
(
"Failed to fetch file. Status code:
$statusCode
"
);
}
}
catch
(
RequestException
$e
)
{
throw
$e
;
}
catch
(
\
Exception
$e
)
{
throw
$e
;
}
}
}
private
function
buildTree
(
$files
)
session
()
->
flash
(
'message'
,
'Parameter updated successfully!'
);
{
$this
->
emit
(
'loadPage'
,
'list'
);
$tree
=
[];
foreach
(
$files
as
$file
)
{
$filePath
=
"IE5DEV.shippingnet"
.
substr
(
$file
[
'file_name'
],
1
);
$pathParts
=
explode
(
'/'
,
$filePath
);
$current
=
&
$tree
;
foreach
(
$pathParts
as
$part
)
{
if
(
!
isset
(
$current
[
$part
]))
{
$current
[
$part
]
=
[];
}
$current
=
&
$current
[
$part
];
}
$current
[
'id'
]
=
$file
[
'fid'
];
}
return
$tree
;
}
public
function
gotoModal
(){
dd
(
"dddd"
);
}
}
public
function
render
()
public
function
render
()
{
{
return
view
(
'livewire.pages.pa
tch.patch
-edit'
);
return
view
(
'livewire.pages.pa
rameter.parameter
-edit'
);
}
}
}
}
app/Http/Livewire/Pages/Parameter/ParameterIndex.php
View file @
00cf7ee2
...
@@ -14,8 +14,14 @@ class ParameterIndex extends Component
...
@@ -14,8 +14,14 @@ class ParameterIndex extends Component
public
$action
=
'list'
;
public
$action
=
'list'
;
public
$searchBy
,
$searchByPage
,
$editPid
,
$message
,
$keyword
,
$perPage
=
20
,
$searchSelected
=
'name'
,
$searchSelectedPage
=
''
;
public
$searchBy
,
$searchByPage
,
$editPid
,
$message
,
$keyword
,
$perPage
=
20
,
$searchSelected
=
'name'
,
$searchSelectedPage
=
''
;
public
$selectedParameters
=
[];
public
$selectedParameters
=
[];
public
$deletePid
;
protected
$listeners
=
[
'deleteItem'
,
'deleteSelected'
,
'showparameterListForm'
];
protected
$listeners
=
[
'deleteItem'
,
'deleteSelected'
,
'showparameterListForm'
,
'loadPage'
];
public
function
mount
()
public
function
mount
()
{
{
...
@@ -31,7 +37,7 @@ class ParameterIndex extends Component
...
@@ -31,7 +37,7 @@ class ParameterIndex extends Component
public
function
render
()
public
function
render
()
{
{
$query
=
ConfParameter
::
select
(
'conf_parameter.PID'
,
'conf_parameter.name'
,
'conf_parameter.value'
,
'conf_parameter.description'
,
'conf_parameter.active'
,
'tab_parameter_info.pageCode'
)
$query
=
ConfParameter
::
select
(
'conf_parameter.PID'
,
'conf_parameter.name'
,
'conf_parameter.value'
,
'conf_parameter.description'
,
'conf_parameter.active'
,
'tab_parameter_info.pageCode'
,
'tab_parameter_info.detail'
)
->
leftJoin
(
'tab_parameter_info'
,
'conf_parameter.name'
,
'='
,
'tab_parameter_info.parameterName'
);
->
leftJoin
(
'tab_parameter_info'
,
'conf_parameter.name'
,
'='
,
'tab_parameter_info.parameterName'
);
if
(
$this
->
searchSelected
&&
$this
->
keyword
)
{
if
(
$this
->
searchSelected
&&
$this
->
keyword
)
{
...
@@ -68,6 +74,7 @@ class ParameterIndex extends Component
...
@@ -68,6 +74,7 @@ class ParameterIndex extends Component
$this
->
editPid
=
$pid
;
$this
->
editPid
=
$pid
;
$this
->
action
=
'edit'
;
$this
->
action
=
'edit'
;
}
}
public
function
showparameterDeleteForm
(
$pid
)
public
function
showparameterDeleteForm
(
$pid
)
{
{
...
@@ -100,4 +107,20 @@ class ParameterIndex extends Component
...
@@ -100,4 +107,20 @@ class ParameterIndex extends Component
$this
->
selectedParameters
=
[];
$this
->
selectedParameters
=
[];
$this
->
showparameterListForm
();
$this
->
showparameterListForm
();
}
}
public
function
deleteItem
(
$pid
)
{
$this
->
deleteParameter
(
$pid
);
}
public
function
deleteSelected
()
{
$this
->
deleteSelectedParameters
();
}
public
function
loadPage
(
$page
)
{
$this
->
action
=
$page
;
$this
->
parameters
=
ConfParameter
::
all
();
}
}
}
bootstrap/cache/livewire-components.php
View file @
00cf7ee2
...
@@ -5,6 +5,7 @@
...
@@ -5,6 +5,7 @@
'main-container'
=>
'App\\Http\\Livewire\\MainContainer'
,
'main-container'
=>
'App\\Http\\Livewire\\MainContainer'
,
'navbar'
=>
'App\\Http\\Livewire\\Navbar'
,
'navbar'
=>
'App\\Http\\Livewire\\Navbar'
,
'pages.parameter.parameter-create'
=>
'App\\Http\\Livewire\\Pages\\Parameter\\ParameterCreate'
,
'pages.parameter.parameter-create'
=>
'App\\Http\\Livewire\\Pages\\Parameter\\ParameterCreate'
,
'pages.parameter.parameter-edit'
=>
'App\\Http\\Livewire\\Pages\\Parameter\\ParameterEdit'
,
'pages.parameter.parameter-index'
=>
'App\\Http\\Livewire\\Pages\\Parameter\\ParameterIndex'
,
'pages.parameter.parameter-index'
=>
'App\\Http\\Livewire\\Pages\\Parameter\\ParameterIndex'
,
'pages.patch.modal-edit-code'
=>
'App\\Http\\Livewire\\Pages\\Patch\\ModalEditCode'
,
'pages.patch.modal-edit-code'
=>
'App\\Http\\Livewire\\Pages\\Patch\\ModalEditCode'
,
'pages.patch.patch-create'
=>
'App\\Http\\Livewire\\Pages\\Patch\\PatchCreate'
,
'pages.patch.patch-create'
=>
'App\\Http\\Livewire\\Pages\\Patch\\PatchCreate'
,
...
...
resources/views/livewire/pages/parameter/parameter-create.blade.php
View file @
00cf7ee2
<div>
<div>
<button
type=
"button"
wire:click=
"loadPage
('Parameter
')"
<button
type=
"button"
wire:click=
"
$emit('
loadPage
', 'list
')"
class=
"btn mx-auto m-3 text-white bg-primary px-3 py-2"
>
Back
</button>
class=
"btn mx-auto m-3 text-white bg-primary px-3 py-2"
>
Back
</button>
<div
class=
"max-w-full mx-auto p-6 bg-gray-100"
>
<div
class=
"max-w-full mx-auto p-6 bg-gray-100"
>
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
<div
class=
"p-12 bg-white shadow-md rounded-lg w-1/2"
>
<div
class=
"p-12 bg-white shadow-md rounded-lg w-1/2"
>
<h2
class=
"text-2xl font-bold mb-4"
>
Create Parameter
</h2>
<h2
class=
"text-2xl font-bold mb-4"
>
Create Parameter
</h2>
<div
class=
"mx-auto p-4"
>
<div
class=
"mx-auto p-4"
>
@if (session()->has('message'))
@if (session()->has('message'))
<div
class=
"alert alert-success"
>
<div
class=
"alert alert-success"
>
{{ session('message') }}
{{ session('message') }}
...
@@ -30,13 +30,12 @@
...
@@ -30,13 +30,12 @@
</div>
</div>
<div
class=
"mb-4"
>
<div
class=
"mb-4"
>
<label
for=
"description"
class=
"block text-sm font-medium text-gray-700"
>
Description
</label>
<label
for=
"description"
class=
"block text-sm font-medium text-gray-700"
>
Description
</label>
<textarea
wire:model.defer=
"description"
id=
"description"
<textarea
wire:model.defer=
"description"
id=
"description"
class=
"w-full mt-1 p-2 border border-gray-300 rounded-md"
></textarea>
class=
"w-full mt-1 p-2 border border-gray-300 rounded-md"
></textarea>
@error('description')
<span
class=
"text-red-500"
>
{{ $message }}
</span>
@enderror
@error('description')
<span
class=
"text-red-500"
>
{{ $message }}
</span>
@enderror
</div>
</div>
<div
class=
"mb-4"
>
<div
class=
"mb-4"
>
<label
for=
"active"
class=
"block text-sm font-medium text-gray-700"
>
Active
</label>
<label
for=
"active"
class=
"block text-sm font-medium text-gray-700"
>
Active
</label>
<select
wire:model.defer=
"active"
id=
"active"
<select
wire:model.defer=
"active"
id=
"active"
...
@@ -46,22 +45,35 @@
...
@@ -46,22 +45,35 @@
</select>
</select>
@error('active')
<span
class=
"text-red-500"
>
{{ $message }}
</span>
@enderror
@error('active')
<span
class=
"text-red-500"
>
{{ $message }}
</span>
@enderror
</div>
</div>
<br>
<div
class=
"mb-4"
>
<label
for=
"detail"
class=
"block text-sm font-medium text-gray-700"
>
More Info
</label>
</div>
<div
class=
"mb-4"
>
<label
for=
"detail"
class=
"block text-sm font-medium text-gray-700"
>
Detail
</label>
<textarea
wire:model.defer=
"detail"
id=
"detail"
class=
"w-full mt-1 p-2 border border-gray-300 rounded-md"
></textarea>
@error('detail')
<span
class=
"text-red-500"
>
{{ $message }}
</span>
@enderror
</div>
<div
class=
"mb-4"
>
<div
class=
"mb-4"
>
<label
for=
"pageCode"
class=
"block text-sm font-medium text-gray-700"
>
Page Code
</label>
<label
for=
"pageCode"
class=
"block text-sm font-medium text-gray-700"
>
Page Code
</label>
<select
wire:model.defer=
"pageCode"
id=
"pageCode"
<div
class=
"w-full mt-1 p-2 border border-gray-300 rounded-md flex flex-wrap"
>
class=
"w-full mt-1 p-2 border border-gray-300 rounded-md"
>
@foreach ($searchByPage as $page)
@foreach ($searchByPage as $page)
<option
value=
""
>
Please Select
</option>
<div
class=
"w-1/2 mb-2 flex items-center"
>
<option
value=
"{{ $page['pagecode'] }}"
>
{{ $page['pagename'] }}
</option>
<input
type=
"checkbox"
wire:model.defer=
"pageCode"
value=
"{{ $page['pagecode'] }}"
id=
"page_{{ $page['pagecode'] }}"
class=
"mr-2"
>
<label
for=
"page_{{ $page['pagecode'] }}"
class=
"text-gray-700"
>
{{ $page['pagename'] }}
</label>
</div>
@endforeach
@endforeach
</
select
>
</
div
>
@error('pageCode')
<span
class=
"text-red-500"
>
{{ $message }}
</span>
@enderror
@error('pageCode')
<span
class=
"text-red-500"
>
{{ $message }}
</span>
@enderror
</div>
</div>
<div
class=
"flex items-center justify-en
d
"
>
<div
class=
"flex items-center justify-
c
en
ter
"
>
<button
type=
"submit"
<button
type=
"submit"
class=
"
ml-3
inline-flex justify-center py-2 px-4 border border-transparent shadow-sm text-sm font-medium rounded-md text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500"
>
class=
"
bg-primary
inline-flex justify-center py-2 px-4 border border-transparent shadow-sm text-sm font-medium rounded-md text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500"
>
Save
Save
</button>
</button>
</div>
</div>
...
...
resources/views/livewire/pages/parameter/parameter-edit.blade.php
View file @
00cf7ee2
<div>
<button
type=
"button"
wire:click=
"$emit('loadPage', 'list')"
class=
"btn mx-auto m-3 text-white bg-primary px-3 py-2"
>
Back
</button>
<div
class=
"max-w-full mx-auto p-6 bg-gray-100"
>
<div
class=
"max-w-full mx-auto p-6 bg-gray-100"
>
<div
class=
"flex flex-wrap -mx-3"
>
<div
class=
"w-full px-6 mb-12 flex justify-center"
>
<div
class=
"w-full md:w-1/2 px-3 mb-6"
>
<div
class=
"p-12 bg-white shadow-md rounded-lg w-1/2"
>
<div
x-data=
"{
<h2
class=
"text-2xl font-bold mb-4"
>
Edit Parameter
</h2>
searchQuery: 'SPN64Bits',
selectedBranch: @entangle('selectedBranch'),
<div
class=
"mx-auto p-4"
>
selectedProject: @entangle('selectedProject'),
@if (session()->has('message'))
projects: @entangle('projects').defer,
<div
class=
"alert alert-success"
>
branches: @entangle('branches').defer,
{{ session('message') }}
fileChanges: @entangle('fileChanges').defer,
</div>
isLoading: false,
@endif
fetchProjects() {
this.isLoading = true;
this.selectedProject = '60';
this.$wire.set('searchProject', this.searchQuery);
},
fetchBranches() {
if (this.selectedProject) {
this.$wire.set('selectedProject', this.selectedProject);
}
}
}"
@
projects-fetched.window=
"isLoading = false"
@
files-fetched.window=
"isLoading = false"
x-init=
"fetchProjects"
class=
"p-6 bg-white shadow-md rounded-lg"
>
<div
class=
""
>
<form
wire:submit.prevent=
"updateParameter"
>
<div
class=
"flex mb-3"
>
<div
class=
"mb-4"
>
<label
for=
"searchProject"
class=
"form-label text-lg mr-2"
>
Search Project:
</label>
<label
for=
"name"
class=
"block text-sm font-medium text-gray-700"
>
Name
</label>
<input
type=
"text"
@
input.debounce.500ms=
"fetchProjects"
<input
type=
"text"
wire:model.defer=
"name"
id=
"name"
class=
"form-input h-8 ml-2 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=
"w-full mt-1 p-2 border border-gray-300 rounded-md"
>
id=
"searchProject"
placeholder=
"Enter project name"
x-model=
"searchQuery"
>
@error('name')
<span
class=
"text-red-500"
>
{{ $message }}
</span>
@enderror
</div>
</div>
</div>
<div
x-show=
"true"
class=
""
>
<div
class=
"mb-4"
>
<div
class=
"flex mb-3"
>
<label
for=
"value"
class=
"block text-sm font-medium text-gray-700"
>
Value
</label>
<label
for=
"project"
class=
"form-label text-lg mr-2"
>
Select Project:
</label>
<input
type=
"text"
wire:model.defer=
"value"
id=
"value"
<div
x-show=
"isLoading"
class=
"mx-auto mt-2"
>
class=
"w-full mt-1 p-2 border border-gray-300 rounded-md"
>
<span>
Loading...
</span>
@error('value')
<span
class=
"text-red-500"
>
{{ $message }}
</span>
@enderror
</div>
</div>
<select
x-model=
"selectedProject"
x-show=
"!isLoading"
@
change=
"fetchBranches"
id=
"project"
class=
"ml-2 w-64 h-8 mt-1 border border-gray-300 rounded-md"
>
<option
value=
""
>
Choose Project
</option>
<template
x-for=
"project in projects"
:key=
"project.id"
>
<option
:value=
"project.id"
x-text=
"project.name"
></option>
</template>
</select>
</div>
</div>
<div
class=
"mb-3"
>
<div
class=
"mb-4"
>
<input
type=
"text"
wire:model.defer=
"startCommit"
placeholder=
"Start Commit"
<label
for=
"description"
class=
"block text-sm font-medium text-gray-700"
>
Description
</label>
class=
"placeholder:text-sm text-lg mb-2 form-input rounded-lg border border-slate-300 px-2"
>
<textarea
wire:model.defer=
"description"
id=
"description"
<input
type=
"text"
wire:model.defer=
"endCommit"
placeholder=
"End Commit"
class=
"w-full mt-1 p-2 border border-gray-300 rounded-md"
></textarea>
class=
"placeholder:text-sm text-lg mb-2 form-input rounded-lg border border-slate-300 px-2"
>
@error('description')
<span
class=
"text-red-500"
>
{{ $message }}
</span>
@enderror
<div
class=
"text-center"
>
</div>
<button
type=
"button"
wire:click=
"getChangedFiles"
class=
"btn mx-auto mt-3 text-white bg-stone-700 px-3 py-2"
>
Get Changed Files
</button>
</div>
</div>
<div
wire:loading.class=
"flex"
wire:loading.class.remove=
"hidden"
class=
"flex inset-0 items-center justify-center z-50 bg-slate-50 dark:bg-navy-900 hidden"
>
<div
class=
"app-preloader grid h-full w-full place-content-center"
>
<div
class=
"app-preloader-inner relative inline-block h-48 w-48"
></div>
</div>
</div>
<div
class=
"mt-5 bg-gray-100 p-4 rounded-lg shadow"
>
<div
class=
"mb-4"
>
<h3
class=
"text-lg mb-3"
>
Changed Files
</h3>
<label
for=
"active"
class=
"block text-sm font-medium text-gray-700"
>
Active
</label>
<div
class=
"file-tree"
>
<select
wire:model.defer=
"active"
id=
"active"
<ul
class=
'pl-4 mt-1'
>
class=
"w-full mt-1 p-2 border border-gray-300 rounded-md"
>
@foreach ($fileChanges as $name => $item)
<option
value=
"Y"
>
Yes
</option>
@include('livewire.pages.patch.tree-item', [
<option
value=
"N"
>
No
</option>
'name' => $name,
</select>
'item' => $item,
@error('active')
<span
class=
"text-red-500"
>
{{ $message }}
</span>
@enderror
])
</div>
@endforeach
</ul>
</div>
</div>
<div
class=
"mb-4"
>
<label
for=
"detail"
class=
"block text-sm font-medium text-gray-700"
>
Detail
</label>
<textarea
wire:model.defer=
"detail"
id=
"detail"
class=
"w-full mt-1 p-2 border border-gray-300 rounded-md"
></textarea>
@error('detail')
<span
class=
"text-red-500"
>
{{ $message }}
</span>
@enderror
</div>
</div>
</div>
<div
class=
"w-full md:w-1/2 px-3 mb-6"
>
<div
class=
"mb-4"
>
<div
class=
"p-6 bg-white shadow-md rounded-lg"
>
<label
for=
"pageCode"
class=
"block text-sm font-medium text-gray-700"
>
Page Code
</label>
<h2
class=
"text-2xl font-bold mb-4"
>
Edit Patch
</h2>
<div
class=
"w-full mt-1 p-2 border border-gray-300 rounded-md flex flex-wrap"
>
<div
class=
"mb-4"
>
@foreach ($searchByPage as $page)
<label
for=
"patch_name"
class=
"block text-gray-700"
>
Patch name
</label>
<div
class=
"w-1/2 mb-2 flex items-center"
>
<input
type=
"text"
id=
"patch_name"
class=
"w-full mt-1 p-2 border border-gray-300 rounded-md"
<input
type=
"checkbox"
wire:model.defer=
"pageCode"
value=
"{{ $page['pagecode'] }}"
id=
"page_{{ $page['pagecode'] }}"
wire:model.defer=
"PATCHNAME"
>
class=
"mr-2"
>
</div>
<label
for=
"page_{{ $page['pagecode'] }}"
class=
"text-gray-700"
>
{{ $page['pagename'] }}
</label>
<div
class=
"mb-4"
>
</div>
<label
for=
"patch_date"
class=
"block text-gray-700"
>
Patch date
</label>
@endforeach
<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"
>
<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"
>
<option
value=
"0"
>
ALL
</option>
<option
value=
"1"
>
32Bits (PHP 5.2)
</option>
<option
value=
"2"
>
64Bits (PHP 5.6)
</option>
<option
value=
"3"
>
64Bits (PHP 8.0)
</option>
</select>
</div>
<div
class=
"mb-4"
>
<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"
class=
"w-full mt-1 p-2 border border-gray-300 rounded-md"
>
</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>
<input
type=
"text"
id=
"pdesc"
wire:model.defer=
"PDESC"
class=
"w-full mt-1 p-2 border border-gray-300 rounded-md"
>
</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"
>
</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"
>
</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
class=
"mb-4"
>
<label
for=
"ptype"
class=
"block text-gray-700"
>
Ptype
</label>
<input
type=
"text"
id=
"ptype"
wire:model.defer=
"PTYPE"
class=
"w-full mt-1 p-2 border border-gray-300 rounded-md"
>
</div>
<div
class=
"mb-4"
>
<label
for=
"specific_customer"
class=
"block text-gray-700"
>
Specific Customer
</label>
<input
type=
"text"
id=
"specific_customer"
class=
"w-full mt-1 p-2 border border-gray-300 rounded-md"
>
</div>
<div
class=
"mb-4"
>
<label
for=
"patchcode"
class=
"block text-gray-700"
>
Patchcode
</label>
<textarea
id=
"patchcode"
wire:model.defer=
"PATCHCODE"
class=
"w-full mt-1 p-2 border border-gray-300 rounded-md"
rows=
"5"
>
pathcode
</textarea>
</div>
<div
class=
"mb-4"
>
<label
for=
"uninstall"
class=
"block text-gray-700"
>
Uninstall
</label>
<input
type=
"text"
id=
"uninstall"
wire:model.defer=
"UNINSTALL"
class=
"w-full mt-1 p-2 border border-gray-300 rounded-md"
value=
"$b=1"
>
</div>
<div
class=
"mb-4"
>
<label
for=
"patchcode_server"
class=
"block text-gray-700"
>
Patchcode_server
</label>
<textarea
id=
"patchcode_server"
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"
wire:click=
"save"
class=
"bg-stone-700 text-white px-4 py-2 rounded-md hover:bg-blue-600"
>
Save
</button>
</div>
</div>
@error('pageCode')
<span
class=
"text-red-500"
>
{{ $message }}
</span>
@enderror
</div>
<div
class=
"flex items-center justify-center"
>
<button
type=
"submit"
class=
"bg-primary inline-flex justify-center py-2 px-4 border border-transparent shadow-sm text-sm font-medium rounded-md text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500"
>
Save
</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
<livewire:pages.patch.modal-edit-code>
</div>
</div>
resources/views/livewire/pages/parameter/parameter-index.blade.php
View file @
00cf7ee2
...
@@ -31,8 +31,8 @@
...
@@ -31,8 +31,8 @@
<div
class=
"px-2 ml-4"
>
<div
class=
"px-2 ml-4"
>
<button
type=
"button"
class=
"py-2 px-3 bg-stone-700 rounded-lg text-white"
<button
type=
"button"
class=
"py-2 px-3 bg-stone-700 rounded-lg text-white"
wire:click=
"showparameterAddForm"
>
Add
</button>
wire:click=
"showparameterAddForm"
>
Add
</button>
<button
type=
"button"
class=
"py-2 px-3 bg-stone-700 rounded-lg text-white"
<button
type=
"button"
class=
"py-2 px-3 bg-stone-700 rounded-lg text-white"
wire:
click=
"
d
eleteSelected
Parameters
"
>
Delete
</button>
on
click=
"
confirmD
eleteSelected
()
"
>
Delete
</button>
</div>
</div>
<div
class=
"inline-flex flex-initial"
>
<div
class=
"inline-flex flex-initial"
>
<div
x-data=
"{ isInputActive: true }"
>
<div
x-data=
"{ isInputActive: true }"
>
...
@@ -125,8 +125,12 @@
...
@@ -125,8 +125,12 @@
<td
class=
"whitespace-nowrap px-1 py-3 sm:px-2"
>
<td
class=
"whitespace-nowrap px-1 py-3 sm:px-2"
>
{{ \Illuminate\Support\Str::limit($para->name, 40) }}
</td>
{{ \Illuminate\Support\Str::limit($para->name, 40) }}
</td>
<td
class=
"whitespace-nowrap px-1 py-3 sm:px-2"
>
{{ $para->value }}
</td>
<td
class=
"whitespace-nowrap px-1 py-3 sm:px-2"
>
{{ $para->value }}
</td>
<td
class=
"whitespace-nowrap px-1 py-3 sm:px-2"
>
{{ $para->description }}
</td>
<td
class=
"whitespace-nowrap px-1 py-3 sm:px-2"
title=
"{{ $para->description }}"
>
<td
class=
"whitespace-nowrap px-1 py-3 sm:px-2"
>
{{ $para->pageCode }}
</td>
{{ \Illuminate\Support\Str::limit($para->description, 40) }}
</td>
<td
class=
"whitespace-nowrap px-1 py-3 sm:px-2"
title=
"{{ $para->pageCode }}"
>
{{ \Illuminate\Support\Str::limit($para->pageCode, 40) }}
</td>
<td
class=
"whitespace-nowrap px-1 py-3 sm:px-2"
>
{{ $para->active }}
</td>
<td
class=
"whitespace-nowrap px-1 py-3 sm:px-2"
>
{{ $para->active }}
</td>
<td
class=
"whitespace-nowrap px-1 py-3 sm:px-2"
>
<td
class=
"whitespace-nowrap px-1 py-3 sm:px-2"
>
<div
class=
"flex justify-center space-x-2"
>
<div
class=
"flex justify-center space-x-2"
>
...
@@ -134,7 +138,7 @@
...
@@ -134,7 +138,7 @@
class=
"btn h-8 w-8 p-0 text-info hover:bg-info/20 focus:bg-info/20 active:bg-info/25"
>
class=
"btn h-8 w-8 p-0 text-info hover:bg-info/20 focus:bg-info/20 active:bg-info/25"
>
<i
class=
"fa fa-edit"
></i>
<i
class=
"fa fa-edit"
></i>
</a>
</a>
<a
wire:
click=
"
deleteParameter
({{ $para->PID }})"
<a
on
click=
"
confirmDelete
({{ $para->PID }})"
class=
"btn h-8 w-8 p-0 text-danger hover:bg-danger/20 focus:bg-danger/20 active:bg-danger/25"
>
class=
"btn h-8 w-8 p-0 text-danger hover:bg-danger/20 focus:bg-danger/20 active:bg-danger/25"
>
<i
class=
"fa fa-trash"
></i>
<i
class=
"fa fa-trash"
></i>
</a>
</a>
...
@@ -153,8 +157,24 @@
...
@@ -153,8 +157,24 @@
@elseif($action === 'add')
@elseif($action === 'add')
<livewire:pages.parameter.parameter-create
/>
<livewire:pages.parameter.parameter-create
/>
@elseif($action === 'edit')
@elseif($action === 'edit')
<
livewire
:
pages.parameter.parameter-edit
:
editPid
=
"
$editPid
"
/>
@
livewire
('
pages.parameter.parameter-edit
', ['
editPid
' =>
$editPid
])
@endif
@endif
</main>
</main>
</div>
</div>
<script>
function
confirmDelete
(
pid
)
{
if
(
confirm
(
"
Are you sure you want to delete this parameter?
"
))
{
Livewire
.
emit
(
'
deleteItem
'
,
pid
);
}
}
function
confirmDeleteSelected
()
{
if
(
confirm
(
"
Are you sure you want to delete the selected parameters?
"
))
{
Livewire
.
emit
(
'
deleteSelected
'
);
}
}
</script>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment