Skip to content
Merged

Dev #143

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CODE/cgi-bin/WebObs/GML.pm
Original file line number Diff line number Diff line change
Expand Up @@ -253,4 +253,8 @@ sub gml2mmdtable {
return @outlines;
}

sub gml2date {

}

1;
2 changes: 1 addition & 1 deletion CODE/cgi-bin/formCLB.pl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion CODE/cgi-bin/formGRID.pl
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
80 changes: 53 additions & 27 deletions CODE/cgi-bin/formNODE.pl
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -371,28 +371,42 @@ =head1 Query string parameters
for (var i=0; i<form.SELs.length; i++) {
form.SELs[i].selected = true;
}

// registering the NODE contacts metadata
var roles = [];
var firstNames = [];
var lastNames = [];
var emails = [];
if (form.email.length > 1) {
for (var i=0; i<form.role.length; i++) {
if (form.firstName[i].value == "" || form.lastName[i].value == "" || form.email[i].value == "") {
alert("A creator must have a first name, a last name and an email adress !");
return false;
} else {
roles.push(form.role[i].value);
firstNames.push(form.firstName[i].value);
lastNames.push(form.lastName[i].value);
emails.push(form.email[i].value);
}
}
form.creators.value = roles.join(',') + '|' + firstNames.join(',') + '|' + lastNames.join(',') + '|' + emails.join(',');
} else {form.creators.value = form.role.value + '|' + form.firstName.value + '|' + form.lastName.value + '|' + form.email.value}

