Skip to content
Merged
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
53 changes: 53 additions & 0 deletions UI Pages/CMDB CI Management UI page/ci_client_script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/* function to fetch the configuration item details like serial No, name , class , install status */
function searchCI() {
var ciNameorId = document.getElementById('ci_input').value;
if (!ciNameorId) {
alert('Please Enter the Configuration item Name or ID');
} else {
var ga = new GlideAjax('ci_lifecycle_management_script_include');
ga.addParam('sysparm_name', 'get_ci_info');
ga.addParam('sysparm_ci_name_or_id', ciNameorId);
ga.getXMLAnswer(function(response) {
var record = JSON.parse(response);
document.getElementById("ci-info").style.display = "block";
document.getElementById('ci_name').innerText = record.name;
document.getElementById('serial_number').innerText = record.serial_number;
document.getElementById('ci_class').innerText = record.ci_class;
document.getElementById('ci_install_status').innerText = record.ci_install_status;
var operations = ['Stolen', 'Retired','In Stock','In Maintenance'];
operations.forEach((operation) => {
var hidden_ele_id = operation.replace(/\s+/g, "");
var elementId = "ci_"+hidden_ele_id;
var ele = document.getElementById(elementId);
if(operation == record.ci_install_status){
ele.style.display = "none";
}
});
});
}
}
/* end of searchCI() */

/* function to update the status of Configuration item */
function UpdateCI(status) {
var ciNameorId = document.getElementById('ci_input').value;
if (ciNameorId) {
var updateci = new GlideAjax('ci_lifecycle_management_script_include');
updateci.addParam('sysparm_name', 'update_ci_info');
updateci.addParam('sysparm_ci_id_or_name', ciNameorId);
updateci.addParam('sysparm_ci_status', status);
updateci.getXMLAnswer(function(response) {
var result = JSON.parse(response);
if(result.updated == true){
alert("Record Updated Successfully");
}

});


} else {
alert('Facing issues to Update the CI');
}

}
/* function to update the status of Configuration item */
136 changes: 136 additions & 0 deletions UI Pages/CMDB CI Management UI page/ci_lifecycle_ui_page.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<!--basic style for html element-->
<style>
.ci-lifecycle-container {
display: flex;
justify-content: center;
text-align: center;
}
.card {
width: 400px;
margin: 20px auto;
border: 1px solid #ddd;
border-radius: 8px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
overflow: hidden;
font-family: Arial, sans-serif;
}
.card-header {
background-color: #007bff;
color: #fff;
padding: 16px;
font-size: 18px;
}
.card-footer, .card-body {
padding: 16px;
}
button {
padding: 10px;
font-size: 14px;
color: #FFFFFF;
background-color: #3cb371;
border: none;
cursor: pointer;
margin: 5px;
}
#ci_input {
padding: 5px;
width: 100%;
}
#ci_search {
margin-left: 1rem;
padding: 15px;
width: 30%;
cursor: pointer;
border-radius: 10px;
background-color: yellow;
}
table {
width: 100%;
border-collapse: collapse;
margin: 20px auto;
font-size: 16px;
border: 1px solid #ddd;
}
th, td {
padding: 12px;
text-align: left;
}
th {
background-color: #f2f2f2;
font-weight: bold;
width: 30%;
}
.card-footer {
background-color: #f9f9f9;
border-top: 1px solid #ddd;
display: flex;
justify-content: center;
}
</style>
<!-- end of styling -->
<div class="ci-lifecycle-container"> <!-- container -->
<div class="ci-lifecycle-header"> <!-- header -->
<h1>CI Lifecycle Management</h1> <!-- header title -->
<!-- search input box and search button -->
<div style="display:flex;">
<input type="text" name="ci_input" id="ci_input" placeholder="Enter CI Id ..." />
<button id="ci_search" name="ci_search" onClick="searchCI()">Search CI</button>
</div>
<!-- end of search -->
<!-- Display Configuration item details -->
<div id="ci-info" style="display:none;">
<div class="card" >
<div class="card-header">
Configuration Item
</div>
<div class="card-body" >
<table>
<tr>
<th style="">Serial No</th>
<td id="serial_number"></td>
</tr>
<tr>
<th style="">Name</th>
<td id="ci_name" ></td>
</tr>
<tr>
<th>CI class</th>
<td id='ci_class'></td>
</tr>
<tr>
<th>Status</th>
<td id="ci_install_status"></td>
</tr>

</table>


</div>
<!-- end -->

<!-- button to change configuration item install status -->
<div class="card-footer" style="">
<!--stolen-->
<button id="ci_Stolen" name="ci_Stolen" onClick="UpdateCI(8)">Stolen</button>
<!--retired-->
<button id="ci_Retired" name="ci_Retired" onClick="UpdateCI(7)">Retire CI
</button>

<!--In stock-->
<button id="ci_InStock" name="ci_InStock" onClick="UpdateCI(6)">In Stock
</button>
<!--In Maintainance-->
<button class="ci_InMaintenance" id="ci_InMaintenance" onclick="UpdateCI(3)" >In maintainace</button>
</div>
<!-- end -->

</div>

</div>
</div>
</div>


</j:jelly>
39 changes: 39 additions & 0 deletions UI Pages/CMDB CI Management UI page/ci_script_include.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
var ci_lifecycle_management_script_include = Class.create(); // script include class name
ci_lifecycle_management_script_include.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
/* function to query the cmdb_ci table to update the status of configuration item */
update_ci_info: function() {
var ci_id = this.getParameter('sysparm_ci_id_or_name');
var cistatus = this.getParameter('sysparm_ci_status');
var gr = new GlideRecord('cmdb_ci');
gr.addQuery('sys_id',ci_id);
gr.query();
if(gr.next()){
gr.setValue('install_status', cistatus);
gr.update();
return JSON.stringify({
"updated":true
});
}
},
/* end of update_ci_info function */


/* function to query the cmdb_ci table to fetch configuration item details according to ci sys_id*/
get_ci_info:function(){
var ciNameOrId = this.getParameter('sysparm_ci_name_or_id');
var gr = new GlideRecord('cmdb_ci');
if(gr.get(ciNameOrId)){
var record = {
success:true,
name: gr.getValue('name'),
serial_number: gr.getValue('serial_number'),
ci_class : gr.getValue('sys_class_name'),
ci_install_status : gr.getDisplayValue('install_status')
};
return JSON.stringify(record);

}
},
/* end of get_ci_info() */
type: 'ci_lifecycle_management_script_include'
});
Loading