Skip to content

Commit

Permalink
dernier push
Browse files Browse the repository at this point in the history
  • Loading branch information
guillaume-peyet committed Aug 8, 2013
1 parent fc20c58 commit 594b736
Show file tree
Hide file tree
Showing 11 changed files with 274 additions and 28 deletions.
68 changes: 67 additions & 1 deletion SwipWebClientSparql/css/styleAdmin.css
@@ -1,3 +1,22 @@
/*
* Généralités
*/
h1, h2
{
cursor: pointer;
}

h2
{
text-align: center;
font-size: 1.2em;
margin: 10px;
color: rgb(100, 60, 60);
}

/*
* Styles d'édition des préfixes
*/
#prefixes label
{
display: inline-block;
Expand Down Expand Up @@ -37,7 +56,54 @@ fieldset
border: groove 2px #508AC5;
}

/*
* Mise en évidence des patrons désactivés
*/

.patternDisactivated
{
background-color: #FF8282;
}
}

/*
* partie Update Patterns
*/
#updatePatterns
{
text-align: center;
display: none;
}

#translatingOptionsPart, #sendingOptionsPart
{
display: none;
}

#inputFile
{
display: none;
}

#selectFileButton
{
margin-bottom: 10px;
}

#updatePatterns textarea
{
width: 800px;
height: 400px;
}

#updatePatterns label
{
display: inline-block;
width: 200px;
text-align: right;
margin-left: 5px;
}

