Changeset 950fa0d for src/main/resources/static/js
- Timestamp:
- 05/24/23 23:18:47 (18 months ago)
- Branches:
- master
- Children:
- 77205be
- Parents:
- 8bcd64c
- Location:
- src/main/resources/static/js
- Files:
-
- 1 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
src/main/resources/static/js/business_admin.js
r8bcd64c r950fa0d 7 7 }).then(function (data) { 8 8 business = data; 9 console.log(business);10 9 var $header = $("#header"); 11 10 … … 74 73 event.preventDefault(); 75 74 }); 75 76 $("#update_services_button").click(function () { 77 businesses = []; 78 console.log("Gjoko"); 79 servicesObj = []; 80 $.each($('#predefined_services_admin_panel input:checked').siblings(), function (index, label) { 81 82 let service = {}; 83 var id = $(label).prop('for'); 84 var text = $(label).text(); 85 var time = $($($(label).parent()).siblings()[0]).children()[0].value; 86 var price = $($($(label).parent()).siblings()[1]).children()[0].value; 87 88 var serviceType = {} 89 if (parseInt(id) != -1) { 90 service['id'] = parseInt(id); 91 serviceType['id'] = business['services'].find(obj => obj.id === parseInt(id))['serviceType']['id']; 92 } else { 93 94 } 95 serviceType['name'] = text.trim(); 96 service['serviceType'] = serviceType; 97 service['duration'] = parseInt(time); 98 service['price'] = parseInt(price); 99 servicesObj.push(service); 100 }); 101 business['services'] = servicesObj; 102 103 businesses.push(business); 104 console.log(JSON.stringify(businesses)); 105 106 $.ajax({ 107 url: "http://localhost:8080/api/business", 108 type:"PATCH", 109 data: JSON.stringify(businesses), 110 contentType:"application/json; charset=utf-8", 111 dataType: 'text', 112 success: function(succ){ 113 alert( "Updates applied successfully" ); 114 }, 115 error: function(err) { 116 alert(err); 117 } 118 }); 119 event.preventDefault(); 120 }); 121 122 $("#update_owner_button").click(function() { 123 businesses = []; 124 console.log("Gjoko"); 125 business['owner']['firstName'] = $('#firstName').val(); 126 business['owner']['lastName'] = $('#lastName').val(); 127 business['owner']['email'] = $('#email').val(); 128 business['owner']['username'] = $('#username').val(); 129 130 businesses.push(business); 131 console.log(JSON.stringify(businesses)); 132 133 $.ajax({ 134 url: "http://localhost:8080/api/business", 135 type:"PATCH", 136 data: JSON.stringify(businesses), 137 contentType:"application/json; charset=utf-8", 138 dataType: 'text', 139 success: function(succ){ 140 alert( "Updates applied successfully" ); 141 }, 142 error: function(err) { 143 alert(err); 144 } 145 }); 146 }); 147 event.preventDefault(); 76 148 }); -
src/main/resources/static/js/fullcalendar.js
r8bcd64c r950fa0d 2755 2755 allDaySlot: true, 2756 2756 allDayText: 'all-day', 2757 firstHour: 6, 2757 firstHour: 8, 2758 lastHour: 10, 2758 2759 slotMinutes: 30, 2759 2760 defaultEventMinutes: 120, … … 2767 2768 minTime: 0, 2768 2769 maxTime: 24, 2769 slotEventOverlap: true2770 slotEventOverlap: false 2770 2771 }); 2771 2772 -
src/main/resources/static/js/homepage.js
r8bcd64c r950fa0d 1 1 $(document).ready(function() { 2 var businessTypes = {}; 3 var businesses = {}; 2 4 var date = new Date(); 3 5 var d = date.getDate(); … … 11 13 */ 12 14 13 15 $.ajax({ 16 type: 'GET', 17 url: "http://localhost:8080/api/user/me", 18 success: function(data, textStatus, request) { 19 if (data) { 20 $('#create').parent().removeClass('hidden-button'); 21 $('#profile').parent().removeClass('hidden-button'); 22 $('#logout').parent().removeClass('hidden-button'); 23 $('#login').parent().addClass('hidden-button'); 24 } else { 25 $('#create').parent().addClass('hidden-button'); 26 $('#profile').parent().addClass('hidden-button'); 27 $('#logout').parent().addClass('hidden-button'); 28 $('#login').parent().removeClass('hidden-button'); 29 } 30 }, 31 error: function (request, textStatus, errorThrown) { 32 console.log(errorThrown); 33 } 34 }); 14 35 /* initialize the external events 15 36 -----------------------------------------------------------------*/ … … 35 56 }); 36 57 58 $.ajax({ 59 url: "http://localhost:8080/api/nomenclatures/businessTypes" 60 }).then(function (data) { 61 businessTypes = data; 62 var $el = $("#companyType"); 63 emptyDropdown($el); 64 65 $.each(data, function (index, obj) { 66 $el.append("<option value=" + obj.value + ">" + obj.text + "</option>"); 67 }); 68 }); 69 70 $("#companyType").change(function () { 71 var selectedVal = $(this).find(':selected').val(); 72 var selectedObj = businessTypes[selectedVal - 1]; 73 $.ajax({ 74 url: "http://localhost:8080/api/business/" + selectedObj.value 75 }).then(function (data) { 76 businesses = data; 77 console.log(data); 78 var $el = $("#company"); 79 var $servicesEl = $("#service"); 80 emptyDropdown($el); 81 emptyDropdown($servicesEl); 82 83 $.each(data, function (index, obj) { 84 $el.append("<option value=" + obj.id + ">" + obj.companyName + "</option>"); 85 }); 86 }); 87 }); 88 89 $("#company").change(function () { 90 var selectedVal = $(this).find(':selected').val(); 91 $.ajax({ 92 url: "http://localhost:8080/api/appointment/business/" + selectedVal 93 }).then(function (data) { 94 console.log(data); 95 var $el = $("#service"); 96 emptyDropdown($el); 97 98 var services = businesses.find(item => item.id == selectedVal)['services']; 99 console.log(services); 100 101 $.each(services, function (index, obj) { 102 $el.append("<option value=" + obj.id + ">" + obj.serviceType.name + "</option>"); 103 }); 104 }); 105 }); 106 37 107 38 108 /* initialize the calendar … … 47 117 editable: false, 48 118 edit: function (start, end, allDay) { 49 119 console.log(start); 120 console.log(end); 50 121 }, 51 122 firstDay: 1, // 1(Monday) this can be changed to 0(Sunday) for the USA system … … 131 202 start: new Date(y, m, d, 10, 30), 132 203 allDay: false, 133 className: 'i mportant'204 className: 'info' 134 205 }, 135 206 { … … 138 209 end: new Date(y, m, d, 14, 0), 139 210 allDay: false, 140 className: 'i mportant'211 className: 'info' 141 212 }, 142 213 { … … 155 226 ], 156 227 }); 157 $("#search").click(function () { 158 alert("qweqew"); 228 229 $("#createAppointment").click(function() { 230 var appointment = {}; 231 appointment['business'] = {'id': parseInt($("#company").val())}; 232 appointment['service'] = {'id': parseInt($("#service").val())}; 233 appointment['startTime'] = $("#startdatetime").val(); 159 234 160 235 $.ajax({ 161 url: "http://localhost:8080/events" 162 }).then(function(data) { 163 console.log(data); 164 }); 165 }); 236 url: "http://localhost:8080/api/appointment", 237 type:"POST", 238 data: JSON.stringify(appointment), 239 contentType:"application/json; charset=utf-8", 240 dataType: 'text', 241 success: function(succ){ 242 console.log('success'); 243 }, 244 error: function(err) { 245 console.log(JSON.stringify(err)); 246 } 247 }); 248 }) 166 249 167 250 }); 168 251 169 function search() { 170 252 document.getElementById("login").addEventListener("click", function(event){ 253 window.location = "/login"; 254 }); 255 256 function emptyDropdown(element) { 257 var defaultOption = element.children().get(0); 258 element.children().remove().end().append(defaultOption); 171 259 } -
src/main/resources/static/js/login.js
r8bcd64c r950fa0d 1 1 document.getElementById("login").addEventListener("click", function(event){ 2 event.preventDefault() 2 event.preventDefault(); 3 3 }); -
src/main/resources/static/js/register_business.js
r8bcd64c r950fa0d 49 49 '<div class="form-outline mb-4">' + 50 50 ' <div class="row">' + 51 ' <div class="col-md- 8">\n' +51 ' <div class="col-md-6">\n' + 52 52 ' <input class="form-check-input" type="checkbox" checked value="' + -1 + '" id="' + -1 + '">\n' + 53 53 ' <label class="form-check-label" for="' + -1 + '">\n' + … … 102 102 }); 103 103 businessObj['services'] = servicesObj; 104 console.log(JSON.stringify(businessObj));105 104 $.ajax({ 106 105 url: "http://localhost:8080/api/business",
Note:
See TracChangeset
for help on using the changeset viewer.