Skip to content

Commit

Permalink
修改exploiters
Browse files Browse the repository at this point in the history
  • Loading branch information
little3201 committed Nov 26, 2024
1 parent f42fd77 commit bbf9785
Show file tree
Hide file tree
Showing 6 changed files with 121 additions and 41 deletions.
Binary file modified .yarn/install-state.gz
Binary file not shown.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@
"build": "quasar build"
},
"dependencies": {
"@quasar/extras": "^1.16.11",
"@quasar/extras": "^1.16.13",
"apexcharts": "^3.54.1",
"axios": "^1.7.3",
"highlight.js": "^11.10.0",
"lottie-web": "^5.12.2",
"pinia": "^2.1.7",
"quasar": "^2.17.1",
"quasar": "^2.17.4",
"vue": "^3.5.12",
"vue-i18n": "^10.0.4",
"vue-router": "^4.4.5"
},
"devDependencies": {
"@quasar/app-vite": "^1.10.2",
"@quasar/app-vite": "^1.11.0",
"@typescript-eslint/eslint-plugin": "^8.11.0",
"@typescript-eslint/parser": "^8.11.0",
"autoprefixer": "^10.4.19",
Expand Down
4 changes: 2 additions & 2 deletions src/api/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import type { Pagination, Schema, Field } from 'src/models'

/**
* Retrieve rows
* @param page Page number
* @param size Items per page
* @param pagination Pagination and sort parameters
* @param filters Optional filter or sort parameters
* @param filters Optional filter or sort parameters
* @returns Rows data
*/
Expand Down
119 changes: 99 additions & 20 deletions src/pages/exploiters/generators/IndexPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,27 +25,57 @@
</q-dialog>

<!-- preview -->
<q-dialog v-model="previewVisible" persistent>
<q-card>
<q-dialog v-model="previewVisible">
<q-card style="max-width: 45em; width: 45em;">
<q-card-section class="row items-center q-pb-none">
<div class="text-h6">{{ $t('preview') }}</div>
<q-space />
<q-btn icon="sym_r_close" flat round dense v-close-popup />
</q-card-section>
<q-card-section>
<q-tabs v-model="tab" class="text-teal">
<q-tab v-for="item in renderedTemplates" :key="item.name" :name="item.name"
:label="item.name + item.suffix" />

<q-card-section style="height: 70vh;" class="scroll">
<q-tabs v-model="tab" no-caps dense>
<q-tab v-for="item in renderedTemplates" :key="item.id" :name="item.id" :label="item.name + item.suffix" />
</q-tabs>
<q-tab-panels v-model="tab" animated>
<q-tab-panel v-for="item in renderedTemplates" :key="item.name" :name="item.name">
<q-tab-panel v-for="item in renderedTemplates" :key="item.id" :name="item.id" style="padding: 0;">
<CodeRender :content="item.content" />
</q-tab-panel>
</q-tab-panels>
</q-card-section>
</q-card>
</q-dialog>

<!-- config -->
<q-dialog v-model="configVisible">
<q-card style="max-width: 65em;">
<q-card-section class="row items-center q-pb-none">
<div class="text-h6">{{ $t('config') }}</div>
<q-space />
<q-btn icon="sym_r_close" flat round dense v-close-popup />
</q-card-section>

<q-card-section style="max-height: 70vh;" class="scroll">
<q-table flat :rows="fields" :columns="configColumns" row-key="id" binary-state-sort hide-pagination
class="full-width">

<template v-slot:header="props">
<q-tr :props="props">
<q-th v-for="col in props.cols" :key="col.name" :props="props">
{{ $t(col.label) }}
</q-th>
</q-tr>
</template>
</q-table>
</q-card-section>

<q-card-actions align="right">
<q-btn title="cancel" type="reset" unelevated :label="$t('cancel')" v-close-popup />
<q-btn title="submit" type="submit" flat :label="$t('submit')" color="primary" />
</q-card-actions>
</q-card>
</q-dialog>

<q-table flat ref="tableRef" :title="$t('schemas')" :rows="rows" :columns="columns" row-key="id"
v-model:pagination="pagination" :loading="loading" :filter="filter" binary-state-sort @request="onRequest"
class="full-width">
Expand All @@ -69,7 +99,25 @@
</q-th>
</q-tr>
</template>

<template v-slot:body-cell-templates="props">
<q-td :props="props">
<q-chip v-for="(item, index) in visibleArray(props.row.templates, 3)" :key="index" color="primary"
text-color="white" class="q-mr-sm" size="sm">
{{ formatTemplates(item as number) }}
</q-chip>
<template v-if="props.row.templates.length > 3">
<q-chip color="primary" text-color="white" class="q-mr-sm" size="sm">
+ {{ props.row.templates.length - 3 }}
<q-tooltip>
<q-chip v-for="(item, index) in props.row.templates.slice(3)" :key="index" text-color="white"
class="q-mr-sm" size="sm">
{{ formatTemplates(item) }}
</q-chip>
</q-tooltip>
</q-chip>
</template>
</q-td>
</template>
<template v-slot:body-cell-lastModifiedDate="props">
<q-td :props="props">
{{ props.row.lastModifiedDate ? date.formatDate(props.row.lastModifiedDate, 'YYYY-MM-DD HH:mm') : '-' }}
Expand Down Expand Up @@ -99,6 +147,7 @@ import CodeRender from 'components/CodeRender.vue'
import { retrieveSchemas, retrieveSchemaFields, retrieveSchemaPreview, fetchSchema } from 'src/api/schemas'
import { retrieveTemplates } from 'src/api/templates'
import type { Schema, Field, Template } from 'src/models'
import { visibleArray } from 'src/utils'
const $q = useQuasar()
Expand Down Expand Up @@ -144,8 +193,23 @@ const columns: QTableProps['columns'] = [
{ name: 'id', label: 'actions', field: 'id' }
]
const configColumns: QTableProps['columns'] = [
{ name: 'name', label: 'name', align: 'left', field: 'name', sortable: true },
{ name: 'dataType', label: 'dataType', align: 'left', field: 'dataType' },
{ name: 'length', label: 'length', align: 'left', field: 'length' },
{ name: 'nullable', label: 'nullable', align: 'left', field: 'nullable' },
{ name: 'comment', label: 'comment', align: 'left', field: 'comment' },
{ name: 'fieldType', label: 'fieldType', align: 'left', field: 'fieldType' },
{ name: 'formType', label: 'formType', align: 'left', field: 'formType' },
{ name: 'queryable', label: 'queryable', align: 'left', field: 'queryable' },
{ name: 'editable', label: 'editable', align: 'left', field: 'editable' },
{ name: 'lastModifiedDate', label: 'lastModifiedDate', align: 'center', field: 'lastModifiedDate' },
{ name: 'id', label: 'actions', field: 'id' }
]
onMounted(() => {
tableRef.value.requestServerInteraction()
loadTemplages()
})
/**
Expand Down Expand Up @@ -183,6 +247,22 @@ async function loadSchemaFields(id: number) {
})
}
async function loadTemplages() {
retrieveTemplates({ page: 1, size: 99 }).then(res => {
templates.value = res.data.content
})
}
async function saveRow(id?: number) {
form.value = { ...initialValues }
visible.value = true
// You can populate the form with existing user data based on the id
if (id) {
fetchSchema(id).then(res => { form.value = res.data })
}
}
function importRow() {
importVisible.value = true
}
Expand All @@ -191,6 +271,7 @@ function previewRow(id: number) {
previewVisible.value = true
retrieveSchemaPreview(id).then(res => {
renderedTemplates.value = res.data
tab.value = res.data[0].id
})
}
Expand All @@ -199,18 +280,6 @@ function configRow(id: number) {
loadSchemaFields(id)
}
async function saveRow(id?: number) {
form.value = { ...initialValues }
retrieveTemplates({ page: 0, size: 99 }).then(res => {
templates.value = res.data.content
})
visible.value = true
// You can populate the form with existing user data based on the id
if (id) {
fetchSchema(id).then(res => { form.value = res.data })
}
}
function removeRow(id: number) {
console.log('id: ', id)
loading.value = true
Expand Down Expand Up @@ -265,4 +334,14 @@ function exportTable() {
})
}
}
/**
* format templates
* @param cellValue cell value
*/
function formatTemplates(cellValue: number): string {
const templateItem = templates.value.find(item => item.id === cellValue)
return templateItem ? templateItem.name + templateItem.suffix : ''
}
</script>
3 changes: 2 additions & 1 deletion src/pages/exploiters/templates/IndexPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
<q-space />
<q-btn icon="sym_r_close" flat round dense v-close-popup />
</q-card-section>
<q-card-section>

<q-card-section style="max-height: 70vh;" class="scroll">
<CodeRender :content="form.content" />
</q-card-section>
</q-card>
Expand Down
30 changes: 15 additions & 15 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -508,9 +508,9 @@ __metadata:
languageName: node
linkType: hard

"@quasar/app-vite@npm:^1.10.2":
version: 1.10.2
resolution: "@quasar/app-vite@npm:1.10.2"
"@quasar/app-vite@npm:^1.11.0":
version: 1.11.0
resolution: "@quasar/app-vite@npm:1.11.0"
dependencies:
"@quasar/render-ssr-error": "npm:^1.0.3"
"@quasar/vite-plugin": "npm:^1.7.0"
Expand Down Expand Up @@ -574,14 +574,14 @@ __metadata:
optional: true
bin:
quasar: bin/quasar
checksum: 10c0/acbc31991a2f4c9f277921602f7f700017c9541ceef3ad36e5237a75c1d65a611098ed6ae480abb16ad946a0b440002bb6d88334e64fd67d1695cad66ba55616
checksum: 10c0/acb7aa9cd8cbd117dc861af89091259aa0aaf7bb1140051dc6760d3ae98f34a261b03972811b17d41c78e7b08b2170506de84b850631d4ce2924e7f7d13bef99
languageName: node
linkType: hard

"@quasar/extras@npm:^1.16.11":
version: 1.16.12
resolution: "@quasar/extras@npm:1.16.12"
checksum: 10c0/663557f7e97ff52f7da66de147ec83e56667c8d7adf7dcf832fdff750f645dc26c591e45c6c35023e70ccd53a964d4e71c8009d2b9beb1b41576bfd49bd63529
"@quasar/extras@npm:^1.16.13":
version: 1.16.13
resolution: "@quasar/extras@npm:1.16.13"
checksum: 10c0/6a43e0bb079e2609aba6faa30a313f9f1823ea58c8ce8bc5d0b1b9661398c0466b74f47a057760fab8d4c22973f910e73f5064f7dbd573ae97f926d33f325ff8
languageName: node
linkType: hard

Expand Down Expand Up @@ -4181,8 +4181,8 @@ __metadata:
version: 0.0.0-use.local
resolution: "leafage-ms@workspace:."
dependencies:
"@quasar/app-vite": "npm:^1.10.2"
"@quasar/extras": "npm:^1.16.11"
"@quasar/app-vite": "npm:^1.11.0"
"@quasar/extras": "npm:^1.16.13"
"@typescript-eslint/eslint-plugin": "npm:^8.11.0"
"@typescript-eslint/parser": "npm:^8.11.0"
apexcharts: "npm:^3.54.1"
Expand All @@ -4200,7 +4200,7 @@ __metadata:
pinia: "npm:^2.1.7"
pinia-plugin-persistedstate: "npm:^3.2.1"
postcss: "npm:^8.4.38"
quasar: "npm:^2.17.1"
quasar: "npm:^2.17.4"
typescript: "npm:^5.4.4"
vue: "npm:^3.5.12"
vue-i18n: "npm:^10.0.4"
Expand Down Expand Up @@ -5139,10 +5139,10 @@ __metadata:
languageName: node
linkType: hard

"quasar@npm:^2.17.1":
version: 2.17.1
resolution: "quasar@npm:2.17.1"
checksum: 10c0/fa562d67dfda8ef30be1c4a7791b00565cd22ec4faa95088e73ad9601690e29ca604b68036ddedee56429b5696307cd88c8db91a70f116e6995fb17aa0345c9b
"quasar@npm:^2.17.4":
version: 2.17.4
resolution: "quasar@npm:2.17.4"
checksum: 10c0/97970661c872e7e5adbed73e97b91c6762d37cc1a65ba66e075f4386c34dc19c3797126915cb014b67ae018c9ab9d93bff5ef464d7d7e3f8ee9ddd61a26a9fed
languageName: node
linkType: hard

Expand Down

0 comments on commit bbf9785

Please sign in to comment.