wad-lab 1.2.2 → 1.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (207) hide show
  1. package/bin/index.js +472 -631
  2. package/package.json +1 -1
  3. package/templates/fullstack-springboot-vue/frontend/vue-axios-basic/src/App.vue +241 -429
  4. package/templates/fullstack-springboot-vue/frontend/vue-axios-basic/src/components/ItemFormModal.vue +183 -0
  5. package/templates/fullstack-springboot-vue/frontend/vue-axios-basic/src/components/ItemPatchModal.vue +193 -0
  6. package/templates/fullstack-springboot-vue/frontend/vue-axios-basic/src/components/ItemTable.vue +177 -0
  7. package/templates/fullstack-springboot-vue/frontend/vue-axios-pinia/src/App.vue +150 -441
  8. package/templates/fullstack-springboot-vue/frontend/vue-axios-pinia/src/components/ItemFormModal.vue +207 -0
  9. package/templates/fullstack-springboot-vue/frontend/vue-axios-pinia/src/components/ItemStats.vue +64 -0
  10. package/templates/fullstack-springboot-vue/frontend/vue-axios-pinia/src/components/ItemTable.vue +195 -0
  11. package/templates/fullstack-springboot-vue/frontend/vue-axios-router/src/App.vue +41 -90
  12. package/templates/fullstack-springboot-vue/frontend/vue-axios-router/src/components/ItemFormModal.vue +173 -0
  13. package/templates/fullstack-springboot-vue/frontend/vue-axios-router/src/components/ItemTable.vue +102 -0
  14. package/templates/fullstack-springboot-vue/frontend/vue-axios-router/src/components/NavBar.vue +57 -0
  15. package/templates/fullstack-springboot-vue/frontend/vue-axios-router/src/views/DepartmentView.vue +132 -296
  16. package/templates/fullstack-springboot-vue/frontend/vue-axios-router/src/views/EmployeeView.vue +126 -219
  17. package/templates/fullstack-springboot-vue/frontend/vue-axios-router-children/src/components/ItemDetail.vue +115 -0
  18. package/templates/fullstack-springboot-vue/frontend/vue-axios-router-children/src/components/ItemTable.vue +104 -0
  19. package/templates/fullstack-springboot-vue/frontend/vue-axios-router-children/src/components/SideBar.vue +59 -0
  20. package/templates/fullstack-springboot-vue/frontend/vue-axios-router-children/src/views/CompanyLayout.vue +2 -51
  21. package/templates/fullstack-springboot-vue/frontend/vue-axios-router-children/src/views/DepartmentListView.vue +92 -250
  22. package/templates/fullstack-springboot-vue/frontend/vue-axios-router-children/src/views/EmployeeDetailView.vue +59 -181
  23. package/templates/fullstack-springboot-vue/frontend/vue-axios-router-children/src/views/EmployeeListView.vue +67 -315
  24. package/templates/fullstack-springboot-vue/frontend/vue-axios-router-pinia/src/App.vue +19 -70
  25. package/templates/fullstack-springboot-vue/frontend/vue-axios-router-pinia/src/components/ItemFormModal.vue +173 -0
  26. package/templates/fullstack-springboot-vue/frontend/vue-axios-router-pinia/src/components/ItemPatchModal.vue +144 -0
  27. package/templates/fullstack-springboot-vue/frontend/vue-axios-router-pinia/src/components/ItemTable.vue +102 -0
  28. package/templates/fullstack-springboot-vue/frontend/vue-axios-router-pinia/src/components/NavBar.vue +53 -0
  29. package/templates/fullstack-springboot-vue/frontend/vue-axios-router-pinia/src/views/DepartmentView.vue +107 -229
  30. package/templates/fullstack-springboot-vue/frontend/vue-axios-router-pinia/src/views/EmployeeView.vue +143 -257
  31. package/templates/game-bingo/script.js +1 -1
  32. package/templates/game-memory-cards/script.js +2 -2
  33. package/templates/game-rock-paper-scissors/index.html +3 -3
  34. package/templates/game-rock-paper-scissors/script.js +2 -2
  35. package/templates/game-tic-tac-toe/script.js +2 -2
  36. package/templates/game-whack-a-mole/index.html +9 -9
  37. package/templates/servlet-basic/WEB-INF/ItemServlet.java +13 -0
  38. package/templates/servlet-basic/WEB-INF/classes/ItemServlet.class +0 -0
  39. package/templates/servlet-flow/WEB-INF/HelloServlet.java +34 -25
  40. package/templates/servlet-flow/WEB-INF/classes/HelloServlet.class +0 -0
  41. package/templates/servlet-jdbc/WEB-INF/JdbcItemServlet.java +13 -0
  42. package/templates/servlet-jdbc/WEB-INF/classes/JdbcItemServlet.class +0 -0
  43. package/templates/snippets/mongo-queries-cheatsheet.txt +105 -0
  44. package/templates/springboot-2model-aggregation-join/.mvn/wrapper/maven-wrapper.properties +3 -0
  45. package/templates/springboot-2model-aggregation-join/mvnw +295 -0
  46. package/templates/springboot-2model-aggregation-join/mvnw.cmd +189 -0
  47. package/templates/springboot-2model-aggregation-join/pom.xml +54 -0
  48. package/templates/springboot-2model-aggregation-join/src/main/java/com/example/aggregation/AggregationApplication.java +11 -0
  49. package/templates/springboot-2model-aggregation-join/src/main/java/com/example/aggregation/controller/DepartmentController.java +65 -0
  50. package/templates/springboot-2model-aggregation-join/src/main/java/com/example/aggregation/controller/EmployeeController.java +65 -0
  51. package/templates/springboot-2model-aggregation-join/src/main/java/com/example/aggregation/dto/DepartmentStatsDTO.java +15 -0
  52. package/templates/springboot-2model-aggregation-join/src/main/java/com/example/aggregation/dto/EmployeeJoinDTO.java +19 -0
  53. package/templates/springboot-2model-aggregation-join/src/main/java/com/example/aggregation/model/Department.java +20 -0
  54. package/templates/springboot-2model-aggregation-join/src/main/java/com/example/aggregation/model/Employee.java +21 -0
  55. package/templates/springboot-2model-aggregation-join/src/main/java/com/example/aggregation/repository/DepartmentRepository.java +9 -0
  56. package/templates/springboot-2model-aggregation-join/src/main/java/com/example/aggregation/repository/EmployeeRepository.java +9 -0
  57. package/templates/springboot-2model-aggregation-join/src/main/java/com/example/aggregation/service/DepartmentService.java +81 -0
  58. package/templates/springboot-2model-aggregation-join/src/main/java/com/example/aggregation/service/EmployeeService.java +80 -0
  59. package/templates/springboot-2model-aggregation-join/src/main/resources/application.properties +2 -0
  60. package/templates/springboot-2model-aggregation-join/src/test/java/com/example/aggregation/AggregationApplicationTests.java +13 -0
  61. package/templates/vue-2model-crud-patch/README.md +64 -0
  62. package/templates/vue-2model-crud-patch/index.html +12 -0
  63. package/templates/vue-2model-crud-patch/package-lock.json +1785 -0
  64. package/templates/vue-2model-crud-patch/package.json +21 -0
  65. package/templates/vue-2model-crud-patch/src/App.vue +63 -0
  66. package/templates/vue-2model-crud-patch/src/components/AnalyticsBoard.vue +291 -0
  67. package/templates/vue-2model-crud-patch/src/components/DepartmentFormModal.vue +138 -0
  68. package/templates/vue-2model-crud-patch/src/components/DepartmentPatchModal.vue +210 -0
  69. package/templates/vue-2model-crud-patch/src/components/DepartmentTable.vue +133 -0
  70. package/templates/vue-2model-crud-patch/src/components/EmployeeFormModal.vue +177 -0
  71. package/templates/vue-2model-crud-patch/src/components/EmployeePatchModal.vue +221 -0
  72. package/templates/vue-2model-crud-patch/src/components/EmployeeTable.vue +171 -0
  73. package/templates/vue-2model-crud-patch/src/components/NavBar.vue +156 -0
  74. package/templates/vue-2model-crud-patch/src/main.js +12 -0
  75. package/templates/vue-2model-crud-patch/src/router/index.js +33 -0
  76. package/templates/vue-2model-crud-patch/src/services/api.js +64 -0
  77. package/templates/vue-2model-crud-patch/src/stores/departmentStore.js +149 -0
  78. package/templates/vue-2model-crud-patch/src/stores/employeeStore.js +143 -0
  79. package/templates/vue-2model-crud-patch/src/style.css +415 -0
  80. package/templates/vue-2model-crud-patch/src/views/AnalyticsView.vue +59 -0
  81. package/templates/vue-2model-crud-patch/src/views/DepartmentsView.vue +135 -0
  82. package/templates/vue-2model-crud-patch/src/views/EmployeesView.vue +143 -0
  83. package/templates/vue-2model-crud-patch/vite.config.js +9 -0
  84. package/templates/vue-axios/src/App.vue +255 -264
  85. package/templates/vue-axios/src/components/ItemFormModal.vue +183 -0
  86. package/templates/vue-axios/src/components/ItemPatchModal.vue +193 -0
  87. package/templates/vue-axios/src/components/ItemTable.vue +177 -0
  88. package/templates/vue-axios-basic/src/App.vue +241 -429
  89. package/templates/vue-axios-basic/src/components/ItemFormModal.vue +183 -0
  90. package/templates/vue-axios-basic/src/components/ItemPatchModal.vue +193 -0
  91. package/templates/vue-axios-basic/src/components/ItemTable.vue +177 -0
  92. package/templates/vue-axios-pinia/src/App.vue +150 -441
  93. package/templates/vue-axios-pinia/src/components/ItemFormModal.vue +207 -0
  94. package/templates/vue-axios-pinia/src/components/ItemStats.vue +64 -0
  95. package/templates/vue-axios-pinia/src/components/ItemTable.vue +195 -0
  96. package/templates/vue-axios-router/src/App.vue +41 -90
  97. package/templates/vue-axios-router/src/components/ItemFormModal.vue +173 -0
  98. package/templates/vue-axios-router/src/components/ItemTable.vue +102 -0
  99. package/templates/vue-axios-router/src/components/NavBar.vue +57 -0
  100. package/templates/vue-axios-router/src/views/DepartmentView.vue +132 -296
  101. package/templates/vue-axios-router/src/views/EmployeeView.vue +126 -219
  102. package/templates/vue-axios-router-children/src/components/ItemDetail.vue +115 -0
  103. package/templates/vue-axios-router-children/src/components/ItemTable.vue +104 -0
  104. package/templates/vue-axios-router-children/src/components/SideBar.vue +59 -0
  105. package/templates/vue-axios-router-children/src/views/CompanyLayout.vue +2 -51
  106. package/templates/vue-axios-router-children/src/views/DepartmentListView.vue +92 -250
  107. package/templates/vue-axios-router-children/src/views/EmployeeDetailView.vue +59 -181
  108. package/templates/vue-axios-router-children/src/views/EmployeeListView.vue +67 -315
  109. package/templates/vue-axios-router-pinia/src/App.vue +19 -70
  110. package/templates/vue-axios-router-pinia/src/components/ItemFormModal.vue +173 -0
  111. package/templates/vue-axios-router-pinia/src/components/ItemPatchModal.vue +144 -0
  112. package/templates/vue-axios-router-pinia/src/components/ItemTable.vue +102 -0
  113. package/templates/vue-axios-router-pinia/src/components/NavBar.vue +53 -0
  114. package/templates/vue-axios-router-pinia/src/views/DepartmentView.vue +107 -229
  115. package/templates/vue-axios-router-pinia/src/views/EmployeeView.vue +143 -257
  116. package/templates/vue-banking-app/src/components/AccountOverview.vue +75 -0
  117. package/templates/vue-banking-app/src/components/TransactionForm.vue +89 -0
  118. package/templates/vue-banking-app/src/components/TransactionTable.vue +113 -0
  119. package/templates/vue-banking-app/src/stores/bankStore.js +16 -3
  120. package/templates/vue-banking-app/src/views/DashboardView.vue +23 -71
  121. package/templates/vue-banking-app/src/views/StatementView.vue +11 -158
  122. package/templates/vue-banking-app/src/views/TransactionFormView.vue +23 -121
  123. package/templates/vue-basics/src/App.vue +105 -76
  124. package/templates/vue-basics/src/components/CounterCard.vue +107 -0
  125. package/templates/vue-basics/src/components/ItemList.vue +99 -0
  126. package/templates/vue-basics/src/components/UserForm.vue +138 -0
  127. package/templates/vue-cart-router-pinia/src/components/CartSummary.vue +139 -0
  128. package/templates/vue-cart-router-pinia/src/components/CheckoutModal.vue +149 -0
  129. package/templates/vue-cart-router-pinia/src/components/ProductCard.vue +63 -0
  130. package/templates/vue-cart-router-pinia/src/stores/cartStore.js +11 -0
  131. package/templates/vue-cart-router-pinia/src/views/CartView.vue +52 -118
  132. package/templates/vue-cart-router-pinia/src/views/CheckoutView.vue +2 -5
  133. package/templates/vue-cart-router-pinia/src/views/ProductCatalogView.vue +20 -56
  134. package/templates/vue-employee-system/src/App.vue +75 -344
  135. package/templates/vue-employee-system/src/components/DepartmentFilter.vue +108 -0
  136. package/templates/vue-employee-system/src/components/EmployeeModal.vue +183 -0
  137. package/templates/vue-employee-system/src/components/EmployeeTable.vue +91 -0
  138. package/templates/vue-employee-system/src/stores/employeeStore.js +12 -0
  139. package/templates/vue-fetch/src/App.vue +261 -285
  140. package/templates/vue-fetch/src/components/FetchFormModal.vue +183 -0
  141. package/templates/vue-fetch/src/components/FetchPatchModal.vue +193 -0
  142. package/templates/vue-fetch/src/components/FetchTable.vue +177 -0
  143. package/templates/vue-food-ordering/src/components/CartSummary.vue +134 -0
  144. package/templates/vue-food-ordering/src/components/FoodMenu.vue +126 -0
  145. package/templates/vue-food-ordering/src/components/OrderModal.vue +150 -0
  146. package/templates/vue-food-ordering/src/views/MenuView.vue +11 -132
  147. package/templates/vue-food-ordering/src/views/OrderCartView.vue +31 -164
  148. package/templates/vue-game-rps/src/App.vue +29 -88
  149. package/templates/vue-game-tictactoe/src/App.vue +23 -53
  150. package/templates/vue-game-whackamole/src/App.vue +44 -63
  151. package/templates/vue-hospital-portal/src/components/AppointmentForm.vue +144 -0
  152. package/templates/vue-hospital-portal/src/components/DoctorCard.vue +73 -0
  153. package/templates/vue-hospital-portal/src/components/PatientTable.vue +123 -0
  154. package/templates/vue-hospital-portal/src/stores/hospitalStore.js +10 -1
  155. package/templates/vue-hospital-portal/src/views/OPDRegistrationView.vue +40 -416
  156. package/templates/vue-hospital-portal/src/views/PatientListView.vue +11 -301
  157. package/templates/vue-library-system/src/components/BookForm.vue +125 -0
  158. package/templates/vue-library-system/src/components/BookTable.vue +112 -0
  159. package/templates/vue-library-system/src/components/BorrowModal.vue +131 -0
  160. package/templates/vue-library-system/src/stores/libraryStore.js +26 -1
  161. package/templates/vue-library-system/src/views/BookCatalogView.vue +34 -415
  162. package/templates/vue-memory-game/src/App.vue +36 -40
  163. package/templates/vue-memory-game/src/stores/memoryStore.js +32 -37
  164. package/templates/vue-router/src/App.vue +24 -14
  165. package/templates/vue-router/src/components/AboutCard.vue +38 -0
  166. package/templates/vue-router/src/components/HomeHero.vue +75 -0
  167. package/templates/vue-router/src/components/NavBar.vue +54 -0
  168. package/templates/vue-router/src/views/ItemsLayout.vue +17 -9
  169. package/templates/vue-router/src/views/ListView.vue +106 -18
  170. package/templates/vue-router-pinia/src/App.vue +24 -14
  171. package/templates/vue-router-pinia/src/components/ItemFormModal.vue +163 -0
  172. package/templates/vue-router-pinia/src/components/ItemTable.vue +90 -0
  173. package/templates/vue-router-pinia/src/components/NavBar.vue +54 -0
  174. package/templates/vue-router-pinia/src/stores/itemStore.js +8 -1
  175. package/templates/vue-router-pinia/src/views/ListView.vue +78 -14
  176. package/templates/vue-router-pinia-springboot/frontend/src/App.vue +25 -8
  177. package/templates/vue-router-pinia-springboot/frontend/src/components/ItemFormModal.vue +183 -0
  178. package/templates/vue-router-pinia-springboot/frontend/src/components/ItemPatchModal.vue +193 -0
  179. package/templates/vue-router-pinia-springboot/frontend/src/components/ItemTable.vue +177 -0
  180. package/templates/vue-router-pinia-springboot/frontend/src/components/NavBar.vue +54 -0
  181. package/templates/vue-router-pinia-springboot/frontend/src/views/ListView.vue +92 -76
  182. package/templates/vue-springboot-mongo-aggregation/frontend/src/App.vue +184 -193
  183. package/templates/vue-springboot-mongo-aggregation/frontend/src/components/AnalyticsCards.vue +56 -0
  184. package/templates/vue-springboot-mongo-aggregation/frontend/src/components/CategorySummaryTable.vue +71 -0
  185. package/templates/vue-springboot-mongo-aggregation/frontend/src/components/ItemTable.vue +114 -0
  186. package/templates/vue-springboot-mongo-crud/frontend/src/App.vue +228 -158
  187. package/templates/vue-springboot-mongo-crud/frontend/src/components/ItemFormModal.vue +183 -0
  188. package/templates/vue-springboot-mongo-crud/frontend/src/components/ItemPatchModal.vue +193 -0
  189. package/templates/vue-springboot-mongo-crud/frontend/src/components/ItemTable.vue +177 -0
  190. package/templates/vue-symposium-system/src/App.vue +41 -256
  191. package/templates/vue-symposium-system/src/components/AttendeeTable.vue +100 -0
  192. package/templates/vue-symposium-system/src/components/EventCard.vue +67 -0
  193. package/templates/vue-symposium-system/src/components/RegistrationForm.vue +118 -0
  194. package/templates/vue-symposium-system/src/stores/symposiumStore.js +10 -0
  195. package/templates/vue-todo-pinia/src/App.vue +40 -138
  196. package/templates/vue-todo-pinia/src/components/TodoFilter.vue +74 -0
  197. package/templates/vue-todo-pinia/src/components/TodoInput.vue +53 -0
  198. package/templates/vue-todo-pinia/src/components/TodoList.vue +101 -0
  199. package/templates/vue-todo-pinia/src/stores/todoStore.js +6 -0
  200. package/templates/vue-todo-router/src/App.vue +5 -36
  201. package/templates/vue-todo-router/src/components/TodoForm.vue +78 -0
  202. package/templates/vue-todo-router/src/components/TodoList.vue +84 -0
  203. package/templates/vue-todo-router/src/components/TodoNavBar.vue +47 -0
  204. package/templates/vue-todo-router/src/data/todoState.js +7 -0
  205. package/templates/vue-todo-router/src/views/AddTodoView.vue +7 -66
  206. package/templates/vue-todo-router/src/views/TodoDetailView.vue +15 -1
  207. package/templates/vue-todo-router/src/views/TodoListView.vue +22 -64
