Commit b530f31f2fad4eef19db75482aafe531f41db96f
1 parent
7d539a8c
Exists in
master
and in
109 other branches
remote sites from json
Showing
5 changed files
with
295 additions
and
95 deletions
Show diff stats
js/app/views/RemoteSearchPlugin.js
1 | 1 | /** |
2 | 2 | * Project : AMDA-NG |
3 | 3 | * Name : RemoteSearchPlug.js |
4 | - * @plugin amdaUI.InteractiveIntervalPlug | |
5 | - * @extends Ext.AbstractPlugin | |
6 | - * @ptype interactiveIntervalPlugin | |
7 | - * @brief Plot interactive session UI (View) | |
8 | - * @author Myriam | |
9 | - * @version $Id: RemoteSearchPlugin.js 1130 2012-12-18 16:45:54Z elena $ | |
10 | - ******************************************************************************** | |
11 | - * FT Id : Date : Name - Description | |
12 | - ******************************************************************************* | |
13 | - * : | |
4 | + * @plugin remoteSearchPlugin | |
5 | + * @extends Ext.AbstractPlugin | |
14 | 6 | */ |
15 | 7 | |
16 | 8 | |
... | ... | @@ -22,93 +14,85 @@ Ext.define('amdaUI.RemoteSearchPlugin', { |
22 | 14 | |
23 | 15 | win : null, |
24 | 16 | |
25 | - constructor: function(config) { | |
26 | - Ext.apply(this, config); | |
27 | - this.callParent(arguments); | |
17 | + constructor: function(config) { | |
18 | + Ext.apply(this, config); | |
19 | + this.callParent(arguments); | |
28 | 20 | }, |
29 | 21 | |
30 | 22 | |
31 | 23 | init: function(cmp) { |
32 | - this.hostCmp = cmp; | |
33 | - this.hostCmp.on({ | |
34 | - open: this.onOpen, | |
35 | - scope: this}); | |
24 | + this.hostCmp = cmp; | |
25 | + this.hostCmp.on({ | |
26 | + open: this.onOpen, | |
27 | + scope: this}); | |
36 | 28 | }, |
37 | - | |
29 | + | |
38 | 30 | onDestroy : function() { |
39 | - this.win = null; | |
31 | + this.win = null; | |
40 | 32 | }, |
41 | 33 | |
42 | 34 | onOpen: function(url) { |
43 | - //TODO just reloa dtree | |
44 | - if (this.win) this.win.destroy(); | |
35 | + //TODO just reload tree | |
36 | + if (this.win) this.win.destroy(); | |
45 | 37 | |
46 | 38 | if (!this.win) { |
47 | - this.win = new Ext.Window({ | |
48 | - id: 'remoteSearch-win', | |
49 | - width: 310, | |
50 | - height: 500, | |
51 | - title: url, | |
52 | - layout: 'fit', | |
53 | - constrain: true, | |
54 | - ghost: false, | |
55 | - items: this.getTree(url), | |
56 | - listeners: { | |
57 | - scope: this, | |
58 | - beforeclose: function(){ | |
59 | - // Ext.PluginManager.unregister(this); | |
60 | - } | |
61 | - }, | |
62 | - getConstrainVector: function(constrainTo){ | |
39 | + this.win = new Ext.Window({ | |
40 | + id: 'remoteSearch-win', | |
41 | + width: 310, | |
42 | + height: 500, | |
43 | + title: url, | |
44 | + layout: 'fit', | |
45 | + constrain: true, | |
46 | + ghost: false, | |
47 | + items: this.getTree(url), | |
48 | + getConstrainVector: function(constrainTo){ | |
63 | 49 | var me = this; |
64 | - if (me.constrain || me.constrainHeader) { | |
65 | - constrainTo = constrainTo || (me.floatParent && me.floatParent.getTargetEl()) || me.container || me.el.getScopeParent(); | |
66 | - return (me.constrainHeader ? me.header.el : me.el).getConstrainVector(constrainTo); | |
67 | - } | |
68 | - } | |
69 | - }); | |
70 | - this.win.on('destroy', this.onDestroy, this); | |
71 | - | |
72 | - // Ext.PluginManager.register(this); | |
73 | - | |
74 | - this.win.show(); | |
75 | - } | |
50 | + if (me.constrain || me.constrainHeader) { | |
51 | + constrainTo = constrainTo || (me.floatParent && me.floatParent.getTargetEl()) || me.container || me.el.getScopeParent(); | |
52 | + return (me.constrainHeader ? me.header.el : me.el).getConstrainVector(constrainTo); | |
53 | + } | |
54 | + } | |
55 | + }); | |
56 | + this.win.on('destroy', this.onDestroy, this); | |
57 | + | |
58 | + this.win.show(); | |
59 | + } | |
76 | 60 | }, |
77 | 61 | |
78 | - getTree : function(url) { | |
79 | - | |
80 | - var store = Ext.create('Ext.data.TreeStore', { | |
81 | - model: 'amdaModel.AmdaNode', | |
82 | - root: { | |
83 | - text: url, | |
84 | - nodeType : 'url', | |
85 | - expanded: true | |
86 | - } , | |
87 | - listeners: { | |
88 | - scope : this, | |
89 | - beforeload: function(store, operation){ | |
90 | - store.proxy.extraParams = { | |
91 | - nodeType: 'url', | |
92 | - baseId: url | |
93 | - }} | |
94 | - } | |
62 | + getTree : function(url) | |
63 | + { | |
64 | + var store = Ext.create('Ext.data.TreeStore', { | |
65 | + model: 'amdaModel.AmdaNode', | |
66 | + root: { | |
67 | + text: url, | |
68 | + nodeType : 'url', | |
69 | + expanded: true | |
70 | + } , | |
71 | + listeners: { | |
72 | + scope : this, | |
73 | + beforeload: function(store, operation){ | |
74 | + store.proxy.extraParams = { | |
75 | + nodeType: 'url', | |
76 | + baseId: url | |
77 | + } | |
78 | + } | |
79 | + } | |
80 | + }); | |
95 | 81 | |
96 | - }); | |
97 | - | |
98 | - var tree = Ext.create('Ext.tree.Panel', { | |
99 | - store: store, | |
100 | - listeners : { | |
101 | - scope : this, | |
102 | - itemdblclick: function(view, record, item, index, event){ | |
103 | - event.stopEvent(); | |
104 | - var form = this.hostCmp.down('form').next().getForm(); | |
105 | - form.getFields().getAt(1).setValue(record.internalId); // internalId ?? | |
106 | - this.win.destroy(); | |
107 | - } | |
108 | - } | |
109 | - }); | |
82 | + var tree = Ext.create('Ext.tree.Panel', { | |
83 | + store: store, | |
84 | + listeners : { | |
85 | + scope : this, | |
86 | + itemdblclick: function(view, record, item, index, event){ | |
87 | + event.stopEvent(); | |
88 | + var form = this.hostCmp.down('form').next().getForm(); | |
89 | + form.getFields().getAt(1).setValue(record.internalId); // internalId ?? | |
90 | + this.win.destroy(); | |
91 | + } | |
92 | + } | |
93 | + }); | |
110 | 94 | |
111 | - return tree; | |
95 | + return tree; | |
112 | 96 | } |
113 | 97 | |
114 | 98 | }); |
115 | 99 | \ No newline at end of file | ... | ... |
js/app/views/UploadPanelUI.js
... | ... | @@ -261,13 +261,18 @@ Ext.define('amdaUI.UploadPanelUI', { |
261 | 261 | |
262 | 262 | this.localUploadId = 'form-uploadfile'; |
263 | 263 | this.remoteUploadId = 'form-uploadurl'; |
264 | - this.nodeType = 'amdaModel.MyDataParamNode'; | |
265 | - //TODO load XML | |
264 | + this.nodeType = 'amdaModel.MyDataParamNode'; | |
266 | 265 | this.store = Ext.create('Ext.data.Store', { |
267 | 266 | fields: ['value', 'name'], |
268 | - data : [ | |
269 | - {"value":"ftp://cdaweb.gsfc.nasa.gov/pub/data/", "name":"CDAWEB/FTP"}/*, | |
270 | - {"value":"ftp://ftp.ngdc.noaa.gov/STP/SOLAR_DATA/", "name":"Solar Data"}*/] | |
267 | + proxy: { | |
268 | + type: 'ajax', | |
269 | + url : 'generic_data/remote_sites.json', | |
270 | + reader: { | |
271 | + type: 'json', | |
272 | + root: 'remote_sites' | |
273 | + } | |
274 | + }, | |
275 | + autoLoad: true | |
271 | 276 | }); |
272 | 277 | |
273 | 278 | this.radioId = 'filefrmt'; |
... | ... | @@ -434,11 +439,20 @@ Ext.define('amdaUI.UploadPanelUI', { |
434 | 439 | this.localUploadId = 'form-uploadtt'; |
435 | 440 | this.remoteUploadId = 'form-uploadtturl'; |
436 | 441 | this.nodeType = 'amdaModel.TimeTableNode'; |
437 | - //TODO load XML | |
442 | + | |
438 | 443 | this.store = Ext.create('Ext.data.Store', { |
439 | - fields: ['value', 'name'], | |
440 | - data : [] | |
444 | + fields: ['value', 'name']/*, | |
445 | + proxy: { | |
446 | + type: 'ajax', | |
447 | + url : 'generic_data/remote_sites.json', | |
448 | + reader: { | |
449 | + type: 'json', | |
450 | + root: 'remote_sites' | |
451 | + } | |
452 | + }, | |
453 | + autoLoad: true*/ | |
441 | 454 | }); |
455 | + | |
442 | 456 | this.radioId = 'ttfrmt'; |
443 | 457 | } |
444 | 458 | else { |
... | ... | @@ -448,11 +462,18 @@ Ext.define('amdaUI.UploadPanelUI', { |
448 | 462 | this.localUploadId = 'form-uploadcat'; |
449 | 463 | this.remoteUploadId = 'form-uploadcaturl'; |
450 | 464 | this.nodeType = 'amdaModel.CatalogNode'; |
451 | - //TODO load XML | |
452 | 465 | this.store = Ext.create('Ext.data.Store', { |
453 | - fields: ['value', 'name'], | |
454 | - data : [] | |
455 | - }); | |
466 | + fields: ['value', 'name']/*, | |
467 | + proxy: { | |
468 | + type: 'ajax', | |
469 | + url : 'generic_data/remote_sites.json', | |
470 | + reader: { | |
471 | + type: 'json', | |
472 | + root: 'remote_sites' | |
473 | + } | |
474 | + }, | |
475 | + autoLoad: true*/ | |
476 | + }); | |
456 | 477 | |
457 | 478 | this.radioId = 'catfrmt'; |
458 | 479 | } |
... | ... | @@ -518,7 +539,7 @@ Ext.define('amdaUI.UploadPanelUI', { |
518 | 539 | var combo = Ext.create('Ext.form.ComboBox', { |
519 | 540 | flex : 4, |
520 | 541 | store: this.store, |
521 | - emptyText: 'Enter Remote Site URL (ftp)', | |
542 | + emptyText: 'Enter Remote Site URL (ftp/http[s])', | |
522 | 543 | queryMode: 'local', |
523 | 544 | displayField: 'name', |
524 | 545 | valueField: 'value' |
... | ... | @@ -556,7 +577,7 @@ Ext.define('amdaUI.UploadPanelUI', { |
556 | 577 | { |
557 | 578 | xtype : 'textfield', |
558 | 579 | name : config.remoteUploadName, |
559 | - emptyText: 'Enter Remote File URL (http or ftp)', | |
580 | + emptyText: 'Enter Remote File URL (ftp/http[s])', | |
560 | 581 | width: 310, |
561 | 582 | listeners: |
562 | 583 | { | ... | ... |
php/old_amda/simple_html_dom.php renamed to php/classes/simple_html_dom.php
... | ... | @@ -0,0 +1,192 @@ |
1 | +/* $Id: timeResFromData.c,v 1.1 2010/08/31 10:32:55 budnik Exp $ */ | |
2 | + | |
3 | +/** @file timeResFromData.c | |
4 | +* @brief Function to get CDAWEB dataset sampling times from data files | |
5 | +*/ | |
6 | +#include <stdio.h> | |
7 | +#include <stdlib.h> | |
8 | +#include <cdf.h> | |
9 | +#include <string.h> | |
10 | +#include <time.h> | |
11 | +#include <math.h> | |
12 | + | |
13 | +#define fileName "temp.cdf" | |
14 | +#define badFile -100 | |
15 | + | |
16 | +/************************************* | |
17 | + Global variables and structures | |
18 | +**************************************/ | |
19 | +long CDFDims, // Number of dimensions in a CDF file | |
20 | + CDFVars, // Number of variables in a CDF file | |
21 | + CDFDimSizes[CDF_MAX_DIMS], // Dimension Sizes in a CDF file | |
22 | + CDFencoding, // Data encoding | |
23 | + CDFmajority, // Variable majority | |
24 | + CDFmaxRec, // max Record number | |
25 | + CDFAttrs; // number of CDF Attributes | |
26 | +// CDFdatatype; | |
27 | + | |
28 | +struct cdfvar { // CDF variable structure | |
29 | + char name[CDF_VAR_NAME_LEN+1]; | |
30 | + long num; //variable number | |
31 | + long datatype; | |
32 | + long numElem; // variable dimensionality | |
33 | + long recVariance; // variable rec Variance | |
34 | + long dimVariances[CDF_MAX_DIMS]; // # of data values in dimSizes | |
35 | +} cdfVar; | |
36 | + | |
37 | +/*-------------------------------------------------------------------------- | |
38 | + * Handles a CDF error. | |
39 | + *--------------------------------------------------------------------------*/ | |
40 | +void cdf_handle_error(CDFstatus status) | |
41 | +{ | |
42 | + char message[CDF_STATUSTEXT_LEN+1]; | |
43 | + | |
44 | + CDFerror (status, message); /* Get the appropriate message */ | |
45 | + fprintf (stderr, "%s\n", message); | |
46 | + exit(1); | |
47 | +} | |
48 | + | |
49 | +void find_min(int* delta, int nRecs, int minFalse, int* minVal) | |
50 | +{ | |
51 | + int i, n, min; | |
52 | + | |
53 | + n = 1; | |
54 | + i = 0; | |
55 | + while (abs(delta[i]) <= minFalse) i++; | |
56 | + if (i < nRecs) { | |
57 | + min = abs(delta[i]); | |
58 | + // printf(" first MIN %d \n", min); | |
59 | + for (i = 1; i < nRecs; i++) { | |
60 | + // printf(" delta %d \n", delta[i]); | |
61 | + if (delta[i] == min) n++; | |
62 | + if (delta[i] < min && delta[i] > minFalse) { | |
63 | + min = delta[i]; | |
64 | + n = 1; | |
65 | + } | |
66 | + } | |
67 | + } else { | |
68 | + min = -10; | |
69 | + n = nRecs; | |
70 | + } | |
71 | + | |
72 | + minVal[0] = min; | |
73 | + minVal[1] = n; | |
74 | + printf(" MIN %d %d\n", min, n); | |
75 | +} | |
76 | + | |
77 | +int main(int argc, char *argv[]) | |
78 | +{ | |
79 | + long RecStart = 0, RecCount, RecInt = 1; | |
80 | + long indices[1] = {0}, intervals[1] = {1}, counts[1] = {1}; | |
81 | + long varN = -1; | |
82 | + long datatype = 0, attrN, maxEntry; | |
83 | + CDFstatus cstatus; // CDF status code | |
84 | + CDFid id; | |
85 | + double *value; | |
86 | + int *delta; | |
87 | + int i, minFalse = 0, numEnough; | |
88 | + int min[2] = {0, 0}; | |
89 | + char attrValue[300]; | |
90 | + float Sampling; | |
91 | + double epoch16[2], dbl_value, dbl_value_; | |
92 | + long year, month, day, hour, minute, sec, msec, mksec, nsec, psec; | |
93 | + long long *int_value; | |
94 | + | |
95 | +/*********************** Open CDF file *****************************/ | |
96 | + if ((cstatus = CDFopen(fileName, &id)) != CDF_OK) | |
97 | + cdf_handle_error(cstatus); | |
98 | + | |
99 | +/*********** treat all vars as zVars with eliminated false dimensionality and get Nrecs **********/ | |
100 | + | |
101 | + if ((cstatus = CDFlib(SELECT_, CDF_zMODE_, zMODEon2, NULL_)) != CDF_OK) | |
102 | + cdf_handle_error (cstatus); | |
103 | + | |
104 | + while (datatype != CDF_EPOCH && datatype != CDF_EPOCH16 && datatype != CDF_TIME_TT2000){ | |
105 | + varN++; | |
106 | + if ((cstatus = CDFlib(SELECT_, zVAR_, varN, | |
107 | + GET_, zVAR_DATATYPE_, &datatype, NULL_)) != CDF_OK) | |
108 | + cdf_handle_error (cstatus); | |
109 | + // if (datatype == CDF_EPOCH16) break; | |
110 | + } | |
111 | + fprintf(stdout,"DATATYPE %d %d\n", varN, datatype); | |
112 | + if ((cstatus = CDFlib(SELECT_, zVAR_, varN, | |
113 | + GET_, zVAR_MAXREC_, &CDFmaxRec, NULL_)) != CDF_OK) | |
114 | + cdf_handle_error (cstatus); | |
115 | + | |
116 | + fprintf(stdout,"Max Recs %d\n", CDFmaxRec+1); | |
117 | + if (CDFmaxRec < 10) { | |
118 | + fprintf(stdout," %d\n", badFile); | |
119 | + exit (0); | |
120 | + } | |
121 | + | |
122 | + if ( datatype == CDF_TIME_TT2000 ) { | |
123 | + int_value = (long long *) malloc (sizeof(long long) * (CDFmaxRec+1)); | |
124 | + /******************* Get Epoch *************************/ | |
125 | + if ((cstatus = CDFlib (SELECT_, | |
126 | + zVAR_, varN, | |
127 | + zVAR_RECNUMBER_, RecStart, | |
128 | + zVAR_RECCOUNT_, CDFmaxRec+1, | |
129 | + zVAR_RECINTERVAL_, RecInt, | |
130 | + zVAR_DIMINDICES_, indices, | |
131 | + zVAR_DIMCOUNTS_, counts, | |
132 | + zVAR_DIMINTERVALS_, intervals, | |
133 | + GET_, zVAR_HYPERDATA_, int_value, NULL_)) != CDF_OK) | |
134 | + cdf_handle_error (cstatus); | |
135 | + } | |
136 | + else { | |
137 | + value = (double *)malloc(sizeof(double)* (CDFmaxRec+1)*((datatype == CDF_EPOCH16)+1)); | |
138 | + /******************* Get Epoch *************************/ | |
139 | + if ((cstatus = CDFlib (SELECT_, | |
140 | + zVAR_, varN, | |
141 | + zVAR_RECNUMBER_, RecStart, | |
142 | + zVAR_RECCOUNT_, CDFmaxRec+1, | |
143 | + zVAR_RECINTERVAL_, RecInt, | |
144 | + zVAR_DIMINDICES_, indices, | |
145 | + zVAR_DIMCOUNTS_, counts, | |
146 | + zVAR_DIMINTERVALS_, intervals, | |
147 | + GET_, zVAR_HYPERDATA_, value, NULL_)) != CDF_OK) | |
148 | + cdf_handle_error (cstatus); | |
149 | + } | |
150 | + | |
151 | + | |
152 | + | |
153 | + delta = (int *)malloc(sizeof(int)* CDFmaxRec); | |
154 | + for (i = 1; i < CDFmaxRec+1; i++) | |
155 | + { | |
156 | + if (datatype == CDF_TIME_TT2000) { | |
157 | + dbl_value_ = CDF_TT2000_to_UTC_EPOCH(int_value[i-1]); | |
158 | + dbl_value = CDF_TT2000_to_UTC_EPOCH(int_value[i]); | |
159 | + delta[i-1] = (int)(dbl_value - dbl_value_ + 50)/100; | |
160 | + } | |
161 | + else { | |
162 | + if (datatype == CDF_EPOCH16) { | |
163 | + epoch16[0] = value[2*(i-1)]; | |
164 | + epoch16[1] = value[2*(i-1)+1]; | |
165 | + EPOCH16breakdown(epoch16, &year, &month, &day, &hour, &minute, &sec, &msec, &mksec, &nsec, &psec); | |
166 | + value[i-1] = computeEPOCH(year, month, day, hour, minute, sec, msec); | |
167 | + epoch16[0] = value[2*i]; | |
168 | + epoch16[1] = value[2*i+1]; | |
169 | + EPOCH16breakdown(epoch16, &year, &month, &day, &hour, &minute, &sec, &msec, &mksec, &nsec, &psec); | |
170 | + value[i] = computeEPOCH(year, month, day, hour, minute, sec, msec); | |
171 | + } | |
172 | + delta[i-1] = (int)(value[i] - value[i-1] + 50)/100; | |
173 | + } | |
174 | + } | |
175 | + // fprintf(stdout,"value %f\n", value[11]-value[10]); | |
176 | + if (datatype == CDF_TIME_TT2000) free(int_value); | |
177 | + else free(value); | |
178 | + // fprintf(stdout,"delta %d\n", delta[0]); | |
179 | + numEnough = CDFmaxRec/10; | |
180 | + while (min[1] < numEnough) { | |
181 | + fprintf(stdout,"minFalse %d\n", minFalse); | |
182 | + find_min(delta, CDFmaxRec, minFalse, min); | |
183 | + minFalse = min[0]; | |
184 | + } | |
185 | + | |
186 | + free(delta); | |
187 | + if ((cstatus = CDFlib(CLOSE_, CDF_, NULL_)) != CDF_OK) | |
188 | + cdf_handle_error (cstatus); | |
189 | + | |
190 | + // fprintf(stdout,"%d %f\n",min[1], (float)min[0]/100.0); | |
191 | + fprintf(stdout,"%f\n",(float)min[0]/10.0); | |
192 | +} | ... | ... |