Compare commits
No commits in common. 'baed641f31a9fe31a18064190a686ea1db060ac0' and 'ab663b1dec2b69c9c59f7a8d0f60a415dc8c18b8' have entirely different histories.
baed641f31
...
ab663b1dec
@ -1,118 +0,0 @@
|
||||
function new_user_entry() {
|
||||
|
||||
}
|
||||
|
||||
function init_User_edit(userID, name) {
|
||||
$('#save-button').attr("onclick", "saveUser(" + userID + ")");
|
||||
$('#delete-button').attr("onclick", "deleteUser(" + userID + ")");
|
||||
$('#user-name-input').val(name);
|
||||
$('#user-password-input').val('');
|
||||
overlay_in();
|
||||
}
|
||||
|
||||
|
||||
function saveUser(userID) {
|
||||
var name_v = $('#user-name-input').val();
|
||||
var password_v = $('#user-password-input').val();
|
||||
|
||||
if(name_v.length > 100) {
|
||||
alert('Name too long (max 100 characters).')
|
||||
return;
|
||||
}
|
||||
var data = new FormData();
|
||||
|
||||
data.append('password', password_v);
|
||||
data.append('name', name_v)
|
||||
|
||||
$.ajax({
|
||||
url: rootURL + 'alterUser/' + userID,
|
||||
type: 'POST',
|
||||
data: data,
|
||||
cache: false,
|
||||
contentType: false,
|
||||
processData: false,
|
||||
success: function(data) {
|
||||
alert("k.");
|
||||
},
|
||||
error: function() {
|
||||
alert("Couldn't update the user information. Please retry.");
|
||||
}
|
||||
});
|
||||
|
||||
end_edit();
|
||||
$('#edit-button').click(function() {
|
||||
init_edit(userID);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function deleteUser(userID) {
|
||||
if (userID < 0){
|
||||
alert('Congratulations! You found the secret UI bug easter egg! This button should not be here, yet I left it specifically because I wanted an easter egg and not because of any other reasons! Good for you!')
|
||||
return;
|
||||
}
|
||||
if (!confirm('Delete the selected user? ')){
|
||||
return;
|
||||
}
|
||||
$.ajax({
|
||||
url: rootURL + 'deleteUser/' + userID,
|
||||
type: 'GET',
|
||||
cache: false,
|
||||
contentType: false,
|
||||
processData: false,
|
||||
success: function() {
|
||||
alert("User removed.");
|
||||
overlay_out();
|
||||
location.reload();
|
||||
},
|
||||
fail: function() {
|
||||
console.log('An error occurred while deleting the entry');
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
function end_edit(){
|
||||
//intentionally left blank
|
||||
}
|
||||
|
||||
|
||||
function show_user_info(userID) {
|
||||
$.getJSON(rootURL + 'getpartinfo/' + partID, function(data) {
|
||||
$('table#details tr#location td p').text(text_filter(data.location_descriptor)); // name is the location friendly name
|
||||
$('#location-dropdown').val(data.location_id);
|
||||
$('#container-dropdown').val(data.container_id);
|
||||
$('table#details tr#partno td p').text(text_filter(data.partno));
|
||||
$('table#details tr#partno td input').val(text_filter(data.partno));
|
||||
$('table#details tr#description td p').text(text_filter(data.description));
|
||||
$('table#details tr#description td input').val(text_filter(data.description));
|
||||
container_onchange();
|
||||
if (data.datasheet != null) {
|
||||
$('tr#datasheet-head').html($('<td>DATASHEET: <a href="parts/getfile/' + data.datasheet + '"><i class="fa fa-file-text" aria-hidden="true"></i></a></td>'));
|
||||
$('#datasheet-input').val(data.datasheet);
|
||||
}
|
||||
else
|
||||
$('tr#datasheet-head td').text('DATASHEET: ');
|
||||
$('#edit-button').click(function() {
|
||||
init_edit(partID);
|
||||
});
|
||||
$('#delete-button').click(function() {
|
||||
delete_entry(partID);
|
||||
});
|
||||
overlay_in();
|
||||
}).fail(function() {
|
||||
console.log( "Fetching part info failed" );
|
||||
});
|
||||
}
|
||||
|
||||
function placeMarker(locationID){
|
||||
//temporarily not used
|
||||
var $img = $('#clickablemap');
|
||||
var currentClickPosX = event.pageX - $img.offset().left;
|
||||
var currentClickPosY = event.pageY - $img.offset().top;
|
||||
|
||||
var correctX = (($img.prop('naturalWidth') / $img.width()) * currentClickPosX).toFixed(0);
|
||||
var correctY = (($img.prop('naturalHeight') / $img.height()) * currentClickPosY).toFixed(0);
|
||||
|
||||
// $("#mapURL").html("elab.png?x=" + correctX + "&y=" + correctY);
|
||||
$("#clickablemap").attr("src", "map/" + $("#mapfile-input").val() + "?x=" + correctX + "&y=" + correctY);
|
||||
}
|
@ -1,53 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>ELAB Part Search Engine - User editor</title>
|
||||
<script
|
||||
src="https://code.jquery.com/jquery-3.2.1.min.js"
|
||||
integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4="
|
||||
crossorigin="anonymous"></script>
|
||||
<link href="https://fonts.googleapis.com/css?family=Roboto:300,400" rel="stylesheet">
|
||||
<link rel="stylesheet" type="text/css" href="{{ baseURL }}/static/style.css">
|
||||
<script src="https://use.fontawesome.com/2fef7be393.js"></script>
|
||||
<script type="text/javascript" src="{{ baseURL }}/static/common.js"></script>
|
||||
<script type="text/javascript" src="{{ baseURL }}/static/userEditorScript.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>USER EDITOR</h1>
|
||||
<p>Get in! Get out! Get your fresh users here! <a href=".">back to parts</a></p>
|
||||
<table id="results" class="results-locations">
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Username</th>
|
||||
</tr>
|
||||
{% for user in users %}
|
||||
<tr onclick="init_User_edit({{user['id']}}, '{{user['username']}}');">
|
||||
<td>{{user['id']}}</td>
|
||||
<td>{{user['username']}}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
<div class="bottom-spacer"></div>
|
||||
|
||||
<div class="shadow" onclick="overlay_out()"></div>
|
||||
<div class="overlay">
|
||||
<h2>User Details</h2>
|
||||
<table id="details">
|
||||
<tr><td>Adding a new user</td></tr>
|
||||
|
||||
<tr><td>Name and password for new user<br />Example: "noob"</td></tr>
|
||||
<tr><td><p></p><input type="text" name="user-name-input" id="user-name-input" placeholder="Name" class="pinfo-input nothidden"/></td></tr>
|
||||
<tr><td><p></p><input type="password" name="user-password-input" id="user-password-input" placeholder="Password" class="pinfo-input nothidden"/></td></tr>
|
||||
|
||||
|
||||
|
||||
|
||||
</table>
|
||||
<div class="round-button-left"><a href="#" id="save-button"><i class="fa fa-check" aria-hidden="true"></i></a></div>
|
||||
<div class="round-button"><a href="#" id="delete-button"><i class="fa fa-trash" aria-hidden="true"></i></a></div>
|
||||
<div class="small-square-button"><a href="#" onclick="overlay_out()"><i class="fa fa-times" aria-hidden="true"></i></a></div>
|
||||
</div>
|
||||
<div class="round-floating-button"><a href="#" onclick="init_User_edit(-1, '', 0)"><i class="fa fa-plus" aria-hidden="true"></i></a></div>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in new issue