console.log(\$(\"#theform\").serialize());
console.log(form.outWKT.value)

if (form.saveAuth.value == 1) {
console.log(form.count_creator);
if ( form.producer.value == "" ) {
alert("Producer can't be empty !");
return false;
}
var nb_creators = form.count_creator.value;
if (nb_creators>1) {
for (var i=0; i<nb_creators; i++) {
if ( form.firstName[i].value == "" ) {
alert("First name can't be empty (make sure the right role is selected too) !");
return false;
}
if ( form.lastName[i].value == "" ) {
alert("Last name can't be empty (make sure the right role is selected too) !");
return false;
}
if ( form.email[i].value == "" ) {
alert("Email can't be empty (make sure the right role is selected too) !");
return false;
}
}
}
if ( form.topics.value == "" ) {
alert("You have to chose at least one topic category (check that you selected the right INSPIRE theme too) !");
return false;
}
if ( form.lineage.value == "" ) {
alert("Lineage can't be empty !");
return false;
}
}

if (\$(\"#theform\").hasChanged() || form.delete.value == 1 || form.locMap.value == 1) {
form.node.value = form.grid.value + form.nodename.value.toUpperCase();
Expand Down Expand Up @@ -718,7 +732,7 @@ =head1 Query string parameters
} geometry.coordinates = coordinates; return geometry;
} else {
geometry.type = "Polygon";
geometry.coordinates = [getBoundingBox(geojson.features.geometry.coordinates)];
geometry.coordinates = [getBoundingBox(geojson.features[0].geometry.coordinates)];
return geometry;
}
}
Expand Down Expand Up @@ -790,6 +804,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 &copy; Esri &mdash; Source: Esri, i-cubed, USDA, USGS, AEX, GeoEye, Getmapping, Aerogrid, IGN, IGP, UPR-EGP, and the GIS User Community';
Expand Down Expand Up @@ -1020,7 +1046,7 @@ =head1 Query string parameters
print "<LABEL style=\"width:80px\" for=\"description\">$__{'Description'}:</LABEL>";
print "<TEXTAREA rows=\"4\" onMouseOut=\"nd()\" onmouseover=\"overlib('$__{help_creationstation_description}')\" cols=\"40\" name=\"description\" id=\"description\">$usrDesc</TEXTAREA>&nbsp;&nbsp;<BR>";
# --- show THEIA fields ?
#print "<LABEL>$__{'show/hide THEIA metadata fields'} ?<INPUT name=\"showHide\" type=\"checkbox\" name=\"show/hide\" onchange=\"showHideTheia(this)\"></LABEL>&nbsp;<BR><BR>";
print "<DIV id=\"theiaChecked\" style=\"display:none;\"><LABEL>$__{'show/hide THEIA metadata fields'} ?<INPUT type=\"checkbox\" name=\"saveAuth\" onchange=\"showHideTheia(this)\" value=0></LABEL>&nbsp;<BR><BR></DIV>";
print "<DIV id=\"showHide\" style=\"display:none;\">";
# --- PRODUCER
print "<LABEL style=\"width:80px\" for=\"producer\">$__{'Producer'}:</LABEL>";
Expand Down Expand Up @@ -1158,14 +1184,14 @@ =head1 Query string parameters
print "</TD>";
print <<FIN;
<script>
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);
Expand Down
6 changes: 0 additions & 6 deletions CODE/cgi-bin/gridsMgr.pl
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
53 changes: 51 additions & 2 deletions CODE/cgi-bin/listGRIDS.pl
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ sub getDomainSefrans {
print "<a name=\"popupY\"></a>";
print WebObs::Search::searchpopup();
print geditpopup();
print feditpopup();

# ---- The GRIDS table
#
Expand All @@ -232,7 +233,7 @@ sub getDomainSefrans {
if ($subsetDomain eq "") {
print "<TH>";
if (WebObs::Users::clientHasAdm(type=>"authmisc",name=>"*")) {
print "&nbsp;<a href='/cgi-bin/gridsMgr.pl' title=\"$__{'Edit/Create a Domain'}\"><img class='ic' src='/icons/modif.png'></a>&nbsp;&nbsp;&nbsp;";
print "&nbsp;<a href='/cgi-bin/gridsMgr.pl' title=\"$__{'Edit/Create a Domain/Producer'}\"><img class='ic' src='/icons/modif.png'></a>&nbsp;&nbsp;&nbsp;";
}
print "Domain</TH>";
}
Expand All @@ -246,7 +247,10 @@ sub getDomainSefrans {
print "<TH>Type</TH>" if ($showType);
print "<TH>Owner</TH>" if ($showOwnr);
print "<TH>Graphs</TH>";
print "<TH>Raw Data</TH>" if ($wantProcs || $wantSefrans);
if (WebObs::Users::clientHasAdm(type=>"authviews",name=>"*") && WebObs::Users::clientHasAdm(type=>"authprocs",name=>"*") ) {
print "<TH>&nbsp;<a href='#popupY' title=\"$__{'Edit/Create a Form'}\" onclick='feditopenPopup(); return false;'><img class='ic' src='/icons/modif.png'></a>" if ($wantProcs || $wantSefrans);
}
print "&nbsp;&nbsp;&nbsp;Raw Data</TH>" if ($wantProcs || $wantSefrans);
print "</TR>\n";
for my $d (@$domains) {
my ($dc, $dn) = @$d;
Expand Down Expand Up @@ -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 .= "<div id=\"feditovly\" style=\"display:none\"></div>";
$SP .= "<form id=\"feditoverlay_form\" style=\"display:none\">";
$SP .= "<p><b><i>Create/edit a FORM</i></b></p>";
=pod
$SP .= "<label for=\"geditN\">$__{'Grid Type'}: <span class=\"small\">select a template</span></label>";
$SP .= " <select size=\"1\" id=\"geditT\" name=\"geditT\">\n";
foreach (@tplates) {
my ($gt,$gn,$gl) = split(/\|/,$_);
my $sel = "";
$sel = "selected" if (($subsetType eq 'all' && $gt eq 'VIEW') || ($gt eq uc($subsetType) && $gn eq 'DEFAULT'));
$SP .= " <option value=\"$gt.$gn\" $sel>$gt: $gl</option>\n";
}
$SP .= " </select>\n";
$SP .= "<br style=\"clear: left\"><br>";
=cut
$SP .= "<label for=\"feditN\">$__{'Form Name'}: <span class=\"small\">short name (uppercase)</span></label>";
$SP .= " <input size=\"40\" id=\"feditN\" name=\"feditN\" value=\"\">\n";
$SP .= "<br style=\"clear: left\"><br>";

$SP .= "<p style=\"margin: 0px; text-align: center\">";
$SP .= "<input type=\"button\" name=\"sendbutton\" value=\"$__{'Create'}\" onclick=\"feditsendPopup(); return false;\" style=\"font-weight:bold\" />";
$SP .= "<input type=\"button\" value=\"cancel\" onclick=\"feditclosePopup(); return false;\" />";
$SP .= "</p>";
$SP .= "</form>";
return $SP;
}

__END__

=pod
Expand Down
27 changes: 21 additions & 6 deletions CODE/cgi-bin/postCLB.pl
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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";
Expand Down
21 changes: 14 additions & 7 deletions CODE/cgi-bin/postNODE.pl
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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};
Expand Down Expand Up @@ -313,6 +314,7 @@ =head1 Query string parameters
push(@lines,"NAME|\"".u2l($name)."\"\n");
push(@lines,"ALIAS|".u2l($alias)."\n");
push(@lines,"TYPE|".u2l($type)."\n");
push(@lines,"DESCRIPTION|".u2l($desc)."\n");
push(@lines,"VALID|$valide\n");
push(@lines,"TZ|$tz\n");
push(@lines,"LAT_WGS84|$lat\n");
Expand All @@ -339,7 +341,7 @@ =head1 Query string parameters
push(@lines,"$GRIDType.$GRIDName.ACQ_RATE|$acqr\n");
push(@lines,"$GRIDType.$GRIDName.LAST_DELAY|$ldly\n");
push(@lines,"$GRIDType.$GRIDName.CHANNEL_LIST|".join(',',@chanlist)."\n");
push(@lines,"$GRIDType.$GRIDName.DESCRIPTION|$desc\n");
push(@lines,"$GRIDType.$GRIDName.DESCRIPTION|".u2l($desc)."\n");
}

# ---- other grid's parameters (not linked to the active grid) are transfered "as is"
Expand Down Expand Up @@ -433,7 +435,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};
Expand Down Expand Up @@ -479,9 +481,14 @@ =head1 Query string parameters

my $sth = $dbh->prepare('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();
}
Expand Down
3 changes: 2 additions & 1 deletion CODE/cgi-bin/postTHEIA.pl
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down
3 changes: 2 additions & 1 deletion CODE/cgi-bin/showNODE.pl
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -640,7 +641,7 @@ =head1 Query string parameters
print "M3G GNSS Metadata</TH>";
} #print "</TH><TD colspan=\"2\">".join("<br>",$m3g_link_sitelog,$m3g_link_gml,$m3g_xml,$txt_rec,$txt_ant)."</TD></TR>\n";
print "</TH><TD>".join("<br>",$m3g_link_sitelog,$m3g_link_gml,$m3g_xml)."<BR>\n";
print "<TABLE><TR><TH>Receiver history feature</TH><TH>Antenna history feature></TH></TR><TR><TD>".wiki2html($txt_rec)."</TD><TD>".wiki2html($txt_ant)."</TD></TR></TABLE></TD>";
print "<TABLE><TR><TH>Receiver history feature</TH><TH>Antenna history feature</TH></TR><TR><TD>".wiki2html($txt_rec)."</TD><TD>".wiki2html($txt_ant)."</TD></TR></TABLE></TD>";
}


Expand Down
Loading