Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Combine UI and API #4

Open
wants to merge 23 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
d12f5b5
make giantswarm client available in qml
janpieper Mar 15, 2015
36b33ef
update version test to 0.15.0
janpieper Mar 15, 2015
112b7a1
moved giantswarm client into instance property
janpieper Mar 15, 2015
a106e0a
covered basic login functionality
janpieper Mar 15, 2015
c8938b0
fill company list model with real data
janpieper Mar 15, 2015
335cd78
added company user handling
janpieper Mar 15, 2015
d90213e
read user data from api
janpieper Mar 15, 2015
5b16b16
disabled update of email and/or password
janpieper Mar 15, 2015
a959fc6
basic environment handling
janpieper Mar 15, 2015
7d907c8
allow environment creation
janpieper Mar 15, 2015
2b60cf5
fetch applications from api
janpieper Mar 15, 2015
d863149
disable login button if email and/or password missing
janpieper Mar 15, 2015
992cb99
expose TextField's textChanging() event
janpieper Mar 16, 2015
0704620
fixed en-/disabling login button
janpieper Mar 16, 2015
e53d6d7
updated bidstack-giantswarm dependency
janpieper Mar 18, 2015
71fc576
show all applications for all companies
janpieper Mar 18, 2015
9197acd
fixed assigning giantswarm client to qml
janpieper Mar 18, 2015
6235b1f
updated bidstack-giantswarm dependency
janpieper Mar 18, 2015
41713ac
fixed navigation's variable name
janpieper Mar 18, 2015
3a28bed
disable password field
janpieper Mar 18, 2015
30890ae
combine company and environment name
janpieper Mar 18, 2015
1bec96c
colorize on status change
janpieper Mar 20, 2015
8916fef
use data from giantswarm api
janpieper Mar 20, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions assets/qml/Account/AccountPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Page {
title: qsTr("Account")
acceptAction: ActionItem {
title: qsTr("Save")
enabled: false // TODO: New API method needed to update both (email & password)
attachedObjects: [
SystemToast {
id: accountCouldNotBeSavedToast
Expand All @@ -34,7 +35,7 @@ Page {
label: qsTr("Username")
inputMode: TextFieldInputMode.Text
hintText: qsTr("Enter your username here")
text: "bidstack"
text: ""
active: false
}
}
Expand All @@ -44,7 +45,7 @@ Page {
label: qsTr("Email")
inputMode: TextFieldInputMode.EmailAddress
hintText: qsTr("Enter your email here")
text: "[email protected]"
text: ""
active: false
}
}
Expand All @@ -55,7 +56,13 @@ Page {
inputMode: TextFieldInputMode.Password
hintText: qsTr("Enter your password here")
text: ""
active: false
}
}
}
onCreationCompleted: {
var user = giantswarm.getUser();
emailTextField.text = user["email"];
usernameTextField.text = user["name"];
}
}
21 changes: 14 additions & 7 deletions assets/qml/Application/ApplicationPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ import bb.cascades 1.4
import "../Elements"

