|
|
@@ -0,0 +1,65 @@
|
|
|
+function editBoard () {
|
|
|
+ document.getElementById('board_edit_content').style.display = 'flex';
|
|
|
+ document.getElementById('saveBtn').style.display = 'inline-block';
|
|
|
+ document.getElementById('board_content').style.display = 'none';
|
|
|
+ document.getElementById('editBtn').style.display = 'none';
|
|
|
+}
|
|
|
+
|
|
|
+function saveEdit() {
|
|
|
+ const id = document.getElementById('board_id').value;
|
|
|
+ const content = document.getElementById('board_edit_content').value;
|
|
|
+ axios.patch('/api/v1/board/detail', {id, content})
|
|
|
+ .then(res => {
|
|
|
+ if (res.status === 200) {
|
|
|
+ adminChangeInner('admin-notice');
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .catch(error => {
|
|
|
+
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+function deleteBoard() {
|
|
|
+ if (confirm('정말 삭제 하시겠습니까?')) {
|
|
|
+ const id = document.getElementById('board_id').value;
|
|
|
+ axios.delete('/api/v1/board', {params : {id}})
|
|
|
+ .then(res => {
|
|
|
+ if (res.status === 200) {
|
|
|
+ alert('삭제가 완료되었습니다.')
|
|
|
+ adminChangeInner('admin-notice');
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .catch(error => {
|
|
|
+ console.log(error)
|
|
|
+ })
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+function insertBoard() {
|
|
|
+ const content = document.getElementById('board_content').value;
|
|
|
+ const title = document.getElementById('board_title').value;
|
|
|
+ const userName = document.getElementById('board_user_name').value;
|
|
|
+ const type = document.getElementById('board_type').value;
|
|
|
+ if (nullCheck(title)) {alert('제목을 입력하세요.'); return false}
|
|
|
+ if (nullCheck(content)) {alert('내용을 입력하세요.'); return false}
|
|
|
+ if (nullCheck(userName)) {alert('이름을 입력하세요.'); return false}
|
|
|
+ if (nullCheck(type)) {alert('타입을 입력하세요.'); return false}
|
|
|
+ let formData = new FormData();
|
|
|
+ formData.append('title', title);
|
|
|
+ formData.append('content', content);
|
|
|
+ formData.append('userName', userName);
|
|
|
+ formData.append('type', type);
|
|
|
+ axios.post('/api/v1/board', formData)
|
|
|
+ .then(res=>{
|
|
|
+ alert('저장이 완료되었습니다.')
|
|
|
+ adminChangeInner('admin-notice');
|
|
|
+
|
|
|
+ })
|
|
|
+ .catch(error=>{
|
|
|
+
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+function nullCheck (data) {
|
|
|
+ return !data || !data.trim();
|
|
|
+}
|