Skip to content
Merged
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
2 changes: 1 addition & 1 deletion app/Providers/EventServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class EventServiceProvider extends ServiceProvider
*/
public function boot()
{
parent::boot();
//parent::boot();

//
}
Expand Down
523 changes: 523 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
},
"dependencies": {
"@fortawesome/fontawesome-free": "^5.13.1",
"express": "^4.17.1",
"mxgraph": "file:mxgraph",
"save-svg-as-png": "^1.4.17"
"save-svg-as-png": "^1.4.17",
"socket.io": "^4.4.0"
}
}
4 changes: 4 additions & 0 deletions public/js/Compiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -718,6 +718,10 @@ function updateSaveButtonInFrontEnd(saved) {
saveOntology.classList.add("saved");
saveOntology.innerHTML = message;
saveOntology.prepend(icon);

if (document.getElementById('id').value > 0) {
socket.emit('updateOntology', document.getElementById('id').value);
}
} else {
if (getLanguage() == "pt")
message = "Alterações não salvas. Clique aqui para salvar";
Expand Down
19 changes: 17 additions & 2 deletions public/js/OntologyManager.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
var ontologyName = document.getElementById("ontology-name");

const ip_address = '127.0.0.1';
const socket_port = '3000'; // porta node
let socket = io(ip_address + ":" + socket_port);

Comment on lines +3 to +6
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Imagino que só está funcionando localmente né? Preciso que você faça outro commit pra fazer funcionar em produção também, por favor.

function saveName(event) {
if (event.key == 'Enter') {
document.getElementById('save-ontology').click();
Expand Down Expand Up @@ -38,13 +42,14 @@ document.addEventListener("DOMContentLoaded", function () {

// Fires the Ajax request when the button is clicked
// Open the selected ontology
$(".openOntology").click(function () {

function updateOntology(id) {
$.ajax({
/* the route pointing to the post function */
url: '/openOntology',
type: 'POST',
/* send the csrf-token and the input to the controller */
data: { _token: CSRF_TOKEN, id: this.getAttribute('id') },
data: { _token: CSRF_TOKEN, id: id },
dataType: 'JSON',
/* remind that 'data' is the response of the OntologyController */
success: function (data) {
Expand Down Expand Up @@ -94,6 +99,16 @@ document.addEventListener("DOMContentLoaded", function () {
updateSaveButtonErrorInFrontEnd();
}
})
}

$(".openOntology").click(function () {
updateOntology(this.getAttribute('id'));
});

socket.on('updateOntology', (ontologyID) => {
if (ontologyID == document.getElementById('id').value) {
updateOntology(document.getElementById('id').value);
}
});
});

Expand Down
1 change: 1 addition & 0 deletions resources/views/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -1105,6 +1105,7 @@
<script type="text/javascript" src="{{asset('js/Compiler.js')}}"></script>
<script type="text/javascript" src="{{asset('js/Converter.js')}}"></script>
<script type="text/javascript" src="{{asset('js/ClassExpressionEditor.js')}}"></script>
<script src="https://cdn.socket.io/4.0.1/socket.io.min.js" integrity="sha384-LzhRnpGmQP+lOvWruF/lgkcqD+WDVt9fU3H4BWmwP5u5LTmkUGafMcpZKNObVMLU" crossorigin="anonymous"></script>
<script type="text/javascript" src="{{asset('js/OntologyManager.js')}}"></script>
<script type="text/javascript" src="{{asset('js/Cell.js')}}"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.5.3/jspdf.debug.js" integrity="sha384-NaWTHo/8YCBYJ59830LTz/P4aQZK1sS0SneOgAvhsIl3zBu8r9RevNg5lHCHAuQ/" crossorigin="anonymous">
Expand Down
1 change: 1 addition & 0 deletions routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@

// Ontologies CRUD
Route::resource('/ontologies', OntologyController::class)->middleware('can:eModelador');

Route::get('/ontologies/download/{userId}/{ontologyId}', [OntologyController::class, 'downloadXML'])->name('ontologies.download')->middleware('can:eModelador');
Route::get('/ontologies/downloadOWL/{userId}/{ontologyId}', [OntologyController::class, 'downloadOWL'])->name('ontologies.downloadOWL')->middleware('can:eModelador');
Route::get('/ontologies/downloadSVG/{userId}/{ontologyId}', [OntologyController::class, 'downloadSVG'])->name('ontologies.downloadSVG')->middleware('can:eModelador');
Expand Down
25 changes: 25 additions & 0 deletions server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const express = require('express');
const app = express();
const server = require('http').createServer(app);
const io = require('socket.io')(server, {
cors: { origin: "*"}
});

io.on('connection', (socket) => {
//console.log('Conectado');

socket.on('updateOntology', (ontologyID) => {
//console.log(ontologyID);

//io.sockets.emit('updateOntology', ontologyID)
socket.broadcast.emit('updateOntology', ontologyID)
});

socket.on('disconnect', (socket) => {
//console.log('Desconectado');
});
})

server.listen(3000, () => {
console.log('Servidor iniciado.');
})