-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d5b8d23
commit 7d29d5d
Showing
50 changed files
with
234 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from flask import Blueprint, render_template, jsonify, request | ||
from nft import Creator | ||
|
||
manage = Blueprint('manage', __name__,url_prefix='/manage') | ||
|
||
@manage.route('/') | ||
def home(): | ||
with Creator() as c: | ||
return render_template('layers.html') | ||
|
||
@manage.route('/layers') | ||
def layers(): | ||
with Creator() as c: | ||
return jsonify(c.get_layers()) | ||
|
||
@manage.route('/upload', methods=['POST']) | ||
def upload(): | ||
with Creator() as c: | ||
return c.upload_layer(request.form,request.files) | ||
|
||
@manage.route('/delete', methods=['GET']) | ||
def delete(): | ||
with Creator() as c: | ||
return c.delete_layer(request.args) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
button { | ||
align-items: center; | ||
background-clip: padding-box; | ||
background-color: #00c0fa; | ||
border: 1px solid transparent; | ||
border-radius: .25rem; | ||
box-shadow: rgba(0, 0, 0, 0.02) 0 1px 3px 0; | ||
box-sizing: border-box; | ||
color: #fff; | ||
cursor: pointer; | ||
display: inline-flex; | ||
font-family: system-ui,-apple-system,system-ui,"Helvetica Neue",Helvetica,Arial,sans-serif; | ||
font-size: 16px; | ||
font-weight: 600; | ||
justify-content: center; | ||
line-height: 1.25; | ||
margin: 0; | ||
min-height: 3rem; | ||
padding: calc(.875rem - 1px) calc(1.5rem - 1px); | ||
position: relative; | ||
text-decoration: none; | ||
transition: all 250ms; | ||
user-select: none; | ||
-webkit-user-select: none; | ||
touch-action: manipulation; | ||
vertical-align: baseline; | ||
width: auto; | ||
} | ||
button:hover, | ||
button:focus { | ||
background-color: #32eafb; | ||
box-shadow: rgba(0, 0, 0, 0.1) 0 4px 12px; | ||
} | ||
button:hover { | ||
transform: translateY(-1px); | ||
} | ||
button:active { | ||
background-color: #0099c8; | ||
box-shadow: rgba(0, 0, 0, .06) 0 2px 4px; | ||
transform: translateY(0); | ||
} | ||
.nfts { | ||
display: grid; | ||
grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); | ||
grid-gap: 20px; | ||
} | ||
|
||
.nft { | ||
display: grid; | ||
} | ||
|
||
.nft img { | ||
width: 100%; | ||
height: 100%; | ||
} | ||
|
||
input { | ||
height: 1.8rem; | ||
} | ||
|
||
select { | ||
height: 2.5rem; | ||
|
||
} |
File renamed without changes
File renamed without changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
|
||
} |
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Manage</title> | ||
<link rel="stylesheet" href="/static/css/style.css"> | ||
</head> | ||
<body> | ||
<label for="layer">Layer:</label> | ||
<select name="layer" id="layer"> | ||
<option value="" selected disabled>None</option> | ||
</select> | ||
<input type="file" id="file" name="image" hidden> | ||
<button onclick="document.getElementById('file').click()">Upload</button> | ||
|
||
<div class="nfts"> | ||
</div> | ||
|
||
<script> | ||
var layers; | ||
|
||
fetch('layers') | ||
.then(res => res.json()) | ||
.then(data => { | ||
const select = document.querySelector('#layer'); | ||
data.forEach(layer => { | ||
const option = document.createElement('option'); | ||
option.value = layer.name; | ||
option.innerText = layer.name.charAt(0).toUpperCase() + layer.name.slice(1); | ||
select.appendChild(option); | ||
}); | ||
layers = data; | ||
}); | ||
|
||
document.querySelector('#layer').addEventListener('change', (e) => { | ||
e.preventDefault(); | ||
document.querySelector('.nfts').innerHTML = ''; | ||
layers.forEach(element => { | ||
if(element.name ==e.target.value){ | ||
element.items.forEach(item => { | ||
const nft = document.createElement('div'); | ||
nft.className = 'nft'; | ||
|
||
const img = document.createElement('img'); | ||
img.src = `/${item}`; | ||
|
||
deletebtn = document.createElement('button'); | ||
deletebtn.innerText = 'Delete'; | ||
deletebtn.onclick = () => { | ||
fetch(`delete?image=${item}`) | ||
.then(res => res.json()) | ||
.then(data => { | ||
if(data.success){ | ||
window.location.reload(); | ||
}else{ | ||
alert('Failed to delete'); | ||
} | ||
}); | ||
} | ||
|
||
nft.appendChild(img); | ||
nft.appendChild(deletebtn); | ||
|
||
document.querySelector('.nfts').appendChild(nft); | ||
}); | ||
} | ||
}); | ||
}); | ||
|
||
document.querySelector('#file').addEventListener('change', (e) => { | ||
e.preventDefault(); | ||
const formData = new FormData(); | ||
formData.append('image', e.target.files[0]); | ||
formData.append('layer', document.querySelector('#layer').value); | ||
if(document.querySelector('#layer').value === ''){ | ||
alert('Please select a layer'); | ||
document.querySelector('#file').value = ''; | ||
return; | ||
}else{ | ||
fetch('upload', { | ||
method: 'POST', | ||
body: formData | ||
}) | ||
.then(res => res.json()) | ||
.then(data => { | ||
console.log(data); | ||
if(data.success){ | ||
alert('Uploaded..!'); | ||
window.location.reload(); | ||
}else{ | ||
alert('Failed to upload'); | ||
} | ||
}); | ||
document.querySelector('#file').value = ''; | ||
} | ||
}); | ||
|
||
|
||
</script> | ||
|
||
|
||
</body> | ||
</html> |