Changeset 1413ee2 for src/main/resources/static/js
- Timestamp:
- 01/03/24 00:00:07 (11 months ago)
- Branches:
- master
- Children:
- 53765dd
- Parents:
- 77205be
- Location:
- src/main/resources/static/js
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
src/main/resources/static/js/admin.js
r77205be r1413ee2 20 20 } 21 21 }); 22 console.log(JSON.stringify(companiesToSave));23 22 24 23 25 24 $.ajax({ 26 url: "http://localhost:8080/api/ business",25 url: "http://localhost:8080/api/admin", 27 26 type:"PATCH", 28 27 data: JSON.stringify(companiesToSave), -
src/main/resources/static/js/business_admin.js
r77205be r1413ee2 2 2 var business = {}; 3 3 4 getBusinessInfo(business); 4 getBusinessInfo().then(function (data) { 5 business = data; 6 }); 5 7 6 8 getAppointments(); … … 33 35 $("#update_services_button").click(function () { 34 36 businesses = []; 35 console.log("Gjoko");36 37 servicesObj = []; 37 38 $.each($('#predefined_services_admin_panel input:checked').siblings(), function (index, label) { … … 43 44 var price = $($($(label).parent()).siblings()[1]).children()[0].value; 44 45 45 var serviceType = {} 46 var serviceType = {}; 46 47 if (parseInt(id) != -1) { 47 48 service['id'] = parseInt(id); … … 56 57 servicesObj.push(service); 57 58 }); 58 business['services'] = servicesObj; 59 60 businesses.push(business); 61 console.log(JSON.stringify(businesses)); 62 63 $.ajax({ 64 url: "http://localhost:8080/api/business", 65 type:"PATCH", 66 data: JSON.stringify(businesses), 67 contentType:"application/json; charset=utf-8", 68 dataType: 'text', 69 success: function(succ){ 70 alert( "Updates applied successfully" ); 71 }, 72 error: function(err) { 73 alert(err); 74 } 75 }); 59 60 var servicesForDelete=[]; 61 $.each($('#predefined_services_admin_panel input:not(:checked)').siblings(), function (index, label) { 62 let id = $(label).prop('for'); 63 let foundService = business['services'].find(obj => obj.id === parseInt(id)); 64 if (foundService !== undefined && foundService['serviceStatus'] === 'ACTIVE') { 65 let service1 = {}; 66 service1['id'] = id; 67 servicesForDelete.push(service1); 68 } 69 }); 70 71 72 updateServices(servicesObj).then(function (response) { 73 getBusinessInfo().then(function (data) { 74 business = data; 75 }); 76 }); 77 78 if (servicesForDelete.length > 0) { 79 deleteServices(servicesForDelete).then(function (response) { 80 getBusinessInfo().then(function (data) { 81 business = data; 82 }); 83 }); 84 } 85 76 86 event.preventDefault(); 77 87 }); … … 79 89 $("#update_owner_button").click(function() { 80 90 businesses = []; 81 business['owner']['firstName'] = $('#firstName').val(); 82 business['owner']['lastName'] = $('#lastName').val(); 83 business['owner']['email'] = $('#email').val(); 84 business['owner']['phoneNumber'] = $('#phoneNumber').val(); 85 business['owner']['username'] = $('#username').val(); 91 owner={}; 92 owner['firstName'] = $('#firstName').val(); 93 owner['lastName'] = $('#lastName').val(); 94 owner['email'] = $('#email').val(); 95 owner['phoneNumber'] = $('#phoneNumber').val(); 96 owner['username'] = $('#username').val(); 97 98 business['owner'] = owner; 86 99 87 100 businesses.push(business); 88 console.log(JSON.stringify(businesses)); 89 90 $.ajax({ 91 url: "http://localhost:8080/api/business", 92 type:"PATCH", 93 data: JSON.stringify(businesses), 94 contentType:"application/json; charset=utf-8", 95 dataType: 'text', 96 success: function(succ){ 97 alert( "Updates applied successfully" ); 98 }, 99 error: function(err) { 100 alert(err); 101 } 101 102 updateBusinessInfo(businesses).then(function() { 103 getBusinessInfo().then(function (found) { 104 business = found; 105 }); 102 106 }); 103 107 }); 104 108 event.preventDefault(); 105 109 }); 110 111 function updateBusinessInfo(businessList) { 112 return $.ajax({ 113 url: "http://localhost:8080/api/business", 114 type:"PATCH", 115 data: JSON.stringify(businessList), 116 contentType:"application/json; charset=utf-8", 117 dataType: 'text', 118 success: function(succ){ 119 alert( "Updates applied successfully" ); 120 }, 121 error: function(err) { 122 alert(err); 123 } 124 }); 125 } 126 127 function updateServices(serviceList) { 128 return $.ajax({ 129 url: "http://localhost:8080/api/service", 130 type:"PATCH", 131 data: JSON.stringify(serviceList), 132 contentType:"application/json; charset=utf-8", 133 dataType: 'text', 134 success: function(succ){ 135 alert( "Updates applied successfully" ); 136 }, 137 error: function(err) { 138 alert(err); 139 } 140 }); 141 } 142 143 function deleteServices(services) { 144 return $.ajax({ 145 url: "http://localhost:8080/api/service/delete", 146 type:"POST", 147 data: JSON.stringify(services), 148 contentType:"application/json; charset=utf-8", 149 dataType: 'text', 150 success: function(succ){ 151 console.log("services deleted successfully"); 152 }, 153 error: function(err) { 154 console.error(err); 155 } 156 }); 157 } 106 158 107 159 function cancelAppointment(appointmentId) { … … 123 175 url: "http://localhost:8080/api/appointment/future/me" 124 176 }).then(function (data) { 125 console.log(data);126 177 var $el = $("#bookings-table-body"); 127 178 $el.empty(); … … 154 205 } 155 206 156 function getBusinessInfo( business) {157 $.ajax({207 function getBusinessInfo() { 208 return $.ajax({ 158 209 url: "http://localhost:8080/api/business/me" 159 }).then(function (data) { 160 business = data; 210 }).then(function (business) { 161 211 var $header = $("#header"); 162 212 163 213 // header 164 $header.text( $header.text() + "" + business["owner"]['firstName'] + " " + business['owner']['lastName']);214 $header.text("Welcome back " + business["owner"]['firstName'] + " " + business['owner']['lastName']); 165 215 166 216 // business info … … 181 231 var $el = $("#predefined_services_admin_panel"); 182 232 $el.empty(); 233 183 234 $.each(business['services'], function (index, obj) { 184 $el.append( 185 235 236 var element = '<div class=\"form-outline mb-4\">' + 186 237 ' <div class="row">' + 187 238 ' <div class="col-md-6">\n' + 188 ' <input class="form-check-input" type="checkbox" checked value=\"' + obj.id + '\" id=\"' + obj.id + '\">\n' + 239 ' <input class="form-check-input" type="checkbox" '; 240 241 if (obj['serviceStatus'] === 'ACTIVE') { 242 element += 'checked'; 243 } 244 245 element += ' value=\"' + obj.id + '\" id=\"' + obj.id + '\">\n' + 189 246 ' <label class="form-check-label" for=\"' + obj.id + '\">\n' + obj['serviceType'].name + '</label>\n' + 190 247 ' </div>' + … … 196 253 ' </div>' + 197 254 ' </div>' + 198 '</div>'); 199 }); 200 }); 201 } 255 '</div>'; 256 257 $el.append(element); 258 }); 259 return business; 260 }); 261 } -
src/main/resources/static/js/customer_admin.js
r77205be r1413ee2 16 16 customerForSave['phoneNumber'] = $('#phoneNumber').val(); 17 17 customerForSave['username'] = $('#username').val(); 18 19 console.log(JSON.stringify(customerForSave));20 18 21 19 $.ajax({ … … 55 53 const recipientId = button.getAttribute('data-bs-id'); 56 54 57 console.log(recipientName + ' ' + recipientId);58 // If necessary, you could initiate an Ajax request here59 // and then do the updating in a callback.60 61 55 // Update the modal's content. 62 56 const modalTitle = reviewModal.querySelector('.modal-title'); … … 97 91 url: "http://localhost:8080/api/appointment/future/me" 98 92 }).then(function (data) { 99 console.log(data);100 93 var $el = $("#appointments-table-body"); 101 94 $el.empty(); … … 194 187 url: "http://localhost:8080/api/review/me" 195 188 }).then(function (data) { 196 console.log(data);197 189 var $el = $("#my-reviews"); 198 190 $el.empty(); … … 233 225 $('#reviewModal').modal('toggle'); 234 226 getPastAppointments(); 227 getReviewsForCustomer(); 235 228 }, 236 229 error: function(error) { … … 248 241 }).success(function (data) { 249 242 alert("Appointment successfully canceled.") 250 get Appointments();243 getFutureAppointments(); 251 244 }).error(function (error) { 252 245 alert("Something went wrong."); -
src/main/resources/static/js/homepage.js
r77205be r1413ee2 102 102 // get already stored service from in-memory 103 103 selectedServices = businesses.find(item => item.id == selectedVal)['services']; 104 console.log(selectedServices); 104 105 resetAndAppendServices(selectedServices); 105 106 }); … … 164 165 165 166 $.each(services, function (index, obj) { 166 $el.append("<option value=" + obj.id + ">" + obj.serviceType.name + "</option>"); 167 if (obj.serviceStatus === 'ACTIVE') { 168 $el.append("<option value=" + obj.id + ">" + obj.serviceType.name + "</option>"); 169 } 167 170 }); 168 171 }
Note:
See TracChangeset
for help on using the changeset viewer.