Skip to content

Commit

Permalink
Merge pull request #2597 from department-of-veterans-affairs/vapo
Browse files Browse the repository at this point in the history
Vapo
  • Loading branch information
Pelentan authored Nov 5, 2024
2 parents 20333c1 + f943e28 commit 34af15b
Show file tree
Hide file tree
Showing 16 changed files with 141 additions and 24 deletions.
2 changes: 1 addition & 1 deletion LEAF-Automated-Tests
29 changes: 28 additions & 1 deletion LEAF_Nexus/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,15 @@ function customTemplate($tpl)
$privilegesArray[$key] = array_map('App\Leaf\XSSHelpers::sanitizeHTML', $privilegesArray[$key]);
}

$memberships = $oc_login->getMembership();
$isAdmin = false;
if (isset($memberships['groupID'][1]))
{
$isAdmin = true;
}

$t_form->assign('is_admin', $isAdmin);

$t_form->assign('indicatorID', (int)$_GET['indicatorID']);
$t_form->assign('UID', (int)$_GET['UID']);
$t_form->assign('indicator', $indicatorArray);
Expand All @@ -382,7 +391,7 @@ function customTemplate($tpl)
break;
case 'view_group_permissions':
$group = new Orgchart\Group($oc_db, $oc_login);

$t_form = new \Smarty;
$t_form->left_delimiter = '<!--{';
$t_form->right_delimiter = '}-->';
Expand All @@ -401,6 +410,15 @@ function customTemplate($tpl)
'css/view_group.css', ));

$groupID = isset($_GET['groupID']) ? (int)$_GET['groupID'] : 0;

$memberships = $oc_login->getMembership();
$isAdmin = false;
if (isset($memberships['groupID'][1]))
{
$isAdmin = true;
}

$t_form->assign('is_admin', $isAdmin);
$t_form->assign('groupID', $groupID);
$t_form->assign('groupTitle', $group->getTitle($groupID));
$t_form->assign('permissions', $group->getPrivileges($groupID));
Expand Down Expand Up @@ -431,6 +449,15 @@ function customTemplate($tpl)
'css/view_group.css', ));

$positionID = isset($_GET['positionID']) ? (int)$_GET['positionID'] : 0;

$memberships = $oc_login->getMembership();
$isAdmin = false;
if (isset($memberships['groupID'][1]))
{
$isAdmin = true;
}

