Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blacklist editor #17

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@
"private": true,
"devDependencies": {
"@types/jquery": "^3.3.2",
"@types/leaflet": "^1.2.7",
"bootstrap": "^4.1.1",
"jquery": "^3.3.1",
"jquery-ui": "^1.12.1",
"leaflet": "^1.3.1",
"node-sass": "^4.9.0",
"popper.js": "^1.14.3",
"ts-loader": "^4.3.0",
Expand Down
6 changes: 6 additions & 0 deletions scss/zerodrop.scss
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
@import "node_modules/bootstrap/scss/bootstrap";
@import "node_modules/leaflet/dist/leaflet";

.zerodrop-map {
height: 20em;
margin-bottom: $spacer;
}
103 changes: 102 additions & 1 deletion templates/new.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,108 @@
<div class="form-group row">
<label for="access_blacklist" class="col-sm-2 col-form-label">Blacklist</label>
<div class="col-sm-10">
<textarea class="form-control bg-dark text-white" style="font-family: Consolas, Lucida Console, monospace;" id="access_blacklist" name="blacklist" rows="6"></textarea>


<div class="btn-group mb-1" role="group" aria-label="Blacklist editor">
<button type="button" class="btn btn-dark">+ IP or Hostname</button>
<button type="button" class="btn btn-dark">+ Network</button>
<button type="button" class="btn btn-dark">+ Database</button>
<button type="button" class="btn btn-dark">+ Geofence</button>
</div>

<div class="zerodrop-blacklist-items">

<div class="card text-white bg-dark mb-1">
<div class="card-header">IP or Hostname Rule
<button class="btn btn-danger btn-sm float-right">Remove</button>
</div>
<div class="card-body">
<div class="d-flex align-items-start">
<div class="flex-grow-1 input-group mb-3">
<div class="input-group-prepend">
<span class="input-group-text" id="basic-addon1">#</span>
</div>
<input type="text" class="form-control" placeholder="Comment" aria-label="Comment" aria-describedby="basic-addon1">
</div>
<div class="btn-group btn-group-toggle ml-3" data-toggle="buttons">
<label class="btn btn-light active">
<input type="radio" name="options" id="option1" autocomplete="off" checked> Block
</label>
<label class="btn btn-light">
<input type="radio" name="options" id="option2" autocomplete="off"> Allow
</label>
</div>
</div>
<p class="card-text">
<input type="text" class="form-control form-control-lg" placeholder="IP or Hostname"/>
</p>
</div>
</div>

<div class="card text-white bg-dark mb-1">
<div class="card-header">Geofence Rule
<button class="btn btn-danger btn-sm float-right">Remove</button>
</div>
<div class="card-body">
<div class="d-flex align-items-start">
<div class="flex-grow-1 input-group mb-3">
<div class="input-group-prepend">
<span class="input-group-text" id="basic-addon1">#</span>
</div>
<input type="text" class="form-control" placeholder="Comment" aria-label="Comment" aria-describedby="basic-addon1">
</div>
<div class="btn-group btn-group-toggle ml-3" data-toggle="buttons">
<label class="btn btn-light active">
<input type="radio" name="options" id="option1" autocomplete="off" checked> Block
</label>
<label class="btn btn-light">
<input type="radio" name="options" id="option2" autocomplete="off"> Allow
</label>
</div>
</div>
<div class="zerodrop-map"></div>
<div class="form-group row">
<label class="col-sm-2 col-form-label">Radius</label>
<div class="col-sm-10">
<input type="range" class="custom-range" min="0" max="1000"/>
</div>
</div>
</div>
</div>

<div class="card mb-1">
<div class="card-header">Database Rule
<button class="btn btn-danger btn-sm float-right">Remove</button></div>
<div class="card-body">
<div class="d-flex align-items-start">
<div class="flex-grow-1 input-group mb-3">
<div class="input-group-prepend">
<span class="input-group-text" id="basic-addon1">#</span>
</div>
<input type="text" class="form-control" placeholder="Comment" aria-label="Comment" aria-describedby="basic-addon1">
</div>
<div class="btn-group btn-group-toggle ml-3" data-toggle="buttons">
<label class="btn btn-light">
<input type="radio" name="options" id="option1" autocomplete="off"> Block
</label>
<label class="btn btn-light active">
<input type="radio" name="options" id="option2" autocomplete="off" checked> Allow
</label>
</div>
</div>
<div class="row">
<label class="col-sm-2 col-form-label">Database</label>
<div class="col-sm-10">
<select class="custom-select custom-select-lg mb-3">
<option value="datacenters">datacenters</option>
<option value="tor">tor</option>
</select>
</div>
</div>
</div>
</div>
</div>

</div>
</div>
<div class="form-group row">
Expand Down
20 changes: 20 additions & 0 deletions ts/zerodrop.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
// Import page dependencies
import * as $ from 'jquery';
import 'jquery-ui/ui/widgets/sortable';
import 'bootstrap/js/src/util';
import 'bootstrap/js/src/tab';
import 'bootstrap/js/src/collapse';
import 'bootstrap/js/src/dropdown';

import * as L from 'leaflet';

import set_emoji_favicon from './emoji-favicon-toolkit';

function humanFileSize(bytes: number, si: boolean): string {
Expand Down Expand Up @@ -46,6 +49,23 @@ $(() => {
const element = $(event.currentTarget);
element.find('input').prop('checked', true);
});

($('.zerodrop-blacklist-items') as any).sortable({
handle: '.card-header'
});

const map = $('.zerodrop-map').get(0);
const leaflet = L.map(map, {
center: [51.505, -0.09],
zoom: 2
});

L.tileLayer('https://api.mapbox.com/styles/v1/dsamarin/cjhod9wkf003m2souy4fltiou/tiles/256/{z}/{x}/{y}?access_token={accessToken}', {
attribution: 'Map data &copy; <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors, <a href="https://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery © <a href="https://www.mapbox.com/">Mapbox</a>',
maxZoom: 18,
accessToken: 'pk.eyJ1IjoiZHNhbWFyaW4iLCJhIjoiY2pob2Q4cDF6MTNlZDNkcnltb2trNnpwbCJ9.UUx6bmFfKjYV2w1x61q9nw'
}).addTo(leaflet);

});

const emojis = ['\u26a0\ufe0f', '\uD83D\uDD17']
Expand Down
Loading