Three different sets of changes in one commit
1. Fix the Networks API to handle duplicate Networks between engines 2. Modify end points to account for this ( breaks scripts and client ) 3. Update Client to handle these changes
This commit is contained in:
1 parent
0c26329d69
commit
12c81c05dd
10 files changed
+298
-221
No files matched your search
@@ -70,7 +70,7 @@
|
||||
<ul>
|
||||
<li class="header">Actions</li>
|
||||
<li><a href="/newTest"><i class="fa-solid fa-plus fa-fw"></i> Create Test</a></li>
|
||||
<li><a href="/networks/upload"><i class="fa-solid fa-upload fa-fw"></i> Upload Net</a></li>
|
||||
<li><a href="/newNetwork"><i class="fa-solid fa-upload fa-fw"></i> Upload Net</a></li>
|
||||
</ul>
|
||||
|
||||
<hr>
|
||||
|
||||
@@ -1,59 +1,22 @@
|
||||
{% extends "OpenBench/base.html" %}
|
||||
|
||||
{% block style %}
|
||||
{% endblock %}
|
||||
{% load static %}
|
||||
|
||||
{% block scripts %}
|
||||
|
||||
{{ networks|json_script:"json-networks" }}
|
||||
|
||||
<script src="{% static 'networks.js' %}"></script>
|
||||
|
||||
<script>
|
||||
|
||||
var Networks = [
|
||||
{% for network in networks %}
|
||||
{
|
||||
'default' : "{{network.default}}",
|
||||
'engine' : "{{network.engine}}",
|
||||
'author' : "{{network.author|capfirst}}",
|
||||
'name' : "{{network.name}}",
|
||||
'hash' : "{{network.sha256}}",
|
||||
},
|
||||
{% endfor %}
|
||||
];
|
||||
|
||||
var Network_Sorting;
|
||||
|
||||
function swap_networks(index1, index2) {
|
||||
|
||||
var temp = Networks[index1];
|
||||
Networks[index1] = Networks[index2];
|
||||
Networks[index2] = temp;
|
||||
|
||||
var table = document.getElementById("network-table");
|
||||
var temp_row = table.rows[index1+1].innerHTML
|
||||
table.rows[index1+1].innerHTML = table.rows[index2+1].innerHTML;
|
||||
table.rows[index2+1].innerHTML = temp_row;
|
||||
}
|
||||
|
||||
function invert_networks() {
|
||||
for (let i = 0; Networks.length > i * 2; i++)
|
||||
swap_networks(i, Networks.length-i-1);
|
||||
}
|
||||
|
||||
function sort_networks(field) {
|
||||
|
||||
if (Network_Sorting == field)
|
||||
return invert_networks();
|
||||
|
||||
for (let i = 0; i != Networks.length; i++)
|
||||
for (let j = i + 1; j != Networks.length; j++)
|
||||
if (Networks[j][field] > Networks[i][field])
|
||||
swap_networks(i, j);
|
||||
|
||||
Network_Sorting = field;
|
||||
};
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function () { sort_networks("default"); }, false);
|
||||
|
||||
</scrpipt>
|
||||
document.addEventListener(
|
||||
'DOMContentLoaded', function () {
|
||||
sort_networks("name");
|
||||
sort_networks("engine");
|
||||
sort_networks("default");
|
||||
}, false
|
||||
);
|
||||
</script>
|
||||
|
||||
{% endblock %}
|
||||
|
||||
@@ -62,31 +25,34 @@
|
||||
<table id="network-table" class="hoverable">
|
||||
|
||||
<tr class="table-header">
|
||||
<th onclick=sort_networks("default")></th>
|
||||
<th onclick=sort_networks("engine")>Engine</th>
|
||||
<th onclick=sort_networks("author")>Uploader</th>
|
||||
<th onclick=sort_networks("name")>Name</th>
|
||||
<th onclick=sort_networks("hash")>Hash</th>
|
||||
<th class="cursor" onclick="sort_networks('default')"></th>
|
||||
<th class="cursor" onclick="sort_networks('engine')">Engine</th>
|
||||
<th class="cursor" onclick="sort_networks('author')">Author</th>
|
||||
<th class="cursor" onclick="sort_networks('name')">Name</th>
|
||||
<th class="cursor" onclick="sort_networks('sha256')")>Hash</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
|
||||
{% for network in networks %}
|
||||
<tr>
|
||||
|
||||
{% if network.default %}
|
||||
<td><i class="fas fa-star" aria-hidden="true"></i></td>
|
||||
{% else %}
|
||||
<td><a class="unstarred" href="/networks/default/{{network.sha256}}">
|
||||
<td><a class="unstarred" href="/networks/{{network.engine}}/default/{{network.sha256}}">
|
||||
<i class="far fa-star" aria-hidden="true"></i></a></td>
|
||||
{% endif %}
|
||||
|
||||
<td><a href="/networks/{{network.engine}}/">{{network.engine}}</a></td>
|
||||
<td><a href="/user/{{network.author}}">{{network.author|capfirst}}</a></td>
|
||||
<td><a href="/networks/download/{{network.sha256}}">{{network.name}}</a></td>
|
||||
<td>{{network.author|capfirst}}</td>
|
||||
<td><a href="/networks/{{network.engine}}/download/{{network.sha256}}">{{network.name}}</a></td>
|
||||
<td>{{network.sha256}}</td>
|
||||
|
||||
<td><a class="redlink" onclick="return confirm('YOU ARE DELETING THIS NETWORK FILE FOREVER')" href="/networks/delete/{{network.sha256}}">
|
||||
<i class="fas fa-minus-circle"></i></a></td>
|
||||
<td>
|
||||
<a class="redlink"
|
||||
onclick="return confirm('YOU ARE DELETING THIS NETWORK FILE FOREVER')"
|
||||
href="/networks/{{network.engine}}/delete/{{network.sha256}}">
|
||||
<i class="fas fa-minus-circle"></i></a>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
||||
|
||||
@@ -1,39 +1,59 @@
|
||||
{% extends "OpenBench/base.html" %}
|
||||
|
||||
{% block scripts %}
|
||||
|
||||
<script>
|
||||
|
||||
document.addEventListener(
|
||||
'DOMContentLoaded', function () {
|
||||
|
||||
var form = document.getElementById("network-form");
|
||||
form.addEventListener("submit", function(event) {
|
||||
|
||||
event.preventDefault(); // Stop event from hitting the wrong URL
|
||||
|
||||
// Adjust the Form endpoint based on Network Name and Engine
|
||||
var network_name = encodeURIComponent(document.getElementById("network-name").value);
|
||||
var engine_name = encodeURIComponent(document.getElementById("network-engine").value);
|
||||
|
||||
// OpenBench Endpoint: networks/engine/upload/name/
|
||||
form.action = '/networks/' + engine_name + '/upload/' + network_name + '/'
|
||||
form.submit()
|
||||
});
|
||||
}, false
|
||||
);
|
||||
|
||||
</script>
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
<form method="post" enctype="multipart/form-data">
|
||||
{% csrf_token %}
|
||||
|
||||
<div class="form">
|
||||
<div class="col">
|
||||
<div class="row">
|
||||
<label>Name</label><input name="name">
|
||||
<form method="post" enctype="multipart/form-data" id="network-form">
|
||||
{% csrf_token %}
|
||||
<div class="form">
|
||||
<div class="col">
|
||||
<div class="row">
|
||||
<label>Name</label><input id="network-name" name="name">
|
||||
</div>
|
||||
<div class="row">
|
||||
<label>Weights</label><input name="netfile" type="file">
|
||||
</div>
|
||||
<div class="row">
|
||||
<label>Engine</label>
|
||||
<select id="network-engine" name="engine">
|
||||
{% for engine in config.engines %}
|
||||
{% if engine == profile.engine %}
|
||||
<option selected value="{{ engine }}">{{ engine }}</option>
|
||||
{% else %}
|
||||
<option value="{{ engine }}">{{ engine }}</option>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
<input type="submit" class="anchorbutton btn-blue w-100" value="Upload">
|
||||
</div>
|
||||
<div class="row">
|
||||
<label>Weights</label><input name="netfile" type="file">
|
||||
</div>
|
||||
<div class="row">
|
||||
<label>Engine</label>
|
||||
<select id="engine" name="engine">
|
||||
{% for engine in config.engines %}
|
||||
{% if engine == profile.engine %}
|
||||
<option selected value="{{ engine }}">{{ engine }}</option>
|
||||
{% else %}
|
||||
<option value="{{ engine }}">{{ engine }}</option>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
|
||||
|
||||
<input type="submit" class="anchorbutton btn-blue w-100" value="Upload">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<form>
|
||||
|
||||
{% endblock %}
|
||||
Reference in new issue
Block a user