서승완
Builds for 1 pipeline canceled in 29 seconds

feat: implement frontend function

...@@ -14,12 +14,12 @@ ...@@ -14,12 +14,12 @@
14 data-target="#sidebarMenu"> 14 data-target="#sidebarMenu">
15 <span class="navbar-toggler-icon"></span> 15 <span class="navbar-toggler-icon"></span>
16 </button> 16 </button>
17 - <input class="form-control form-control-dark w-100" type="text" placeholder="KhuBox에서 검색"> 17 + <div class="w-100"></div>
18 - <ul class="navbar-nav px-3"> 18 +<!-- <ul class="navbar-nav px-3">-->
19 - <li class="nav-item text-nowrap"> 19 +<!-- <li class="nav-item text-nowrap">-->
20 - <a class="nav-link" href="#!/settings">설정</a> 20 +<!-- <a class="nav-link" href="#!/settings">설정</a>-->
21 - </li> 21 +<!-- </li>-->
22 - </ul> 22 +<!-- </ul>-->
23 <ul class="navbar-nav px-3"> 23 <ul class="navbar-nav px-3">
24 <li class="nav-item text-nowrap"> 24 <li class="nav-item text-nowrap">
25 <a class="nav-link" href="#!/logout">로그아웃</a> 25 <a class="nav-link" href="#!/logout">로그아웃</a>
...@@ -161,12 +161,13 @@ ...@@ -161,12 +161,13 @@
161 </div> 161 </div>
162 </div> 162 </div>
163 </main> 163 </main>
164 + <input type="hidden" id="this-group-id">
164 <main id="manage_group" style="display:none;" role="main" class="col-md-9 ml-sm-auto col-lg-10 px-md-4"> 165 <main id="manage_group" style="display:none;" role="main" class="col-md-9 ml-sm-auto col-lg-10 px-md-4">
165 <div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 mb-3"> 166 <div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 mb-3">
166 <h1 class="h2">그룹 설정</h1> 167 <h1 class="h2">그룹 설정</h1>
167 </div> 168 </div>
168 <div class="accordion" id="manage_group_accord"> 169 <div class="accordion" id="manage_group_accord">
169 - <div class="card"> 170 + <div id="card-1" style="display:none;" class="card">
170 <div class="card-header"> 171 <div class="card-header">
171 <h2 class="mb-0"> 172 <h2 class="mb-0">
172 <button class="btn btn-link btn-block text-left" type="button" data-toggle="collapse" data-target="#manage_group_accord1" aria-expanded="true" aria-controls="collapseOne"> 173 <button class="btn btn-link btn-block text-left" type="button" data-toggle="collapse" data-target="#manage_group_accord1" aria-expanded="true" aria-controls="collapseOne">
...@@ -183,16 +184,16 @@ ...@@ -183,16 +184,16 @@
183 <small class="form-text text-muted">변경할 그룹명을 입력해주세요.</small> 184 <small class="form-text text-muted">변경할 그룹명을 입력해주세요.</small>
184 <small class="form-text text-muted">모든 그룹원에게 변경이 반영됩니다.</small> 185 <small class="form-text text-muted">모든 그룹원에게 변경이 반영됩니다.</small>
185 </div> 186 </div>
186 - <button type="button" class="btn btn-primary" onclick="GroupJoin();">변경</button> 187 + <button type="button" class="btn btn-primary" onclick="ChangeGroupName();">변경</button>
187 </form> 188 </form>
188 </div> 189 </div>
189 </div> 190 </div>
190 </div> 191 </div>
191 - <div class="card"> 192 + <div id="card-2" style="display:none;" class="card">
192 <div class="card-header"> 193 <div class="card-header">
193 <h2 class="mb-0"> 194 <h2 class="mb-0">
194 <button class="btn btn-link btn-block text-left collapsed" type="button" data-toggle="collapse" data-target="#manage_group_accord2" aria-expanded="false" aria-controls="collapseTwo"> 195 <button class="btn btn-link btn-block text-left collapsed" type="button" data-toggle="collapse" data-target="#manage_group_accord2" aria-expanded="false" aria-controls="collapseTwo">
195 - 초대코드 조회 및 재발급 196 + 초대코드 조회
196 </button> 197 </button>
197 </h2> 198 </h2>
198 </div> 199 </div>
...@@ -204,13 +205,11 @@ ...@@ -204,13 +205,11 @@
204 <input type="text" class="form-control" id="group-invite-code" readonly> 205 <input type="text" class="form-control" id="group-invite-code" readonly>
205 <small class="form-text text-muted">위의 초대코드를 입력하면 그룹원이 가입할 수 있습니다.</small> 206 <small class="form-text text-muted">위의 초대코드를 입력하면 그룹원이 가입할 수 있습니다.</small>
206 </div> 207 </div>
207 - <button type="button" class="btn btn-success" onclick="GroupCreate();">재발급</button>
208 - <small class="form-text text-muted">재발급할 경우 기존의 초대코드로는 더 이상 가입할 수 없습니다.</small>
209 </form> 208 </form>
210 </div> 209 </div>
211 </div> 210 </div>
212 </div> 211 </div>
213 - <div class="card"> 212 + <div id="card-3" style="display:none;" class="card">
214 <div class="card-header"> 213 <div class="card-header">
215 <h2 class="mb-0"> 214 <h2 class="mb-0">
216 <button class="btn btn-link btn-block text-left collapsed" type="button" data-toggle="collapse" data-target="#manage_group_accord3" aria-expanded="false" aria-controls="collapseTwo"> 215 <button class="btn btn-link btn-block text-left collapsed" type="button" data-toggle="collapse" data-target="#manage_group_accord3" aria-expanded="false" aria-controls="collapseTwo">
...@@ -233,7 +232,7 @@ ...@@ -233,7 +232,7 @@
233 </div> 232 </div>
234 </div> 233 </div>
235 </div> 234 </div>
236 - <div class="card"> 235 + <div id="card-4" style="display:none;" class="card">
237 <div class="card-header"> 236 <div class="card-header">
238 <h2 class="mb-0"> 237 <h2 class="mb-0">
239 <button class="btn btn-link btn-block text-left collapsed" type="button" data-toggle="collapse" data-target="#manage_group_accord4" aria-expanded="false" aria-controls="collapseTwo"> 238 <button class="btn btn-link btn-block text-left collapsed" type="button" data-toggle="collapse" data-target="#manage_group_accord4" aria-expanded="false" aria-controls="collapseTwo">
...@@ -244,14 +243,14 @@ ...@@ -244,14 +243,14 @@
244 <div id="manage_group_accord4" class="collapse" data-parent="#manage_group_accord"> 243 <div id="manage_group_accord4" class="collapse" data-parent="#manage_group_accord">
245 <div class="card-body"> 244 <div class="card-body">
246 <form> 245 <form>
247 - <button type="button" class="btn btn-warning" onclick="GroupCreate();">그룹 탈퇴</button> 246 + <button type="button" class="btn btn-warning" onclick="GroupExit();">그룹 탈퇴</button>
248 <small class="form-text text-muted">탈퇴하면 그룹 내 파일에 접근할 수 없습니다.</small> 247 <small class="form-text text-muted">탈퇴하면 그룹 내 파일에 접근할 수 없습니다.</small>
249 <small class="form-text text-muted">초대코드를 받으면 재가입할 수 있습니다.</small> 248 <small class="form-text text-muted">초대코드를 받으면 재가입할 수 있습니다.</small>
250 </form> 249 </form>
251 </div> 250 </div>
252 </div> 251 </div>
253 </div> 252 </div>
254 - <div class="card"> 253 + <div id="card-5" style="display:none;" class="card">
255 <div class="card-header"> 254 <div class="card-header">
256 <h2 class="mb-0"> 255 <h2 class="mb-0">
257 <button class="btn btn-link btn-block text-left collapsed" type="button" data-toggle="collapse" data-target="#manage_group_accord5" aria-expanded="false" aria-controls="collapseTwo"> 256 <button class="btn btn-link btn-block text-left collapsed" type="button" data-toggle="collapse" data-target="#manage_group_accord5" aria-expanded="false" aria-controls="collapseTwo">
......
...@@ -6,6 +6,12 @@ $("body").on('dblclick', 'tr.single-file', function(e) { ...@@ -6,6 +6,12 @@ $("body").on('dblclick', 'tr.single-file', function(e) {
6 }); 6 });
7 7
8 const ProcessHash = () => { 8 const ProcessHash = () => {
9 + $('#card-1').hide();
10 + $('#card-2').hide();
11 + $('#card-3').hide();
12 + $('#card-4').hide();
13 + $('#card-5').hide();
14 +
9 $('#menu-me').removeClass('active'); 15 $('#menu-me').removeClass('active');
10 $('#menu-public').removeClass('active'); 16 $('#menu-public').removeClass('active');
11 $('#menu-starred').removeClass('active'); 17 $('#menu-starred').removeClass('active');
...@@ -74,6 +80,7 @@ const ProcessHash = () => { ...@@ -74,6 +80,7 @@ const ProcessHash = () => {
74 $('#main-1').show(); 80 $('#main-1').show();
75 $('#main-2').show(); 81 $('#main-2').show();
76 $('#manage_group').show(); 82 $('#manage_group').show();
83 + ProcessGroup();
77 } else if (location.hash.indexOf('#!/files/') > -1) { 84 } else if (location.hash.indexOf('#!/files/') > -1) {
78 ProcessMain(); 85 ProcessMain();
79 $('#main-1').show(); 86 $('#main-1').show();
...@@ -354,7 +361,7 @@ const GetStarredList = () => { ...@@ -354,7 +361,7 @@ const GetStarredList = () => {
354 const GoShareLink = (file_id) => { 361 const GoShareLink = (file_id) => {
355 $('#share-pop').append(` 362 $('#share-pop').append(`
356 <div class="alert alert-info alert-dismissible fade show" role="alert"> 363 <div class="alert alert-info alert-dismissible fade show" role="alert">
357 - ${`http://localhost:63342/front/#!/files/${file_id}`} 364 + ${`https://khubox.khunet.net/#!/files/${file_id}`}
358 <button type="button" class="close" data-dismiss="alert" aria-label="Close"> 365 <button type="button" class="close" data-dismiss="alert" aria-label="Close">
359 <span aria-hidden="true">&times;</span> 366 <span aria-hidden="true">&times;</span>
360 </button> 367 </button>
...@@ -785,3 +792,96 @@ const GroupCreate = () => { ...@@ -785,3 +792,96 @@ const GroupCreate = () => {
785 } 792 }
786 }); 793 });
787 }; 794 };
795 +
796 +const ChangeGroupName = () => {
797 + const post_data = {
798 + name: $('#change-group-name').val(),
799 + };
800 + $.ajax({
801 + url: `https://khubox-api.khunet.net/groups/${$('#this-group-id').val()}`,
802 + headers: {
803 + 'Authorization': `Bearer ${localStorage.getItem('token')}`,
804 + },
805 + type: 'PATCH',
806 + data: JSON.stringify(post_data),
807 + success: (response) => {
808 + if (response.result === true) {
809 + alert('성공적으로 변경되었습니다.');
810 + getGroups();
811 + } else {
812 + alert(response.error)
813 + }
814 + }
815 + });
816 +};
817 +
818 +const ProcessGroup = () => {
819 + const group_id = location.hash.substring(10);
820 + $('#this-group-id').val(group_id);
821 +
822 + $.ajax({
823 + url: `https://khubox-api.khunet.net/groups/${group_id}`,
824 + headers: {
825 + 'Authorization': `Bearer ${localStorage.getItem('token')}`,
826 + },
827 + type: 'GET',
828 + success: (response) => {
829 + if (response.result === true) {
830 + $('#change-group-name').val(response.data.name);
831 + if (response.data.is_owner === true) {
832 + $('#group-invite-code').val(response.data.invite_code);
833 + $('#card-1').show();
834 + $('#card-2').show();
835 + // $('#card-3').show();
836 + // $('#card-5').show();
837 + } else {
838 + // $('#card-4').show();
839 + }
840 +
841 + } else {
842 + alert(response.error)
843 + }
844 + }
845 + });
846 +
847 +};
848 +
849 +const GroupExit = () => {
850 + //
851 + // $.ajax({
852 + // url: 'https://khubox-api.khunet.net/users/me',
853 + // headers: {
854 + // 'Authorization': `Bearer ${localStorage.getItem('token')}`,
855 + // },
856 + // type: 'GET',
857 + // success: (response) => {
858 + // if (response.result === true) {
859 + //
860 + //
861 + // $.ajax({
862 + // url: `https://khubox-api.khunet.net/groups/${$('#this-group-id').val()}/users/${response.data.id}`,
863 + // headers: {
864 + // 'Authorization': `Bearer ${localStorage.getItem('token')}`,
865 + // },
866 + // type: 'DELETE',
867 + // success: (response) => {
868 + // if (response.result === true) {
869 + // alert('성공적으로 탈퇴되었습니다.');
870 + // getGroups();
871 + // } else {
872 + // alert(response.error)
873 + // }
874 + // }
875 + // });
876 + //
877 + //
878 + //
879 + // } else {
880 + // alert(response.error);
881 + // }
882 + // }
883 + // });
884 +
885 +
886 +
887 +};
......