Kaynağa Gözat

feat(AdvancedTable): Boolean filter types and other additions

Owen Diffey 3 yıl önce
ebeveyn
işleme
39b68fcfb4

+ 1 - 1
backend/logic/actions/dataRequests.js

@@ -67,7 +67,7 @@ export default {
 							newQuery[filter.property] = { $gt: data };
 						} else if (filterType === "numberGreaterEqual") {
 							newQuery[filter.property] = { $gte: data };
-						} else if (filterType === "numberEquals") {
+						} else if (filterType === "numberEquals" || filterType === "boolean") {
 							newQuery[filter.property] = { $eq: data };
 						}
 

+ 1 - 1
backend/logic/actions/news.js

@@ -163,7 +163,7 @@ export default {
 							newQuery[filter.property] = { $gt: data };
 						} else if (filterType === "numberGreaterEqual") {
 							newQuery[filter.property] = { $gte: data };
-						} else if (filterType === "numberEquals") {
+						} else if (filterType === "numberEquals" || filterType === "boolean") {
 							newQuery[filter.property] = { $eq: data };
 						}
 

+ 1 - 1
backend/logic/actions/punishments.js

@@ -222,7 +222,7 @@ export default {
 							newQuery[filter.property] = { $gt: data };
 						} else if (filterType === "numberGreaterEqual") {
 							newQuery[filter.property] = { $gte: data };
-						} else if (filterType === "numberEquals") {
+						} else if (filterType === "numberEquals" || filterType === "boolean") {
 							newQuery[filter.property] = { $eq: data };
 						}
 

+ 1 - 1
backend/logic/actions/reports.js

@@ -166,7 +166,7 @@ export default {
 							newQuery[filter.property] = { $gt: data };
 						} else if (filterType === "numberGreaterEqual") {
 							newQuery[filter.property] = { $gte: data };
-						} else if (filterType === "numberEquals") {
+						} else if (filterType === "numberEquals" || filterType === "boolean") {
 							newQuery[filter.property] = { $eq: data };
 						}
 

+ 1 - 1
backend/logic/actions/users.js

@@ -237,7 +237,7 @@ export default {
 							newQuery[filter.property] = { $gt: data };
 						} else if (filterType === "numberGreaterEqual") {
 							newQuery[filter.property] = { $gte: data };
-						} else if (filterType === "numberEquals") {
+						} else if (filterType === "numberEquals" || filterType === "boolean") {
 							newQuery[filter.property] = { $eq: data };
 						}
 

+ 1 - 1
backend/logic/playlists.js

@@ -1021,7 +1021,7 @@ class _PlaylistsModule extends CoreClass {
 								newQuery[filter.property] = { $gt: data };
 							} else if (filterType === "numberGreaterEqual") {
 								newQuery[filter.property] = { $gte: data };
-							} else if (filterType === "numberEquals") {
+							} else if (filterType === "numberEquals" || filterType === "boolean") {
 								newQuery[filter.property] = { $eq: data };
 							}
 

+ 1 - 1
backend/logic/songs.js

@@ -378,7 +378,7 @@ class _SongsModule extends CoreClass {
 								newQuery[filter.property] = { $gt: data };
 							} else if (filterType === "numberGreaterEqual") {
 								newQuery[filter.property] = { $gte: data };
-							} else if (filterType === "numberEquals") {
+							} else if (filterType === "numberEquals" || filterType === "boolean") {
 								newQuery[filter.property] = { $eq: data };
 							}
 

+ 1 - 1
backend/logic/stations.js

@@ -504,7 +504,7 @@ class _StationsModule extends CoreClass {
 								newQuery[filter.property] = { $gt: data };
 							} else if (filterType === "numberGreaterEqual") {
 								newQuery[filter.property] = { $gte: data };
-							} else if (filterType === "numberEquals") {
+							} else if (filterType === "numberEquals" || filterType === "boolean") {
 								newQuery[filter.property] = { $eq: data };
 							}
 

