native: add delete key
This commit is contained in:
parent
cb0a920653
commit
b6cdd0c173
1 changed files with 30 additions and 0 deletions
|
@ -114,6 +114,7 @@ Rectangle {
|
||||||
Text { text: qsTr("Start"); color: getColors().text; Layout.preferredWidth: 100; font.bold: true }
|
Text { text: qsTr("Start"); color: getColors().text; Layout.preferredWidth: 100; font.bold: true }
|
||||||
Text { text: qsTr("End"); color: getColors().text; Layout.preferredWidth: 100; font.bold: true }
|
Text { text: qsTr("End"); color: getColors().text; Layout.preferredWidth: 100; font.bold: true }
|
||||||
Text { text: qsTr("Group"); color: getColors().text; Layout.preferredWidth: 150; font.bold: true }
|
Text { text: qsTr("Group"); color: getColors().text; Layout.preferredWidth: 150; font.bold: true }
|
||||||
|
Text { text: qsTr("Actions"); color: getColors().text; Layout.preferredWidth: 100; font.bold: true }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -143,6 +144,14 @@ Rectangle {
|
||||||
Text { text: model.start; color: getColors().text; Layout.preferredWidth: 100; elide: Text.ElideRight }
|
Text { text: model.start; color: getColors().text; Layout.preferredWidth: 100; elide: Text.ElideRight }
|
||||||
Text { text: model.end; color: getColors().text; Layout.preferredWidth: 100; elide: Text.ElideRight }
|
Text { text: model.end; color: getColors().text; Layout.preferredWidth: 100; elide: Text.ElideRight }
|
||||||
Text { text: model.group; color: getColors().text; Layout.preferredWidth: 150; elide: Text.ElideRight }
|
Text { text: model.group; color: getColors().text; Layout.preferredWidth: 150; elide: Text.ElideRight }
|
||||||
|
|
||||||
|
Button {
|
||||||
|
text: qsTr("Delete")
|
||||||
|
Layout.preferredWidth: 100
|
||||||
|
onClicked: {
|
||||||
|
deleteLicense(model.key)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -175,6 +184,10 @@ Rectangle {
|
||||||
}
|
}
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
|
loadLicenses()
|
||||||
|
}
|
||||||
|
|
||||||
|
function loadLicenses() {
|
||||||
var xhr = new XMLHttpRequest();
|
var xhr = new XMLHttpRequest();
|
||||||
xhr.open("GET", "https://api.clan-war.net/api/v1/licenses");
|
xhr.open("GET", "https://api.clan-war.net/api/v1/licenses");
|
||||||
xhr.setRequestHeader("Authorization", "Bearer " + authToken);
|
xhr.setRequestHeader("Authorization", "Bearer " + authToken);
|
||||||
|
@ -226,4 +239,21 @@ Rectangle {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function deleteLicense(key) {
|
||||||
|
var xhr = new XMLHttpRequest();
|
||||||
|
xhr.open("DELETE", "https://api.clan-war.net/api/v1/licenses/" + key);
|
||||||
|
xhr.setRequestHeader("Authorization", "Bearer " + authToken);
|
||||||
|
xhr.onreadystatechange = function() {
|
||||||
|
if (xhr.readyState === XMLHttpRequest.DONE) {
|
||||||
|
if (xhr.status === 200) {
|
||||||
|
console.log("License deleted successfully");
|
||||||
|
loadLicenses(); // Reload licenses after deletion
|
||||||
|
} else {
|
||||||
|
console.log("Error deleting license: " + xhr.status);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
xhr.send();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue