Skip to content

Commit

Permalink
all metrics fixes #658 (#659)
Browse files Browse the repository at this point in the history
  • Loading branch information
dgershman authored Sep 29, 2022
1 parent 6280e7d commit 638b156
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 18 deletions.
1 change: 1 addition & 0 deletions RELEASENOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

### 4.2.1 (UNRELEASED)
* SMS blackhole feature [#656]
* Fixed an issue with `All` metrics. Only available now for Yap admins. [#658]

### 4.2.0 (September 9, 2022)
* Yap now requires PHP version 8.0 and higher. [#623]
Expand Down
4 changes: 3 additions & 1 deletion app/Http/Controllers/LegacyController.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ public function index(Request $request)
$path .= '/index.php';
}

if (str_starts_with($request->path(), 'admin') || str_ends_with($request->path(), 'clear-session.php')) {
if (str_starts_with($request->path(), 'admin') && str_ends_with($request->path(), '_api.php')) {
$content_type = 'application/json';
} elseif (str_starts_with($request->path(), 'admin') || str_ends_with($request->path(), 'clear-session.php')) {
$content_type = 'text/html';
} elseif (str_ends_with($request->path(), 'upgrade-advisor.php')) {
$content_type = 'application/json';
Expand Down
5 changes: 5 additions & 0 deletions legacy/_includes/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -1289,6 +1289,11 @@ function canManageUsers()
(isset($_SESSION['auth_permissions']) && (intval($_SESSION['auth_permissions']) & AdminInterfaceRights::MANAGE_USERS));
}

function isTopLevelAdmin()
{
return (isset($_SESSION['auth_is_admin']) && boolval($_SESSION['auth_is_admin']));
}

function getServiceBodiesRightsIds()
{
$ids = [];
Expand Down
4 changes: 2 additions & 2 deletions legacy/admin/auth_verify.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function is_session_expired()
}
}

if (isset($_REQUEST["service_body_id"]) && $_REQUEST["service_body_id"] > -1) {
if (isset($_REQUEST["service_body_id"]) && $_REQUEST["service_body_id"] > 0) {
$found = false;
$service_body_rights = getServiceBodiesRights();
if (isset($service_body_rights)) {
Expand All @@ -26,7 +26,7 @@ function is_session_expired()
if (!$found) {
session_unset();
}
} elseif (isset($_REQUEST["service_body_id"]) && $_REQUEST["service_body_id"] == -1) {
} elseif (isset($_REQUEST["service_body_id"]) && $_REQUEST["service_body_id"] == 0 && isTopLevelAdmin()) {
$found = true;
}

Expand Down
1 change: 0 additions & 1 deletion legacy/admin/cdr_api.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<?php
require_once 'auth_verify.php';
header("content-type: application/json");
echo json_encode(adjustedCallRecords(getReportsServiceBodies(), $_REQUEST['date_range_start'], $_REQUEST['date_range_end']));
2 changes: 1 addition & 1 deletion legacy/admin/footer.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php require_once 'users_control.php'; ?>
<script src="<?php echo url(sprintf("/public/dist/js/yap.min.js?v=%s", time()))?>"></script>
<script src="<?php echo url(sprintf("/public/dist/js/yap.js?v=%s", time()))?>"></script>
</body>
</html>
1 change: 0 additions & 1 deletion legacy/admin/metric_api.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php
require_once 'auth_verify.php';
header("content-type: application/json");
$reportsServiceBodies = getReportsServiceBodies();
$GLOBALS["metrics"] = getMetric($reportsServiceBodies, $_REQUEST['date_range_start'], $_REQUEST['date_range_end']);
$GLOBALS["summary"] = getMetricCounts($reportsServiceBodies, $_REQUEST['date_range_start'], $_REQUEST['date_range_end']);
Expand Down
5 changes: 3 additions & 2 deletions legacy/admin/reports.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
<div id="reports-servicebodies-dropdown-container">
<select class="form-control form-control-sm" id="service_body_id" name="service_body_id">
<option selected value="-1">-= Select A Service Body =-</option>
<?php if (isTopLevelAdmin()) { ?>
<option value="0">All</option>
<?php
<?php }
$serviceBodies = getServiceBodiesForUser();
sort_on_field($serviceBodies, 'name');
foreach ($serviceBodies as $item) {?>
Expand Down Expand Up @@ -76,7 +77,7 @@ function getServiceBodyById(id) {
<div id="events-table" style="display:none;"></div>
</div>
</div>
<script src="<?php echo url("/public/dist/js/yap-reports.min.js")?>"></script>
<script src="<?php echo url("/public/dist/js/yap-reports.js")?>"></script>
<?php require_once 'footer.php';?>
<script type="text/javascript" src="<?php echo url("/public/dist/js/daterangepicker.js") ?>"></script>
<link rel="stylesheet" type="text/css" href="<?php echo url("/public/dist/css/daterangepicker.css") ?>" />
Expand Down
22 changes: 12 additions & 10 deletions public/src/js/yap-core.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,16 +253,18 @@ function drawMetricsMap(data) {
var call_events = data[i].call_events[j];
if (JSON.parse(call_events['meta'])['coordinates'] !== undefined && (call_events['event_id'] === 1 || call_events['event_id'] === 14)) {
var location = JSON.parse(call_events['meta'])['coordinates'];
var content = location['location'];
var myIcon = L.icon({
iconUrl: parseInt(call_events['event_id']) === 1 ? volunteersMarker : meetingsMarker,
iconSize: [32, 32],
});

var latLng = [location['latitude'], location['longitude']];
var marker = L.marker(latLng, {icon: myIcon, title: content}).addTo(metrics_map);
marker.bindPopup(content);
bounds.push(latLng);
if (location['location'] !== null) {
var content = location['location'];
var myIcon = L.icon({
iconUrl: parseInt(call_events['event_id']) === 1 ? volunteersMarker : meetingsMarker,
iconSize: [32, 32],
});

var latLng = [location['latitude'], location['longitude']];
var marker = L.marker(latLng, {icon: myIcon, title: content}).addTo(metrics_map);
marker.bindPopup(content);
bounds.push(latLng);
}
}
}
}
Expand Down

0 comments on commit 638b156

Please sign in to comment.