Commit 9a89081f8902f810754d7b2d5c53f1fa341d089c
Exists in
master
and in
91 other branches
Merge branch 'master' into multiplot
Showing
10 changed files
with
126 additions
and
19 deletions
Show diff stats
js/app/controllers/PlotModule.js
... | ... | @@ -216,6 +216,7 @@ Ext.define('amdaDesktop.PlotModule', { |
216 | 216 | var win = desktop.getWindow(this.id); |
217 | 217 | if (win) { |
218 | 218 | // Plot UI is opened => add plot in a new tab |
219 | + me.linkedNode.get('object').plots().add(plotNode); | |
219 | 220 | me.getUiContent().editPlot(plotNode); |
220 | 221 | win.show(); |
221 | 222 | } |
... | ... |
js/app/views/PlotComponents/PlotTabContent.js
js/app/views/PlotComponents/PlotTabPanel.js
... | ... | @@ -49,6 +49,15 @@ Ext.define('amdaPlotComp.PlotTabPanel', { |
49 | 49 | } |
50 | 50 | } |
51 | 51 | }, |
52 | + | |
53 | + isDirty : function() { | |
54 | + var dirty = false; | |
55 | + this.multiplot_object.plots().each(function (rec, index) { | |
56 | + if (rec.get('object').get('id') != '') | |
57 | + dirty |= rec.get('object').isDirty(); | |
58 | + }); | |
59 | + return dirty; | |
60 | + }, | |
52 | 61 | |
53 | 62 | addPlotNode: function(plotNode, selectTab, refreshMultiPlot) |
54 | 63 | { |
... | ... |
js/app/views/PlotUI.js
... | ... | @@ -98,8 +98,8 @@ Ext.define('amdaUI.PlotUI', { |
98 | 98 | var module = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.plot.id); |
99 | 99 | if (module) |
100 | 100 | module.closeInteractiveSession(); |
101 | - | |
102 | - return this.object.isDirty(); | |
101 | + | |
102 | + return this.plotTabs.isDirty(); | |
103 | 103 | }, |
104 | 104 | |
105 | 105 | /** |
... | ... |
php/RemoteDataCenter/RemoteParamManager.php
... | ... | @@ -47,7 +47,7 @@ class RemoteParamManager |
47 | 47 | if (!file_exists(USERWSDIR."RemoteParams.xml")) |
48 | 48 | return array("err" => "RemoteParams file error"); |
49 | 49 | |
50 | - if (!$this->xmlDom->load($this->xmlName)) | |
50 | + if (!@$this->xmlDom->load($this->xmlName)) | |
51 | 51 | return array("err" => "RemoteParams file error"); |
52 | 52 | |
53 | 53 | return array("success" => true); |
... | ... |
php/classes/AmdaAction.php
... | ... | @@ -282,9 +282,10 @@ class AmdaAction |
282 | 282 | $not_yet = true; |
283 | 283 | } |
284 | 284 | } |
285 | -// if ($child->parentNode->getAttribute('restriction') > 1 ) { | |
286 | -// $timeRestriction = true; | |
287 | -// } | |
285 | + | |
286 | + if ($child->parentNode->hasAttribute('timeRestriction')) { | |
287 | + $timeRestriction = $child->parentNode->getAttribute('timeRestriction'); | |
288 | + } | |
288 | 289 | } |
289 | 290 | |
290 | 291 | $component_info = array(); |
... | ... | @@ -302,9 +303,10 @@ class AmdaAction |
302 | 303 | $not_yet = true; |
303 | 304 | } |
304 | 305 | } |
305 | -// if ($child->parentNode->parentNode->getAttribute('restriction') > 1) { | |
306 | -// $timeRestriction = true; | |
307 | -// } | |
306 | + | |
307 | + if ($child->parentNode->parentNode->hasAttribute('timeRestriction')) { | |
308 | + $timeRestriction = $child->parentNode->parentNode->getAttribute('timeRestriction'); | |
309 | + } | |
308 | 310 | |
309 | 311 | if ($child->hasAttribute("index1")) |
310 | 312 | $component_info["index1"] = $child->getAttribute('index1'); |
... | ... | @@ -330,7 +332,7 @@ class AmdaAction |
330 | 332 | if ($isParameter) { |
331 | 333 | $objectMgr = new AliasMgr(); |
332 | 334 | $alias = $objectMgr->getAlias($id); |
333 | - | |
335 | + $info .= '</br><i>ID : '.$id.'</i>'; | |
334 | 336 | $childrenToReturn[] = array('text' => $name,'alias' => $alias, |
335 | 337 | 'id' => $id,'nodeType' => $nodeType, 'info' => $info, "component_info" => $component_info, |
336 | 338 | 'globalStart' => $globalStart, 'globalStop' => $globalStop, 'timeRestriction' => $timeRestriction, |
... | ... | @@ -342,23 +344,31 @@ class AmdaAction |
342 | 344 | $rank = $child->getAttribute('rank'); |
343 | 345 | } |
344 | 346 | |
345 | - $disable = $child->hasAttribute('group'); | |
347 | + if ($child->hasAttribute("timeRestriction")) { | |
348 | + $timeRestriction = $child->getAttribute("timeRestriction"); | |
349 | + } | |
350 | + $disable = TRUE; | |
346 | 351 | |
347 | - if ($disable) { | |
352 | + if ($child->hasAttribute('group')) { | |
348 | 353 | if ($child->getAttribute("group") === "TBD") { |
349 | 354 | $info .= "<br/><b>Under Testing</b>"; |
350 | - } | |
355 | + } | |
351 | 356 | else { |
352 | 357 | $info .= "<br/><b>Restricted Access : Group ".$child->getAttribute('group')."</b>"; |
358 | + if (!empty($timeRestriction)) { | |
359 | + $disable = FALSE; | |
360 | + $info .= "<br/><b>Time Restriction : ".$timeRestriction."</b>"; | |
361 | + } | |
353 | 362 | } |
354 | 363 | } |
355 | 364 | else { |
365 | + $disable = FALSE; | |
356 | 366 | if ($child->hasAttribute('restriction') && $child->getAttribute('restriction') == 'plotOnly') |
357 | 367 | $info .= "<br/><b>Plot Only!!!</b>"; |
358 | 368 | } |
359 | 369 | |
360 | 370 | $childrenToReturn[] = array('text' => $name, 'id' => $id,'nodeType' => $nodeType, 'info' => $info, |
361 | - 'leaf' => false, 'help' => $help, 'disable' => $disable, 'rank' => $rank); | |
371 | + 'leaf' => false, 'help' => $help, 'disable' => $disable, 'rank' => $rank, 'timeRestriction' => $timeRestriction); | |
362 | 372 | } |
363 | 373 | break; |
364 | 374 | |
... | ... |
php/classes/AmdaClient.php
... | ... | @@ -107,6 +107,19 @@ class AmdaClient { |
107 | 107 | // return true; |
108 | 108 | // } |
109 | 109 | // |
110 | + | |
111 | + /* Get list of VI with TimeRestriction in DDBASE */ | |
112 | + public function getDatasetsWithTimeRestriction() { | |
113 | + try { | |
114 | + $restrictions = $this->client->getDatasetsWithTimeRestriction(); | |
115 | + } | |
116 | + catch (SoapFault $exception) { | |
117 | + error_log($exception->faultstring.PHP_EOL, 1, email); | |
118 | + return FALSE; | |
119 | + } | |
120 | + return $restrictions; | |
121 | + } | |
122 | + | |
110 | 123 | /* Get Time Restriction from VI in DDBASE */ |
111 | 124 | public function getTimeRestriction($dataSet) { |
112 | 125 | try { |
... | ... |
php/classes/FilterResSimu.php
... | ... | @@ -16,7 +16,7 @@ |
16 | 16 | $this->simXmlName = $basePath; |
17 | 17 | $this->simXml = new DomDocument("1.0"); |
18 | 18 | if (file_exists($this->simXmlName)) { |
19 | - $this->simXml->load($this->simXmlName); | |
19 | + @$this->simXml->load($this->simXmlName); | |
20 | 20 | $this->simRootEl = $this->simXml->documentElement; |
21 | 21 | } |
22 | 22 | $this->simXP = new domxpath($this->simXml); |
... | ... |
php/classes/UserMgr.php
... | ... | @@ -25,6 +25,8 @@ class UserMgr |
25 | 25 | protected $userGrpsCheckSum; //use to know if there is a modification in user groups |
26 | 26 | protected $amdaClient; //client to dd webservice |
27 | 27 | protected $paramMgr, $baseExtXml; |
28 | + protected $datasetsTimeRestriction; | |
29 | + protected $datasetsTimeRestrictionCheckSum; | |
28 | 30 | |
29 | 31 | public $isFirst = false; |
30 | 32 | public $isOldWS = false; |
... | ... | @@ -151,6 +153,55 @@ class UserMgr |
151 | 153 | } |
152 | 154 | } |
153 | 155 | |
156 | + protected function loadDatasetsTimeRestriction() | |
157 | + { | |
158 | + if (isset($this->datasetsTimeRestriction)) { | |
159 | + return; | |
160 | + } | |
161 | + $restrictionFilePath = datasetsTimeRestrictionJson; | |
162 | + if (file_exists($restrictionFilePath)) { | |
163 | + // Re-use the cache file if it's not older than 3600s. | |
164 | + if (abs(time() - filemtime($restrictionFilePath)) < 3600) { | |
165 | + $fileContent = file_get_contents($restrictionFilePath); | |
166 | + if (!empty($fileContent)) { | |
167 | + $this->datasetsTimeRestriction = json_decode($fileContent, TRUE); | |
168 | + if (isset($this->datasetsTimeRestriction) && ($this->datasetsTimeRestriction !== FALSE)) { | |
169 | + $this->datasetsTimeRestrictionCheckSum = md5($fileContent); | |
170 | + return; | |
171 | + } | |
172 | + } | |
173 | + } | |
174 | + } | |
175 | + | |
176 | + $this->datasetsTimeRestrictionCheckSum = ''; | |
177 | + $this->datasetsTimeRestriction = $this->amdaClient->getDatasetsWithTimeRestriction(); | |
178 | + | |
179 | + if ($this->datasetsTimeRestriction !== FALSE) { | |
180 | + foreach ($this->datasetsTimeRestriction as &$datasetTimeRestriction) { | |
181 | + $timeRestriction = $datasetTimeRestriction['restriction']; | |
182 | + //Parse time restriction | |
183 | + $n = sscanf($timeRestriction, "%04d-%02d-%02d", $yy, $mm, $dd); | |
184 | + if ($n != 3) { | |
185 | + $n = sscanf($timeRestriction, "%d", $ndays); | |
186 | + if ($n != 1) { | |
187 | + //Cannot parse the time restriction | |
188 | + $timeRestriction = ''; | |
189 | + } | |
190 | + else { | |
191 | + $timeRestriction = date("Y-m-d", strtotime("-$ndays days"))."T23:59:59.999Z"; | |
192 | + } | |
193 | + } | |
194 | + else { | |
195 | + $timeRestriction .= "T23:59:59.999Z"; | |
196 | + } | |
197 | + $datasetTimeRestriction['restriction'] = $timeRestriction; | |
198 | + } | |
199 | + $content = json_encode($this->datasetsTimeRestriction); | |
200 | + $this->datasetsTimeRestrictionCheckSum = md5($content); | |
201 | + file_put_contents($restrictionFilePath, $content); | |
202 | + } | |
203 | + } | |
204 | + | |
154 | 205 | /* |
155 | 206 | * Check if special groups with settings exist and user is from these groups |
156 | 207 | * Take the first group from user list |
... | ... | @@ -617,12 +668,15 @@ class UserMgr |
617 | 668 | |
618 | 669 | protected function makeLocalTree() |
619 | 670 | { |
671 | + $this->loadDatasetsTimeRestriction(); | |
672 | + | |
620 | 673 | $this->loadUserGrps(); |
621 | 674 | |
622 | 675 | if (file_exists(USERWSDIR.'LocalParams.xml')) { |
623 | - if (file_exists(USERWSDIR.'userGrpsChecksum')) { | |
676 | + if (file_exists(USERWSDIR.'userGrpsChecksum') && file_exists(USERWSDIR.'datasetsTimeRestrictionCheckSum')) { | |
624 | 677 | $lastGrpsChecksum = file_get_contents(USERWSDIR.'userGrpsChecksum'); |
625 | - if ($lastGrpsChecksum == $this->userGrpsCheckSum) { | |
678 | + $lastDatasetsTimeRestrictionCheckSum = file_get_contents(USERWSDIR.'datasetsTimeRestrictionCheckSum'); | |
679 | + if (($lastGrpsChecksum == $this->userGrpsCheckSum) && ($lastDatasetsTimeRestrictionCheckSum == $this->datasetsTimeRestrictionCheckSum)) { | |
626 | 680 | //No modification in groups for this user |
627 | 681 | if (filemtime(USERWSDIR.'LocalParams.xml') == filemtime(LocalData.'/LocalParams.xml')) { |
628 | 682 | //And no modification in LocalParams file => skip makeLocalTree |
... | ... | @@ -637,8 +691,10 @@ class UserMgr |
637 | 691 | die("Login for ".$this->user." failed: Can't copy LocalParams.xml"); |
638 | 692 | //Save groups checksum used to generate this user local tree |
639 | 693 | file_put_contents(USERWSDIR.'userGrpsChecksum', $this->userGrpsCheckSum); |
694 | + //Save datasets time restrictions used to generate this user local tree | |
695 | + file_put_contents(USERWSDIR.'datasetsTimeRestrictionCheckSum', $this->datasetsTimeRestrictionCheckSum); | |
640 | 696 | |
641 | - $result = $this->updateTreeForGrps(USERWSDIR.'LocalParams.xml'); | |
697 | + $result = $this->updateTreeForGrpsAndTimeRestrictions(USERWSDIR.'LocalParams.xml'); | |
642 | 698 | |
643 | 699 | //Set modif time to the original one |
644 | 700 | touch(USERWSDIR.'LocalParams.xml', filemtime(LocalData.'/LocalParams.xml')); |
... | ... | @@ -646,7 +702,7 @@ class UserMgr |
646 | 702 | return TRUE; |
647 | 703 | } |
648 | 704 | |
649 | - protected function updateTreeForGrps($file) | |
705 | + protected function updateTreeForGrpsAndTimeRestrictions($file) | |
650 | 706 | { |
651 | 707 | if (!isset($this->userGrps)) |
652 | 708 | return TRUE; |
... | ... | @@ -671,6 +727,20 @@ class UserMgr |
671 | 727 | } |
672 | 728 | } |
673 | 729 | } |
730 | + | |
731 | + if (!empty($this->datasetsTimeRestriction)) { | |
732 | + foreach ($this->datasetsTimeRestriction as $datasetTimeRestriction) { | |
733 | + $nodes = $xp->query("//dataset[@xml:id='".str_replace('_','-',$datasetTimeRestriction['vi'])."']"); | |
734 | + if ($nodes->length > 0) { | |
735 | + foreach ($nodes as $node) { | |
736 | + $timeRestriction = $datasetTimeRestriction['restriction']; | |
737 | + if (!empty($timeRestriction)) { | |
738 | + $node->setAttribute('timeRestriction', $timeRestriction); | |
739 | + } | |
740 | + } | |
741 | + } | |
742 | + } | |
743 | + } | |
674 | 744 | |
675 | 745 | return $xml->save($file); |
676 | 746 | } |
... | ... |
php/config.php
... | ... | @@ -90,6 +90,7 @@ define('orbitsAllXml',LocalData.'/OrbitsAll.xml'); |
90 | 90 | define('FeedbackXml', DATAPATH.'/Feedback/Feedback.xml'); |
91 | 91 | define('specialGrpsXml',SpecialSettingsDir.'/Groups.xml'); |
92 | 92 | define('specialSettingsXml',SpecialSettingsDir.'/Settings.xml'); |
93 | +define('datasetsTimeRestrictionJson',LocalData.'/datasetsTimeRestriction.json'); | |
93 | 94 | |
94 | 95 | //Help info dirs |
95 | 96 | define('HELPPATH', IHM_SRC_DIR."/help/"); |
... | ... |