Skip to content

Commit

Permalink
Update #568 & #569
Browse files Browse the repository at this point in the history
- Fixed exception for template for timezone component
- Fixed TZ extraction from wikipedia failing.
- Refactored widgets and dashboard components/packages.
- Removed old widgetsserviceprovider as its moved to basepackages.
  • Loading branch information
oyeaussie committed Aug 30, 2024
1 parent 5803e87 commit 1e3d246
Show file tree
Hide file tree
Showing 29 changed files with 262 additions and 278 deletions.
6 changes: 3 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[submodule "phpunit"]
path = phpunit
url = https://github.com/sp-framework/phpunit.git
[submodule "apps/Core/Packages/Devtools/GeoExtractData/Data"]
path = apps/Core/Packages/Devtools/GeoExtractData/Data
url = https://github.com/sp-framework/geodata.git
[submodule "docker"]
path = docker
url = https://github.com/sp-framework/docker-sp-core.git
[submodule "apps/Core/Packages/Devtools/GeoExtractData/Data"]
path = apps/Core/Packages/Devtools/GeoExtractData/Data
url = https://github.com/sp-framework/geodata.git
21 changes: 10 additions & 11 deletions apps/Core/Components/Dashboards/DashboardsComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,27 @@ class DashboardsComponent extends BaseComponent
public function viewAction()
{
if (isset($this->getData()['widgets'])) {
$this->getNewToken();

if ($this->getData()['widgets'] == 'info') {
$this->getNewToken();
return $this->basepackages->widgets->getWidget($this->getData()['id'], 'info')['info'];
} else if ($this->getData()['widgets'] == 'content') {
} else if ($this->getData()['widgets'] == 'content') {//This is when we add the widget via list of widgets in dashboard.
$dashboardWidget = $this->basepackages->dashboards->getDashboardWidgetById($this->getData()['id'], $this->getData()['did']);

$dashboardWidget['getWidgetData'] = true;

$this->getNewToken();
return $this->basepackages->widgets->getWidget($this->getData()['wid'], 'content', $dashboardWidget)['content'];
}
} else {
if (isset($this->getData()['id'])) {
$dashboardId = $this->getData()['id'];
} else {
$app = $this->apps->getAppInfo();

if (is_string($app['settings'])) {
$app['settings'] = $this->helper->decode($app['settings'], true);
if (is_string($this->app['settings'])) {
$this->app['settings'] = $this->helper->decode($this->app['settings'], true);
}

if (isset($app['settings']['defaultDashboard'])) {
$dashboardId = $app['settings']['defaultDashboard'];
if (isset($this->app['settings']['defaultDashboard'])) {
$dashboardId = $this->app['settings']['defaultDashboard'];
}
}
}
Expand Down Expand Up @@ -110,11 +109,11 @@ public function removeWidgetFromDashboardAction()
);
}

public function getWidgetContentAction()
public function getDashboardWidgetsAction()
{
$this->requestIsPost();

$this->basepackages->dashboards->getWidgetContent($this->postData());
$this->basepackages->dashboards->getDashboardWidgets($this->postData());

$this->addResponse(
$this->basepackages->dashboards->packagesData->responseMessage,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,11 @@ public function processAction()
}

try {
$success = false;

if (isset($this->postData()['geo']) && $this->postData()['geo'] == 'true') {
$this->geoExtractDataPackage->downloadGeoData();
$this->geoExtractDataPackage->processGeoData();
$success = $this->geoExtractDataPackage->downloadGeoData();
$success = $this->geoExtractDataPackage->processGeoData();
}

if (isset($this->postData()['timezone']) && $this->postData()['timezone'] == 'true') {
Expand All @@ -49,16 +51,18 @@ public function processAction()
}

if (isset($this->postData()['ip']) && $this->postData()['ip'] == 'true') {
$this->geoExtractDataPackage->downloadGeoIpv4Data();
$this->geoExtractDataPackage->unzipGeoIpv4Data();
$this->geoExtractDataPackage->processGeoIpv4Data();
$this->geoExtractDataPackage->downloadGeoIpv6Data();
$this->geoExtractDataPackage->unzipGeoIpv6Data();
$this->geoExtractDataPackage->processGeoIpv6Data();
$this->geoExtractDataPackage->mergeGeoIpData();
$success = $this->geoExtractDataPackage->downloadGeoIpv4Data();
$success = $this->geoExtractDataPackage->unzipGeoIpv4Data();
$success = $this->geoExtractDataPackage->processGeoIpv4Data();
$success = $this->geoExtractDataPackage->downloadGeoIpv6Data();
$success = $this->geoExtractDataPackage->unzipGeoIpv6Data();
$success = $this->geoExtractDataPackage->processGeoIpv6Data();
$success = $this->geoExtractDataPackage->mergeGeoIpData();
}

$this->geoExtractDataPackage->zipData();
if ($success) {
$this->geoExtractDataPackage->zipData();
}

$this->addResponse(
$this->geoExtractDataPackage->packagesData->responseMessage,
Expand Down Expand Up @@ -150,14 +154,18 @@ protected function registerProgressMethods()
return false;
}

$methods = array_merge($methods,
[
if ((isset($this->postData()['geo']) && $this->postData()['geo'] == 'true') ||
(isset($this->postData()['geo']) && $this->postData()['geo'] == 'true')
) {
$methods = array_merge($methods,
[
'method' => 'zipData',
'text' => 'Zip Geo Location Data...',
[
'method' => 'zipData',
'text' => 'Zip Geo Location Data...',
]
]
]
);
);
}

$this->basepackages->progress->registerMethods($methods);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ public function viewAction()
$this->geoTimezones,
'system/geo/timezones/view',
null,
['zone_name', 'tz_name', 'gmt_offset', 'gmt_offset_name', 'gmt_offset_dst', 'gmt_offset_name_dst', 'abbreviation'],
['zone_name', 'tz_name', 'gmt_offset', 'gmt_offset_name', 'abbreviation', 'gmt_offset_dst', 'gmt_offset_name_dst', 'abbreviation_dst'],
true,
['zone_name', 'tz_name', 'gmt_offset', 'gmt_offset_name', 'gmt_offset_dst', 'gmt_offset_name_dst', 'abbreviation'],
['zone_name', 'tz_name', 'gmt_offset', 'gmt_offset_name', 'abbreviation', 'gmt_offset_dst', 'gmt_offset_name_dst', 'abbreviation_dst'],
$controlActions,
['gmt_offset'=>'gmt offset (secs)','gmt_offset_dst'=>'gmt offset DST (secs)','tz_name'=>'time zone name'],
$replaceColumns,
Expand Down
2 changes: 1 addition & 1 deletion apps/Core/Packages/Devtools/GeoExtractData/Data
Submodule Data updated from 45cf43 to 7111b2
Original file line number Diff line number Diff line change
Expand Up @@ -194,33 +194,34 @@ protected function processTimezoneData()

if ($table[0] && $table[0]->children) {
foreach ($table[0]->children as $tr) {
if (isset($tr->children[4]) && trim($tr->children[4]->plaintext) === 'Canonical') {
$zoneName = trim($tr->children[2]->plaintext);
if (isset($tr->children[3]) && strtolower(trim($tr->children[3]->plaintext)) === 'canonical') {
$zoneName = trim($tr->children[1]->plaintext);

$zoneKey = strtolower(str_replace('/', '', $zoneName));

$wikiTz[$zoneKey]['zoneName'] = trim($tr->children[2]->plaintext);
$wikiTz[$zoneKey]['gmtOffsetName'] = 'UTC' . trim($tr->children[5]->plaintext);
$wikiTz[$zoneKey]['gmtOffset'] = $this->getGMTOffset(trim($tr->children[5]->plaintext));
$wikiTz[$zoneKey]['gmtOffsetNameDST'] = 'UTC' . trim($tr->children[6]->plaintext);
$wikiTz[$zoneKey]['gmtOffsetDST'] = $this->getGMTOffset(trim($tr->children[6]->plaintext));
$wikiTz[$zoneKey]['zoneName'] = trim($tr->children[1]->plaintext);
$wikiTz[$zoneKey]['tzName'] = trim($tr->children[2]->plaintext);
if ($wikiTz[$zoneKey]['tzName'] === '') {
$wikiTz[$zoneKey]['tzName'] = $wikiTz[$zoneKey]['zoneName'];
}
$wikiTz[$zoneKey]['gmtOffsetName'] = 'UTC' . trim($tr->children[4]->plaintext);
$wikiTz[$zoneKey]['gmtOffset'] = $this->getGMTOffset(trim($tr->children[4]->plaintext));
$wikiTz[$zoneKey]['abbreviation'] = trim($tr->children[6]->plaintext);
$wikiTz[$zoneKey]['gmtOffsetNameDST'] = 'UTC' . trim($tr->children[5]->plaintext);
$wikiTz[$zoneKey]['gmtOffsetDST'] = $this->getGMTOffset(trim($tr->children[5]->plaintext));
if (count($tr->children) === 10) {
$wikiTz[$zoneKey]['abbreviationDST'] = trim($tr->children[7]->plaintext);
} else {
$wikiTz[$zoneKey]['abbreviationDST'] = '-';
}
}
}
}

$allCountries = $this->helper->decode($this->localContent->read($this->sourceDir . 'AllCountries.json'), true);

foreach ($allCountries as $country) {
if (isset($country['timezones']) && count($country['timezones']) > 0) {
foreach ($country['timezones'] as $tzKey => $tz) {
$tzName = strtolower(str_replace('/', '', $tz['zoneName']));
if (count($wikiTz) === 0) {
$this->addResponse('Not able to extract tz data.', 1);

if (isset($wikiTz[$tzName])) {
$wikiTz[$tzName] = array_replace($tz, $wikiTz[$tzName]);
} else {
$wikiTz[$tzName] = $tz;
}
}
}
return false;
}

try {
Expand All @@ -229,6 +230,8 @@ protected function processTimezoneData()
throw $e;
}

$this->addResponse('Downloaded and extract Tz data');

return true;
}

Expand Down
32 changes: 21 additions & 11 deletions apps/Core/Views/Default/html/dashboards/dashboards.html
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ <h6><i class="fa fa-fw fa-info-circle text-info"></i> No widgets added to this d
)}}
</div>
<script>
/* globals paginatedPNotify GridStack Swal */
/* globals paginatedPNotify GridStack Swal BazContentFields */
var dataCollectionComponent, dataCollectionSection, dataCollectionSectionForm;

if (!window['dataCollection']['{{componentId}}']) {
Expand Down Expand Up @@ -107,22 +107,24 @@ <h6><i class="fa fa-fw fa-info-circle text-info"></i> No widgets added to this d
}

grid = dataCollectionComponent['{{componentId}}-{{sectionId}}']['grid'] = GridStack.init({
'draggable' : {
'handle' : '[data-card-widget="move"]'
'draggable' :
{
'handle' : '.btn-tool-move .fa-up-down-left-right'
},
'margin' : '5px',
'animate' : false
'animate' : false,
'sizeToContent' : true
});

}

initGrid();

grid.on('added', function(e, items) {
//eslint-disable-next-line
console.log(items);
items.forEach(function(item) {
populateGridData(item);
});
initWidgetCardButtons();
});

function fixHeight(item) {
Expand All @@ -136,6 +138,7 @@ <h6><i class="fa fa-fw fa-info-circle text-info"></i> No widgets added to this d
data.items.forEach(function(item) {
populateGridData(item);
});
initWidgetCardButtons();
});

