-
Notifications
You must be signed in to change notification settings - Fork 3.2k
feat: Certificate list supports search by name and hides specified co… #8410
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -56,8 +56,13 @@ func NewIWebsiteSSLService() IWebsiteSSLService { | |
| func (w WebsiteSSLService) Page(search request.WebsiteSSLSearch) (int64, []response.WebsiteSSLDTO, error) { | ||
| var ( | ||
| result []response.WebsiteSSLDTO | ||
| opts []repo.DBOption | ||
| ) | ||
| total, sslList, err := websiteSSLRepo.Page(search.Page, search.PageSize, repo.WithOrderBy("created_at desc")) | ||
| opts = append(opts, repo.WithOrderBy("created_at desc")) | ||
| if search.Domain != "" { | ||
| opts = append(opts, websiteSSLRepo.WithByDomain(search.Domain)) | ||
| } | ||
| total, sslList, err := websiteSSLRepo.Page(search.Page, search.PageSize, opts...) | ||
| if err != nil { | ||
| return 0, nil, err | ||
| } | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The code does not contain any significant irregularities or major issues, but there are a few optimizations and improvements that could be made:
if search.Domain == "" {
// Skip this filter if the domain is not provided
} else {
opts = append(opts, websiteSSLRepo.WithByDomain(search.Domain))
}
total, sslList, err := websiteSSLRepo.Page(search.Page, search.PageSize, opts...)This way, changes like additional sorting criteria can be easily added without modifying multiple calls to the
Here's a slightly refactored version incorporating some of these suggestions: func (w WebsiteSSLService) Page(search request.WebsiteSSLSearch) (int64, []response.WebsiteSSLDTO, error) {
opts := []repo.DBOption{
repo.WithOrderBy("created_at desc"),
}
if search.Domain != "" {
opts = append(opts, websiteSSLRepo.WithByDomain(search.Domain))
}
total, sslList, err := websiteSSLRepo.PageWithOptions(search.Page, search.PageSize, opts...)
if err != nil && total > 0 {
err = fmt.Errorf("%d records returned while fetching SSL data failed: %v", total, err)
}
return total, sslList, err
}These suggestions will help make the |
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,7 +23,15 @@ | |
| </el-button> | ||
| </template> | ||
| <template #rightToolBar> | ||
| <TableSearch @search="search()" v-model:searchName="req.domain" /> | ||
| <TableRefresh @search="search()" /> | ||
| <fu-table-column-select | ||
| :columns="columns" | ||
| trigger="hover" | ||
| :title="$t('commons.table.selectColumn')" | ||
| popper-class="popper-class" | ||
| :only-icon="true" | ||
| /> | ||
| </template> | ||
| <template #main> | ||
| <ComplexTable | ||
|
|
@@ -32,41 +40,33 @@ | |
| @search="search()" | ||
| v-model:selects="selects" | ||
| v-loading="loading" | ||
| :columns="columns" | ||
| localKey="sslColumn" | ||
| > | ||
| <el-table-column type="selection" width="30" /> | ||
| <el-table-column | ||
| :label="$t('website.domain')" | ||
| fix | ||
| show-overflow-tooltip | ||
| prop="primaryDomain" | ||
| min-width="150px" | ||
| ></el-table-column> | ||
| <el-table-column | ||
| :label="$t('website.otherDomains')" | ||
| fix | ||
| show-overflow-tooltip | ||
| prop="domains" | ||
| min-width="90px" | ||
| ></el-table-column> | ||
| <el-table-column | ||
| :label="$t('ssl.applyType')" | ||
| fix | ||
| show-overflow-tooltip | ||
| prop="provider" | ||
| min-width="110px" | ||
| > | ||
| <el-table-column :label="$t('ssl.applyType')" show-overflow-tooltip prop="provider" width="90px"> | ||
| <template #default="{ row }">{{ getProvider(row.provider) }}</template> | ||
| </el-table-column> | ||
| <el-table-column | ||
| :label="$t('ssl.acmeAccount')" | ||
| fix | ||
| show-overflow-tooltip | ||
| prop="acmeAccount.email" | ||
| min-width="110px" | ||
| width="150px" | ||
| ></el-table-column> | ||
| <el-table-column | ||
| :label="$t('commons.table.status')" | ||
| fix | ||
| show-overflow-tooltip | ||
| prop="status" | ||
| width="100px" | ||
|
|
@@ -94,7 +94,7 @@ | |
| </div> | ||
| </template> | ||
| </el-table-column> | ||
| <el-table-column :label="$t('commons.button.log')" width="100px"> | ||
| <el-table-column :label="$t('commons.button.log')" width="80px"> | ||
| <template #default="{ row }"> | ||
| <el-button @click="openSSLLog(row)" link type="primary" v-if="row.provider != 'manual'"> | ||
| {{ $t('website.check') }} | ||
|
|
@@ -103,11 +103,11 @@ | |
| </el-table-column> | ||
| <el-table-column | ||
| :label="$t('website.brand')" | ||
| fix | ||
| show-overflow-tooltip | ||
| prop="organization" | ||
| width="150px" | ||
| ></el-table-column> | ||
| <el-table-column :label="$t('website.remark')" fix prop="description" min-width="100px"> | ||
| <el-table-column :label="$t('website.remark')" prop="description" width="100px"> | ||
| <template #default="{ row }"> | ||
| <fu-read-write-switch> | ||
| <template #read> | ||
|
|
@@ -119,7 +119,7 @@ | |
| </fu-read-write-switch> | ||
| </template> | ||
| </el-table-column> | ||
| <el-table-column :label="$t('ssl.autoRenew')" fix min-width="100px"> | ||
| <el-table-column :label="$t('ssl.autoRenew')" width="100px"> | ||
| <template #default="{ row }"> | ||
| <el-switch | ||
| :disabled="row.provider === 'dnsManual' || row.provider === 'manual'" | ||
|
|
@@ -133,7 +133,7 @@ | |
| :label="$t('website.expireDate')" | ||
| :formatter="dateFormat" | ||
| show-overflow-tooltip | ||
| width="200px" | ||
| width="180px" | ||
| /> | ||
| <fu-table-operations | ||
| :ellipsis="3" | ||
|
|
@@ -198,6 +198,10 @@ const logRef = ref(); | |
| const caRef = ref(); | ||
| const obtainRef = ref(); | ||
| let selects = ref<any>([]); | ||
| const columns = ref([]); | ||
| const req = reactive({ | ||
| domain: '', | ||
| }); | ||
|
|
||
| const routerButton = [ | ||
| { | ||
|
|
@@ -286,12 +290,13 @@ const mobile = computed(() => { | |
| }); | ||
|
|
||
| const search = () => { | ||
| const req = { | ||
| const request = { | ||
| page: paginationConfig.currentPage, | ||
| pageSize: paginationConfig.pageSize, | ||
| domain: req.domain, | ||
| }; | ||
| loading.value = true; | ||
| searchSSL(req) | ||
| searchSSL(request) | ||
| .then((res) => { | ||
| data.value = res.data.items || []; | ||
| paginationConfig.total = res.data.total; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here are some observations and suggestions regarding the code:
Overall, you're making good progress and most elements look reasonable given their current complexity and functionality requirements. Here's an optimized version focusing on reducing redundancy, improving readability, and ensuring consistency across your component: // Simplified Column Definition in Script Block
const defaultColumns = [
{ label: $t('website.domain'), prop: 'primaryDomain', min_width: 150 },
// Add other common columns here
];
columns.value = defaultColumns;
function searchSSL(params) {
const request = {
page: paginationConfig.currentPage,
pageSize: paginationConfig.pageSize,
...params,
};
fetch(sslApiUrl, {
method: 'GET',
headers: apiHeaders,
body: JSON.stringify(request),
})
.then(response => response.json())
.then(res => {
console.log(res);
if (!res.success) throw Error(`Error fetching ssl list`);
data.value = res.data.items || [];
paginationConfig.total = res.data.total;
})
.catch(error => {
loading.value = false;
handleError();
});
}
fetchCaList(searchParams)
.then(data => {
...
});
obtainCertification({ domains, email })
...
};By addressing these areas, your code should become cleaner and potentially more efficient while retaining its existing behavior and functionalities. Always validate performance impact and adjust accordingly during development. |
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a code snippet from an interface (
ISSLRepo) and its implementations for querying SSL websites based on various conditions. The changes made include adding a new methodWithByDomainto allow filtering by domain name, modifying the existingPagefunction slightly to incorporate pagination parameters, and implementing error handling where necessary.Irregularities/Issues:
Pagefunction currently returns two values (the total count and a slice of models). While this pattern can be useful, it might not work correctly if errors occur during database operations. Consider wrapping these in a single return value with custom types that handle both data and potential errors.Optimization Suggestions:
Indexing: If using SQLite, consider creating indexes on columns used frequently in WHERE clauses like
acme_account_id,dns_account_id,ca_id, andprimary_domain. This can significantly speed up queries.Consistency in Functionality: Ensure consistency across all filter functions regarding whether they return the original model or a modified model with additional fields. For example, use the same approach for returning the "first" model as you do for paginated results.
Performance Tuning: Depending on the complexity of your query and usage patterns, consider optimizing SQL performance by analyzing slow queries, rewriting complex queries into simpler ones, or caching common query results.
Refactoring for Readability: Break down larger functions or methods into smaller, more focused parts if they become difficult to manage visually. This improves readability and maintainability.
These suggestions aim to improve the robustness, efficiency, and overall quality of the codebase managing SSL website records.