$t_form->assign('is_admin', $isAdmin);
$t_form->assign('positionID', $positionID);
$t_form->assign('positionTitle', $position->getTitle($positionID));
$t_form->assign('permissions', $position->getPrivileges($positionID));
Expand Down
2 changes: 1 addition & 1 deletion LEAF_Nexus/js/employeeSelector.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ employeeSelector.prototype.search = function () {
: "";
var positionTitle =
response[i].positionData != undefined
? response[i].positionData.positionTitle
? response[i].positionData[0].positionTitle
: "";
var groupTitle = "";

Expand Down
2 changes: 1 addition & 1 deletion LEAF_Nexus/js/nationalEmployeeSelector.js
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ nationalEmployeeSelector.prototype.runSearchQuery = function (query, domain) {
: "";
var positionTitle =
response[i].positionData != undefined
? response[i].positionData.positionTitle
? response[i].positionData[0].positionTitle
: "";
positionTitle =
positionTitle == "" && response[i].data[23] !== undefined
Expand Down
12 changes: 9 additions & 3 deletions LEAF_Nexus/sources/Employee.php
Original file line number Diff line number Diff line change
Expand Up @@ -1442,6 +1442,7 @@ public function search($input, $indicatorID = '')

if (count($searchResult) > 0)
{

$empUID_list = '';
foreach ($searchResult as $employee)
{
Expand Down Expand Up @@ -1471,10 +1472,15 @@ public function search($input, $indicatorID = '')
$currEmpUID = $searchResult[$i]['empUID'];
if (isset($tdata[$searchResult[$i]['empUID']]))
{
$finalResult[$currEmpUID]['positionData'] = $tdata[$searchResult[$i]['empUID']];
$finalResult[$currEmpUID]['serviceData'] = $position->getService($finalResult[$currEmpUID]['positionData']['positionID']);
//$finalResult[$currEmpUID]['positionData'] = $tdata[$currEmpUID];
$finalResult[$currEmpUID]['serviceData'] = $position->getService($tdata[$currEmpUID]['positionID']);
}
$finalResult[$currEmpUID]['data'] = $this->getAllData($searchResult[$i]['empUID']);
$finalResult[$currEmpUID]['data'] = $this->getAllData($currEmpUID);
}

// attach all the assigned positions
foreach ($result as $employeeData){
$finalResult[$employeeData['empUID']]['positionData'][] = $employeeData;
}
}
return $finalResult;
Expand Down
14 changes: 10 additions & 4 deletions LEAF_Nexus/sources/Position.php
Original file line number Diff line number Diff line change
Expand Up @@ -757,11 +757,17 @@ public function search($input, $tag = '', $searchEmployees = 0)

foreach ($employees as $temp)
{
if (isset($temp['positionData']) && is_array($temp['positionData'])
&& $temp['positionData']['positionID'] > 0)

if (isset($temp['positionData']) && is_array($temp['positionData']) )
{
$tempResult[] = array('positionID' => $temp['positionData']['positionID'],
'positionTitle' => $temp['positionData']['positionTitle'], );

foreach($temp['positionData'] as $allPositionData ){
if($allPositionData['positionID'] > 0){
$tempResult[] = array('positionID' => $allPositionData['positionID'],
'positionTitle' => $allPositionData['positionTitle'], );
}
}

}
}

Expand Down
2 changes: 1 addition & 1 deletion LEAF_Nexus/templates/view_group_permissions.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
<td style="width: 100px" title="This allows permissions to be granted to others">Grant</td>
</tr>
<!--{foreach from=$permissions item=permission}-->
<!--{if $permission.UID == 2 || $permission.UID == 1}-->
<!--{if $is_admin == FALSE && ($permission.UID == 2 || $permission.UID == 1)}-->
<tr style="background-color: <!--{cycle values='#e0e0e0,#c4c4c4'}-->; opacity: 50%;">
<td id="<!--{$permission.categoryID|strip_tags}-->_<!--{$permission.UID|strip_tags}-->" style="font-size: 14px; font-weight: bold"><img src="images/largespinner.gif" alt="" /> Loading <!--{$permission.categoryID|strip_tags}-->...</td>
<td id="<!--{$permission.categoryID|strip_tags}-->_<!--{$permission.UID|strip_tags}-->_read" style="font-size: 14px">
Expand Down
4 changes: 3 additions & 1 deletion LEAF_Nexus/templates/view_permissions.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
<td style="width: 100px" title="This allows permissions to be granted to others">Grant</td>
</tr>
<!--{foreach from=$permissions item=permission}-->
<!--{if $permission.UID == 2 || $permission.UID == 1}-->

<!--{if $is_admin == FALSE && ($permission.UID == 2 || $permission.UID == 1)}-->
<tr style="background-color: <!--{cycle values='#e0e0e0,#c4c4c4'}-->; opacity: 50%;">
<td id="<!--{$permission.categoryID|strip_tags}-->_<!--{$permission.UID|strip_tags}-->" style="font-size: 14px; font-weight: bold"><img src="images/largespinner.gif" alt="" /> Loading <!--{$permission.categoryID|strip_tags}-->...</td>
<td id="<!--{$permission.categoryID|strip_tags}-->_<!--{$permission.UID|strip_tags}-->_read" style="font-size: 14px">
Expand All @@ -49,6 +50,7 @@
</td>
<td id="<!--{$permission.categoryID|strip_tags}-->_<!--{$permission.UID|strip_tags}-->_write" style="font-size: 14px">
<div class="buttonNorm">

<!--{if $permission.write == 1}-->
<img src="dynicons/?img=gnome-emblem-default.svg&amp;w=32" alt="" /> Yes
<!--{else}-->
Expand Down
2 changes: 1 addition & 1 deletion LEAF_Nexus/templates/view_position_permissions.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<td style="width: 100px" title="This allows permissions to be granted to others">Grant</td>
</tr>
<!--{foreach from=$permissions item=permission}-->
<!--{if $permission.UID == 2 || $permission.UID == 1}-->
<!--{if $is_admin == FALSE && ($permission.UID == 2 || $permission.UID == 1)}-->
<tr style="background-color: <!--{cycle values='#e0e0e0,#c4c4c4'}-->; opacity: 50%;">
<td id="<!--{$permission.categoryID|strip_tags}-->_<!--{$permission.UID|strip_tags}-->" style="font-size: 14px; font-weight: bold"><img src="images/largespinner.gif" alt="" /> Loading <!--{$permission.categoryID|strip_tags}-->...</td>
<td id="<!--{$permission.categoryID|strip_tags}-->_<!--{$permission.UID|strip_tags}-->_read" style="font-size: 14px">
Expand Down
4 changes: 2 additions & 2 deletions LEAF_Request_Portal/admin/templates/mod_account_updater.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -460,12 +460,12 @@ function searchGroupsOldAccount(accountAndTaskInfo, queue) {
function searchPositionsOldAccount(accountAndTaskInfo, queue) {
const { oldAccount, newAccount } = accountAndTaskInfo;
return new Promise ((resolve, reject) => {
fetch(`${orgchartPath}/api/position/search?noLimit=1`)
fetch(`${orgchartPath}/api/position/search?q=username.disabled:${oldAccount}&employeeSearch=1&noLimit=1`)
.then(res => res.json())
.then(data => {
let positionInfo = {};
const userPositions = data.filter(p => p.employeeList.some(emp => emp.userName === oldAccount));
console.log(userPositions);
if (userPositions.length > 0) {
let recordIDs = '';
userPositions.forEach(ele => {
Expand Down
9 changes: 5 additions & 4 deletions LEAF_Request_Portal/js/formGrid.js
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ var LeafFormGrid = function (containerID, options) {
rootMargin: -stickyHeaderOffset - 1 + 'px 0px 0px 0px',
threshold: 1,
});

observer.observe(domHeader);
}

Expand Down Expand Up @@ -416,7 +416,7 @@ var LeafFormGrid = function (containerID, options) {
var tDate;
for (let i in currentData) {
if (currentData[i][key] == undefined) {
currentData[i][key] = document.querySelector(`#${prefixID}${currentData[i].recordID}_${key}`).innerHTML;
currentData[i][key] = document.querySelector(`#${prefixID}${currentData[i].recordID}_${key}`)?.innerHTML;
currentData[i][key] =
currentData[i][key] == undefined ? "" : currentData[i][key];
}
Expand Down Expand Up @@ -863,9 +863,9 @@ var LeafFormGrid = function (containerID, options) {

/**
* Set the working data set (uncommon)
*
*
* setDataBlob() is more commonly used
*
*
* @params array - Expects format: [{recordID}, ...]
* @memberOf LeafFormGrid
*/
Expand Down Expand Up @@ -1145,6 +1145,7 @@ var LeafFormGrid = function (containerID, options) {
stickyHeaderOffset = Number(offset.replace('px', ''));
},
stop: function () {
renderCache = {};
isRenderingBody = false;
},
setRootURL: function (url) {
Expand Down
2 changes: 1 addition & 1 deletion LEAF_Request_Portal/scripts/sync_services.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@
$group_portal = new Portal\Group($db, $login);
$service_portal = new Portal\Service($db, $login);
$system_portal = new Portal\System($db, $login);
$syncing = $system_portal->syncSystem($group);
$syncing = $system_portal->syncSystem($group, $site_paths);

echo $syncing;
26 changes: 24 additions & 2 deletions LEAF_Request_Portal/sources/System.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ class System

private $fileExtensionWhitelist;

private $site_data;

private $dataActionLogger;

public function __construct($db, $login)
Expand Down Expand Up @@ -593,7 +595,7 @@ public function setNationalLinkedPrimary()
* getFileList retrieves filenames uploaded via Admin Panel -> File Manager
*
* @param bool getLastModified If set to true, the returned elements within the array include [file, modifiedTime]
*
*
* @return array
*/
public function getFileList(?bool $getLastModified = false): array
Expand Down Expand Up @@ -702,6 +704,7 @@ public function getPrimaryAdmin()
$user = $dir->lookupLogin($primaryAdminRes[0]['userID']);
$result = isset($user[0]) ? $user[0] : $primaryAdminRes[0]['userID'];
}

return $result;
}

Expand Down Expand Up @@ -795,7 +798,7 @@ public function getHistory($filterById)
*
* Created at: 10/3/2022, 6:59:30 AM (America/New_York)
*/
public function syncSystem(\Orgchart\Group $nexus_group): string
public function syncSystem(\Orgchart\Group $nexus_group, array $site_data = null): string
{
// update services and service chiefs
$this->removeServices();
Expand All @@ -816,9 +819,28 @@ public function syncSystem(\Orgchart\Group $nexus_group): string
$this->cleanupSystemAdmin();
$this->cleanupUsers();

if ($site_data !== null) {
$this->site_data = $site_data;
$this->cleanupPortalGroups();
}


return 'Syncing has finished. You are set to go.';
}

private function cleanupPortalGroups(): void
{
$vars = array();
$sql = "DELETE
FROM `{$this->site_data['portal_database']}`.`groups` `db1`
WHERE `groupID` NOT IN (
SELECT `db2`.`groupID`
FROM `{$this->site_data['orgchart_database']}`.`groups` `db2`)
AND `groupID` > 0";

$this->db->prepared_query($sql, $vars);
}

private function cleanupUsers(): void
{
$groups = new Group($this->db, $this->login);
Expand Down
6 changes: 6 additions & 0 deletions LEAF_Request_Portal/templates/view_reports.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -749,6 +749,7 @@ function editLabels() {
}
tempColorData = Object.assign({ }, gridColorData);
grid.stop();
$('#generateReport').click();
dialog.hide();
});
Expand Down Expand Up @@ -1489,6 +1490,11 @@ $(function() {
checkIfOneTypeSearchedAndUpdate(inQuery.terms);
t_inIndicators = JSON.parse(LZString.decompressFromBase64(indicators));
t_inIndicators.forEach(ind => {
if (+ind?.indicatorID > 0) {
indicatorSort[ind.indicatorID] = ind.sort;
}
});
let queryColors = JSON.parse(LZString.decompressFromBase64(colors));
if (queryColors !== null) {
gridColorData = queryColors;
Expand Down
25 changes: 24 additions & 1 deletion health_checks/index.php
Original file line number Diff line number Diff line change
@@ -1 +1,24 @@
pong
<?php

/* this health check will ensure that php is up and running by the very
of the fact the page gets rendered.
It will also get a simple query from the database to ensure that it
is up and running.
*/

if (!defined('DIRECTORY_HOST')) define('DIRECTORY_HOST', getenv('DATABASE_HOST'));
if (!defined('DIRECTORY_DB')) define('DIRECTORY_DB', getenv('DATABASE_DB_DIRECTORY'));
if (!defined('DIRECTORY_USER')) define('DIRECTORY_USER', getenv('DATABASE_USERNAME'));
if (!defined('DIRECTORY_PASS')) define('DIRECTORY_PASS', getenv('DATABASE_PASSWORD'));

require_once '/var/www/html/app/Leaf/Db.php';

$db = new \Leaf\Db(DIRECTORY_HOST, DIRECTORY_USER, DIRECTORY_PASS, 'national_leaf_launchpad');

// get something simple from the db to return
$sql = 'show status';
$result = $db->query($sql);

echo $result['uptime'];
24 changes: 24 additions & 0 deletions scripts/leaf-scripts/healthcheck.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

/* this health check will ensure that php is up and running by the very
of the fact the page gets rendered.
It will also get a simple query from the database to ensure that it
is up and running.
*/

if (!defined('DIRECTORY_HOST')) define('DIRECTORY_HOST', getenv('DATABASE_HOST'));
if (!defined('DIRECTORY_DB')) define('DIRECTORY_DB', getenv('DATABASE_DB_DIRECTORY'));
if (!defined('DIRECTORY_USER')) define('DIRECTORY_USER', getenv('DATABASE_USERNAME'));
if (!defined('DIRECTORY_PASS')) define('DIRECTORY_PASS', getenv('DATABASE_PASSWORD'));

require_once '/var/www/html/app/Leaf/Db.php';

$db = new \App\Leaf\Db(DIRECTORY_HOST, DIRECTORY_USER, DIRECTORY_PASS, 'national_leaf_launchpad');

// get something simple from the db to return
$sql = 'show status';
$result = $db->query($sql);

echo $result['uptime'];

0 comments on commit 34af15b

Please sign in to comment.