Skip to content

Commit

Permalink
disseminations
Browse files Browse the repository at this point in the history
  • Loading branch information
nczirjak-acdh committed Nov 12, 2024
1 parent 445db90 commit 1e5c728
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 16 deletions.
2 changes: 1 addition & 1 deletion js/arche_detail.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
jQuery(function ($) {

$.noConflict();
"use strict";
var resObj = {};
var resId = "";
Expand Down
17 changes: 16 additions & 1 deletion src/Controller/ArcheBaseController.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class ArcheBaseController extends ControllerBase {
public function __construct() {
(isset($_SESSION['language'])) ? $this->siteLang = strtolower($_SESSION['language']) : $this->siteLang = "en";
$this->config = Config::fromYaml(\Drupal::service('extension.list.module')->getPath('arche_core_gui') . '/config/config.yaml');

$this->checkTmpDirs();
try {
$this->pdo = new \PDO($this->config->dbConnStr);
$baseUrl = $this->config->rest->urlBase . $this->config->rest->pathBase;
Expand All @@ -39,7 +39,22 @@ public function __construct() {
return array();
}
}

private function checkTmpDirs(){
//translations
// Ensure the directory exists (you may need to create it)
\Drupal::service('file_system')->prepareDirectory('public://translations', \Drupal\Core\File\FileSystemInterface::CREATE_DIRECTORY);

//tmp_files
// Define a path for the temporary files subdirectory
// Ensure the directory exists (you may need to create it)
\Drupal::service('file_system')->prepareDirectory('public://tmp_files', \Drupal\Core\File\FileSystemInterface::CREATE_DIRECTORY);

//config - sites/default/files/config_tlpXNA-ReYSeqYjmFBBCPxdygkZ95C_n73LVRKAXtzVywwEXIa2HSiI8OMNjzjxZcXYpMKd3ug/sync
\Drupal::service('file_system')->prepareDirectory('public://config_tlpXNA-ReYSeqYjmFBBCPxdygkZ95C_n73LVRKAXtzVywwEXIa2HSiI8OMNjzjxZcXYpMKd3ug', \Drupal\Core\File\FileSystemInterface::CREATE_DIRECTORY);
\Drupal::service('file_system')->prepareDirectory('public://config_tlpXNA-ReYSeqYjmFBBCPxdygkZ95C_n73LVRKAXtzVywwEXIa2HSiI8OMNjzjxZcXYpMKd3ug/sync', \Drupal\Core\File\FileSystemInterface::CREATE_DIRECTORY);
}

/**
* If the API needs a different response language then we have to change the
* session lang params to get the desired lang string translation
Expand Down
8 changes: 6 additions & 2 deletions src/Object/ThreeDObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class ThreeDObject
{
private $client;
private $tmpDir;
private $allowedExtension = array("ply", "nxs");
private $allowedExtension = array("ply", "nxs", "obj");
private $result = array();

public function __construct()
Expand All @@ -33,8 +33,10 @@ private function setTmpDir(string $tmpDir): void
public function downloadFile(string $repoUrl, string $tmpDir): array
{
$this->setTmpDir($tmpDir.'/tmp_files/');

try {
$this->doTheRequest($repoUrl);

} catch (\GuzzleHttp\Exception\ClientException $ex) {
\Drupal::logger('acdh_repo_gui')->notice($ex->getMessage());
$this->result = array('error' => $ex->getMessage());
Expand All @@ -52,11 +54,13 @@ public function downloadFile(string $repoUrl, string $tmpDir): array
*/
private function doTheRequest(string $repoUrl)
{

$request = new \GuzzleHttp\Psr7\Request('GET', $repoUrl);
//send async request

$promise = $this->client->sendAsync($request)->then(function ($response) {
if ($response->getStatusCode() == 200) {

//get the filename
if (count($response->getHeader('Content-Disposition')) > 0) {
$header = $this->getHeaderData($response->getHeader('Content-Disposition'));
Expand Down
22 changes: 13 additions & 9 deletions templates/disseminations/metadata-3d-viewer.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,19 @@
$.ajax({
url: '/browser/api/get3DURL/' + resId,
method: 'GET',
success: function (data) {
console.log("success");
console.log(data);
init3dhop(data);
setup3dhop();
moveToolbar(20, 20);
window.onerror = handleError;
success: function (response) {
if (typeof response !== 'undefined') {
init3dhop();
setup3dhop(response);
moveToolbar(20, 20);
window.onerror = handleError;
$('.viewer-3d-basic').removeClass('d-none');
}
},
error: function (xhr, status, error) {
console.log('get3DURL xhr :');
console.log(xhr);
console.log('get3DURL status :' + status);
console.log('get3DURL error :' + error);
}
});
Expand All @@ -68,11 +72,11 @@
$('#3dhop').html('<div>' + message + '</div>');
}
function setup3dhop() {
function setup3dhop(url) {
presenter = new Presenter("draw-canvas");
presenter.setScene({
meshes: {
"MS_Name": {url: '{{ data|raw }}'}
"MS_Name": {url: url}
},
modelInstances: {
"Model1": {mesh: "MS_Name"}
Expand Down
6 changes: 3 additions & 3 deletions templates/metadata/basic-block.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,9 @@
{{ include(arche_core_gui_path ~ '/templates/disseminations/metadata-audio-viewer.html.twig', {'data': data} ) }}
{% endif%}

{% if data.is3DObject() %}
{{ include(arche_core_gui_path ~ '/templates/disseminations/metadata-3d-viewer.html.twig', {'data': data} ) }}
{% endif%}
{% if data.is3DObject() %}
{{ include(arche_core_gui_path ~ '/templates/disseminations/metadata-3d-viewer.html.twig' ) }}
{% endif%}


</div>
Expand Down

0 comments on commit 1e5c728

Please sign in to comment.