Skip to content

Commit

Permalink
HQ Escalations demo
Browse files Browse the repository at this point in the history
  • Loading branch information
OSPFNeighbour committed Nov 8, 2024
1 parent 4eb8b85 commit 93a2f29
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/contentscripts/jobs/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,16 @@ let job_nearest_lhq = (
</div>
);

let job_escalations_lhq = (
<div class="form-group" id="escalations-lhq" style="display: none;">
<label class="col-xs-3 col-sm-2 col-md-4 col-lg-3 control-label"><img style="margin-left:-21px;width:16px;vertical-align:inherit;margin-right:5px"
src={chrome.runtime.getURL("icons/lh-black.png")} />HQ Escalations</label>
<div id="escalations-lhq-box" class="col-xs-9 col-sm-10 col-md-8 col-lg-9">
<p id="escalations-lhq-text" class="form-control-static">Waiting...</p>
</div>
</div>
);

let job_nearest_rescue_lhq = (
<div class="form-group" id="nearest-rescue-lhq-group" style="display: none;">
<label class="col-xs-3 col-sm-2 col-md-4 col-lg-3 control-label"><img style="margin-left:-21px;width:16px;vertical-align:inherit;margin-right:5px"
Expand Down Expand Up @@ -422,6 +432,9 @@ $('fieldset.col-md-12').each(function(k,v){
$('#editRfaForm > fieldset.col-md-8 > div > label').each(function(k,v){
var $v = $(v);
if (v.innerText == 'LGA') {

$v.parent().before(job_escalations_lhq)

$v.parent().after(job_nearest_rescue_lhq)

$v.parent().after(job_nearest_lhq)
Expand Down
79 changes: 79 additions & 0 deletions src/injectscripts/jobs/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -1527,6 +1527,85 @@ whenJobIsReady(function () {

$('#nearest-rescue-lhq-text').append(searchButton);
}

if (user.currentHqId == 1) { //only show for SOC
if (masterViewModel.entityAssignedTo.peek() != null) {
$('#escalations-lhq').show()
$.ajax({
type: 'GET',
url:
urls.Base +
'/Api/v1/ContactGroups/Search?EntityIds%5B%5D=' +
masterViewModel.entityAssignedTo.peek().Id +
'&PageIndex=1&PageSize=100&SortField=JobReceived&SortOrder=desc&_=1730938352523',
beforeSend: function (n) {
n.setRequestHeader('Authorization', 'Bearer ' + user.accessToken);
},
cache: false,
dataType: 'json',
data: { LighthouseFunction: 'InstantSectorButton', userId: user.Id },
complete: function (response, textStatus) {
if (textStatus == 'success') {
if (response.responseJSON.Results.length) {
let groups = [];
let jobType = masterViewModel.jobType.peek().Name
switch (jobType) {
case "FR":
jobType = "Flood Rescue"
break;
case "Flood Misc":
jobType = "Flood"
break;
case "GLR":
jobType = "General Land Rescue"
break;
case "VR":
jobType = "Vertical Rescue"
break;
default:
jobType = masterViewModel.jobType.peek().Name
}
response.responseJSON.Results.forEach(function (group) {
if (group.Escalation == true) {
if (group.Types.some(function (i) {
console.log(i.Name, jobType)
if (i.Name.includes(jobType)) {
return true
}
})) {
let groupDom = (
<a type="button" style="margin-bottom:5px; margin-right: 5px;" class="btn btn-primary btn-xs" data-unit={group.Id}>
{group.Name}
</a>
);
$(groupDom).click(function (e) {
window.open(`/ContactGroups/${group.Id}/Edit`, '_blank').focus();
});
groups.push(groupDom);
} else {
let groupDom = (
<a type="button" style="margin-bottom:5px; margin-right: 5px;" class="btn btn-default btn-xs mr-1" data-unit={group.Id}>
{group.Name}
</a>
);
$(groupDom).click(function (e) {
console.log(e)
window.open(`/ContactGroups/${group.Id}/Edit`, '_blank').focus();
});
groups.push(groupDom);
}
}
})
$('#escalations-lhq-text').empty();
$('#escalations-lhq-text').append(groups);
}
}
}
})

}
}

});

whenLighthouseIsReady(function () {
Expand Down

0 comments on commit 93a2f29

Please sign in to comment.