Page {
property variant application;
property string application_name;
property string company_name;
property string environment_name;
titleBar: TitleBar {
title: qsTr("Application")
acceptAction: ActionItem {
Expand All @@ -26,7 +28,7 @@ Page {
}
Container {
Label {
text: application["name"]
text: application_name
textStyle.fontSize: FontSize.Large
bottomMargin: ui.du(0)
}
Expand All @@ -41,7 +43,8 @@ Page {
rightMargin: ui.du(0)
}
StatusLabel {
status: application["status"]
id: statusLabel
status: "unknown"
leftMargin: ui.du(0)
}
}
Expand Down Expand Up @@ -85,10 +88,14 @@ Page {
}
}
onCreationCompleted: {
servicesDataModel.insertList([
{ name: "website", status: "starting" },
{ name: "api", status: "failed" }
]);
var application = giantswarm.getApplicationStatus(
company_name,
environment_name,
application_name
);

statusLabel.status = application["status"];
servicesDataModel.insertList(application["services"]);
}
onTriggered: {
nav.push(Qt.createComponent(
Expand Down
25 changes: 15 additions & 10 deletions assets/qml/Application/ApplicationsPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ NavigationPane {
}
verticalAlignment: VerticalAlignment.Center
Label {
text: ListItemData.name
text: ListItemData.application_name
textStyle.fontSize: FontSize.Large
bottomMargin: 0
}
Label {
text: ListItemData.environment
text: ListItemData.company_name + "/" + ListItemData.environment_name
verticalAlignment: VerticalAlignment.Center
textStyle.fontSize: FontSize.Small
textStyle.color: Color.Gray
Expand All @@ -57,17 +57,22 @@ NavigationPane {
}
}
onCreationCompleted: {
applicationsDataModel.insertList([
{ name: "bidstack-api", environment: "bidstack/staging", status: "up" },
{ name: "giantswarm-weather", environment: "giantswarm/production", status: "starting" }
]);
applicationsDataModel.insertList(
giantswarm.getAllApplications().map(function (application) {
return {
application_name: application["application"],
company_name: application["company"],
environment_name: application["environment"]
};
})
);
}
onTriggered: {
navigation.push(Qt.createComponent(
nav.push(Qt.createComponent(
"ApplicationPage.qml"
).createObject(nav, {
application: applicationsDataModel.data(indexPath)
}));
).createObject(nav, applicationsDataModel.data(
indexPath
)));
}
}
}
Expand Down
8 changes: 2 additions & 6 deletions assets/qml/Application/ComponentPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ Page {
layoutProperties: StackLayoutProperties {
spaceQuota: 1
}
text: ListItemData.name
text: ListItemData.id
textStyle.fontSize: FontSize.Large
verticalAlignment: VerticalAlignment.Center
}
Expand All @@ -85,11 +85,7 @@ Page {
}
}
onCreationCompleted: {
instancesDataModel.insertList([
{ name: "c6ef55dc-d501-4669-b175-34b5c112ba79", status: "up" },
{ name: "37df40f4-fd6d-4b60-a662-d7d61ec0741c", status: "starting" },
{ name: "7a1f51cf-33b7-4a5b-b101-c943dcc8b48a", status: "failed" }
]);
instancesDataModel.insertList(component["instances"]);
}
onTriggered: {
nav.push(Qt.createComponent(
Expand Down
2 changes: 1 addition & 1 deletion assets/qml/Application/InstancePage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Page {
spaceQuota: 1
}
Label {
text: instance["name"]
text: instance["id"]
textStyle.fontSize: FontSize.Large
bottomMargin: ui.du(0)
}
Expand Down
5 changes: 1 addition & 4 deletions assets/qml/Application/ServicePage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,7 @@ Page {
}
}
onCreationCompleted: {
componentsDataModel.insertList([
{ name: "nginx", status: "up" },
{ name: "rails", status: "up" }
]);
componentsDataModel.insertList(service["components"]);
}
onTriggered: {
nav.push(Qt.createComponent(
Expand Down
9 changes: 5 additions & 4 deletions assets/qml/Company/CompaniesPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,11 @@ NavigationPane {
}
}
onCreationCompleted: {
companiesDataModel.insertList([
{ name: "bidstack" },
{ name: "giantswarm" }
]);
companiesDataModel.insertList(
giantswarm.getCompanies().map(function (companyName) {
return { name: companyName };
}
));
}
onTriggered: {
nav.push(Qt.createComponent(
Expand Down
23 changes: 17 additions & 6 deletions assets/qml/Company/CompanyPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,12 @@ Page {
confirmButton.label: qsTr("Add")
onFinished: {
if (result == SystemUiResult.ConfirmButtonSelection) {
if (true) {
var added = giantswarm.addUserToCompany(
company["name"], // company name
inputFieldTextEntry() // name of user
);

if (added) {
usersDataModel.insert({ name: inputFieldTextEntry() });
userHasSuccessfullyBeenAddedToast.show();
} else {
Expand Down Expand Up @@ -113,7 +118,12 @@ Page {
confirmButton.label: qsTr("Yes")
onFinished: {
if (result == SystemUiResult.ConfirmButtonSelection) {
if (true) {
var removed = giantswarm.removeUserFromCompany(
company["name"], // company name
ListItemData.name // name of user
);

if (removed) {
item.ListItem.view.dataModel.removeAt(item.ListItem.indexPath);
userHasSuccessfullyBeenRemovedToast.show();
} else {
Expand All @@ -140,10 +150,11 @@ Page {
}
}
onCreationCompleted: {
usersDataModel.insertList([
{ name: "jan.pieper" },
{ name: "support" }
]);
usersDataModel.insertList(giantswarm.getCompanyUsers(
company["name"]
).map(function (username) {
return { name: username };
}));
}
}
}
Expand Down
5 changes: 5 additions & 0 deletions assets/qml/Elements/LabeledTextField.qml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import bb.cascades 1.4

Container {
id: labeledTextField

signal textChanging();

property alias label: label.text
property alias text: textField.text
property alias inputMode: textField.inputMode
Expand All @@ -19,5 +23,6 @@ Container {
textStyle.fontSize: FontSize.Large
accessibility.labelledBy: label
text: ""
onTextChanging: labeledTextField.textChanging()
}
}
8 changes: 4 additions & 4 deletions assets/qml/Elements/StatusLabel.qml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import bb.cascades 1.4

Label {
property string status;

text: status
textStyle.fontSize: FontSize.Small
onCreationCompleted: {

onStatusChanged: {
if (status == "up") {
textStyle.color = Color.Green
} else if (status == "starting") {
Expand All @@ -17,4 +17,4 @@ Label {
textStyle.color = Color.Gray
}
}
}
}
17 changes: 9 additions & 8 deletions assets/qml/Environment/EnvironmentCreatePage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,19 @@ Sheet {
}
]
onTriggered: {
var companyName = companyDropDown.value;
var environmentName = environmentTextField.text;
var companyName = companyDropDown.value
, environmentName = environmentTextField.text;

if (true) {
if (true) {
if (giantswarm.hasEnvironment(companyName, environmentName)) {
if (giantswarm.createEnvironment(companyName, environmentName)) {
sheet.environmentCreated(companyName, environmentName);
environmentHasSuccessfullyBeenCreatedToast.show();
sheet.close();
} else {
environmentAlreadyExistentToast.show();
environmentCouldNotBeCreatedToast.show();
}
} else {
environmentCouldNotBeCreatedToast.show();
environmentAlreadyExistentToast.show();
}
}
}
Expand All @@ -66,8 +66,9 @@ Sheet {
}
}
onCreationCompleted: {
addOption("bidstack");
addOption("giantswarm");
giantswarm.getCompanies().forEach(function (companyName) {
addOption(companyName);
});
}
}
}
Expand Down
22 changes: 17 additions & 5 deletions assets/qml/Environment/EnvironmentsPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,16 @@ NavigationPane {
confirmButton.label: qsTr("Yes")
onFinished: {
if (result == SystemUiResult.ConfirmButtonSelection) {
if (true) {
var parts = ListItemData.name.split("/")
, companyName = parts[0]
, environmentName = parts[1];

var deleted = giantswarm.deleteEnvironment(
companyName,
environmentName
);

if (deleted) {
item.ListItem.view.dataModel.removeAt(item.ListItem.indexPath);
environmentHasSuccessfullyBeenRemovedToast.show();
} else {
Expand All @@ -118,10 +127,13 @@ NavigationPane {
}
}
onCreationCompleted: {
environmentsDataModel.insertList([
{ name: "bidstack/staging" },
{ name: "giantswarm/production" }
]);
environmentsDataModel.insertList(
giantswarm.getEnvironments().map(function (environment) {
return {
name: environment["company_name"] + "/" + environment["name"]
};
})
);
}
}
}
Expand Down
Loading