Skip to content
Snippets Groups Projects
Commit 3c7999cd authored by Syed OMAR's avatar Syed OMAR
Browse files

adding services in the AddServiceSceneController.java works

parent 1efb0c37
No related branches found
No related tags found
No related merge requests found
Pipeline #8313 canceled
[{"platform":"master","username":"syed","password":"MKyNsHSAOnLZrlaR+NfDMA==:M6yx0sHwB/ZbR4GjLQ3BICZXGAef2re2Np9UTbq4tEs="}]
\ No newline at end of file
[{"platform":"master","username":"syed","password":"i6ZciAQEoJyg6jJN5zggAQ==:pr8VZRZjxixRun/w6CGeZYhv9iG7epkxNlaSSd+8aUQ="},{"platform":"bobby","username":"hello","password":"11FNYAADZMJgkGqoylU8sQ==:khPaPmuaSCYqunc4xL2XLp0bJVKxwTfgsk0KTdna+Kw="}]
\ No newline at end of file
......@@ -6,11 +6,26 @@ import javafx.fxml.FXMLLoader;
import javafx.scene.Node;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Alert;
import javafx.scene.control.TextField;
import javafx.stage.Stage;
import java.io.IOException;
public class AddServiceSceneController {
@FXML
private TextField serviceField;
@FXML
private TextField usernameField;
@FXML
private TextField passwordField;
@FXML
private TextField confirmPasswordField;
@FXML
private void handleBack(ActionEvent event) {
try {
......@@ -34,4 +49,40 @@ public class AddServiceSceneController {
e.printStackTrace();
}
}
@FXML
private void handleAdd(ActionEvent event) {
String platform = serviceField.getText();
String username = usernameField.getText();
String password = passwordField.getText();
String confirmUser = confirmPasswordField.getText();
if (password.equals(confirmUser)) {
try {
DataStorage ds = new DataStorage("master_login.json");
ds.addData(platform, username, password);
ds.saveToJSON();
Alert alert = new Alert(Alert.AlertType.INFORMATION);
alert.setTitle("Add Service");
alert.setHeaderText("Success");
alert.setContentText("Service added successfully.");
alert.showAndWait();
Parent root = FXMLLoader.load(getClass().getResource("MainPage.fxml"));
Stage stage = (Stage) ((Node) event.getSource()).getScene().getWindow();
stage.setScene(new Scene(root));
stage.show();
} catch (Exception e) {
e.printStackTrace();
}
} else {
Alert alert = new Alert(Alert.AlertType.ERROR);
alert.setTitle("Add Service");
alert.setHeaderText("Error");
alert.setContentText("Password does not match Confirm Password.");
alert.showAndWait();
}
}
}
\ No newline at end of file
......@@ -49,10 +49,10 @@
</Label>
</children></AnchorPane>
<Label layoutX="88.0" layoutY="187.0" text="Name of Service" />
<TextField layoutX="60.0" layoutY="210.0" prefHeight="26.0" prefWidth="472.0" promptText="Name" />
<TextField fx:id="serviceField" layoutX="60.0" layoutY="210.0" prefHeight="26.0" prefWidth="472.0" promptText="Name" />
<Label layoutX="82.0" layoutY="350.0" prefHeight="17.0" prefWidth="179.0" text="Password" />
<Label layoutX="86.0" layoutY="267.0" prefHeight="17.0" prefWidth="147.0" text="Username" />
<TextField layoutX="60.0" layoutY="287.0" prefHeight="26.0" prefWidth="472.0" promptText="Username" />
<TextField fx:id="usernameField" layoutX="60.0" layoutY="287.0" prefHeight="26.0" prefWidth="472.0" promptText="Username" />
<Label layoutX="84.0" layoutY="431.0" prefHeight="17.0" prefWidth="179.0" text="Confirm Password" />
<ImageView fitHeight="25.0" fitWidth="17.0" layoutX="65.0" layoutY="431.0" pickOnBounds="true" preserveRatio="true">
<image>
......@@ -74,9 +74,9 @@
<Image url="@Gearss.png" />
</image>
</ImageView>
<PasswordField layoutX="60.0" layoutY="369.0" prefHeight="26.0" prefWidth="471.0" promptText="Password" />
<PasswordField layoutX="58.0" layoutY="451.0" prefHeight="26.0" prefWidth="471.0" promptText="Confirm Password" />
<Button layoutX="93.0" layoutY="538.0" mnemonicParsing="false" prefHeight="33.0" prefWidth="146.0" style="-fx-background-color: #3c8bff;" text="ADD">
<PasswordField fx:id="passwordField" layoutX="60.0" layoutY="369.0" prefHeight="26.0" prefWidth="471.0" promptText="Password" />
<PasswordField fx:id="confirmPasswordField" layoutX="58.0" layoutY="451.0" prefHeight="26.0" prefWidth="471.0" promptText="Confirm Password" />
<Button fx:id="addInfo" layoutX="93.0" layoutY="538.0" mnemonicParsing="false" onAction="#handleAdd" prefHeight="33.0" prefWidth="146.0" style="-fx-background-color: #3c8bff;" text="ADD">
<textFill>
<LinearGradient endX="1.0" endY="1.0">
<stops>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment