Skip to content

Commit

Permalink
Fix Model Deletion and Class Editing (#362)
Browse files Browse the repository at this point in the history
* fixed model upload bug

* removed unused func

* fix delete-model-bug

* style-fix

* fix-changeClassList

* fix css

* fix error
  • Loading branch information
leoarc authored Apr 14, 2020
1 parent be95cd1 commit ed2ee60
Show file tree
Hide file tree
Showing 5 changed files with 431 additions and 426 deletions.
4 changes: 2 additions & 2 deletions apps/model/model.css
Original file line number Diff line number Diff line change
Expand Up @@ -290,15 +290,15 @@ ul.disabled {
.form-style #weightsupload{
cursor: pointer;
}
#removeModel{
.btn-del{
background-color: red;
border: none;
color: white;
padding: 12px 16px;
font-size: 14px;
cursor: pointer;
}
#chngClassListBtn{
.btn-change{
background-color: rgb(133, 53, 199);
border: none;
color: white;
Expand Down
16 changes: 9 additions & 7 deletions apps/model/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -745,6 +745,7 @@ async function deleteModel(name) {
if (status) {
alert('Deleted', name);
showInfo();
modelName.splice(modelName.indexOf(name.split('/').pop().split('_').splice(2).join('_').slice(0, -3)), 1);
}
}
} else {
Expand All @@ -758,7 +759,7 @@ async function showInfo() {
var table = document.querySelector('#mdata');
var tx = db.transaction('models_store', 'readonly');
var store = tx.objectStore('models_store');

var modelCount=0;
empty(table);
// Update table data
(function(callback) {
Expand Down Expand Up @@ -787,19 +788,20 @@ async function showInfo() {
td = row.insertCell();
td.innerHTML = date;
td = row.insertCell();
td.innerHTML = '<button class="btn btn-primary btn-xs my-xs-btn" '+
'id="removeModel" type="button"><i class="material-icons"'+
td.innerHTML = '<button class="btn-del" '+
'id=removeModel'+ modelCount+' type="button"><i class="material-icons"'+
'style="font-size:16px;">delete_forever</i>Remove Model</button>';
td = row.insertCell();
td.innerHTML = '<button class="btn btn-primary btn-xs my-xs-btn" '+
'id="chngClassListBtn" type="button"><i class="material-icons"' +
td.innerHTML = '<button class="btn-change" '+
'id=chngClassListBtn'+ modelCount+' type="button"><i class="material-icons"' +
'style="font-size:16px;">edit</i> Edit Classes</button>';
document.getElementById('removeModel').addEventListener('click', () => {
document.getElementById('removeModel'+modelCount).addEventListener('click', () => {
deleteModel(name);
});
document.getElementById('chngClassListBtn').addEventListener('click', () => {
document.getElementById('chngClassListBtn'+modelCount).addEventListener('click', () => {
showNewClassInput(name);
});
modelCount+=1;
};
}
}
Expand Down
2 changes: 1 addition & 1 deletion apps/segment/segment.css
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ ul.disabled {
.form-style #weightsupload{
cursor: pointer;
}
#removeModel{
.btn-del{
background-color: red;
border: none;
color: white;
Expand Down
9 changes: 6 additions & 3 deletions apps/segment/segment.js
Original file line number Diff line number Diff line change
Expand Up @@ -1125,6 +1125,7 @@ async function deleteModel(name) {
if (status) {
alert('Deleted', name);
showInfo();
modelName.splice(modelName.indexOf(name.split('_').splice(1).join('_').slice(0, -3)), 1);
}
}
} else {
Expand All @@ -1139,6 +1140,7 @@ async function showInfo() {
var table = document.querySelector('#mdata');
var tx = db.transaction('models_store', 'readonly');
var store = tx.objectStore('models_store');
var modelCount=0;

empty(table);
// Update table data
Expand All @@ -1164,12 +1166,13 @@ async function showInfo() {
td = row.insertCell();
td.innerHTML = date;
td = row.insertCell();
td.innerHTML = '<button class="btn btn-primary btn-xs my-xs-btn" '+
'id="removeModel" type="button"><i class="material-icons"'+
td.innerHTML = '<button class="btn-del" '+
'id=removeModel'+modelCount+' type="button"><i class="material-icons"'+
'style="font-size:16px;">delete_forever</i>Remove Model</button>';
document.getElementById('removeModel').addEventListener('click', () => {
document.getElementById('removeModel'+modelCount).addEventListener('click', () => {
deleteModel(name);
});
modelCount+=1;
};
}
}
Expand Down
Loading

0 comments on commit ed2ee60

Please sign in to comment.