From 23a80c6a60c17c2ff9bccf4d462333d4975f0613 Mon Sep 17 00:00:00 2001 From: ldassin Date: Wed, 8 Nov 2023 16:56:18 +0100 Subject: [PATCH 1/6] re-introduced the show metadata form in formNODE.pl to ask user if he wants to write the database --- CODE/cgi-bin/formNODE.pl | 22 +++++++++++++++++----- CODE/cgi-bin/postNODE.pl | 7 ++++--- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/CODE/cgi-bin/formNODE.pl b/CODE/cgi-bin/formNODE.pl index fa889e70..6b17409b 100755 --- a/CODE/cgi-bin/formNODE.pl +++ b/CODE/cgi-bin/formNODE.pl @@ -790,6 +790,18 @@ =head1 Query string parameters } } +function showHideTheia(checkbox){ + const theia = document.getElementById("showHide"); + + if (checkbox.checked == false) { + theia.style.display = "none"; + document.form.saveAuth.value = 0; + } else { + theia.style.display = "block"; + document.form.saveAuth.value = 1; + } +} + // creating and parametring the map for the geographic location choice var esriAttribution = 'Tiles © Esri — Source: Esri, i-cubed, USDA, USGS, AEX, GeoEye, Getmapping, Aerogrid, IGN, IGP, UPR-EGP, and the GIS User Community'; @@ -1020,7 +1032,7 @@ =head1 Query string parameters print ""; print "  
"; # --- show THEIA fields ? - #print " 

"; + print "
 