+ 20 - 1
frontend/src/components/AdvancedTable.vue

@@ -133,6 +133,21 @@
 										</option>
 									</select>
 								</div>
+								<div
+									v-else-if="
+										filter.filterType.name &&
+										filter.filterType.name === 'boolean'
+									"
+									class="control is-expanded select"
+								>
+									<select
+										v-model="filter.data"
+										:disabled="!filter.filterType"
+									>
+										<option :value="true">true</option>
+										<option :value="false">false</option>
+									</select>
+								</div>
 								<div v-else class="control is-expanded">
 									<input
 										v-if="
@@ -839,6 +854,10 @@ export default {
 				numberEquals: {
 					name: "numberEquals",
 					displayName: "=="
+				},
+				boolean: {
+					name: "boolean",
+					displayName: "Boolean"
 				}
 			},
 			bulkPopup: {
@@ -1831,7 +1850,7 @@ export default {
 							top: 0;
 							left: 0;
 							bottom: 0;
-							right: 0;
+							right: 5px;
 							z-index: 5;
 						}
 					}

+ 39 - 2
frontend/src/pages/Admin/tabs/Playlists.vue

@@ -222,8 +222,15 @@ export default {
 					name: "type",
 					displayName: "Type",
 					property: "type",
-					filterTypes: ["contains", "exact", "regex"],
-					defaultFilterType: "contains"
+					filterTypes: ["exact", "regex"],
+					defaultFilterType: "exact",
+					filterValues: [
+						"genre",
+						"station",
+						"user",
+						"user-disliked",
+						"user-liked"
+					]
 				},
 				{
 					name: "privacy",
@@ -233,6 +240,36 @@ export default {
 					defaultFilterType: "exact",
 					filterValues: ["public", "private"]
 				},
+				{
+					name: "songsCount",
+					displayName: "Songs Count",
+					property: "songsCount",
+					filterTypes: [
+						"numberLesserEqual",
+						"numberLesser",
+						"numberGreater",
+						"numberGreaterEqual",
+						"numberEquals",
+						"exact",
+						"regex"
+					],
+					defaultFilterType: "numberLesser"
+				},
+				{
+					name: "totalLength",
+					displayName: "Total Length",
+					property: "totalLength",
+					filterTypes: [
+						"numberLesserEqual",
+						"numberLesser",
+						"numberGreater",
+						"numberGreaterEqual",
+						"numberEquals",
+						"exact",
+						"regex"
+					],
+					defaultFilterType: "numberLesser"
+				},
 				{
 					name: "createdBy",
 					displayName: "Created By",

+ 79 - 8
frontend/src/pages/Admin/tabs/Punishments.vue

@@ -61,6 +61,22 @@
 						slotProps.item.reason
 					}}</span>
 				</template>
+				<template #column-punishedBy="slotProps">
+					<user-id-to-username
+						:user-id="slotProps.item.punishedBy"
+						:link="true"
+					/>
+				</template>
+				<template #column-punishedAt="slotProps">
+					<span :title="new Date(slotProps.item.punishedAt)">{{
+						getDateFormatted(slotProps.item.punishedAt)
+					}}</span>
+				</template>
+				<template #column-expiresAt="slotProps">
+					<span :title="new Date(slotProps.item.expiresAt)">{{
+						getDateFormatted(slotProps.item.expiresAt)
+					}}</span>
+				</template>
 			</advanced-table>
 			<div class="card">
 				<header class="card-header">
