mirror of https://github.com/itflow-org/itflow
Spruce up the share UI modal and client logins
This commit is contained in:
parent
83bcae3962
commit
d2fdc5f7d8
|
|
@ -72,7 +72,8 @@
|
|||
<input type="datetime-local" class="form-control form-control-sm" name="start" required>
|
||||
</div>
|
||||
<div class="col-md-6 mb-3">
|
||||
<input type="datetime-local" class="form-control form-control-sm" name="end" required>
|
||||
<input type="datetime-local" class="form-control form-control-sm" name="end"
|
||||
required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
@ -157,4 +158,4 @@
|
|||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -105,7 +105,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli,"SELECT FOUND_ROWS()"));
|
|||
</td>
|
||||
<td><?php echo $login_username_display; ?></td>
|
||||
<td>
|
||||
<a tabindex="0" class="btn btn-sm" data-toggle="popover" data-trigger="focus" data-placement="left" data-content="<?php echo $login_password; ?>"><i class="fas fa-circle text-secondary"></i></a><button class="btn btn-sm clipboardjs" data-clipboard-text="<?php echo $login_password; ?>"><i class="far fa-copy text-secondary"></i></button></td>
|
||||
<a tabindex="0" href="#" data-toggle="popover" data-trigger="focus" data-placement="top" data-content="<?php echo $login_password; ?>"><i class="fas fa-2x fa-ellipsis-h text-secondary"></i><i class="fas fa-2x fa-ellipsis-h text-secondary"></i></a><button class="btn btn-sm clipboardjs" data-clipboard-text="<?php echo $login_password; ?>"><i class="far fa-copy text-secondary"></i></button>
|
||||
</td>
|
||||
<td><?php echo $otp_display; ?></td>
|
||||
<td><?php echo $login_uri_display; ?></td>
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ TODO:
|
|||
- Better handle replying to closed tickets
|
||||
- Support for authenticating with OAuth
|
||||
- Documentation
|
||||
- Seperate Mailbox Account for tickets 2022-12-14 - JQ
|
||||
|
||||
Relate PRs to https://github.com/itflow-org/itflow/issues/225 & https://forum.itflow.org/d/11-road-map & https://forum.itflow.org/d/31-tickets-from-email
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -78,8 +78,7 @@ if($item_type == "Document"){
|
|||
// Logging
|
||||
mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Sharing', log_action = 'View', log_description = 'Viewed shared $item_type via link - Item ID: $item_id', log_client_id = '$client_id', log_created_at = NOW(), log_ip = '$ip', log_user_agent = '$user_agent', company_id = '1'");
|
||||
|
||||
}
|
||||
elseif($item_type == "File"){
|
||||
}elseif($item_type == "File"){
|
||||
$file_sql = mysqli_query($mysqli, "SELECT * FROM files WHERE file_id = '$item_related_id' AND file_client_id = '$client_id' LIMIT 1");
|
||||
$file_row = mysqli_fetch_array($file_sql);
|
||||
|
||||
|
|
@ -98,8 +97,7 @@ elseif($item_type == "File"){
|
|||
echo "<a href=\"guest_download_file.php?id=$item_id&key=$item_key\" download=\"$file_name;\">Download $file_name</a>";
|
||||
|
||||
|
||||
}
|
||||
elseif($item_type == "Login"){
|
||||
}elseif($item_type == "Login"){
|
||||
$encryption_key = $_GET['ek'];
|
||||
|
||||
$login_sql = mysqli_query($mysqli, "SELECT * FROM logins WHERE login_id = '$item_related_id' AND login_client_id = '$client_id' LIMIT 1");
|
||||
|
|
|
|||
152
share_modal.php
152
share_modal.php
|
|
@ -1,82 +1,96 @@
|
|||
<script>
|
||||
function populateShareModal(client_id, item_type, item_ref_id){
|
||||
document.getElementById("share_client_id").value = client_id;
|
||||
document.getElementById("share_item_type").value = item_type;
|
||||
document.getElementById("share_item_ref_id").value = item_ref_id;
|
||||
}
|
||||
|
||||
function generateShareLink(){
|
||||
let client_id = document.getElementById("share_client_id").value;
|
||||
let item_type = document.getElementById("share_item_type").value;
|
||||
let item_ref_id = document.getElementById("share_item_ref_id").value;
|
||||
let item_note = document.getElementById("share_note").value;
|
||||
let item_views = document.getElementById("share_views").value;
|
||||
let item_expires = document.getElementById("share_expires").value;
|
||||
function populateShareModal(client_id, item_type, item_ref_id){
|
||||
document.getElementById("share_client_id").value = client_id;
|
||||
document.getElementById("share_item_type").value = item_type;
|
||||
document.getElementById("share_item_ref_id").value = item_ref_id;
|
||||
}
|
||||
|
||||
// Check values are provided
|
||||
if(item_views && item_expires && item_note){
|
||||
// Send a GET request to ajax.php as ajax.php?share_generate_link=true....
|
||||
jQuery.get(
|
||||
"ajax.php",
|
||||
{share_generate_link: 'true', client_id: client_id, type: item_type, id: item_ref_id, note: item_note ,views: item_views, expires: item_expires},
|
||||
function(data){
|
||||
function generateShareLink(){
|
||||
let client_id = document.getElementById("share_client_id").value;
|
||||
let item_type = document.getElementById("share_item_type").value;
|
||||
let item_ref_id = document.getElementById("share_item_ref_id").value;
|
||||
let item_note = document.getElementById("share_note").value;
|
||||
let item_views = document.getElementById("share_views").value;
|
||||
let item_expires = document.getElementById("share_expires").value;
|
||||
|
||||
// If we get a response from ajax.php, parse it as JSON
|
||||
const response = JSON.parse(data);
|
||||
// Check values are provided
|
||||
if(item_views && item_expires && item_note){
|
||||
// Send a GET request to ajax.php as ajax.php?share_generate_link=true....
|
||||
jQuery.get(
|
||||
"ajax.php",
|
||||
{share_generate_link: 'true', client_id: client_id, type: item_type, id: item_ref_id, note: item_note ,views: item_views, expires: item_expires},
|
||||
function(data){
|
||||
|
||||
document.getElementById("share_link_header").hidden = false;
|
||||
document.getElementById("share_link").hidden = false;
|
||||
document.getElementById("share_link").value = response;
|
||||
// If we get a response from ajax.php, parse it as JSON
|
||||
const response = JSON.parse(data);
|
||||
|
||||
document.getElementById("share_link_header").hidden = false;
|
||||
document.getElementById("share_link").hidden = false;
|
||||
document.getElementById("share_link").value = response;
|
||||
|
||||
// Copy link to clipboard
|
||||
navigator.clipboard.writeText(response);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Copy link to clipboard
|
||||
navigator.clipboard.writeText(response);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="modal" id="shareModal" tabindex="-1">
|
||||
<div class="modal-dialog modal-md">
|
||||
<div class="modal-content bg-dark">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title"><i class="fa fa-fw fa-share"></i> Share</h5>
|
||||
<button type="button" class="close text-white" data-dismiss="modal">
|
||||
<span>×</span>
|
||||
</button>
|
||||
<div class="modal-dialog modal-md">
|
||||
<div class="modal-content bg-dark">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title"><i class="fa fa-fw fa-share"></i> Generate Share Link</h5>
|
||||
<button type="button" class="close text-white" data-dismiss="modal">
|
||||
<span>×</span>
|
||||
</button>
|
||||
</div>
|
||||
<form action="ajax.php" method="GET" id="newShareLink">
|
||||
<input type="hidden" name="client_id" id="share_client_id" value="">
|
||||
<input type="hidden" name="item_type" id="share_item_type" value="">
|
||||
<input type="hidden" name="item_ref_id" id="share_item_ref_id" value="">
|
||||
<div class="modal-body bg-white">
|
||||
|
||||
<label>Views / Expire <strong class="text-danger">*</strong></label>
|
||||
<div class="form-row">
|
||||
<div class="col-4">
|
||||
<div class="input-group mb-3">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-eye"></i></span>
|
||||
</div>
|
||||
<input type="number" class="form-control" name="views" id="share_views" placeholder="Views before link expires" value="1" required>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-body bg-white">
|
||||
|
||||
<h2>Get Share URL</h2>
|
||||
<form action="ajax.php" method="GET" id="newShareLink">
|
||||
<input type="hidden" name="client_id" id="share_client_id" value="">
|
||||
<input type="hidden" name="item_type" id="share_item_type" value="">
|
||||
<input type="hidden" name="item_ref_id" id="share_item_ref_id" value="">
|
||||
<div class="form-group">
|
||||
<label for="views">Number of views allowed <strong class="text-danger">*</strong></label>
|
||||
<input type="number" class="form-control" name="views" id="share_views" placeholder="Views before link expires" value="1" required autofocus>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="views">Link Expiry date <strong class="text-danger">*</strong></label>
|
||||
<input type="datetime-local" class="form-control" name="expires" id="share_expires" required autofocus>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="note">Note <strong class="text-danger">*</strong></label>
|
||||
<input type="text" class="form-control" name="note" id="share_note" placeholder="Client visible note" required autofocus>
|
||||
</div>
|
||||
<button class="form-control" onclick="event.preventDefault(); generateShareLink()">Share</button>
|
||||
</form>
|
||||
<p><i>Note: Login passwords are shared "as is" and will not update</i></p>
|
||||
|
||||
<hr>
|
||||
|
||||
<h3 id="share_link_header" hidden>Share URL:</h3>
|
||||
<input type="text" class="form-control" disabled id="share_link" hidden value="">
|
||||
|
||||
<div class="col-8">
|
||||
<div class="input-group mb-3">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-calendar"></i></span>
|
||||
</div>
|
||||
<input type="datetime-local" class="form-control" name="expires" id="share_expires" required>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<textarea class="form-control" rows="4" name="note" id="share_note" placeholder="Client visible note" required></textarea>
|
||||
</div>
|
||||
|
||||
<p><i>Note: Login passwords are shared "as is" and will not update</i></p>
|
||||
|
||||
<div class="modal-footer bg-white">
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
|
||||
</div>
|
||||
</div>
|
||||
<hr>
|
||||
|
||||
<h3 id="share_link_header" hidden>Share URL:</h3>
|
||||
<input type="text" class="form-control" disabled id="share_link" hidden value="">
|
||||
|
||||
</div>
|
||||
|
||||
<div class="modal-footer bg-white">
|
||||
<button type="button" class="btn btn-outline-secondary" data-dismiss="modal">Cancel</button>
|
||||
<button type="button" class="btn btn-primary" onclick="event.preventDefault(); generateShareLink()"><strong><i class="fa fa-fw fa-check"></i> Generate</strong></button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
Loading…
Reference in New Issue