@@ -1,11 +1,15 @@
1
1
  <script setup>
2
- import { ref, onMounted } from 'vue';
3
- import ItemService from './services/ItemService';
4
- import AnalyticsService from './services/AnalyticsService';
5
-
6
- const items = ref([]);
7
- const summaries = ref([]);
8
- const isEditing = ref(false);
2
+ import { ref, computed, onMounted } from 'vue'
3
+ import ItemService from './services/ItemService'
4
+ import AnalyticsService from './services/AnalyticsService'
5
+ import AnalyticsCards from './components/AnalyticsCards.vue'
6
+ import CategorySummaryTable from './components/CategorySummaryTable.vue'
7
+ import ItemTable from './components/ItemTable.vue'
8
+
9
+ const items = ref([])
10
+ const summaries = ref([])
11
+ const isEditing = ref(false)
12
+ const showModal = ref(false)
9
13
  const form = ref({
10
14
  id: '',
11
15
  name: '',
@@ -13,199 +17,186 @@ const form = ref({
13
17
  category: '',
14
18
  price: 0,
15
19
  quantity: 0
16
- });
17
- const searchId = ref('');
18
- const selectedItem = ref(null);
19
-
20
- const loadData = async () => {
21
- await Promise.all([loadItems(), loadAnalytics()]);
22
- };
23
-
24
- const loadItems = async () => {
25
- const res = await ItemService.getAll();
26
- items.value = res.data;
27
- };
28
-
29
- const loadAnalytics = async () => {
30
- const res = await AnalyticsService.getCategorySummary();
31
- summaries.value = res.data;
32
- };
33
-
34
- const saveItem = async () => {
20
+ })
21
+
22
+ const totalCategories = computed(() => summaries.value.length)
23
+ const totalQuantity = computed(() =>
24
+ items.value.reduce((sum, item) => sum + Number(item.quantity || 0), 0)
25
+ )
26
+ const totalValue = computed(() =>
27
+ items.value.reduce((sum, item) => sum + (Number(item.price || 0) * Number(item.quantity || 0)), 0)
28
+ )
29
+
30
+ async function loadData() {
31
+ await Promise.all([loadItems(), loadAnalytics()])
32
+ }
33
+
34
+ async function loadItems() {
35
+ const res = await ItemService.getAll()
36
+ items.value = res.data || []
37
+ }
38
+
39
+ async function loadAnalytics() {
40
+ const res = await AnalyticsService.getCategorySummary()
41
+ summaries.value = res.data || []
42
+ }
43
+
44
+ function openCreate() {
45
+ isEditing.value = false
46
+ form.value = { id: '', name: '', description: '', category: '', price: 0, quantity: 0 }
47
+ showModal.value = true
48
+ }
49
+
50
+ function openEdit(item) {
51
+ isEditing.value = true
52
+ form.value = { ...item }
53
+ showModal.value = true
54
+ }
55
+
56
+ async function saveItem() {
35
57
  if (isEditing.value) {
36
- await ItemService.update(form.value.id, {
37
- id: form.value.id,
38
- name: form.value.name,
39
- description: form.value.description,
40
- category: form.value.category,
41
- price: form.value.price,
42
- quantity: form.value.quantity
43
- });
58
+ await ItemService.update(form.value.id, form.value)
44
59
  } else {
45
- await ItemService.create({
46
- id: form.value.id,
47
- name: form.value.name,
48
- description: form.value.description,
49
- category: form.value.category,
50
- price: form.value.price,
51
- quantity: form.value.quantity
52
- });
60
+ await ItemService.create(form.value)
53
61
  }
54
- resetForm();
55
- loadData();
56
- };
57
-
58
- const editItem = (item) => {
59
- isEditing.value = true;
60
- form.value = { ...item };
61
- };
62
-
63
- const resetForm = () => {
64
- isEditing.value = false;
65
- form.value = { id: '', name: '', description: '', category: '', price: 0, quantity: 0 };
66
- };
67
-
68
- const deleteItem = async (id) => {
69
- await ItemService.delete(id);
70
- if (selectedItem.value && selectedItem.value.id === id) {
71
- selectedItem.value = null;
62
+ showModal.value = false
63
+ await loadData()
64
+ }
65
+
66
+ async function deleteItem(id) {
67
+ if (confirm('Delete this item?')) {
68
+ await ItemService.delete(id)
69
+ await loadData()
72
70
  }
73
- loadData();
74
- };
75
-
76
- const fetchSingleItem = async (id) => {
77
- const targetId = id || searchId.value;
78
- if (!targetId) return;
79
- const res = await ItemService.getById(targetId);
80
- selectedItem.value = res.data;
81
- };
71
+ }
82
72
 
83
- onMounted(loadData);
73
+ onMounted(() => {
74
+ loadData()
75
+ })
84
76
  </script>
85
77
 
86
78
  <template>
87
- <h2>Item Management and MongoDB Aggregation Analytics</h2>
88
-
89
- <h3>{{ isEditing ? 'Edit Item (PUT)' : 'Add New Item (POST)' }}</h3>
90
- <form @submit.prevent="saveItem">
91
- <label>Custom ID (Optional):</label>
92
- <br>
93
- <input v-model="form.id" placeholder="ID (e.g. 101 or leave blank for auto)" :disabled="isEditing" />
94
- <br><br>
95
-
96
- <label>Name:</label>
97
- <br>
98
- <input v-model="form.name" placeholder="Name" required />
99
- <br><br>
100
-
101
- <label>Description:</label>
102
- <br>
103
- <input v-model="form.description" placeholder="Description" required />
104
- <br><br>
105
-
106
- <label>Category:</label>
107
- <br>
108
- <input v-model="form.category" placeholder="Category" required />
109
- <br><br>
110
-
111
- <label>Price:</label>
112
- <br>
113
- <input v-model.number="form.price" type="number" step="0.01" placeholder="Price" required />
114
- <br><br>
115
-
116
- <label>Quantity:</label>
117
- <br>
118
- <input v-model.number="form.quantity" type="number" placeholder="Quantity" required />
119
- <br><br>
120
-
121
- <button type="submit">{{ isEditing ? 'Update Item (PUT)' : 'Create Item (POST)' }}</button>
122
- <button type="button" v-if="isEditing" @click="resetForm">Cancel</button>
123
- </form>
124
-
125
- <hr>
126
-
127
- <h3>Fetch Single Item By ID (GET /api/items/:id)</h3>
128
- <input v-model="searchId" placeholder="Enter Item ID" />
129
- <button type="button" @click="fetchSingleItem(searchId)">Fetch Detail</button>
130
-
131
- <div v-if="selectedItem">
132
- <br>
133
- <b>Item Details:</b>
134
- <br>
135
- ID: {{ selectedItem.id }}
136
- <br>
137
- Name: {{ selectedItem.name }}
138
- <br>
139
- Description: {{ selectedItem.description }}
140
- <br>
141
- Category: {{ selectedItem.category }}
142
- <br>
143
- Price: {{ selectedItem.price }}
144
- <br>
145
- Quantity: {{ selectedItem.quantity }}
146
- <br>
147
- <button type="button" @click="selectedItem = null">Close Details</button>
79
+ <div class="agg-container">
80
+ <header class="header">
81
+ <h1>Spring Boot + MongoDB Aggregation Dashboard</h1>
82
+ <p>Modular: AnalyticsCards, CategorySummaryTable, ItemTable</p>
83
+ </header>
84
+
85
+ <AnalyticsCards
86
+ :total-categories="totalCategories"
87
+ :total-quantity="totalQuantity"
88
+ :total-value="totalValue"
89
+ />
90
+
91
+ <CategorySummaryTable :summaries="summaries" />
92
+
93
+ <ItemTable
94
+ :items="items"
95
+ @create="openCreate"
96
+ @edit="openEdit"
97
+ @delete="deleteItem"
98
+ />
99
+
100
+ <div v-if="showModal" class="modal-overlay" @click.self="showModal = false">
101
+ <div class="modal-card">
102
+ <h3>{{ isEditing ? 'Edit Item' : 'Add Item' }}</h3>
103
+ <form @submit.prevent="saveItem" class="form">
104
+ <input v-model="form.name" placeholder="Name" required />
105
+ <input v-model="form.description" placeholder="Description" required />
106
+ <input v-model="form.category" placeholder="Category" required />
107
+ <input v-model.number="form.price" type="number" step="any" placeholder="Price" required />
108
+ <input v-model.number="form.quantity" type="number" placeholder="Quantity" required />
109
+ <div class="actions">
110
+ <button type="button" class="btn btn-secondary" @click="showModal = false">Cancel</button>
111
+ <button type="submit" class="btn btn-primary">Save</button>
112
+ </div>
113
+ </form>
114
+ </div>
115
+ </div>
148
116
  </div>
149
-
150
- <hr>
151
-
152
- <h3>Aggregation Analytics: Category Summary</h3>
153
- <button type="button" @click="loadAnalytics">Refresh Analytics</button>
154
- <br><br>
155
-
156
- <table>
157
- <thead>
158
- <tr>
159
- <th>Category</th>
160
- <th>Total Price</th>
161
- <th>Average Price</th>
162
- <th>Total Quantity</th>
163
- <th>Item Count</th>
164
- </tr>
165
- </thead>
166
- <tbody>
167
- <tr v-for="summary in summaries" :key="summary.category">
168
- <td>{{ summary.category }}</td>
169
- <td>{{ summary.totalPrice }}</td>
170
- <td>{{ summary.avgPrice }}</td>
171
- <td>{{ summary.totalQuantity }}</td>
172
- <td>{{ summary.count }}</td>
173
- </tr>
174
- </tbody>
175
- </table>
176
-
177
- <hr>
178
-
179
- <h3>Items List (GET /api/items)</h3>
180
- <button type="button" @click="loadData">Refresh All</button>
181
- <br><br>
182
-
183
- <table>
184
- <thead>
185
- <tr>
186
- <th>ID</th>
187
- <th>Name</th>
188
- <th>Description</th>
189
- <th>Category</th>
190
- <th>Price</th>
191
- <th>Quantity</th>
192
- <th>Actions</th>
193
- </tr>
194
- </thead>
195
- <tbody>
196
- <tr v-for="item in items" :key="item.id">
197
- <td>{{ item.id }}</td>
198
- <td>{{ item.name }}</td>
199
- <td>{{ item.description }}</td>
200
- <td>{{ item.category }}</td>
201
- <td>{{ item.price }}</td>
202
- <td>{{ item.quantity }}</td>
203
- <td>
204
- <button type="button" @click="fetchSingleItem(item.id)">View</button>
205
- <button type="button" @click="editItem(item)">Edit</button>
206
- <button type="button" @click="deleteItem(item.id)">Delete</button>
207
- </td>
208
- </tr>
209
- </tbody>
210
- </table>
211
117
  </template>
118
+
119
+ <style>
120
+ * { box-sizing: border-box; }
121
+ body {
122
+ margin: 0;
123
+ font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
124
+ background-color: #f8fafc;
125
+ color: #334155;
126
+ }
127
+ </style>
128
+
129
+ <style scoped>
130
+ .agg-container {
131
+ max-width: 1000px;
132
+ margin: 0 auto;
133
+ padding: 30px 16px;
134
+ }
135
+
136
+ .header {
137
+ margin-bottom: 24px;
138
+ }
139
+
140
+ .header h1 {
141
+ font-size: 24px;
142
+ color: #0f172a;
143
+ }
144
+
145
+ .header p {
146
+ color: #64748b;
147
+ font-size: 14px;
148
+ }
149
+
150
+ .modal-overlay {
151
+ position: fixed;
152
+ inset: 0;
153
+ background: rgba(0, 0, 0, 0.4);
154
+ display: flex;
155
+ align-items: center;
156
+ justify-content: center;
157
+ z-index: 1000;
158
+ padding: 16px;
159
+ }
160
+
161
+ .modal-card {
162
+ background: #ffffff;
163
+ border-radius: 8px;
164
+ width: 100%;
165
+ max-width: 400px;
166
+ padding: 20px;
167
+ }
168
+
169
+ .modal-card h3 {
170
+ margin-top: 0;
171
+ margin-bottom: 12px;
172
+ }
173
+
174
+ .form {
175
+ display: flex;
176
+ flex-direction: column;
177
+ gap: 10px;
178
+ }
179
+
180
+ .form input {
181
+ padding: 8px 10px;
182
+ border: 1px solid #cbd5e1;
183
+ border-radius: 6px;
184
+ }
185
+
186
+ .actions {
187
+ display: flex;
188
+ justify-content: flex-end;
189
+ gap: 10px;
190
+ margin-top: 8px;
191
+ }
192
+
193
+ .btn {
194
+ padding: 8px 14px;
195
+ border-radius: 6px;
196
+ cursor: pointer;
197
+ border: 1px solid transparent;
198
+ }
199
+
200
+ .btn-primary { background: #0284c7; color: #fff; }
201
+ .btn-secondary { background: #f1f5f9; color: #475569; }
202
+ </style>
@@ -0,0 +1,56 @@
1
+ <script setup>
2
+ defineProps({
3
+ totalCategories: { type: Number, default: 0 },
4
+ totalQuantity: { type: Number, default: 0 },
5
+ totalValue: { type: Number, default: 0 }
6
+ })
7
+ </script>
8
+
9
+ <template>
10
+ <div class="analytics-cards">
11
+ <div class="stat-card">
12
+ <span class="label">Total Categories</span>
13
+ <strong class="value">{{ totalCategories }}</strong>
14
+ </div>
15
+ <div class="stat-card">
16
+ <span class="label">Total Inventory Units</span>
17
+ <strong class="value">{{ totalQuantity }}</strong>
18
+ </div>
19
+ <div class="stat-card">
20
+ <span class="label">Total Inventory Valuation</span>
21
+ <strong class="value">${{ Number(totalValue).toFixed(2) }}</strong>
22
+ </div>
23
+ </div>
24
+ </template>
25
+
26
+ <style scoped>
27
+ .analytics-cards {
28
+ display: grid;
29
+ grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
30
+ gap: 16px;
31
+ margin-bottom: 20px;
32
+ }
33
+
34
+ .stat-card {
35
+ background: #ffffff;
36
+ border: 1px solid #e2e8f0;
37
+ border-radius: 8px;
38
+ padding: 16px;
39
+ display: flex;
40
+ flex-direction: column;
41
+ gap: 4px;
42
+ }
43
+
44
+ .label {
45
+ font-size: 11px;
46
+ text-transform: uppercase;
47
+ color: #64748b;
48
+ font-weight: 600;
49
+ }
50
+
51
+ .value {
52
+ font-size: 24px;
53
+ font-weight: 700;
54
+ color: #0284c7;
55
+ }
56
+ </style>
@@ -0,0 +1,71 @@
1
+ <script setup>
2
+ defineProps({
3
+ summaries: { type: Array, required: true }
4
+ })
5
+ </script>
6
+
7
+ <template>
8
+ <div class="summary-container">
9
+ <h3>Category Aggregation Summary</h3>
10
+ <table class="summary-table">
11
+ <thead>
12
+ <tr>
13
+ <th>Category</th>
14
+ <th>Total Quantity</th>
15
+ <th>Avg Price</th>
16
+ <th>Total Valuation</th>
17
+ </tr>
18
+ </thead>
19
+ <tbody>
20
+ <tr v-if="summaries.length === 0">
21
+ <td colspan="4" class="empty">No category aggregations computed.</td>
22
+ </tr>
23
+ <tr v-for="s in summaries" :key="s.category || s._id">
24
+ <td><strong>{{ s.category || s._id || 'Uncategorized' }}</strong></td>
25
+ <td>{{ s.totalQuantity || s.count || 0 }}</td>
26
+ <td>${{ Number(s.avgPrice || 0).toFixed(2) }}</td>
27
+ <td>${{ Number(s.totalValue || (s.totalQuantity * s.avgPrice) || 0).toFixed(2) }}</td>
28
+ </tr>
29
+ </tbody>
30
+ </table>
31
+ </div>
32
+ </template>
33
+
34
+ <style scoped>
35
+ .summary-container {
36
+ overflow-x: auto;
37
+ background: #ffffff;
38
+ border: 1px solid #e2e8f0;
39
+ border-radius: 8px;
40
+ padding: 16px;
41
+ margin-bottom: 20px;
42
+ }
43
+
44
+ .summary-container h3 {
45
+ font-size: 16px;
46
+ margin-bottom: 12px;
47
+ }
48
+
49
+ .summary-table {
50
+ width: 100%;
51
+ border-collapse: collapse;
52
+ font-size: 13px;
53
+ }
54
+
55
+ th, td {
56
+ padding: 10px;
57
+ border-bottom: 1px solid #f1f5f9;
58
+ text-align: left;
59
+ }
60
+
61
+ th {
62
+ background: #f8fafc;
63
+ color: #475569;
64
+ }
65
+
66
+ .empty {
67
+ text-align: center;
68
+ color: #94a3b8;
69
+ padding: 16px;
70
+ }
71
+ </style>
@@ -0,0 +1,114 @@
1
+ <script setup>
2
+ defineProps({
3
+ items: { type: Array, required: true }
4
+ })
5
+
6
+ const emit = defineEmits(['create', 'edit', 'delete'])
7
+ </script>
8
+
9
+ <template>
10
+ <div class="table-container">
11
+ <div class="table-header">
12
+ <h3>Inventory Items</h3>
13
+ <button type="button" class="btn btn-primary" @click="emit('create')">Add Item</button>
14
+ </div>
15
+
16
+ <table class="data-table">
17
+ <thead>
18
+ <tr>
19
+ <th>ID</th>
20
+ <th>Name</th>
21
+ <th>Category</th>
22
+ <th>Price</th>
23
+ <th>Quantity</th>
24
+ <th>Actions</th>
25
+ </tr>
26
+ </thead>
27
+ <tbody>
28
+ <tr v-if="items.length === 0">
29
+ <td colspan="6" class="empty">No inventory items found.</td>
30
+ </tr>
31
+ <tr v-for="item in items" :key="item.id">
32
+ <td>{{ item.id }}</td>
33
+ <td><strong>{{ item.name }}</strong></td>
34
+ <td><span class="badge">{{ item.category }}</span></td>
35
+ <td>${{ Number(item.price).toFixed(2) }}</td>
36
+ <td>{{ item.quantity }}</td>
37
+ <td class="action-cell">
38
+ <button type="button" class="btn btn-warning" @click="emit('edit', item)">Edit</button>
39
+ <button type="button" class="btn btn-danger" @click="emit('delete', item.id)">Delete</button>
40
+ </td>
41
+ </tr>
42
+ </tbody>
43
+ </table>
44
+ </div>
45
+ </template>
46
+
47
+ <style scoped>
48
+ .table-container {
49
+ overflow-x: auto;
50
+ background: #ffffff;
51
+ border: 1px solid #e2e8f0;
52
+ border-radius: 8px;
53
+ padding: 16px;
54
+ }
55
+
56
+ .table-header {
57
+ display: flex;
58
+ justify-content: space-between;
59
+ align-items: center;
60
+ margin-bottom: 12px;
61
+ }
62
+
63
+ .table-header h3 {
64
+ font-size: 16px;
65
+ margin: 0;
66
+ }
67
+
68
+ .data-table {
69
+ width: 100%;
70
+ border-collapse: collapse;
71
+ font-size: 13px;
72
+ }
73
+
74
+ th, td {
75
+ padding: 10px;
76
+ border-bottom: 1px solid #f1f5f9;
77
+ text-align: left;
78
+ }
79
+
80
+ th {
81
+ background: #f8fafc;
82
+ color: #475569;
83
+ }
84
+
85
+ .badge {
86
+ background: #e0f2fe;
87
+ color: #0369a1;
88
+ padding: 2px 6px;
89
+ border-radius: 4px;
90
+ }
91
+
92
+ .action-cell {
93
+ display: flex;
94
+ gap: 6px;
95
+ }
96
+
97
+ .btn {
98
+ padding: 4px 8px;
99
+ border-radius: 4px;
100
+ font-size: 12px;
101
+ cursor: pointer;
102
+ border: 1px solid transparent;
103
+ }
104
+
105
+ .btn-primary { background: #0284c7; color: #fff; }
106
+ .btn-warning { background: #d97706; color: #fff; }
107
+ .btn-danger { background: #cf222e; color: #fff; }
108
+
109
+ .empty {
110
+ text-align: center;
111
+ color: #94a3b8;
112
+ padding: 20px;
113
+ }
114
+ </style>