-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
247 lines (234 loc) · 10.7 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
<!DOCTYPE html>
<html lang="en">
<!-- Helper websites:
https://medium.com/codingthesmartway-com-blog/getting-started-with-axios-166cb0035237
https://bootswatch.com/
-->
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Swapper UI</title>
<!-- BOOTSTRAP 5 -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
<!-- BOOTSTRAP VUE -->
<!-- <script src="https://cdn.jsdelivr.net/npm/bootstrap-vue@latest/dist/bootstrap-vue.min.js"></script> -->
<!-- AXIOS -->
<script src="https://cdn.jsdelivr.net/npm/axios@latest/dist/axios.min.js"></script>
<!-- VUE -->
<script src="https://cdn.jsdelivr.net/npm/vue@latest"></script>
<!-- CHART.JS -->
<script src="https://cdn.jsdelivr.net/npm/chart.js@latest"></script>
<!-- EXTERN CSS -->
<link rel="stylesheet" href="site.css">
<!-- INTERN CSS -->
<style>
.custom-button {
width: 150px;
}
</style>
</head>
<!-- SHIFT + ALT + F -->
<body>
<div id="background">
<img src="Images/SWAPPER_BG.jpg" alt="Background">
</div>
<div class="container">
<div class="text-center text-light p-5">
<h1><b>SWAPPER</b></h1>
<h7><b>S</b>pongebobs-<b>W</b>eb-<b>APP</b>lication-of-<b>E</b>asy<b>R</b>equests</h7>
<h6>| #json | #vue-3 | #axios | #bootstrap5 | #CORS | </h6>
<h7><a href="https://mf-REST-Book.azurewebsites.net/api/Book" target="_blank">TARGET SITE FOR .json-string</a>
</h7>
</div>
<div class="row">
<div class="column-7 text-light"> <!-- Første item række1 fylder 7 colonner -->
<h5>API-backend correspondance</h5>
</div>
</div>
<div id="app"> <!-- Nej.. Man kan ikke have 2 id samme div element -->
<div id="accordion">
<!-- GET() SECTION -->
<div class="card">
<div class="card-header">
<a class="btn" data-bs-toggle="collapse" href="#collapseGet">
<button class="btn btn-info text-light custom-button" type="button"><b>GET</b></button><b> /api/Books/</b>
</a>
</div>
<div class="collapse show" id="collapseGet">
<!-- data-bs-parent: Sørger for alle andre `class="collapse"` lukker når andre er viste -->
<div class="card-body row">
<div class="col-md-5">
<div class="mb-3 mt-3">
<div class="d-flex justify-content-between">
<button id="getAllButton" @click="getAllBooks" class="btn btn-info text-light"><b>Get all books</b></button>
<button id="clearButton" @click="clearOutput" class="btn btn-outline-info"><b>Clear </b></button>
</div>
</div>
<div class="input-group mb-3 mt-3">
<input v-model="byTitle" type="text" class="form-control" placeholder="Title name">
<button id="filterByTitle" @click="filterByTitle(byTitle)" class="btn btn-info text-light"><b>Filter
by Title</b></button>
<!-- <button id="resetFilter" @click="resetFilter" class="btn btn-outline-info"><b>Reset Filter</b></button> -->
</div>
<div class="input-group mb-3 mt-3">
<input v-model.number="minPrice" class="form-control" type="number" placeholder="Min price">
<input v-model.number="maxPrice" class="form-control" type="number" placeholder="Max price">
<button id="filterByPrice" @click="filterByPrice()" class="btn btn-info text-light"><b>Filter by
Price</b></button>
</div>
<div>
<ul v-if="bookList.null"> Loading...
<li>
<span><b>{{getAllStatMsg}}</b></span>
<span><b>{{getByTitStatMsg}}</b></span>
</li>
</ul>
<ul v-if="bookList.length">
<li>
<span><b>{{getAllStatMsg}}</b></span>
<span><b>{{getByTitStatMsg}}</b></span>
</li>
<!-- <li v-for="book in bookList"> {{ book }} </li> -->
<table v-if="bookList.length> 0" class="table table-bordered">
<thead>
<th><button @click="sortById()">Id</button></th>
<th><button @click="sortByTitle()">Title</button></th>
<th>Price
<button @click="sortByPriceAscending()">asc</button>
<button @click="sortByPriceDescending()">desc</button>
</th>
</thead>
<tbody>
<tr v-for="book in bookList">
<td>{{book.id}}</td>
<td>{{book.title}}</td>
<td>{{book.price}}</td>
</tr>
</tbody>
</table>
</ul>
<div v-else> No books
<ul>
<li>
<span><b>{{getAllStatMsg}}</b></span>
<span><b>{{getByTitStatMsg}}</b></span>
</li>
</ul>
</div>
</div>
</div>
<div class="col-md-5">
<div class="card-body">
<canvas id="myChart"></canvas>
</div>
</div>
</div>
</div>
</div>
<!-- POST() SECTION -->
<div class="card">
<div class="card-header">
<a class="btn" data-bs-toggle="collapse" href="#collapsePost">
<button class="btn btn-success text-light custom-button" type="button"><b>POST</b></button>
<b> /api/Books/</b>
</a>
</div>
<div id="collapsePost" class="collapse"> <!-- data-bs-parent="#accordion" -->
<div class="card-body col-md-5">
<div class="input-group mb-3 mt-3">
<input v-model="addData.title" type="text" class="form-control" placeholder="Title name">
<!-- type=number: sikrer os vi kun kan input tal via browseren -->
<!-- v-model.number: er den forventede værdi (null vs "") fx: updData: { ... price: null } -->
<input v-model.number="addData.price" type="number" class="form-control" placeholder="Price">
<button id="buttonPost" @click="addBook()" class="btn btn-success"><b>Create</b></button>
</div>
<div>
<ul>
<li><span><b>{{addStatMsg}}</b></span></li>
</ul>
</div>
</div>
</div>
</div>
<!-- GET(ID) SECTION -->
<div class="card">
<div class="card-header">
<a class="btn" data-bs-toggle="collapse" href="#collapseGetId">
<button class="btn btn-info text-light custom-button" type="button"><b>GET</b></button><b>
/api/Books/{id}</b>
</a>
</div>
<div id="collapseGetId" class="collapse">
<div class="card-body col-md-5">
<div class="input-group mb-3 mt-3">
<input v-model.number="getId" type="number" class="form-control" placeholder="ID ">
<button id="buttonGetById" @click="getById(getId)" class="btn btn-info text-light"><b>Get by
ID</b></button>
</div>
<div>
<ul v-if="singleBook">
<li> <span><b>{{ getIdStatMsg }}</b></span></li>
<li> {{ singleBook }}</li>
</ul>
<ul v-else>
<li><span><b>{{getIdStatMsg}}</b></span></li>
</div>
</div>
</div>
<!-- PUT(id) SECTION -->
<div class="card">
<div class="card-header">
<a class="btn" data-bs-toggle="collapse" href="#collapseUpdate">
<button class="btn btn-warning text-light custom-button" type="button"><b>PUT </b></button>
<b> /api/Books/{id}</b>
</a>
</div>
<div id="collapseUpdate" class="collapse">
<div class="card-body col-md-5">
<div class="input-group mb-3 mt-3">
<input v-model.number="updData.id" type="number" class="form-control" placeholder="ID">
<input v-model="updData.title" type="text" class="form-control" placeholder="Title name">
<input v-model.number="updData.price" type="number" class="form-control" placeholder="Price">
<button id="buttonPut" @click="updateBook(updData.id)" class="btn btn-warning text-light"
:disabled="!updData.id"><b>Edit </b></button>
<!-- <button id="buttonPut" @click="updateBook()" class="btn btn-warning text-light"><b>Edit </b></button> -->
</div>
<div><span><b>{{updStatMsg}}</b></span></div>
</div>
</div>
</div>
<!-- DELETE(id) SECTION -->
<div class="card">
<div class="card-header">
<a class="btn" data-bs-toggle="collapse" href="#collapseDelete">
<button class="btn btn-danger text-light custom-button" type="button"><b>DELETE</b></button>
<b> /api/Books/{id}</b>
</a>
</div>
<div id="collapseDelete" class="collapse">
<div class="card-body col-md-5">
<div class="input-group mb-3 mt-3">
<!-- Input field for the ID of the book to delete -->
<input v-model.number="id" type="number" class="form-control" placeholder="ID">
<!-- Button to trigger the deleteBook method -->
<button id="buttonDelete" @click="deleteBook(id)"
class="btn btn-danger text-light"><b>Delete</b></button>
</div>
<div>
<span><b>{{delStatMsg}}</b></span><!-- <span :class="{ 'text-success': delStatMsg, 'text-danger': !delStatMsg }"><b>{{delStatMsg || 'Book not found!'}}</b></span> -->
</div>
</div>
</div>
</div>
</div>
<!-- ACCORDION /END: BELOW -->
</div>
<!-- ID = APP /END: BELOW -->
</div>
<!-- CONTAINER /END: BELOW -->
</div>
<br><br><br>
<script src="js/main.js"></script>
</body>
</html>