From 14abf16b18547bd663feed90fa541aa96940dd1e Mon Sep 17 00:00:00 2001 From: jbonnefont Date: Fri, 27 Sep 2019 16:04:14 +0200 Subject: [PATCH 01/23] change highcharts to highstock- get the events from WS - events on the graphic- change a bug logout on actionView/YiiEventModel only --- controllers/EventController.php | 164 +++++++++--------- controllers/ScientificObjectController.php | 61 ++++--- models/yiiModels/EventCreation.php | 5 - models/yiiModels/YiiEventModel.php | 7 +- .../scientific-object/data_visualization.php | 103 ++++++++++- web/css/site.css | 70 ++++---- 6 files changed, 259 insertions(+), 151 deletions(-) diff --git a/controllers/EventController.php b/controllers/EventController.php index 07dc0baf..3b6ed9da 100644 --- a/controllers/EventController.php +++ b/controllers/EventController.php @@ -1,4 +1,5 @@ */ -class EventController extends GenericController { - +class EventController extends GenericController { + const PARAM_ANNOTATIONS_DATA_PROVIDER = "paramAnnotations"; const PARAM_UPDATABLE = "paramUpdatable"; - const ANNOTATIONS_PAGE = "annotations-page"; const INFRASTRUCTURES_DATA = "infrastructures"; const INFRASTRUCTURES_DATA_URI = "infrastructureUri"; const INFRASTRUCTURES_DATA_LABEL = "infrastructureLabel"; const INFRASTRUCTURES_DATA_TYPE = "infrastructureType"; const EVENT_TYPES = "eventTypes"; - const SENSORS_DATA = "sensors"; const SENSOR_DATA_URI = "sensorUri"; const SENSOR_DATA_LABEL = "sensorLabel"; const SENSOR_DATA_TYPE = "sensorType"; - const PARAM_CONCERNED_ITEMS_URIS = 'concernedItemsUris'; const TYPE = 'type'; const PARAM_RETURN_URL = "returnUrl"; @@ -52,35 +51,35 @@ class EventController extends GenericController { * @var string */ public $returnUrl; - + /** * Lists the events. * @return mixed */ public function actionIndex() { $searchModel = new EventSearch(); - + $searchParams = Yii::$app->request->queryParams; - + if (isset($searchParams[WSConstants::PAGE])) { $searchParams[WSConstants::PAGE] = $searchParams[WSConstants::PAGE] - 1; } $searchParams[WSConstants::PAGE_SIZE] = Yii::$app->params['indexPageSize']; - + $searchResult = $searchModel->search(Yii::$app->session[WSConstants::ACCESS_TOKEN], $searchParams); - + if (is_string($searchResult)) { if ($searchResult === WSConstants::TOKEN_INVALID) { return $this->redirect(Yii::$app->urlManager->createUrl(SiteMessages::SITE_LOGIN_PAGE_ROUTE)); } else { return $this->render(SiteMessages::SITE_ERROR_PAGE_ROUTE, [ - SiteMessages::SITE_PAGE_NAME => SiteMessages::INTERNAL_ERROR, - SiteMessages::SITE_PAGE_MESSAGE => $searchResult]); + SiteMessages::SITE_PAGE_NAME => SiteMessages::INTERNAL_ERROR, + SiteMessages::SITE_PAGE_MESSAGE => $searchResult]); } } else { return $this->render('index', [ - 'searchModel' => $searchModel, - 'dataProvider' => $searchResult]); + 'searchModel' => $searchModel, + 'dataProvider' => $searchResult]); } } @@ -92,51 +91,56 @@ public function actionIndex() { public function actionView($id) { // Get request parameters $searchParams = Yii::$app->request->queryParams; - + // Get event $event = (new YiiEventModel())->getEvent(Yii::$app->session[WSConstants::ACCESS_TOKEN], $id); - - // Get documents - $searchDocumentModel = new DocumentSearch(); - $searchDocumentModel->concernedItemFilter = $id; - $documentProvider = $searchDocumentModel->search( - Yii::$app->session[WSConstants::ACCESS_TOKEN], - [YiiEventModel::CONCERNED_ITEMS => $id]); - - // Get annotations - $annotationProvider = $event->getEventAnnotations(Yii::$app->session[WSConstants::ACCESS_TOKEN], $searchParams); - $annotationProvider->pagination->pageParam = self::ANNOTATIONS_PAGE; - - // Render the view of the event - if (is_array($event) && isset($event[WSConstants::TOKEN_INVALID])) { - return redirectToLoginPage(); + if (is_string($event)) { + if ($event === \app\models\wsModels\WSConstants::TOKEN_INVALID) { + return $this->redirect(Yii::$app->urlManager->createUrl("site/login")); + } else { + return $this->render('/site/error', [ + 'name' => Yii::t('app/messages', 'Internal error'), + 'message' => $event]); + } } else { + + // Get documents + $searchDocumentModel = new DocumentSearch(); + $searchDocumentModel->concernedItemFilter = $id; + $documentProvider = $searchDocumentModel->search( + Yii::$app->session[WSConstants::ACCESS_TOKEN], [YiiEventModel::CONCERNED_ITEMS => $id]); + + // Get annotations + $annotationProvider = $event->getEventAnnotations(Yii::$app->session[WSConstants::ACCESS_TOKEN], $searchParams); + $annotationProvider->pagination->pageParam = self::ANNOTATIONS_PAGE; + + // Render the view of the event + return $this->render('view', [ - 'model' => $event, - 'dataDocumentsProvider' => $documentProvider, - self::PARAM_ANNOTATIONS_DATA_PROVIDER => $annotationProvider, - self::PARAM_UPDATABLE => !$this->hasUnupdatableProperties($event) + 'model' => $event, + 'dataDocumentsProvider' => $documentProvider, + self::PARAM_ANNOTATIONS_DATA_PROVIDER => $annotationProvider, + self::PARAM_UPDATABLE => !$this->hasUnupdatableProperties($event) ]); } } - - private function hasUnupdatableProperties($eventAction) : bool { - foreach($eventAction->properties as $property) { - if($property->relation !== Yii::$app->params['from'] - && $property->relation !== Yii::$app->params['to']) { + + private function hasUnupdatableProperties($eventAction): bool { + foreach ($eventAction->properties as $property) { + if ($property->relation !== Yii::$app->params['from'] && $property->relation !== Yii::$app->params['to']) { return true; } } return false; } - + /** * Gets the event types URIs. * @return event types URIs */ public function getSensorTypes() { $model = new \app\models\yiiModels\YiiSensorModel(); - + $sensorsTypes = []; $model->page = 0; $model->pageSize = Yii::$app->params['webServicePageSizeMax']; @@ -148,17 +152,17 @@ public function getSensorTypes() { $sensorsTypes[$sensorType->uri] = $sensorType->uri; } } - + return $sensorsTypes; } - + /** * Gets the event types URIs. * @return event types URIs */ public function getEventsTypes() { $model = new YiiEventModel(); - + $eventsTypes = []; $model->page = 0; $model->pageSize = Yii::$app->params['webServicePageSizeMax']; @@ -170,10 +174,10 @@ public function getEventsTypes() { $eventsTypes[$eventType->uri] = $eventType->uri; } } - + return $eventsTypes; } - + /** * Gets all infrastructures. * @return experiments @@ -187,18 +191,17 @@ public function getInfrastructuresUrisTypesLabels() { return WSConstants::TOKEN_INVALID; } else { foreach ($infrastructures->models as $infrastructure) { - $infrastructuresUrisTypesLabels[] = - [ - self::INFRASTRUCTURES_DATA_URI => $infrastructure->uri, - self::INFRASTRUCTURES_DATA_LABEL => $infrastructure->label, - self::INFRASTRUCTURES_DATA_TYPE => $infrastructure->rdfType - ]; + $infrastructuresUrisTypesLabels[] = [ + self::INFRASTRUCTURES_DATA_URI => $infrastructure->uri, + self::INFRASTRUCTURES_DATA_LABEL => $infrastructure->label, + self::INFRASTRUCTURES_DATA_TYPE => $infrastructure->rdfType + ]; } } - + return $infrastructuresUrisTypesLabels; } - + /** * Gets all sensors. * @return sensors @@ -213,18 +216,17 @@ public function getSensorsUrisTypesLabels() { return WSConstants::TOKEN_INVALID; } else { foreach ($sensors->models as $sensor) { - $sensorsUrisTypesLabels[] = - [ - self::SENSOR_DATA_URI => $sensor->uri, - self::SENSOR_DATA_LABEL => $sensor->label, - self::SENSOR_DATA_TYPE => $sensor->rdfType - ]; + $sensorsUrisTypesLabels[] = [ + self::SENSOR_DATA_URI => $sensor->uri, + self::SENSOR_DATA_LABEL => $sensor->label, + self::SENSOR_DATA_TYPE => $sensor->rdfType + ]; } } - + return $sensorsUrisTypesLabels; } - + /** * Displays the form to create an event or creates it in case of form submission. * @return mixed redirect in case of error or after successfully create @@ -234,21 +236,21 @@ public function actionCreate() { $sessionToken = Yii::$app->session[WSConstants::ACCESS_TOKEN]; $event = new EventCreation(); $event->isNewRecord = true; - + // Display form if (!$event->load(Yii::$app->request->post())) { $event->load(Yii::$app->request->get(), ''); - if(Yii::$app->request->get()['type'] === "scientific-objects"){ - $event->load(array(self::PARAM_CONCERNED_ITEMS_URIS =>array_keys(Yii::$app->session['scientific-object'])),''); + if (Yii::$app->request->get()['type'] === "scientific-objects") { + $event->load(array(self::PARAM_CONCERNED_ITEMS_URIS => array_keys(Yii::$app->session['scientific-object'])), ''); } $event->creator = $this->getCreatorUri($sessionToken); $this->loadFormParams(); - return $this->render('create', ['model' => $event]); - - // Submit form - } else { - $dataToSend[] = $event->attributesToArray(); - $requestResults = $event->insert($sessionToken, $dataToSend); + return $this->render('create', ['model' => $event]); + + // Submit form + } else { + $dataToSend[] = $event->attributesToArray(); + $requestResults = $event->insert($sessionToken, $dataToSend); return $this->handlePostPutResponse($requestResults, $event->returnUrl); } } @@ -262,21 +264,21 @@ public function actionUpdate($id) { $sessionToken = Yii::$app->session[WSConstants::ACCESS_TOKEN]; $event = new EventUpdate(); $event->isNewRecord = false; - + // Display form if (!$event->load(Yii::$app->request->post())) { $event = $event->getEvent($sessionToken, $id); $this->loadFormParams(); - return $this->render('update', ['model' => $event]); - - // Submit form + return $this->render('update', ['model' => $event]); + + // Submit form } else { - $dataToSend[] = $event->attributesToArray(); - $requestResults = $event->update($sessionToken, $dataToSend); - return $this->handlePostPutResponse($requestResults, ['view', 'id' => $event->uri]); + $dataToSend[] = $event->attributesToArray(); + $requestResults = $event->update($sessionToken, $dataToSend); + return $this->handlePostPutResponse($requestResults, ['view', 'id' => $event->uri]); } } - + /** * Loads params used by the forms (creation or update). */ @@ -284,9 +286,8 @@ private function loadFormParams() { $this->view->params[self::EVENT_TYPES] = $this->getEventsTypes(); $this->view->params[self::INFRASTRUCTURES_DATA] = $this->getInfrastructuresUrisTypesLabels(); $this->view->params[self::SENSORS_DATA] = $this->getSensorsUrisTypesLabels(); - } - + /** * Gets the creator of an event. */ @@ -295,4 +296,5 @@ private function getCreatorUri($sessionToken) { $userModel->findByEmail($sessionToken, Yii::$app->session['email']); return $userModel->uri; } + } diff --git a/controllers/ScientificObjectController.php b/controllers/ScientificObjectController.php index 0959c6a2..e50c2764 100755 --- a/controllers/ScientificObjectController.php +++ b/controllers/ScientificObjectController.php @@ -20,6 +20,7 @@ use app\models\yiiModels\YiiScientificObjectModel; use app\models\yiiModels\ScientificObjectSearch; use app\models\yiiModels\YiiExperimentModel; +use app\models\yiiModels\EventSearch; require_once '../config/config.php'; @@ -426,9 +427,9 @@ public function actionCreateMultipleScientificObjects() { $cpt = 0; $insertionResult = $scientificObjectModel->insert($sessionToken, $forWebService); - + $forWebService = []; - + if ($insertionResult->{\app\models\wsModels\WSConstants::METADATA}->status[0]->exception->type != "Error") { foreach ($insertionResult->{\app\models\wsModels\WSConstants::METADATA}->{\app\models\wsModels\WSConstants::DATA_FILES} as $scientificObjectUri) { $return["objectUris"][] = $scientificObjectUri; @@ -808,13 +809,13 @@ public function actionDownloadCsv() { } else { $wktGeometry = ""; } - - $stringToWrite .= $model->uri . Yii::$app->params['csvSeparator'] . - $model->label . Yii::$app->params['csvSeparator'] . - $model->rdfType . Yii::$app->params['csvSeparator'] . - $model->experiment . Yii::$app->params['csvSeparator'] . - '"' . $wktGeometry . '"' . Yii::$app->params['csvSeparator'] . - "\n"; + + $stringToWrite .= $model->uri . Yii::$app->params['csvSeparator'] . + $model->label . Yii::$app->params['csvSeparator'] . + $model->rdfType . Yii::$app->params['csvSeparator'] . + $model->experiment . Yii::$app->params['csvSeparator'] . + '"' . $wktGeometry . '"' . Yii::$app->params['csvSeparator'] . + "\n"; } $totalPage = intval($searchModel->totalPages); @@ -959,14 +960,14 @@ public function actionDataVisualization($uri, $label, $experimentUri = null) { * e.g : * { * "variable": "http:\/\/www.opensilex.org\/demo\/id\/variable\/v0000001", - * "scientificObjectData": [ - * "label": "Scientific object label", - * "dataFromProvenance": [ - * "provenance":"Data provenance uri", - * "data": ["1,874809","2015-02-10"], - * ["2,313261","2015-03-15"],.. - * ] - * ] + * "scientificObjectData":{ + * "label": "Scientific object label", + * "dataFromProvenance":{ + * "ProvenanceUri1": [["1,874809","2015-02-10"],..], + * "ProvenanceUri2": [["2,313261","2015-03-15"],..], + * ... + * } + * } * } */ @@ -995,10 +996,24 @@ public function actionDataVisualization($uri, $label, $experimentUri = null) { if (!empty($data)) { $toReturn["variable"] = $searchModel->variable; $scientificObjectData["dataFromProvenance"] = $dataByProvenance; - $toReturn["scientificObjectData"][] = $scientificObjectData; + $toReturn["scientificObjectData"] = $scientificObjectData; } - + //Get the events associate to the sci. obj. to put on the Highcharts Graph + $searchModel = null; + $searchModel = new EventSearch(); + $searchModel->pageSize = 800; + $searchModel->searchConcernedItemUri = $uri; + $searchResult = $searchModel->search($token, null); + $events = array(); + + foreach ($searchResult->getModels() as $model) { + $events[] = [ + 'date' =>(strtotime($model->date)) * 1000, + 'title' => explode('#',$model->rdfType)[1], + 'text' => $model->uri + ]; + } //on FORM submitted: //check if image visualization is activated @@ -1008,7 +1023,7 @@ public function actionDataVisualization($uri, $label, $experimentUri = null) { $selectedProvenance = isset($_POST['provenances']) ? $_POST['provenances'] : null; if (isset($_POST['filter']) && $_POST['filter'] !== "") { $selectedPositionIndex = $_POST['filter']; - $attribut=explode(":",Yii::$app->params['image.filter']['metadata.position'][$selectedPositionIndex]); + $attribut = explode(":", Yii::$app->params['image.filter']['metadata.position'][$selectedPositionIndex]); $filterToSend = "{'metadata." . $attribut[0] . "':'" . $attribut[1] . "'}"; } return $this->render('data_visualization', [ @@ -1016,14 +1031,14 @@ public function actionDataVisualization($uri, $label, $experimentUri = null) { 'variables' => $variables, 'data' => $toReturn, 'show' => $show, - 'dateStart' => $searchModel->startDate, - 'dateEnd' => $searchModel->endDate, + 'dateStart' => $_POST['dateStart'], + 'dateEnd' => $_POST['dateEnd'], 'selectedVariable' => $selectedVariable, 'imageTypeSelected' => $imageTypeSelected, 'selectedProvenance' => $selectedProvenance, 'selectedPosition' => $selectedPositionIndex, // seems that select widget use index when they are selectable number values 'filterToSend' => $filterToSend, - 'test' => $selectedPosition, + 'events' => $events, ]); } else { //If there is no variable given, just redirect to the visualization page. return $this->render('data_visualization', [ diff --git a/models/yiiModels/EventCreation.php b/models/yiiModels/EventCreation.php index 8c91b3a8..ffcfd18b 100644 --- a/models/yiiModels/EventCreation.php +++ b/models/yiiModels/EventCreation.php @@ -32,11 +32,6 @@ class EventCreation extends EventAction { public $creator; const CREATOR = 'creator'; - /** - * To kind of object ? Vector, sensor, scientific object (link to the cart functionnality) - * proposition name: target/ category .. - */ - public $category; /** * @inheritdoc */ diff --git a/models/yiiModels/YiiEventModel.php b/models/yiiModels/YiiEventModel.php index 947219f6..57468830 100644 --- a/models/yiiModels/YiiEventModel.php +++ b/models/yiiModels/YiiEventModel.php @@ -140,9 +140,10 @@ protected function arrayToAttributes($array) { public function getEvent($sessionToken, $uri) { $event = $this->wsModel->getEvent($sessionToken, $uri); if (!is_string($event)) { - if (isset($event[WSConstants::TOKEN_INVALID])) { - return $event; - } else { + if (isset($event->{'metadata'}->{'status'}[0]->{'exception'}->{'details'}) + && $event->{'metadata'}->{'status'}[0]->{'exception'}->{'details'} === \app\models\wsModels\WSConstants::TOKEN_INVALID) { + return \app\models\wsModels\WSConstants::TOKEN_INVALID; + } else { $this->arrayToAttributes($event); $this->uri = $uri; return $this; diff --git a/views/scientific-object/data_visualization.php b/views/scientific-object/data_visualization.php index 193a1870..2a45dc8c 100644 --- a/views/scientific-object/data_visualization.php +++ b/views/scientific-object/data_visualization.php @@ -11,6 +11,7 @@ use yii\widgets\ActiveForm; use yii\helpers\Html; use miloschuman\highcharts\Highcharts; +use miloschuman\highcharts\Highstock; use yii\web\JsExpression; use yii\helpers\Url; @@ -27,7 +28,6 @@ ?>
-

-

".Yii::t('app/messages', 'You have to click a graphic point to see images on that date.')."

"; +

" . Yii::t('app/messages', 'You have to click a graphic point to see images on that date.') . "

"; } ?> @@ -248,15 +248,100 @@ if (empty($data)) { echo "

" . Yii::t('app/messages', 'No result found.') . "

"; } else { + + /** + * @var series (before) + * @example + * [ + * [ + * 'name'=>'provenance 1', + * 'data'=>[[],[],[],...] + * ], + * [ 'name'=>'provenance 2', + * 'data'=>[[],[],[],...] + * ], + * + * ] + */ + /** + * @var series (now) + * @example + * [ + * [ + * 'type'=> 'line', + * 'name'=> 'provenance 1', + * 'id'=> 'provenance 1', + * 'data'=>[[1492139471018, 1569],[],[],...], + * 'visible':true, + * 'marker':[ + * 'enabled' :true, + * 'radius' :3 + * ] + * ], + * [ + * 'type'=> 'line', + * 'name'=> 'provenance 2', + * 'id'=> 'provenance 2', + * 'data'=>[[1492139471018, 2769],[],[],...], + * 'visible':true, + * 'marker':[ + * 'enabled' :true, + * 'radius' :3 + * ] + * ],[....], + * [ + * 'type'=> 'flags', + * 'name'=> 'event' + * 'data'=>[ + * [ + * 'x'=>1492139471018, + * 'title'=>'irrigation', + * 'text'=>'http://www.opensilex.org/id/event/f45d3221-104d-4ff2-ad8e-917e99970e05' + * ], + * [ + * ],.. + * ], + * 'lineWidth'=>1, + * 'y'=>-50, + * 'events'=> [ + * 'click'=>new JsExpression("function(event) {}") + * ] + * ] + * ] + */ $series = []; - foreach ($data["scientificObjectData"][0]["dataFromProvenance"]as $dataFromProvenanceKey => $dataFromProvenanceValue) { - $series[] = ['name' => $dataFromProvenanceKey, - 'data' => $dataFromProvenanceValue]; + foreach ($data["scientificObjectData"]["dataFromProvenance"]as $dataFromProvenanceKey => $dataFromProvenanceValue) { + $series[] = [ + 'type' => 'line', + 'name' => $dataFromProvenanceKey, + 'data' => $dataFromProvenanceValue + ]; + } + + foreach ($events as $event) { + $Eventsdata[] = [ + 'x' => $event['date'], + 'title' => $event['title'], + 'text' => $event['text'] + ]; } + + $eventsTab[] = [ + 'type' => 'flags', + 'name' => 'Events', + 'lineWidth' => 1, + 'y' => -50, + 'data' => $Eventsdata + ]; + + $series[] = $eventsTab[0]; + //var_dump($series); + + $url2 = Url::to(['image/search-from-scientific-object']); $objectURI = $model->uri; if ($show) { - echo Highcharts::widget([ + echo Highstock::widget([ 'id' => 'graphic', 'options' => [ 'chart' => [ @@ -268,6 +353,8 @@ 'subtitle' => [ 'text' => Yii::t('app/messages', 'Click and drag in the plot area to zoom in!') ], + 'legend' => [ + 'enabled' => true], 'xAxis' => [ 'type' => 'datetime', 'title' => 'Date'], @@ -310,7 +397,7 @@ ] ]); } else { - echo Highcharts::widget([ + echo Highstock::widget([ 'id' => 'graphic', 'options' => [ 'time' => ['timezoneOffset' => -2 * 60], @@ -321,6 +408,8 @@ 'subtitle' => [ 'text' => 'Click and drag in the plot area to zoom in' ], + 'legend' => [ + 'enabled' => true], 'xAxis' => [ 'type' => 'datetime', 'title' => 'Date', diff --git a/web/css/site.css b/web/css/site.css index 1ca779d8..f3801184 100755 --- a/web/css/site.css +++ b/web/css/site.css @@ -1,20 +1,26 @@ html,body { height: 100%; } + +#graphic{ + width: 100%; + height: 1000px !important; + text-align: center; +} /*SILEX:info*/ /*use in views/scientific-object/date_visualization.php*/ /*Vertical list of images*/ ul.images { - margin: 0; - padding: 0; - white-space: nowrap; - max-width: 1140px; - overflow-x: auto; + margin: 0; + padding: 0; + white-space: nowrap; + max-width: 1140px; + overflow-x: auto; } ul.images li { - display: inline-block; - width: 200px; - margin: 0 2px; + display: inline-block; + width: 200px; + margin: 0 2px; } /*//\SILEX:info*/ @@ -23,10 +29,10 @@ ul.images li { /* Fix position of the carousel in the modal*/ /*//\SILEX:required*/ .modal.and { - position: fixed; + position: fixed; } - /*SILEX:info*/ - /*use in views/scientific-object/date_visualization.php*/ +/*SILEX:info*/ +/*use in views/scientific-object/date_visualization.php*/ /*Override the default max-width of the tooltip*/ /*//\SILEX:info*/ .tooltip-inner { @@ -37,38 +43,38 @@ ul.images li { /*use in views/scientific-object/date_visualization.php*/ /*Gradient on the photo in the modal to see the text in white */ .pickgradient{ - position:relative; - display:inline-block; + position:relative; + display:inline-block; } .pickgradient:after { - content:''; - position:absolute; - left:0; bottom:0; - width:100%; height:40%; - display:inline-block; - background: -moz-linear-gradient(top, rgba(0,0,0,0) 0%, rgba(0,0,0,0.65) 100%); /* FF3.6+ */ - background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(0,0,0,0.65)), color-stop(100%,rgba(0,0,0,0))); /* Chrome,Safari4+ */ - background: -webkit-linear-gradient(top, rgba(0,0,0,0) 0%,rgba(0,0,0,0.65) 100%); /* Chrome10+,Safari5.1+ */ - background: -o-linear-gradient(top, rgba(0,0,0,0) 0%,rgba(0,0,0,0.65) 100%); /* Opera 11.10+ */ - background: -ms-linear-gradient(top, rgba(0,0,0,0) 0%,rgba(0,0,0,0.65) 100%); /* IE10+ */ - background: linear-gradient(to bottom, rgba(0,0,0,0) 0%,rgba(0,0,0,0.65) 100%); /* W3C */ - filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#a6000000', endColorstr='#00000000',GradientType=0 ); /* IE6-9 */ + content:''; + position:absolute; + left:0; bottom:0; + width:100%; height:40%; + display:inline-block; + background: -moz-linear-gradient(top, rgba(0,0,0,0) 0%, rgba(0,0,0,0.65) 100%); /* FF3.6+ */ + background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(0,0,0,0.65)), color-stop(100%,rgba(0,0,0,0))); /* Chrome,Safari4+ */ + background: -webkit-linear-gradient(top, rgba(0,0,0,0) 0%,rgba(0,0,0,0.65) 100%); /* Chrome10+,Safari5.1+ */ + background: -o-linear-gradient(top, rgba(0,0,0,0) 0%,rgba(0,0,0,0.65) 100%); /* Opera 11.10+ */ + background: -ms-linear-gradient(top, rgba(0,0,0,0) 0%,rgba(0,0,0,0.65) 100%); /* IE10+ */ + background: linear-gradient(to bottom, rgba(0,0,0,0) 0%,rgba(0,0,0,0.65) 100%); /* W3C */ + filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#a6000000', endColorstr='#00000000',GradientType=0 ); /* IE6-9 */ } /*//\SILEX:info*/ .btn:focus,.btn:active { - outline: none !important; - box-shadow: none !important; + outline: none !important; + box-shadow: none !important; } - /*SILEX:info*/ - /*use in views/scientific-object/index.php*/ +/*SILEX:info*/ +/*use in views/scientific-object/index.php*/ /*width of the cart button*/ /*//\SILEX:info*/ #cart-btn { width:88px; /* the size for a 5 digits number*/ - + } @@ -125,7 +131,7 @@ ul.images li { margin: 0 auto; pointer-events: all; } - + /*//\SILEX:info*/ @@ -302,7 +308,7 @@ table .form-group { list-style-type: none; } .li_tiret:before { - content: '- '; + content: '- '; } /*CSS Loader*/ From 0d7bfa540dc0d4833a4d2e207c2f7d4d68d3d053 Mon Sep 17 00:00:00 2001 From: jbonnefont Date: Mon, 30 Sep 2019 14:52:14 +0200 Subject: [PATCH 02/23] optimisation --- .../scientific-object/data_visualization.php | 97 ++++++++----------- web/css/site.css | 2 +- 2 files changed, 39 insertions(+), 60 deletions(-) diff --git a/views/scientific-object/data_visualization.php b/views/scientific-object/data_visualization.php index 2a45dc8c..69d21187 100644 --- a/views/scientific-object/data_visualization.php +++ b/views/scientific-object/data_visualization.php @@ -10,7 +10,6 @@ use Yii; use yii\widgets\ActiveForm; use yii\helpers\Html; -use miloschuman\highcharts\Highcharts; use miloschuman\highcharts\Highstock; use yii\web\JsExpression; use yii\helpers\Url; @@ -314,7 +313,12 @@ $series[] = [ 'type' => 'line', 'name' => $dataFromProvenanceKey, - 'data' => $dataFromProvenanceValue + 'data' => $dataFromProvenanceValue, + 'visible' => true, + 'marker' => [ + 'enabled' => true, + 'radius' => 3 + ] ]; } @@ -340,12 +344,11 @@ $url2 = Url::to(['image/search-from-scientific-object']); $objectURI = $model->uri; - if ($show) { - echo Highstock::widget([ + $options=[ 'id' => 'graphic', 'options' => [ 'chart' => [ - 'zoomType' => 'x' + 'zoomType' => 'xy', ], 'title' => [ 'text' => $variables[$data["variable"]] @@ -357,9 +360,12 @@ 'enabled' => true], 'xAxis' => [ 'type' => 'datetime', - 'title' => 'Date'], + 'title' => 'Date', + ], 'yAxis' => [ - 'title' => null, + 'title' => [ + 'text'=>$variables[$data["variable"]] + ], 'labels' => [ 'format' => '{value:.2f}' ] @@ -370,10 +376,26 @@ ], 'plotOptions' => [ 'series' => [ + 'dataGrouping' => [ + 'enabled' => false + ], 'cursor' => 'pointer', - 'point' => [ - 'events' => [ - 'click' => new JsExpression(" function() {" + 'marker' => [ + 'enabled' => true, + 'states' => [ + 'hover' => [ + 'enabled' => true + ], + 'radius' => 2 + ]], + + ] + ] + ] + ]; + + if ($show) { + $options['options']['plotOptions']['series']['point']['events']['click']=new JsExpression(" function() {" . "var searchFormData = new FormData();" . "console.log( Highcharts.dateFormat('%Y-%m-%dT%H:%M:%S+0200', 1500768000000));" . "searchFormData.append('concernedItems[]', \"$objectURI\");" @@ -389,55 +411,12 @@ . " contentType: false," . " data: searchFormData," . "}).done(function (data) {onDayImageListHTMLFragmentReception(data);} - ).fail(function (jqXHR, textStatus) {alert('ERROR : ' + jqXHR);});}") - ] - ], - ] - ] - ] - ]); - } else { - echo Highstock::widget([ - 'id' => 'graphic', - 'options' => [ - 'time' => ['timezoneOffset' => -2 * 60], - 'chart' => [ - 'zoomType' => 'x' - ], - 'title' => ['text' => $variables[$data["variable"]]], - 'subtitle' => [ - 'text' => 'Click and drag in the plot area to zoom in' - ], - 'legend' => [ - 'enabled' => true], - 'xAxis' => [ - 'type' => 'datetime', - 'title' => 'Date', - ], - 'yAxis' => [ - 'title' => null, - 'labels' => [ - 'format' => '{value:.2f}' - ] - ], - 'series' => $series, - 'tooltip' => [ - 'xDateFormat' => '%Y-%m-%d %H:%M', - ], - 'plotOptions' => [ - 'series' => [ - 'cursor' => 'pointer', - 'point' => [ - 'events' => [ - 'click' => new JsExpression(" function() {" - . "}") - ] - ] - ] - ] - ] - ]); - } + ).fail(function (jqXHR, textStatus) {alert('ERROR : ' + jqXHR);});}"); + } + echo Highstock::widget($options); + + + } } ?> diff --git a/web/css/site.css b/web/css/site.css index f3801184..18b52c8c 100755 --- a/web/css/site.css +++ b/web/css/site.css @@ -4,7 +4,7 @@ html,body { #graphic{ width: 100%; - height: 1000px !important; + height: 600px !important; text-align: center; } /*SILEX:info*/ From c2936bdc72cde4a29c7b3e0dd8f8f2d01ff93a42 Mon Sep 17 00:00:00 2001 From: jbonnefont Date: Mon, 30 Sep 2019 15:43:03 +0200 Subject: [PATCH 03/23] little changes on images rendering --- views/scientific-object/data_visualization.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/views/scientific-object/data_visualization.php b/views/scientific-object/data_visualization.php index 69d21187..e7cd2e22 100644 --- a/views/scientific-object/data_visualization.php +++ b/views/scientific-object/data_visualization.php @@ -200,17 +200,17 @@ -
+

+ echo "

" . Yii::t('app/messages', 'You have to click a graphic point to see images on that date.') . "

"; } ?>
    - +