This commit is contained in:
Sphereso 2024-07-11 23:31:17 +02:00
commit a2180678c0
3 changed files with 92 additions and 2 deletions

67
native/AddGroup.qml Normal file
View file

@ -0,0 +1,67 @@
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()
}
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);
}
}

View file

@ -19,6 +19,7 @@ qt_add_qml_module(alisa
MainPage.qml
LoginScreen.qml
AddData.qml
AddGroup.qml
RESOURCES
Assets/Icons/turbo.svg

View file

@ -50,7 +50,21 @@ Rectangle {
Layout.alignment: Qt.AlignVCenter
onClicked: {
// Create and show a new window
var newWindow = newWindowComponent.createObject(null, { authToken: authToken });
var newWindow = addLicenseWindow.createObject(null, { authToken: authToken });
if (newWindow !== null) {
newWindow.show();
} else {
console.log("Failed to create new window");
}
}
}
Button {
text: qsTr("Add License Group")
Layout.alignment: Qt.AlignVCenter
onClicked: {
// Create and show a new window
var newWindow = addLicenseGroupWindow.createObject(null, { authToken: authToken });
if (newWindow !== null) {
newWindow.show();
} else {
@ -148,13 +162,21 @@ Rectangle {
}
Component {
id: newWindowComponent
id: addLicenseWindow
AddData {
id: dataWindow
authToken: authToken
}
}
Component {
id: addLicenseGroupWindow
AddGroup {
id: dataWindow
authToken: authToken
}
}
Component.onCompleted: {
var xhr = new XMLHttpRequest();
xhr.open("GET", "https://api.clan-war.net/api/v1/licenses");