This commit is contained in:
2020-12-01 17:23:13 -03:00
parent 09e8c226bb
commit 9852a8cbdc
274 changed files with 24706 additions and 0 deletions

81
public/js/admin.js Normal file
View File

@ -0,0 +1,81 @@
$(document).ready(function() {
$('#databases').submit(function(e) {
e.preventDefault();
var db = $("[name='database']").val();
var models = [];
var namespaces = [];
$.post('?p=admin&action=listModels', {"database": db}).done(function(data) {
//console.debug(data);
var info = $.parseJSON(data);
//console.debug(info.models);
models = info.models;
//console.debug(models);
$.post('?p=admin&action=listNamespaces').done(function(data) {
//console.debug(data);
info = $.parseJSON(data);
//console.debug(info.models);
namespaces = info.namespaces;
//console.debug(namespaces);
$.each(models, function(i, elem) {
var div = $('<div></div>').attr('class', 'row');
div.append($('<div></div>').attr('class', 'col-md-2').html(elem.model));
var div2 = $('<div></div>').attr('class', 'row');
$.each(namespaces, function(j, ns) {
div2.append($('<div></div>').attr('class', 'col-md-3').append($('<span></span>').attr('class', 'ns').attr('data-table', elem.table).attr('data-ns', ns).html(ns)));
});
div.append($('<div></div>').attr('class', 'col-md-9').append(div2));
div.append($('<div></div>').attr('class', 'col-md-1 remove').append($('<span></span>').attr('class', 'glyphicon glyphicon-remove')));
$('#results').append(div);
});
$('.ns').css('cursor', 'pointer');
$('.remove').css('cursor', 'pointer');
$('.ns').mouseover(function(e) {
$(this).parent().addClass('bg-success');
$(this).parent().parent().parent().parent().addClass('bg-warning');
}).mouseout(function(e) {
$(this).parent().removeClass('bg-success');
$(this).parent().parent().parent().parent().removeClass('bg-warning');
});
$('.remove').mouseover(function(e) {
$(this).parent().addClass('bg-danger');
}).mouseout(function(e) {
$(this).parent().removeClass('bg-danger');
});
$('.ns').click(function(e) {
var table = $(this).attr('data-table');
var ns = $(this).attr('data-ns');
execute(table, ns);
});
$('.remove').click(function(e) {
$(this).parent().remove();
});
});
});
return false;
});
});
function execute(table, ns) {
console.debug(table, ns);
var db = $("[name='database']").val();
$.post('?p=admin&action=createModel', {"table": table, "namespace": ns, "database": db}).done(function(data) {
console.debug(data);
var info = $.parseJSON(data);
console.debug(info);
if (info.result) {
$(".ns[data-table='" + table + "']").parent().parent().parent().parent().remove();
} else {
alert('Error');
}
});
}

89
public/js/app.js Normal file

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,56 @@
$(document).ready(function(e) {
$('.glyphicon-copy').click(function(ev) {
var name = $(this).attr('data-name');
var n = $(this).attr('data-n');
var total = $("input[name='cuotas']").val();
if (name == 'fecha') {
copyDate(n, total);
return;
}
var value = $("input[name='" + name + n + "']").val();
if (value == '') {
return;
}
if (name == 'numero') {
copyIncrement(name, value, n, total);
return;
}
copyDown(name, value, n, total);
});
});
function copyDate(start, end) {
var d = $("select[name='day" + start + "']").val()
var m = $("select[name='month" + start + "']").val() - 1
var y = $("select[name='year" + start + "']").val()
var f = new Date(y, m, d)
for (i = parseInt(start) + 1; i < end; i ++) {
f = new Date(f.setMonth(f.getMonth() + 1));
if (f.getDate() < d) {
f.setDate(0)
}
$("select[name='day" + i + "']").val(f.getDate())
$("select[name='month" + i + "']").val(f.getMonth() + 1)
$("select[name='year" + i + "']").val(f.getFullYear())
}
}
function copyIncrement(name, value, start, end, type = 'input') {
var val = parseInt(value) + 1;
for (i = parseInt(start) + 1; i < end; i ++) {
$(type + "[name='" + name + i + "']").val(val ++);
}
}
function copyDown(name, value, start, end, type = 'input') {
for (i = parseInt(start) + 1; i < end; i ++) {
$(type + "[name='" + name + i + "']").val(value);
}
}