diff --git a/src/web/admin/admin_register_list.html b/src/web/admin/admin_register_list.html
index ff3ccdf..08aa4c6 100644
--- a/src/web/admin/admin_register_list.html
+++ b/src/web/admin/admin_register_list.html
@@ -25,11 +25,11 @@
let maestroName = $("#search_name").val();
if(maestroName.length === 0) {
- // $("#search_name_notice").val("학생 이름을 입력하세요.");
+ $("#error_message").text("학생 이름을 입력하세요.");
$("#search_name").focus();
}
- loadMaestroList($maestroName);
+ loadMaestroList(maestroName);
}
function loadMaestroList($maestroName) {
@@ -43,6 +43,7 @@
// console.log(xhr.responseText.length);
if(xhr.responseText.length === 0 || xhr.responseText === null) {
console.log("no data from server");
+ $("#error_message").text("서버에서 요청을 수행하지 못했습니다.");
return;
}
@@ -51,16 +52,19 @@
if(replyJSON === null) {
console.log("no data from server");
+ $("#error_message").text("서버에서 데이터가 넘어오지 않았습니다.");
return;
}
if(replyJSON["ERROR"] !== undefined || replyJSON["RESULT"] === undefined) {
console.log(replyJSON["ERROR"]);
+ $("#error_message").text(replyJSON["ERROR"]);
return;
}
if(replyJSON["RESULT"] === "fail") {
console.log(replyJSON["RESULT"]);
+ $("#error_message").text(replyJSON["ERROR"]);
return;
}
@@ -138,6 +142,7 @@
// console.log(xhr.responseText.length);
if(xhr.responseText.length === 0 || xhr.responseText === null) {
console.log("no data from server");
+ $("#error_message").text("서버에서 요청을 수행하지 못했습니다.");
return;
}
@@ -146,20 +151,24 @@
if(replyJSON === null) {
console.log("no data from server");
+ $("#error_message").text("서버에서 데이터가 넘어오지 않았습니다.");
return;
}
if(replyJSON["ERROR"] !== undefined || replyJSON["RESULT"] === undefined) {
console.log(replyJSON["ERROR"]);
+ $("#error_message").text(replyJSON["ERROR"]);
return;
}
if(replyJSON["RESULT"] === "fail") {
console.log(replyJSON["RESULT"]);
+ $("#error_message").text(replyJSON["ERROR"]);
return;
}
loadMaestroList("");
+ $("#error_message").text("마에스트로 계정이 정상적으로 등록되었습니다.");
}
}
}
@@ -177,19 +186,24 @@
diff --git a/src/web/admin/login.html b/src/web/admin/login.html
index f833daf..5562e99 100644
--- a/src/web/admin/login.html
+++ b/src/web/admin/login.html
@@ -10,6 +10,7 @@
+
@@ -54,17 +50,19 @@
-
- 관리자 아이디
-
- 암호
-
-
+
+ 관리자 아이디
+
+ 암호
+
+
-
+
+
+
diff --git a/src/web/js/main.js b/src/web/js/main.js
index 530790c..fd8ee27 100644
--- a/src/web/js/main.js
+++ b/src/web/js/main.js
@@ -33,5 +33,4 @@ function logout() {
maestroID = -1;
sessionStorage.setItem("maestroID", maestroID);
location.href = './../main/index.html';
-}
-
+}
\ No newline at end of file
diff --git a/src/web/js/request_server.js b/src/web/js/request_server.js
new file mode 100644
index 0000000..21cb1e8
--- /dev/null
+++ b/src/web/js/request_server.js
@@ -0,0 +1,63 @@
+function sendRequestServer(url, sendParams, onSuccess, onFail, isDebugMode) {
+ // console.log(url);
+ // console.log(sendParams);
+ // console.log(onSuccess);
+ // console.log(onFail);
+ // console.log(isDebugMode);
+
+ let xhr = new XMLHttpRequest(); //new로 생성.
+ xhr.open('POST', url, true);
+ xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
+ xhr.send(sendParams);
+ xhr.onload = function() {
+ if(xhr.readyState === 4 && xhr.status === 200) {
+ // console.log(xhr.responseText);
+ // console.log(xhr.responseText.length);
+
+ if(xhr.responseText.length === 0 || xhr.responseText === null) {
+ let error_message = "서버에서 요청을 수행하지 못했습니다.";
+ printErrorMessage(error_message, onFail, isDebugMode);
+ return;
+ }
+
+ let jsonReply = JSON.parse(xhr.responseText);
+ // console.log(jsonReply);
+
+ if(jsonReply === null) {
+ let error_message = "서버에서 데이터가 넘어오지 않았습니다.";
+ printErrorMessage(error_message, onFail, isDebugMode);
+ return;
+ }
+
+ if(!isSuccess(jsonReply)) {
+ let error_message = getErrorMessage(jsonReply);
+ printErrorMessage(error_message, onFail, isDebugMode);
+ return;
+ }
+
+ onSuccess(jsonReply);
+ }
+ }
+}
+
+function isSuccess(jsonReply) {
+ if(jsonReply["result"] === undefined)
+ return false;
+
+ if(jsonReply["result"] === "fail")
+ return false;
+
+ return true;
+}
+
+function getErrorMessage(jsonReply) {
+ return jsonReply["error"];
+}
+
+function printErrorMessage(message, onFail, isDebugMode) {
+ if(onFail !== undefined && onFail !== null)
+ onFail(message);
+
+ if(isDebugMode === true)
+ console.log(message);
+}
\ No newline at end of file
diff --git a/src/web/server/lib/send_error_code.php b/src/web/server/lib/send_error_code.php
deleted file mode 100644
index d3eeb28..0000000
--- a/src/web/server/lib/send_error_code.php
+++ /dev/null
@@ -1,10 +0,0 @@
- $error_code
- );
- echo json_encode($returnValue, JSON_UNESCAPED_UNICODE);
-}
-
-?>
\ No newline at end of file
diff --git a/src/web/server/lib/send_reply_json.php b/src/web/server/lib/send_reply_json.php
new file mode 100644
index 0000000..a0339bc
--- /dev/null
+++ b/src/web/server/lib/send_reply_json.php
@@ -0,0 +1,35 @@
+close();
+}
+
+function send_result_fail() {
+ global $jsonReply;
+ global $db_conn;
+
+ $jsonReply["result"] = "fail";
+ echo json_encode($jsonReply, JSON_UNESCAPED_UNICODE);
+ $db_conn->close();
+}
+
+?>
\ No newline at end of file
diff --git a/src/web/server/maestro/login.php b/src/web/server/maestro/login.php
index e3a4995..786f919 100644
--- a/src/web/server/maestro/login.php
+++ b/src/web/server/maestro/login.php
@@ -1,9 +1,11 @@
close();
+ set_error_message("등록되지 않은 마에스트로 아이디입니다.");
+ send_result_fail();
exit;
}
-$replyJSON = login($maestro_name, $password);
-if($replyJSON === null || $replyJSON[MaestroID] === null) {
- $replyJSON["ERROR"] = "비밀번호를 잘못 입력하셨습니다.";
- echo json_encode($replyJSON, JSON_UNESCAPED_UNICODE);
- $db_conn->close();
+$login_data = login($maestro_name, $password);
+if($login_data === null || $login_data[maestroID] === null) {
+ set_error_message("비밀번호가 틀렸습니다.");
+ send_result_fail();
exit;
}
-echo json_encode($replyJSON, JSON_UNESCAPED_UNICODE);
-$db_conn->close();
+set_data("maestroId", $login_data[maestroID]);
+send_result_success();
exit;
+
+
function get_maestro_id($maestro_name) {
global $db_conn;
@@ -65,8 +65,8 @@ function login($maestro_name, $password) {
$stmt->fetch();
$stmt->close();
- $replyJSON["MaestroID"] = $maestro_id;
- return $replyJSON;
+ $result["maestroID"] = $maestro_id;
+ return $result;
}
?>
\ No newline at end of file
diff --git a/src/web/server/setup/connect_db.php b/src/web/server/setup/connect_db.php
index ab1374d..fd45821 100644
--- a/src/web/server/setup/connect_db.php
+++ b/src/web/server/setup/connect_db.php
@@ -1,7 +1,7 @@
connect_error) {
- send_error_code("Connection failed: ".$db_conn->connect_error);
+ set_error_message("Failed to connect DB: ".$db_conn->connect_error);
+ send_result_fail();
exit;
-}
-
-$query = "USE jisangs";
-$result = mysqli_query($db_conn, $query);
-
-
-function send_error_message($replyJSON, $error_message) {
- $replyJSON["ERROR"] = $error_message;
- echo json_encode($replyJSON, JSON_UNESCAPED_UNICODE);
- // $db_conn->close();
-}
-
-function send_result_message($replyJSON, $result_message) {
- $replyJSON["RESULT"] = $result_message;
- echo json_encode($replyJSON, JSON_UNESCAPED_UNICODE);
- // $db_conn->close();
+} else {
+ $query = "USE jisangs";
+ $result = mysqli_query($db_conn, $query);
}
?>
\ No newline at end of file