"; print "
"; # --- PRODUCER print ""; @@ -1158,14 +1170,14 @@ =head1 Query string parameters print ""; print < - const theia = document.getElementById("showHide"); + const checked = document.getElementById("theiaChecked"); const auth = $theiaAuth; - + if (auth == 1) { // console.log(theia); - theia.style.display = "block"; + checked.style.display = "block"; } else { - theia.style.display = "none"; + checked.style.display = "none"; } var map = L.map('map', mapOptions); diff --git a/CODE/cgi-bin/postNODE.pl b/CODE/cgi-bin/postNODE.pl index 0074ae69..6e3e7538 100755 --- a/CODE/cgi-bin/postNODE.pl +++ b/CODE/cgi-bin/postNODE.pl @@ -147,9 +147,10 @@ =head1 Query string parameters } } else { htmlMsgNotOK ("Invalid NODE (".$cgi->param('node').") posted for create/update/delete") } -# ---- checking if user is a THEIA user +# ---- checking if user is a THEIA user and if he wants to save data in metadatabase # my $theiaAuth = $WEBOBS{THEIA_USER_FLAG}; +my $saveAuth = $cgi->param('saveAuth') // ''; # ---- where are the NODE's directory and NODE's conf file ? my %allNodeGrids = WebObs::Grids::listNodeGrids(node=>$NODEName); @@ -172,7 +173,7 @@ =head1 Query string parameters @lines = readFile($NODES{FILE_NODES2NODES},qr/^(?!$NODEName\|)/); saveN2N(@lines); - if ( isok($theiaAuth) ) { + if ( isok($theiaAuth) and isok($saveAuth) ) { # --- connecting to the database my $driver = "SQLite"; my $database = $WEBOBS{SQL_METADATA}; @@ -433,7 +434,7 @@ =head1 Query string parameters } else { htmlMsgNotOK("$geojsonfile $!") } } -if ( isok($theiaAuth) ) { +if ( isok($theiaAuth) and $saveAuth == 1 ) { # --- connecting to the database my $driver = "SQLite"; my $database = $WEBOBS{SQL_METADATA}; From 97deae5772e7ce65385e083b9a5bf8a4808ffb18 Mon Sep 17 00:00:00 2001 From: ldassin Date: Thu, 9 Nov 2023 16:14:16 +0100 Subject: [PATCH 2/6] Fixed an issue with producer Id prefixes --- CODE/cgi-bin/postCLB.pl | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/CODE/cgi-bin/postCLB.pl b/CODE/cgi-bin/postCLB.pl index e254dbf2..8b349cd3 100755 --- a/CODE/cgi-bin/postCLB.pl +++ b/CODE/cgi-bin/postCLB.pl @@ -152,11 +152,26 @@ =head1 Query string parameters my $password = ""; my $dbh = DBI->connect($dsn, $userid, $password, { RaiseError => 1 }) or die $DBI::errstr; + + # reading the NODEName dataset row to get the producer id + my $stmt = qq(SELECT identifier FROM datasets WHERE identifier LIKE "\%$GRIDName.$NODEName"); + my $sth = $dbh->prepare( $stmt ); + my $rv = $sth->execute() or die $DBI::errstr; + + if($rv < 0) { + print $DBI::errstr; + } + + my $producerId; + + while( my @row = $sth->fetchrow_array() ) { + $producerId = (split /_/, $row[0])[0]; + } - my $station = $GRIDName.'.'.$NODEName; - my $dataset = 'OBSE_DAT_'.$GRIDName.'.'.$NODEName; - my $dataname = 'OBSE_OBS_'.$GRIDName.'.'.$NODEName.'_'.$GRID{THEIA_SELECTED_TS}.'.txt'; - my $extension= $NODEName.'_'.$GRID{THEIA_SELECTED_TS}.'.txt'; + my $station = $GRIDName.'.'.$NODEName; + my $dataset = "$producerId\_DAT_$GRIDName.$NODEName"; + my $dataname = "$producerId\_OBS_$GRIDName.$NODEName\_$GRID{THEIA_SELECTED_TS}.txt"; + my $extension = "$NODEName\_$GRID{THEIA_SELECTED_TS}.txt"; my $filepath; foreach (@donnees) { @@ -169,8 +184,8 @@ =head1 Query string parameters my $chan = $obs[2]; # observations table - my $obsid = 'OBSE_OBS_'.$GRIDName.'.'.$NODEName.'_'.$id; - my @first_date = split(/ /,$obs[0]); + my $obsid = "$producerId\_OBS_$GRIDName.$NODEName\_$id"; + my @first_date = split(/ /,$obs[0]); my $first_year = $first_date[0]; my $first_hour = $first_date[3] || "00"; my $first_minute = $first_date[4] || "00"; From e504b33a5d9878ed298b071754240089bd5226f8 Mon Sep 17 00:00:00 2001 From: ldassin Date: Thu, 9 Nov 2023 16:18:07 +0100 Subject: [PATCH 3/6] fixed some bugs --- CODE/cgi-bin/formNODE.pl | 58 +++++++++++++++++++++++++--------------- CODE/cgi-bin/postNODE.pl | 14 +++++++--- 2 files changed, 46 insertions(+), 26 deletions(-) diff --git a/CODE/cgi-bin/formNODE.pl b/CODE/cgi-bin/formNODE.pl index 6b17409b..46049d5c 100755 --- a/CODE/cgi-bin/formNODE.pl +++ b/CODE/cgi-bin/formNODE.pl @@ -244,7 +244,7 @@ =head1 Query string parameters } # ---- load the database information if NODE is already filled out in the contacts table -my $stmt = qq(SELECT * FROM contacts WHERE EXISTS ( SELECT related_id from contacts ) AND related_id LIKE "\%$GRIDName.$NODEName"); +my $stmt = qq(SELECT * FROM contacts WHERE EXISTS ( SELECT related_id from contacts ) AND related_id LIKE "$usrProducer\%$GRIDName.$NODEName"); my $sth = $dbh->prepare( $stmt ); my $rv = $sth->execute() or die $DBI::errstr; @@ -371,28 +371,42 @@ =head1 Query string parameters for (var i=0; i 1) { - for (var i=0; i1) { + for (var i=0; iprepare('INSERT OR REPLACE INTO sampling_features (IDENTIFIER, NAME, GEOMETRY) VALUES (?,?,?);'); $sth->execute($alias,$alias,$point); - - $sth = $dbh->prepare('INSERT OR REPLACE INTO datasets (IDENTIFIER, TITLE, DESCRIPTION, SUBJECT, SPATIALCOVERAGE, LINEAGE) VALUES (?,?,?,?,?,?);'); - $sth->execute($id,$name,$desc,$subject,$spatialcov,$lineage); + + if ($spatialcov eq "") { + $sth = $dbh->prepare('INSERT OR REPLACE INTO datasets (IDENTIFIER, TITLE, DESCRIPTION, SUBJECT, LINEAGE) VALUES (?,?,?,?,?);'); + $sth->execute($id,$name,$desc,$subject,$lineage); + } else { + $sth = $dbh->prepare('INSERT OR REPLACE INTO datasets (IDENTIFIER, TITLE, DESCRIPTION, SUBJECT, SPATIALCOVERAGE, LINEAGE) VALUES (?,?,?,?,?,?);'); + $sth->execute($id,$name,$desc,$subject,$spatialcov,$lineage); + } $dbh->disconnect(); } From 8b5fdd88b19270b084865174ea9ce014b9f92cee Mon Sep 17 00:00:00 2001 From: ldassin Date: Mon, 13 Nov 2023 13:39:56 +0100 Subject: [PATCH 4/6] fixed an issue with the coordinates in geojson format --- CODE/cgi-bin/postTHEIA.pl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CODE/cgi-bin/postTHEIA.pl b/CODE/cgi-bin/postTHEIA.pl index 0a4754ad..e60b1e67 100755 --- a/CODE/cgi-bin/postTHEIA.pl +++ b/CODE/cgi-bin/postTHEIA.pl @@ -227,9 +227,10 @@ sub compressTxtFiles { my $lon = $coordinates[1]; $coordinates[2] = $coordinates[2] + 0; my $alt = $coordinates[2]; + my @new_crds = ($coordinates[1],$coordinates[0]); my %geometry = ( type => (split '\(|\)', $geometry)[0], - coordinates => \@coordinates, + coordinates => \@new_crds, ); my %samplingFeature = ( name => $row[6], From 9c80112ab27f70c3746bffb9680a5afbcbbc4598 Mon Sep 17 00:00:00 2001 From: ldassin Date: Mon, 13 Nov 2023 13:42:12 +0100 Subject: [PATCH 5/6] added the possibility to select nodes and channels that we want to send to THEIA --- CODE/cgi-bin/formCLB.pl | 2 +- CODE/cgi-bin/formGRID.pl | 2 +- CODE/cgi-bin/gridsMgr.pl | 6 ---- CODE/cgi-bin/listGRIDS.pl | 53 +++++++++++++++++++++++++++++-- CODE/cgi-bin/showNODE.pl | 3 +- CODE/cgi-bin/showTHEIA.pl | 13 ++++---- CODE/css/listGRIDS.css | 65 +++++++++++++++++++++++++++++++++++++++ 7 files changed, 127 insertions(+), 17 deletions(-) diff --git a/CODE/cgi-bin/formCLB.pl b/CODE/cgi-bin/formCLB.pl index 539d71dd..15f528cf 100755 --- a/CODE/cgi-bin/formCLB.pl +++ b/CODE/cgi-bin/formCLB.pl @@ -83,7 +83,7 @@ sub sort_clb_lines { if (%CLBS) { @clbNote = wiki2html(join("",readFile($CLBS{NOTES}))); @fieldCLB = readCfg($CLBS{FIELDS_FILE}); - if ( $theiaAuth != 1 ) { pop(@fieldCLB); } + unless ( isok($theiaAuth) ) { pop(@fieldCLB); } if (@fieldCLB) { $fileDATA = "$NODES{PATH_NODES}/$NODEName/$GRIDType.$GRIDName.$NODEName.clb"; $fileDATA = "$NODES{PATH_NODES}/$NODEName/$NODEName.clb" if ( ! -e $fileDATA ); # for backwards compatibility diff --git a/CODE/cgi-bin/formGRID.pl b/CODE/cgi-bin/formGRID.pl index 0283483d..cb9a0272 100755 --- a/CODE/cgi-bin/formGRID.pl +++ b/CODE/cgi-bin/formGRID.pl @@ -66,7 +66,7 @@ =head1 CONFIGURATION VARIABLES use WebObs::Form; use WebObs::Utils; use WebObs::i18n; -my $me = $ENV{SCRIPT_NAME}; + # ---- misc inits # set_message(\&webobs_cgi_msg); diff --git a/CODE/cgi-bin/gridsMgr.pl b/CODE/cgi-bin/gridsMgr.pl index 798c8d74..d9d2af32 100755 --- a/CODE/cgi-bin/gridsMgr.pl +++ b/CODE/cgi-bin/gridsMgr.pl @@ -137,12 +137,6 @@ =head1 QUERY-STRING PARAMETERS push(@nameFunders, (split ':|\(', $_)[1]); push(@acronyms, (split '\(|\)', $_)[1]); } -=pod -my @typeFunders= split('_,', (split '\|', $QryParm->{'funders'})[0]); -my @idScanR = split('_,', (split '\|', $QryParm->{'funders'})[1]); -my @funders = split('_,', (split '\|', $QryParm->{'funders'})[2]); -my @acronyms = split('_,', (split '\|', $QryParm->{'funders'})[3]); -=cut my @onlineRes = split('_,', $QryParm->{'onlineRes'}); foreach (@onlineRes) { diff --git a/CODE/cgi-bin/listGRIDS.pl b/CODE/cgi-bin/listGRIDS.pl index 11908ff2..f4de5abc 100755 --- a/CODE/cgi-bin/listGRIDS.pl +++ b/CODE/cgi-bin/listGRIDS.pl @@ -223,6 +223,7 @@ sub getDomainSefrans { print ""; print WebObs::Search::searchpopup(); print geditpopup(); + print feditpopup(); # ---- The GRIDS table # @@ -232,7 +233,7 @@ sub getDomainSefrans { if ($subsetDomain eq "") { print ""; if (WebObs::Users::clientHasAdm(type=>"authmisc",name=>"*")) { - print "    "; + print "    "; } print "Domain"; } @@ -246,7 +247,10 @@ sub getDomainSefrans { print "Type" if ($showType); print "Owner" if ($showOwnr); print "Graphs"; - print "Raw Data" if ($wantProcs || $wantSefrans); + if (WebObs::Users::clientHasAdm(type=>"authviews",name=>"*") && WebObs::Users::clientHasAdm(type=>"authprocs",name=>"*") ) { + print " " if ($wantProcs || $wantSefrans); + } + print "   Raw Data" if ($wantProcs || $wantSefrans); print "\n"; for my $d (@$domains) { my ($dc, $dn) = @$d; @@ -477,6 +481,51 @@ sub geditpopup { return $SP; } +# ---- helper edit form popup +sub feditpopup { + # prepares a list of form's templates +=pod + my @tplates; + my @tmp = glob("$WEBOBS{ROOT_CODE}/tplates/{VIEW,PROC,SEFRAN}.*"); + foreach my $t (@tmp) { + if (! -l $t) { + my @conf = readCfg($t); + next if (@conf == 1); # readCfg returns [0] if the file is empty + my %G = @conf; + $t =~ s/$WEBOBS{ROOT_CODE}\/tplates\///; + my ($gt,$gn) = split(/\./,$t); + push(@tplates,"$gt|$gn|".u2l($G{NAME})); + } + } +=cut + my $SP = ""; + $SP .= "
"; + $SP .= "
"; + $SP .= "

Create/edit a FORM

"; +=pod + $SP .= ""; + $SP .= " \n"; + $SP .= "

"; +=cut + $SP .= ""; + $SP .= " \n"; + $SP .= "

"; + + $SP .= "

"; + $SP .= ""; + $SP .= ""; + $SP .= "

"; + $SP .= "
"; + return $SP; +} + __END__ =pod diff --git a/CODE/cgi-bin/showNODE.pl b/CODE/cgi-bin/showNODE.pl index 1c03954d..53c73fb5 100755 --- a/CODE/cgi-bin/showNODE.pl +++ b/CODE/cgi-bin/showNODE.pl @@ -12,6 +12,7 @@ =head1 DESCRIPTION Displays data associated to a NODE identified by its fully qualified name (node=gridtype.gridname.nodename) +Although a NODE is an independent entity, a GRID-context (the 2 high level qualifiers of the Although a NODE is an independent entity, a GRID-context (the 2 high level qualifiers of the fully qualified nodename) is required as a validation/authorization/reference information. @@ -640,7 +641,7 @@ =head1 Query string parameters print "M3G GNSS Metadata"; } #print "".join("
",$m3g_link_sitelog,$m3g_link_gml,$m3g_xml,$txt_rec,$txt_ant)."\n"; print "".join("
",$m3g_link_sitelog,$m3g_link_gml,$m3g_xml)."
\n"; - print "
Receiver history featureAntenna history feature>
".wiki2html($txt_rec)."".wiki2html($txt_ant)."
"; + print "
Receiver history featureAntenna history feature
".wiki2html($txt_rec)."".wiki2html($txt_ant)."
"; } diff --git a/CODE/cgi-bin/showTHEIA.pl b/CODE/cgi-bin/showTHEIA.pl index 9202beb6..0f33209d 100755 --- a/CODE/cgi-bin/showTHEIA.pl +++ b/CODE/cgi-bin/showTHEIA.pl @@ -192,11 +192,12 @@ =head1 DESCRIPTION my %G = readProc($GRIDName); #print $G{$GRIDName}."\n"; %GRID = %{$G{$GRIDName}}; - my @NODELIST = split / /,$GRID{THEIA_SELECTED_NODELIST}; + my @NODELIST = split /,/,$GRID{THEIA_SELECTED_NODELIST}; if ( clientHasEdit(type=>"auth".lc($GRIDType)."s",name=>"$GRIDName") || clientHasAdm(type=>"auth".lc($GRIDType)."s",name=>"$GRIDName") ){ - if ( grep(/^$NODEName$/,@NODELIST) || substr($NODEName, 1) ~~ $GRID{THEIA_SELECTED_NODELIST}) { + #if ( grep(/^$NODEName/,@NODELIST) || substr($NODEName, 1) ~~ @NODELIST) { + if ( $GRID{THEIA_SELECTED_NODELIST} =~ substr($NODEName,1) ) { my $subject = join(',', split(/_/,$row[3])); - push(@NODELIST, $NODEName); + #push(@NODELIST, $NODEName); # ---- extracting datasets contacts data my $stmt2 = qq(SELECT * FROM contacts WHERE related_id LIKE '$row[0]%';); @@ -281,10 +282,10 @@ =head1 DESCRIPTION @CHANLIST = split /,/,$NODE{"PROC.$GRIDName.CHANNEL_LIST"}; my $fileDATA = "$NODES{PATH_NODES}/$NODEName/PROC.$GRIDName.$NODEName.clb"; my @donnees = map { my @e = split /\|/; \@e; } readCfgFile($fileDATA); - my @vars = map {$donnees[$_-1]} @CHANLIST; - #print $donnees[0]; + my @vars = map {$donnees[$_-1][3]} @CHANLIST; if ( clientHasEdit(type=>"auth".lc($GRIDType)."s",name=>"$GRIDName") || clientHasAdm(type=>"auth".lc($GRIDType)."s",name=>"$GRIDName") ) { - if ( (grep(/^$NODEName$/,@NODELIST) || substr($NODEName, 1) ~~ $GRID{THEIA_SELECTED_NODELIST}) and $channelId ~~ @vars) { + #if ( grep(/^$NODEName/,@NODELIST) || substr($NODEName, 1) ~~ @NODELIST and $channelId ~~ @vars) { + if ( $GRID{THEIA_SELECTED_NODELIST} =~ substr($NODEName,1) and $channelId ~~ @vars ) { my $subject = join(',', split(/_/,$row[3])); print "" ."" diff --git a/CODE/css/listGRIDS.css b/CODE/css/listGRIDS.css index 17de3e67..dc8fb395 100644 --- a/CODE/css/listGRIDS.css +++ b/CODE/css/listGRIDS.css @@ -65,3 +65,68 @@ h2.h2gn { padding: 5px 0 5px 2px; float: left; } + +#feditovly { + display: none; + position: fixed; + top:0px; left:0px; width:100%; height:100%; + text-align:center; vertical-align:middle; + opacity: 0.4; + background-color:#000000; + z-index: 10000; +} + +#feditoverlay_form { + position: absolute; + border: 3px solid gray; + border-radius: 5px; + padding: 10px; + background: #FFFFEE; + width: 440px; + height: auto; + opacity: 1; + z-index: 10001; +} +#feditoverlay_form label{ + display:block; + font-weight:bold; + text-align:right; + width:120px; + float:left; +} +#feditoverlay_form .small{ + color: #666666; + display:block; + font-size: x-small; + font-weight: lighter; + text-align:right; + width:120px; +} +#feditoverlay_form input[type=text]{ + float:left; + padding:4px 2px; + border:solid 1px #aacfe4; + width:300px; + margin:2px 0 15px 10px; +} +#feditoverlay_form input[type=checkbox]{ + float:left; + padding:4px 2px; + /* + border:solid 1px #aacfe4; + margin:2px 0 15px 10px; + */ +} +#feditoverlay_form select{ + float:left; + padding:1px 1px; +} +#feditoverlay_form p { + background: #EAE4CE; + width: 100%; + height: 20px; + padding: 5px 0 5px 2px; + float: left; +} + + From 8c9d6c6a7a1aca72da67d93644ea415daacf9117 Mon Sep 17 00:00:00 2001 From: ldassin Date: Mon, 13 Nov 2023 13:42:47 +0100 Subject: [PATCH 6/6] Added geodesy version of XML.pm --- CODE/cgi-bin/WebObs/GML.pm | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CODE/cgi-bin/WebObs/GML.pm b/CODE/cgi-bin/WebObs/GML.pm index e70615ac..cf9cd466 100755 --- a/CODE/cgi-bin/WebObs/GML.pm +++ b/CODE/cgi-bin/WebObs/GML.pm @@ -253,4 +253,8 @@ sub gml2mmdtable { return @outlines; } +sub gml2date { + +} + 1;