#updatePatterns input[type=text]
{
width: 300px;
}
121 changes: 119 additions & 2 deletions SwipWebClientSparql/js/admin.js
Expand Up @@ -6,7 +6,7 @@ function removePrefix(event) {
$.ajax
({
type: 'POST',
url: 'http://localhost/SWIP_Admin/php/deletePrefixes.php',
url: 'http://swip.univ-tlse2.fr/SwipWebClient/php/deletePrefixes.php',
data: { uri: id }
})
.done(function(data) {
Expand All @@ -27,7 +27,124 @@ function removePrefix(event) {
});
}

function showHideAfterTitle()
{
var nextElem = $(this).next();

if (nextElem.is(':visible'))
nextElem.slideUp('normal');
else
nextElem.slideDown('normal', function () {
var scollHeight = nextElem.offset().top;

$('html,body').animate({
scrollTop: scollHeight
}, 'normal');
});
}

$(function (){
// upload des nouveau patterns
$('h1, h2').click(showHideAfterTitle);

$('#selectFileButton').click(function(){
$('#inputFile').click();
});

$('#inputFile').change(function(){
var form = new FormData($('#updatePatterns form')[0]);

$.ajax({
url: './readFile.php',
type: 'POST',
xhr: function() {
var myXhr = $.ajaxSettings.xhr();
return myXhr;
},
data: form,
cache: false,
contentType: false,
processData: false
})
.success(function (data) {
$('#patternText').val(data);
})
.error(function(jqXHR){
alert('Unable to load this file...\n' + jqXHR.responseText);
});
});

$('#upload').click(function(){
var patternName = $('#patternName').val();
var ontologyUri = $('#ontologyUri').val();
var authorUri = $('#authorUri').val();
var patternsText = $('#patternText').val();

$.ajax({
url: 'http://swip.univ-tlse2.fr/Patterns/PatternsWS/rest/patternsTextToRdf',
type: 'POST',
dataType: 'text',
data: {
setName: patternName,
ontologyUri: ontologyUri,
authorUri: authorUri,
patterns: patternsText
}
})
.success(function (data) {
if ($('#results').length == 0) {
$('#updatePatterns').append("<h2 id = 'titleResultsPart'>Translation results</h2>\n" +
"<form>\n" +
" <textarea id = 'results'>\n" +
data + "\n" +
" </textarea>\n" +
" <br />\n" +
" <h2 id = 'titleSendingPart'>Sending Options</h2>\n" +
" <div id = 'sendingOptionsPart'>\n" +
" <label for = 'dir'>Directory" +
" <sup title = 'Subdirectory of \"/stockage/data/\"'>1</sup>:" +
" </label>\n" +
" <input type='text' id='dir' value='musicbrainz/rdfdata-patterns/' />\n"+
" <br />\n" +
" <label for = 'fName'>File name:</label>" +
" <input type = 'text' id = 'fName' value = 'patterns-rdf.xml' />" +
" </div>\n" +
" <input id = 'sendServer' type = 'button' value = 'Send to the server' />\n"+
"</form>\n");
$('#titleSendingPart').click(showHideAfterTitle);
$('#sendServer').click(function(){
var patternsXML = $('#results').val();
var dir = $('#dir').val();
var fName = $('#fName').val();
$.ajax({
url: 'http://swip.univ-tlse2.fr/SwipWebClient/php/saveFile.php',
type: 'POST',
dataType: 'text',
data: {
subdirectory: dir,
fileName: fName,
content: patternsXML
}
})
.success(function () {
alert('Patterns saved ! Think to launch tdbloader and restart fuseki...')
})
.error(function(jqXHR){
alert("Unable to save patterns : " + jqXHR.responseText);
});
});
} else {
$('#results').val(data);
}

if (!$('#titleResultsPart').is(':visible'))
$('#titleResultsPart').click(showHideAfterTitle).click();
})
.error(function(jqXHR){
alert('Unable to upload patterns...');
});
});

// anime le bouton d'ajout de préfixe
$('#addButton').mousedown(function(){
this.src = "../img/addButtonClick.png";
Expand Down Expand Up @@ -75,7 +192,7 @@ $(function (){
$.ajax
({
type: 'POST',
url: 'http://localhost/SWIP_Admin/php/addPrefixes.php',
url: 'http://swip.univ-tlse2.fr/SwipWebClient/php/addPrefixes.php',
data: { uri: uri, prefix: prefix }
})
.done(function(data) {
Expand Down
10 changes: 5 additions & 5 deletions SwipWebClientSparql/js/arbor.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion SwipWebClientSparql/js/patternViewer.js
Expand Up @@ -191,7 +191,7 @@ function loadPrefixes()
({
type: 'GET',
dataType: "json",
url: 'http://localhost/SWIP_Admin/php/listPrefixes.php'
url: 'http://swip.univ-tlse2.fr/SwipWebClient/php/listPrefixes.php'
})
.done(function(data) {
listPrefixes = data;
Expand Down
7 changes: 4 additions & 3 deletions SwipWebClientSparql/patternViewer.html
Expand Up @@ -78,7 +78,7 @@

<div class = "item" id = "connection">
<img class = "showHideButton" src = "./img/padlock.png" />
<form class = "panel" action = "./PHP/admin.php" method = "post">
<form class = "panel" action = "./php/admin.php" method = "post">
<label for = "id">Login: </label>
<input type = "text" id = "id" name = "id" />
<br />
Expand All @@ -97,7 +97,7 @@
</div>

<!-- scripts template -->
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="js/vendor/jquery-1.9.1.min.js"><\/script>')</script>
<script src="js/plugins.js"></script>

Expand All @@ -114,8 +114,9 @@
<script type="text/javascript" src="./js/jquery.ui.touch-punch.min.js"></script>

<!-- scripts perso -->
<script type="text/javascript" src="./js/jquery.jsPlumb-1.3.16-all-min.js "></script>
<script type="text/javascript" src="./js/jquery.jsPlumb-1.3.16-all-min.js"></script>
<script type="text/javascript" src="./js/arbor.js"></script>
<script type = "text/javascript" src = "./js/jquery-mousewheel.js"></script>
<script type = "text/javascript" src = "./js/matchRecursive.js"></script>

<script type = "text/javascript" src = "./js/semanticWebTools.js"></script>
Expand Down
26 changes: 25 additions & 1 deletion SwipWebClientSparql/php/admin.php
Expand Up @@ -12,7 +12,7 @@
<link rel="stylesheet" href="../css/global.css" type="text/css">
<link rel="stylesheet" href="../css/patternViewer.css" type="text/css">
<link rel="stylesheet" href="../css/styleAdmin.css" type="text/css">
</head>
</head>

<body>
<?php
Expand Down Expand Up @@ -119,6 +119,30 @@
<button id = "toggleMoving">Stop moving</button>
<div id = "layout">
</div>
<h1>Update Patterns</h1>
<div id = "updatePatterns">
<form>
<input type = "file" id = "inputFile" name = "inputFile" />
<input type = "button" id = "selectFileButton" value = "Load file" />
<br />
<textarea id = "patternText"></textarea>
<br />

<h2>Translating Options</h2>
<p id = "translatingOptionsPart">
<label for = "patternName">Pattern set name:</label>
<input type = "text" id = "patternName" value = "musicbrainz"/>
<br />
<label for = "ontologyUri">Targeted ontology URI:</label>
<input type = "text" id = "ontologyUri" value = "http://purl.org/ontology/mo/"/>
<br />
<label for = "authorUri">Author URI:</label>
<input type = "text" id = "authorUri" value = "http://camillepradel.com/uris#me"/>
</p>

<input type = "button" id = "upload" value = "Upload patterns" />
</form>
</div>
</div>

<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js"></script>
Expand Down
15 changes: 15 additions & 0 deletions SwipWebClientSparql/php/readFile.php
@@ -0,0 +1,15 @@
<?php
if (isset($_FILES['inputFile'])){
//checks for errors and checks that file is uploaded
if ($_FILES['inputFile']['error'] == UPLOAD_ERR_OK && is_uploaded_file($_FILES['inputFile']['tmp_name']))
{
echo file_get_contents($_FILES['inputFile']['tmp_name']);
}
else
{
echo 'Unable to load this file...';
}
} else {
echo 'No file found...';
}
?>
23 changes: 23 additions & 0 deletions SwipWebClientSparql/php/saveFile.php
@@ -0,0 +1,23 @@
<?php
include 'util/sessions.php';

initConnections();

if ($isConnected)
{
if (isset($_POST['content']) && isset($_POST['subdirectory']) && isset($_POST['fileName'])) {
$filePath = "/stockage/data/".$_POST['subdirectory'].$_POST['fileName'];
$file = fopen($filePath, "w");
if (!$file) {
throw new Exception("Unable to create the file at path : \"".$filePath."\"");
} else {
fputs($file, $_POST['content']);
fclose($file);
}
} else {
throw new Exception('Any content to save...');
}
} else {
throw new Exception("You don't have administrator rights....");
}
?>
2 changes: 1 addition & 1 deletion SwipWebClientSparql/php/util/codesBD.php
@@ -1,4 +1,4 @@
<?php
<?php
// identifiants de connexion en local :
define('LOGIN', "root");
define('PASSWORD', "");
Expand Down
2 changes: 1 addition & 1 deletion SwipWebClientSparql/php/util/dataBases.php
@@ -1,4 +1,4 @@
<?php
<?php
/***********************************
* Connexions à la base de données *
***********************************/
Expand Down

0 comments on commit 594b736

Please sign in to comment.