2024-07-11 23:19:24 +02:00
|
|
|
|
|
|
|
import QtQuick 2.15
|
|
|
|
import QtQuick.Window 2.15
|
|
|
|
import QtQuick.Layouts 2.15
|
|
|
|
import QtQuick.Controls 2.15
|
|
|
|
|
|
|
|
Window {
|
|
|
|
SystemPalette { id: activeColors; colorGroup: SystemPalette.Active }
|
|
|
|
SystemPalette { id: inactiveColors; colorGroup: SystemPalette.Inactive }
|
|
|
|
SystemPalette { id: disabledColors; colorGroup: SystemPalette.Disabled }
|
|
|
|
|
|
|
|
function getColors() {
|
|
|
|
return dataScreen.active ? activeColors : inactiveColors;
|
|
|
|
}
|
|
|
|
|
|
|
|
id: dataScreen
|
|
|
|
visible: true
|
|
|
|
color: getColors().window
|
|
|
|
|
|
|
|
title: qsTr("Alisa - Add License Group")
|
|
|
|
|
|
|
|
property string authToken: ""
|
|
|
|
|
|
|
|
TextField {
|
|
|
|
id: nameT
|
|
|
|
anchors {
|
|
|
|
horizontalCenter: parent.horizontalCenter
|
|
|
|
topMargin: 5
|
|
|
|
top: parent.top // Assuming there's no loginL defined in your code
|
|
|
|
}
|
|
|
|
placeholderText: qsTr("Name")
|
|
|
|
Keys.onReturnPressed: submit()
|
|
|
|
}
|
|
|
|
|
|
|
|
Button {
|
|
|
|
id: submitB
|
|
|
|
anchors {
|
|
|
|
horizontalCenter: parent.horizontalCenter
|
|
|
|
topMargin: 5
|
|
|
|
top: nameT.bottom
|
|
|
|
}
|
|
|
|
text: qsTr("Submit")
|
|
|
|
|
|
|
|
onClicked: submit()
|
|
|
|
Keys.onReturnPressed: submit()
|
2024-07-12 09:27:17 +02:00
|
|
|
|
2024-07-11 23:19:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function submit() {
|
|
|
|
var xhr = new XMLHttpRequest();
|
|
|
|
xhr.open("POST", "https://api.clan-war.net/api/v1/groups");
|
|
|
|
xhr.setRequestHeader("Content-Type", "application/json");
|
|
|
|
xhr.setRequestHeader("Authorization", "Bearer " + authToken);
|
|
|
|
xhr.onreadystatechange = function() {
|
|
|
|
if (xhr.readyState === XMLHttpRequest.DONE) {
|
|
|
|
if (xhr.status != 200) {
|
|
|
|
console.log("Submission failed: " + xhr.status);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var data = JSON.stringify({
|
|
|
|
name: nameT.text,
|
|
|
|
});
|
|
|
|
|
|
|
|
xhr.send(data);
|
2024-07-12 09:27:17 +02:00
|
|
|
dataScreen.close()
|
2024-07-11 23:19:24 +02:00
|
|
|
}
|
|
|
|
}
|