native: add license goup adder
This commit is contained in:
parent
238629fde6
commit
6a7ccbe06f
3 changed files with 92 additions and 2 deletions
67
native/AddGroup.qml
Normal file
67
native/AddGroup.qml
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
|
@ -19,6 +19,7 @@ qt_add_qml_module(alisa
|
||||||
MainPage.qml
|
MainPage.qml
|
||||||
LoginScreen.qml
|
LoginScreen.qml
|
||||||
AddData.qml
|
AddData.qml
|
||||||
|
AddGroup.qml
|
||||||
|
|
||||||
RESOURCES
|
RESOURCES
|
||||||
Assets/Icons/turbo.svg
|
Assets/Icons/turbo.svg
|
||||||
|
|
|
@ -50,7 +50,21 @@ Rectangle {
|
||||||
Layout.alignment: Qt.AlignVCenter
|
Layout.alignment: Qt.AlignVCenter
|
||||||
onClicked: {
|
onClicked: {
|
||||||
// Create and show a new window
|
// 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) {
|
if (newWindow !== null) {
|
||||||
newWindow.show();
|
newWindow.show();
|
||||||
} else {
|
} else {
|
||||||
|
@ -148,13 +162,21 @@ Rectangle {
|
||||||
}
|
}
|
||||||
|
|
||||||
Component {
|
Component {
|
||||||
id: newWindowComponent
|
id: addLicenseWindow
|
||||||
AddData {
|
AddData {
|
||||||
id: dataWindow
|
id: dataWindow
|
||||||
authToken: authToken
|
authToken: authToken
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Component {
|
||||||
|
id: addLicenseGroupWindow
|
||||||
|
AddGroup {
|
||||||
|
id: dataWindow
|
||||||
|
authToken: authToken
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
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");
|
||||||
|
|
Loading…
Reference in a new issue