grid.on('resizestart', function(e, el) {
Expand All @@ -151,7 +154,7 @@ <h6><i class="fa fa-fw fa-info-circle text-info"></i> No widgets added to this d
postData[$('#security-token').attr('name')] = $('#security-token').val();
postData['dashboard_id'] = $('#{{componentId}}-{{sectionId}}-dashboards').select2().val();

$.post('{{links.url("dashboards/getWidgetContent")}}', postData, function(response) {
$.post('{{links.url("dashboards/getDashboardWidgets")}}', postData, function(response) {
if (response.tokenKey && response.token) {
$("#security-token").attr("name", response.tokenKey);
$("#security-token").val(response.token);
Expand All @@ -178,8 +181,6 @@ <h6><i class="fa fa-fw fa-info-circle text-info"></i> No widgets added to this d
$('#{{componentId}}-{{sectionId}}-no-widgets').attr('hidden', false);
}
$('#{{componentId}}-{{sectionId}}-dashboard-loader').attr('hidden', true);

initRemoveButtons();
}, 'json');
}
populateGridStructure();
Expand All @@ -205,7 +206,7 @@ <h6><i class="fa fa-fw fa-info-circle text-info"></i> No widgets added to this d
}


function initRemoveButtons() {
function initWidgetCardButtons() {
$('.btn-tool-widgetRemove').off();
$('.btn-tool-widgetRemove').click(function() {
Swal.fire({
Expand Down Expand Up @@ -262,7 +263,10 @@ <h6><i class="fa fa-fw fa-info-circle text-info"></i> No widgets added to this d
$('#{{componentId}}-{{sectionId}}-edit-widgets').attr('disabled', true);
$('#{{componentId}}-{{sectionId}}-edit-widgets').attr('hidden', true);
}

return;
}
paginatedPNotify('error', {'text' : response.responseMessage});
}, 'json');
}
});
Expand All @@ -271,7 +275,14 @@ <h6><i class="fa fa-fw fa-info-circle text-info"></i> No widgets added to this d
$('.btn-tool-settings').off();
$('.btn-tool-settings').click(function() {
$(this).parents('.card').first().find('.widgets-setting-modal').modal('show');

BazContentFields.init({
'componentId' : "{{componentId}}",
'sectionId' : "{{componentId}}-{{sectionId}}",
'fieldId' : "{{componentId}}-{{sectionId}}-worldclock-" + $(this).parents('.grid-stack-item').attr('gs-id') + "-clocks"
});
});

}

function addWidgetToGrid(widgetsData) {
Expand Down Expand Up @@ -305,7 +316,6 @@ <h6><i class="fa fa-fw fa-info-circle text-info"></i> No widgets added to this d

grid.addWidget(newWidget);
dataCollectionComponent['{{componentId}}-{{sectionId}}'][widgetsData['widget']['method']] = { };
initRemoveButtons();

//Disable so that we dont add duplicates unless multiple is set to 1.
if (widgetsData['widget']['multiple'] && widgetsData['widget']['multiple'] == '0') {
Expand Down
Loading

0 comments on commit 1e3d246

Please sign in to comment.