Skip to content
This repository has been archived by the owner on Jan 11, 2023. It is now read-only.

Commit

Permalink
Merge branch 'master' of github.com:N-Schaef/shreddr
Browse files Browse the repository at this point in the history
  • Loading branch information
N-Schaef committed Apr 9, 2021
2 parents a3185c9 + 1cbaea9 commit 87999d9
Show file tree
Hide file tree
Showing 12 changed files with 3,716 additions and 3,263 deletions.
6,667 changes: 3,524 additions & 3,143 deletions web/assets/dist/js/jscolor.js

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion web/assets/pages/dashboard.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ body {

.feather {
width: 16px;
height: 16px;
}

/*
Expand Down
18 changes: 11 additions & 7 deletions web/assets/pages/document.css
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
/* Style the input field */
#filterTags {
padding: 5px;
margin-top: -8px;
border: 0;
border-radius: 0;
background: #f1f1f1;
.btn-text {
margin-inline-start: .5em;
}

.tag-add-menu {
padding: .5rem .5rem;
}

.tag-add-menu .dropdown-item {
margin: .5rem auto;
border-radius: 3px;
}
37 changes: 37 additions & 0 deletions web/assets/pages/documents.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,40 @@
.tag-btn {
margin-right: .3em;
}

.tag-filter-menu {
padding: .5rem .5rem;
}

.tag-filter-menu .dropdown-item {
margin: .5rem auto;
border-radius: 3px;
}

.docbutton-container {
position: relative;
}

.docbuttons {
position: absolute;
top: 0;
}

.doc-card {
/* Make sure document buttons always fit
inside the card */
min-width: 170px;
}

.doc-image {
padding: 1em;
height: 100%;
object-fit: contain;
}

.doc-title {
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
font-size: large;
}
68 changes: 37 additions & 31 deletions web/assets/pages/documents.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,12 @@ function removeTagFilter(tagId) {
location.reload();
}



function createSearchTagButton(){
var div = $("<div></div>");
var dropdownButton = $("<button class=\"btn btn-sm btn-outline-secondary dropdown-toggle mr-1\" type=\"button\" id=\"addTagButton\" data-toggle=\"dropdown\"><span data-feather=\"tag\"></span></button>");
var items = $("<div class=\"dropdown-menu\" aria-labelledby=\"addTagButton\"></div>");
var filter = $("<input class=\"form-control\" id=\"filterTags\" type=\"text\" placeholder=\"Search..\">");
var items = $("<div class=\"tag-filter-menu dropdown-menu\" aria-labelledby=\"addTagButton\"></div>");
var filter = $("<input class=\"form-control\" id=\"filterTags\" type=\"text\" placeholder=\"Search...\">");

filter.on("keyup", function() {
var value = $(this).val().toLowerCase();
$(".dropdown-menu button").filter(function() {
Expand All @@ -35,6 +34,7 @@ function createSearchTagButton(){
var item = $("<button class=\"dropdown-item\" type=\"button\"></button>");
item.text(value.name);
item.css("background-color", value.color);
item.css("color", isDark(value.color) ? "var(--light)" : "var(--dark)")
item.on("click", function(){
filterByTag(key)
}.bind(key));
Expand All @@ -53,6 +53,7 @@ function createTagButton(tagId, clickFunc) {
}
btn.text(tag.name);
btn.css("background-color", tag.color);
btn.css("color", isDark(tag.color) ? "var(--light)" : "var(--dark)")
btn.addClass("tag-" + tag.id);
btn.on("click", clickFunc);
return btn;
Expand Down Expand Up @@ -104,32 +105,37 @@ function nextHandler(pageIndex){

function createDocumentCard(doc) {
const template = `
<div class="card shadow-sm h-100" id="doc-${doc.id}">
<div class="card-header" style="padding: .5rem;">
<a href="/documents/${doc.id}" class="text-dark" style="text-decoration: none;"><h5 class="card-title">${doc.title}</h5></a>
</div>
<img class="card-img-bottom" src="/thumbnails/${doc.id}.jpg" rel="nofollow" alt="Document thumbnail">
<div class="card-body">
<p class="card-text"></p>
</div>
<div class="btn-group docbuttons w-100" style="display: none;">
<a href="/documents/${doc.id}/download" title="Download document" class="btn btn-primary w-100 download-doc"
style="border-radius: 0 !important;">${feather.icons['download'].toSvg()}</a>
<button type="button" title="Reprocess document" class="btn btn-secondary w-100 reimport-doc"
style="border-radius: 0 !important;">${feather.icons['refresh-cw'].toSvg()}</button>
<a href="/documents/${doc.id}" title="Edit document metadata" class="btn btn-secondary w-100 edit-doc"
style="border-radius: 0 !important;">${feather.icons['edit'].toSvg()}</a>
<button type="button" title="Remove document" class="btn btn-danger w-100 remove-doc"
style="border-radius: 0 !important;">${feather.icons['trash-2'].toSvg()}</button>
</div>
<div class="card-footer text-muted" style="padding: .5rem;">
<div class="created">Imported Yesterday</div>
<div class="inferred"></div>
</div>
</div>
<div class="doc-card card shadow-sm h-100" id="doc-${doc.id}">
<div class="card-header" style="padding: .5rem;">
<a href="/documents/${doc.id}" class="text-dark" style="text-decoration: none;">
<div class="doc-title">${doc.title}</div>
</a>
</div>
<div class="docbutton-container">
<div class="btn-group docbuttons w-100" style="display: none;">
<a href="/documents/${doc.id}/download" title="Download document" class="btn btn-primary w-100 download-doc"
style="border-radius: 0 !important;">${feather.icons['download'].toSvg()}</a>
<button type="button" title="Reprocess document" class="btn btn-secondary w-100 reimport-doc"
style="border-radius: 0 !important;">${feather.icons['refresh-cw'].toSvg()}</button>
<a href="/documents/${doc.id}" title="Edit document metadata" class="btn btn-secondary w-100 edit-doc"
style="border-radius: 0 !important;">${feather.icons['edit'].toSvg()}</a>
<button type="button" title="Remove document" class="btn btn-danger w-100 remove-doc"
style="border-radius: 0 !important;">${feather.icons['trash-2'].toSvg()}</button>
</div>
</div>
<img class="card-img-bottom doc-image" src="/thumbnails/${doc.id}.jpg" rel="nofollow" alt="Document thumbnail">
<div class="card-body">
<p class="card-text"></p>
</div>
<div class="card-footer text-muted" style="padding: .5rem;">
<div class="created">Imported Yesterday</div>
<div class="inferred"></div>
</div>
</div>
`


Expand Down Expand Up @@ -180,7 +186,7 @@ function createDocumentCard(doc) {
date.setUTCSeconds(doc.extracted.doc_date);
card.find(".inferred").text("Document: " + date.toLocaleDateString());
}
let cardDiv = $("<div class=\"col-11 col-sm-10 col-md-6 col-lg-4 col-xl-2 py-2 \"></div>")
let cardDiv = $("<div class=\"col-12 col-sm-6 col-md-6 col-lg-4 col-xl-2 py-2 \"></div>")
cardDiv.html(card);
return cardDiv;
}
Expand Down
5 changes: 4 additions & 1 deletion web/assets/pages/show_doc.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,12 @@ function createTagButton(docId, tagMap, tagId, clickFunc) {
var btn = $("<a href=\"/tags/"+tagId+"\" type=\"button\" class=\"btn btn-secondary btn-sm tag-btn mb-2\" style=\"border-color: transparent;\"></a>");
btn.text(tag.name);
btn.css("background-color", tag.color);
btn.css("color", isDark(tag.color) ? "var(--light)" : "var(--dark)")
btn.addClass("tag-" + tag.id);
btn.on("click", clickFunc);
var removebtn = $("<button type=\"button\" class=\"btn btn-sm btn-secondary tag-btn mb-2\" style=\"border-color: transparent;\"><span data-feather=\"x\"></span></button>");
removebtn.css("background-color", tag.color);
removebtn.css("color", isDark(tag.color) ? "var(--light)" : "var(--dark)")
removebtn.on("click", function () {
$.ajax({
url: '/documents/' + docId + '/tags/' + tag.id,
Expand All @@ -111,7 +113,7 @@ function createTagButton(docId, tagMap, tagId, clickFunc) {
function createAddButton(docId, tagMap) {
var div = $("<div></div>");
var dropdownButton = $("<button class=\"btn btn-sm btn-success dropdown-toggle\" type=\"button\" id=\"addTagButton\" data-toggle=\"dropdown\"><span data-feather=\"plus\"></span></button>");
var items = $("<div class=\"dropdown-menu\" aria-labelledby=\"addTagButton\"></div>");
var items = $("<div class=\"dropdown-menu tag-add-menu\" aria-labelledby=\"addTagButton\"></div>");
var filter = $("<input class=\"form-control\" id=\"filterTags\" type=\"text\" placeholder=\"Search..\">");
filter.on("keyup", function () {
var value = $(this).val().toLowerCase();
Expand All @@ -125,6 +127,7 @@ function createAddButton(docId, tagMap) {
var item = $("<button class=\"dropdown-item\" type=\"button\"></button>");
item.text(value.name);
item.css("background-color", value.color);
item.css("color", isDark(value.color) ? "var(--light)" : "var(--dark)");
item.on("click", function () {
$.ajax({
url: '/documents/' + docId + '/tags/' + value.id,
Expand Down
40 changes: 23 additions & 17 deletions web/assets/pages/tags.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,36 @@

(function () {
'use strict'

$.get("/tags/json")
.done(function( data ) {
$.each(data, function () {
if(this.deactivated) {return;}
var newTag = $("body").find("#tag").clone();
newTag.find(".card-header").append(this.name);
if(this.color != null){
newTag.find(".card-header").css('background-color', this.color);
if (this.deactivated) {
return;
}
newTag.find(".edit-tag").attr("href","/tags/"+this.id+"");

var newTag = $("template.tag").contents().clone();
newTag.find(".card-header").append(this.name);
newTag.find(".edit-tag").attr("href",`/tags/${this.id}`);
newTag.find(".remove-tag").on('click', function(){
$.ajax({
url: '/tags/'+this.id,
type: 'DELETE',
success: function(result) {
location.reload();
}
});
}.bind(this)
);
$.ajax({
url: '/tags/'+this.id,
type: 'DELETE',
success: function(result) {
location.reload();
}
});
}.bind(this)
);

if (this.color != null) {
var header = newTag.find(".card-header");
header.css('background-color', this.color);
header.css('color', isDark(this.color) ? "var(--light)" : "var(--dark");
}

newTag.show();
$(newTag).appendTo("#tags");
feather.replace(); // Fill icon placeholders
});
});

})()
3 changes: 1 addition & 2 deletions web/pages/documents.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ <h1 class="h2">Documents</h1>
<div id="alertText"></div>
</div>

<div class="container"></div>


<div class="row justify-content-center" id="documents">

</div>
Expand Down
61 changes: 36 additions & 25 deletions web/pages/edit_tag.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
<script>var curr_page = "Edit Tag";</script>
<script src="/assets/dist/js/jscolor.js"></script>
<script>
// let's define custom preset
jscolor.presets.shreddr = {
format: 'hex',
hash: true,
width: 200,
height: 100,
palette: ["#A778B4", "#9B62A7", "#8C4E99", "#6F4C9B", "#6059A9",
"#5568B8", "#4E79C5", "#4D8AC6", "#4E96BC", "#549EB3",
"#59A5A9", "#60AB9E", "#69B190", "#77B77D", "#8CBC68",
"#A6BE54", "#BEBC48", "#D1B541", "#DDAA3C", "#E49C39",
"#E78C35", "#E67932", "#E4632D", "#DF4828", "#DA2222"],
paletteCols: 10,
}
</script>

<main class="col-md-9 ml-sm-auto col-lg-10 px-md-4">
<form method="post">
Expand All @@ -11,7 +26,7 @@

<div class="mb-3">
<label for="tagColor" class="form-label">Color</label>
<input class="form-control" value="{{color}}" name="color" id="tagColor" data-jscolor="{hash:true}">
<input class="form-control" value="{{color}}" name="color" id="tagColor" data-jscolor="{preset:'shreddr'}">
<small id="colorHelp" class="form-text text-muted">The color the tag will have</small>
</div>

Expand All @@ -26,25 +41,23 @@
<small id="tagHelp" class="form-text text-muted">Type matcher to use</small>
</div>


<!--- Full Matcher -->
<div id="fullMatcher">
<div class="mb-3">
<label for="fullMatcherMatchStr" class="form-label">Match String</label>
<input type="text" class="form-control" value="{{full_match_str}}" name="full_matcher_match_str" id="fullMatcherMatchStr" aria-describedby="fullMatcherMatchStr-Help">
<small id="fullMatcherMatchStr-Help" class="form-text text-muted">The string to match</small>
</div>
<div class="mb-3">
<label for="fullMatcherMatchStr" class="form-label">Match String</label>
<input type="text" class="form-control" value="{{full_match_str}}" name="full_matcher_match_str" id="fullMatcherMatchStr" aria-describedby="fullMatcherMatchStr-Help">
<small id="fullMatcherMatchStr-Help" class="form-text text-muted">The string to match</small>
</div>

<div class="mb-3">
<div class="custom-control custom-checkbox">
<input class="custom-control-input" name="full_matcher_case_insensitive" type="checkbox" id="fullMatcherCaseInsensitive" {{checked}}>
<label class="custom-control-label" for="fullMatcherCaseInsensitive">
Case insensitive
</label>
<div class="mb-3">
<div class="custom-control custom-checkbox">
<input class="custom-control-input" name="full_matcher_case_insensitive" type="checkbox" id="fullMatcherCaseInsensitive" {{checked}}>
<label class="custom-control-label" for="fullMatcherCaseInsensitive">
Case insensitive
</label>
</div>
</div>
</div>
</div>


<!--- Any Matcher -->
<div id="anyMatcher" style="display:none;">
Expand All @@ -62,18 +75,16 @@
</label>
</div>
</div>
</div>
</div>

<!--- Regex Matcher -->

<div id="Regex" style="display:none;">
<div class="mb-3">
<label for="regexMatchStr" class="form-label " >Regular Expression</label>
<input type="text" class="form-control" value="{{regex_str}}" name="regex_match_string" id="regexMatchStr" aria-describedby="regexMatchStr-Help">
<small id="regexMatchStr-Help" class="form-text text-muted">A regular expression that has to match for the tag to be applied</small>
</div>

</div>
<div id="Regex" style="display:none;">
<div class="mb-3">
<label for="regexMatchStr" class="form-label " >Regular Expression</label>
<input type="text" class="form-control" value="{{regex_str}}" name="regex_match_string" id="regexMatchStr" aria-describedby="regexMatchStr-Help">
<small id="regexMatchStr-Help" class="form-text text-muted">A regular expression that has to match for the tag to be applied</small>
</div>
</div>

<button type="submit" class="btn btn-primary">Submit</button>
</form>
Expand Down
Loading

0 comments on commit 87999d9

Please sign in to comment.