@@ -157,7 +173,7 @@ export default {
 				{
 					name: "status",
 					displayName: "Status",
-					properties: ["status", "active", "expiresAt"],
+					properties: ["status"],
 					sortable: false,
 					defaultWidth: 150
 				},
@@ -179,16 +195,41 @@ export default {
 					displayName: "Reason",
 					properties: ["reason"],
 					sortProperty: "reason"
+				},
+				{
+					name: "punishedBy",
+					displayName: "Punished By",
+					properties: ["punishedBy"],
+					sortProperty: "punishedBy",
+					defaultWidth: 200,
+					defaultVisibility: "hidden"
+				},
+				{
+					name: "punishedAt",
+					displayName: "Punished At",
+					properties: ["punishedAt"],
+					sortProperty: "punishedAt",
+					defaultWidth: 200,
+					defaultVisibility: "hidden"
+				},
+				{
+					name: "expiresAt",
+					displayName: "Expires At",
+					properties: ["expiresAt"],
+					sortProperty: "verifiedAt",
+					defaultWidth: 200,
+					defaultVisibility: "hidden"
 				}
 			],
 			filters: [
-				// {
-				// 	name: "status",
-				// 	displayName: "Status",
-				// 	property: "status",
-				// 	filterTypes: ["contains", "exact", "regex"],
-				// 	defaultFilterType: "contains"
-				// },
+				{
+					name: "status",
+					displayName: "Status",
+					property: "status",
+					filterTypes: ["exact", "regex"],
+					defaultFilterType: "exact",
+					filterValues: ["Active", "Inactive"]
+				},
 				{
 					name: "type",
 					displayName: "Type",
@@ -209,6 +250,27 @@ export default {
 					property: "reason",
 					filterTypes: ["contains", "exact", "regex"],
 					defaultFilterType: "contains"
+				},
+				{
+					name: "punishedBy",
+					displayName: "Punished By",
+					property: "punishedBy",
+					filterTypes: ["contains", "exact", "regex"],
+					defaultFilterType: "contains"
+				},
+				{
+					name: "punishedAt",
+					displayName: "Punished At",
+					property: "punishedAt",
+					filterTypes: ["datetimeBefore", "datetimeAfter"],
+					defaultFilterType: "datetimeBefore"
+				},
+				{
+					name: "expiresAt",
+					displayName: "Expires At",
+					property: "expiresAt",
+					filterTypes: ["datetimeBefore", "datetimeAfter"],
+					defaultFilterType: "datetimeBefore"
 				}
 			]
 		};
@@ -246,6 +308,15 @@ export default {
 				}
 			);
 		},
+		getDateFormatted(createdAt) {
+			const date = new Date(createdAt);
+			const year = date.getFullYear();
+			const month = `${date.getMonth() + 1}`.padStart(2, 0);
+			const day = `${date.getDate()}`.padStart(2, 0);
+			const hour = `${date.getHours()}`.padStart(2, 0);
+			const minute = `${date.getMinutes()}`.padStart(2, 0);
+			return `${year}-${month}-${day} ${hour}:${minute}`;
+		},
 		// init() {
 		// 	this.socket.dispatch("apis.joinAdminRoom", "punishments", () => {});
 		// },

+ 9 - 9
frontend/src/pages/Admin/tabs/Users.vue

@@ -377,13 +377,13 @@ export default {
 						filterTypes: ["contains", "exact", "regex"],
 						defaultFilterType: "contains"
 					},
-					// {
-					// 	name: "hasPassword",
-					// 	displayName: "Has Password",
-					// 	property: "hasPassword",
-					// 	filterTypes: ["contains", "exact", "regex"],
-					// 	defaultFilterType: "contains"
-					// },
+					{
+						name: "hasPassword",
+						displayName: "Has Password",
+						property: "hasPassword",
+						filterTypes: ["boolean"],
+						defaultFilterType: "boolean"
+					},
 					{
 						name: "role",
 						displayName: "Role",
@@ -403,8 +403,8 @@ export default {
 						name: "emailVerified",
 						displayName: "Email Verified",
 						property: "email.verified",
-						filterTypes: ["contains", "exact", "regex"],
-						defaultFilterType: "contains"
+						filterTypes: ["boolean"],
+						defaultFilterType: "boolean"
 					},
 					{
 						name: "songsRequested",