Skip to content

Commit

Permalink
feat: add directive auto complete and documents #816
Browse files Browse the repository at this point in the history
  • Loading branch information
0xJacky committed Jan 21, 2025
1 parent 830ed28 commit 5911462
Show file tree
Hide file tree
Showing 25 changed files with 4,288 additions and 306 deletions.
18 changes: 18 additions & 0 deletions api/nginx/directives.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package nginx

import (
"net/http"

"github.com/0xJacky/Nginx-UI/internal/nginx"
"github.com/gin-gonic/gin"
"github.com/uozi-tech/cosy"
)

func GetDirectives(c *gin.Context) {
directives, err := nginx.GetDirectives()
if err != nil {
cosy.ErrHandler(c, err)
return
}
c.JSON(http.StatusOK, directives)
}
1 change: 1 addition & 0 deletions api/nginx/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ func InitRouter(r *gin.RouterGroup) {
r.POST("nginx/test", Test)
r.GET("nginx/status", Status)
r.POST("nginx_log", GetNginxLogPage)
r.GET("nginx/directives", GetDirectives)
}

func InitNginxLogRouter(r *gin.RouterGroup) {
Expand Down
1 change: 0 additions & 1 deletion app/.idea/jsLinters/eslint.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions app/src/api/ngx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ export interface NgxLocation {
comments: string
}

export type DirectiveMap = Record<string, { links: string[] }>

const ngx = {
build_config(ngxConfig: NgxConfig) {
return http.post('/ngx/build_config', ngxConfig)
Expand Down Expand Up @@ -61,6 +63,10 @@ const ngx = {
test() {
return http.post('/nginx/test')
},

get_directives(): Promise<DirectiveMap> {
return http.get('/nginx/directives')
},
}

export default ngx
2 changes: 1 addition & 1 deletion app/src/language/LINGUAS
Original file line number Diff line number Diff line change
@@ -1 +1 @@
en zh_CN zh_TW fr_FR es de_DE ru_RU vi_VN ko_KR tr_TR ar
en zh_CN zh_TW fr_FR es de_DE ru_RU vi_VN ko_KR tr_TR ar
66 changes: 39 additions & 27 deletions app/src/language/ar/app.po
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ msgstr "أضف مفتاح مرور"
msgid "Add Configuration"
msgstr "إضافة تكوين"

#: src/views/site/ngx_conf/directive/DirectiveAdd.vue:95
#: src/views/site/ngx_conf/directive/DirectiveAdd.vue:117
msgid "Add Directive Below"
msgstr "أضف التوجيه أدناه"

Expand Down Expand Up @@ -179,7 +179,7 @@ msgstr "هل أنت متأكد أنك تريد الحذف؟"
msgid "Are you sure you want to recover this item?"
msgstr "هل أنت متأكد أنك تريد استرداد هذا العنصر؟"

#: src/views/site/ngx_conf/directive/DirectiveEditorItem.vue:88
#: src/views/site/ngx_conf/directive/DirectiveEditorItem.vue:95
msgid "Are you sure you want to remove this directive?"
msgstr "هل أنت متأكد أنك تريد إزالة هذا التوجيه؟"

Expand All @@ -203,7 +203,7 @@ msgstr "المساعد"
msgid "Attempts"
msgstr "محاولات"

#: src/views/preference/Preference.vue:154
#: src/views/preference/Preference.vue:155
msgid "Auth"
msgstr "مصادقة"

Expand Down Expand Up @@ -265,7 +265,7 @@ msgid "Base information"
msgstr "المعلومات الأساسية"

#: src/views/config/ConfigEditor.vue:243
#: src/views/preference/Preference.vue:148
#: src/views/preference/Preference.vue:149
#: src/views/site/site_edit/RightSettings.vue:79
#: src/views/stream/components/RightSettings.vue:74
msgid "Basic"
Expand Down Expand Up @@ -294,7 +294,7 @@ msgstr "ترقية متعددة"
msgid "Belows are selected items that you want to batch modify"
msgstr "فيما يلي العناصر المحددة التي تريد تعديلها دفعة واحدة"

#: src/views/system/About.vue:39
#: src/views/system/About.vue:55
msgid "Build with"
msgstr "بناء مع"

Expand Down Expand Up @@ -330,7 +330,7 @@ msgstr "إلغاء"
msgid "Category"
msgstr "فئة"

#: src/views/preference/Preference.vue:160
#: src/views/preference/Preference.vue:161
msgid "Cert"
msgstr "شهادة"

Expand Down Expand Up @@ -408,7 +408,7 @@ msgstr "تم المسح بنجاح"
msgid "Command"
msgstr "أمر"

#: src/views/site/ngx_conf/directive/DirectiveEditorItem.vue:106
#: src/views/site/ngx_conf/directive/DirectiveEditorItem.vue:113
#: src/views/site/ngx_conf/LocationEditor.vue:105
#: src/views/site/ngx_conf/LocationEditor.vue:136
#: src/views/site/ngx_conf/NgxServer.vue:134
Expand Down Expand Up @@ -443,7 +443,7 @@ msgstr "متصل"
msgid "Connection lost, please refresh the page."
msgstr "تم فقدان الاتصال، يرجى تحديث الصفحة."

#: src/views/site/ngx_conf/directive/DirectiveEditorItem.vue:111
#: src/views/site/ngx_conf/directive/DirectiveEditorItem.vue:118
#: src/views/site/ngx_conf/LocationEditor.vue:117
#: src/views/site/ngx_conf/LocationEditor.vue:145
msgid "Content"
Expand Down Expand Up @@ -605,15 +605,15 @@ msgstr "وصف"
msgid "Details"
msgstr "تفاصيل"

#: src/views/system/About.vue:22
#: src/views/system/About.vue:28
msgid "Development Mode"
msgstr "وضع التطوير"

#: src/views/site/ngx_conf/directive/DirectiveAdd.vue:73
#: src/views/site/ngx_conf/directive/DirectiveAdd.vue:89
msgid "Directive"
msgstr "توجيه"

#: src/views/site/ngx_conf/directive/DirectiveEditor.vue:21
#: src/views/site/ngx_conf/directive/DirectiveEditor.vue:28
msgid "Directives"
msgstr "توجيهات"

Expand Down Expand Up @@ -725,6 +725,18 @@ msgstr "هل تريد إزالة هذا الخادم؟"
msgid "Do you want to remove this upstream?"
msgstr "هل تريد إزالة هذا المصدر؟"

#: src/views/site/ngx_conf/directive/DirectiveAdd.vue:105
#: src/views/site/ngx_conf/directive/DirectiveDocuments.vue:15
#, fuzzy
msgid "Document"
msgid_plural "Documents"
msgstr[0] "ملف API"
msgstr[1] "ملف API"
msgstr[2] "ملف API"
msgstr[3] "ملف API"
msgstr[4] "ملف API"
msgstr[5] "ملف API"

#: src/views/certificate/WildcardCertificate.vue:68
msgid "Domain"
msgstr "نطاق"
Expand Down Expand Up @@ -1215,7 +1227,7 @@ msgstr "تركه فارغًا لن يغير شيئًا"
msgid "Lego disable CNAME Support"
msgstr "تعطيل دعم ‏Lego CNAME"

#: src/views/system/About.vue:47
#: src/views/system/About.vue:63
msgid "License"
msgstr "رخصة"

Expand Down Expand Up @@ -1269,7 +1281,7 @@ msgstr "تم تسجيل الدخول بنجاح"
msgid "Logout successful"
msgstr "تم تسجيل الخروج بنجاح"

#: src/views/preference/Preference.vue:178
#: src/views/preference/Preference.vue:179
msgid "Logrotate"
msgstr "تدوير السجلات"

Expand Down Expand Up @@ -1358,7 +1370,7 @@ msgstr "تعديل التكوين"
msgid "Modify Mode"
msgstr "وضع التعديل"

#: src/views/site/ngx_conf/directive/DirectiveAdd.vue:54
#: src/views/site/ngx_conf/directive/DirectiveAdd.vue:68
msgid "Multi-line Directive"
msgstr "توجيه متعدد الأسطر"

Expand Down Expand Up @@ -1414,7 +1426,7 @@ msgstr "تم إصدار نسخة جديدة"
msgid "Next"
msgstr "التالي"

#: src/views/preference/Preference.vue:166
#: src/views/preference/Preference.vue:167
msgid "Nginx"
msgstr "Nginx"

Expand Down Expand Up @@ -1481,7 +1493,7 @@ msgstr "تم إعادة تشغيل Nginx بنجاح"
#: src/views/notification/Notification.vue:38
#: src/views/preference/AuthSettings.vue:138
#: src/views/preference/CertSettings.vue:70
#: src/views/site/ngx_conf/directive/DirectiveEditorItem.vue:90
#: src/views/site/ngx_conf/directive/DirectiveEditorItem.vue:97
#: src/views/site/ngx_conf/LocationEditor.vue:90
#: src/views/site/site_list/SiteList.vue:148
#: src/views/stream/StreamList.vue:164
Expand Down Expand Up @@ -1590,7 +1602,7 @@ msgstr "بمجرد اكتمال التحقق، سيتم إزالة السجلا
msgid "Online"
msgstr "متصل"

#: src/views/preference/Preference.vue:172
#: src/views/preference/Preference.vue:173
msgid "OpenAI"
msgstr "أوبن أي آي"

Expand Down Expand Up @@ -1620,7 +1632,7 @@ msgstr "الكتابة فوق"
msgid "Overwrite exist file"
msgstr "الكتابة فوق الملف الموجود"

#: src/views/site/ngx_conf/directive/DirectiveAdd.vue:78
#: src/views/site/ngx_conf/directive/DirectiveAdd.vue:94
msgid "Params"
msgstr "عوامل"

Expand Down Expand Up @@ -1759,7 +1771,7 @@ msgstr "يرجى ترقية واجهة Nginx البعيدة إلى أحدث إص
msgid "Pre-release"
msgstr "ما قبل الإصدار"

#: src/routes/index.ts:266 src/views/preference/Preference.vue:143
#: src/routes/index.ts:266 src/views/preference/Preference.vue:144
msgid "Preference"
msgstr "تفضيل"

Expand All @@ -1775,7 +1787,7 @@ msgstr "حظر تغيير كلمة مرور root في العرض التوضيح
msgid "Prohibit deleting the default user"
msgstr "حظر حذف المستخدم الافتراضي"

#: src/views/system/About.vue:35
#: src/views/system/About.vue:51
msgid "Project Team"
msgstr "فريق المشروع"

Expand Down Expand Up @@ -2026,15 +2038,15 @@ msgstr "يعمل"
#: src/views/config/components/ConfigName.vue:58
#: src/views/config/ConfigEditor.vue:224
#: src/views/preference/components/Passkey.vue:136
#: src/views/preference/Preference.vue:189
#: src/views/site/ngx_conf/directive/DirectiveEditorItem.vue:120
#: src/views/preference/Preference.vue:190
#: src/views/site/ngx_conf/directive/DirectiveEditorItem.vue:127
#: src/views/site/site_edit/components/ConfigName.vue:54
#: src/views/site/site_edit/SiteEdit.vue:271
#: src/views/stream/StreamEdit.vue:252
msgid "Save"
msgstr "حفظ"

#: src/views/site/ngx_conf/directive/DirectiveAdd.vue:105
#: src/views/site/ngx_conf/directive/DirectiveAdd.vue:127
msgid "Save Directive"
msgstr "حفظ التوجيه"

Expand Down Expand Up @@ -2063,7 +2075,7 @@ msgstr "تم حفظ الموقع %{site} إلى %{node} بنجاح"
#: src/components/StdDesign/StdDataDisplay/StdBatchEdit.vue:47
#: src/components/StdDesign/StdDataDisplay/StdCurd.vue:97
#: src/views/certificate/CertificateEditor.vue:49
#: src/views/preference/Preference.vue:112
#: src/views/preference/Preference.vue:113
msgid "Save successfully"
msgstr "تم الحفظ بنجاح"

Expand Down Expand Up @@ -2113,7 +2125,7 @@ msgstr "إرسال"
#: src/views/preference/components/Passkey.vue:56
#: src/views/preference/components/TOTP.vue:44
#: src/views/preference/components/TOTP.vue:57
#: src/views/preference/Preference.vue:116
#: src/views/preference/Preference.vue:117
#: src/views/site/site_list/SiteList.vue:40
#: src/views/site/site_list/SiteList.vue:72 src/views/stream/StreamList.vue:113
#: src/views/stream/StreamList.vue:81 src/views/system/Upgrade.vue:42
Expand Down Expand Up @@ -2160,7 +2172,7 @@ msgstr "عرض"
msgid "Sign in with a passkey"
msgstr "تسجيل الدخول باستخدام مفتاح المرور"

#: src/views/site/ngx_conf/directive/DirectiveAdd.vue:51
#: src/views/site/ngx_conf/directive/DirectiveAdd.vue:65
msgid "Single Directive"
msgstr "توجيه واحد"

Expand Down Expand Up @@ -2716,7 +2728,7 @@ msgstr "كتابة الشهادة إلى القرص"

#: src/views/preference/AuthSettings.vue:137
#: src/views/preference/CertSettings.vue:69
#: src/views/site/ngx_conf/directive/DirectiveEditorItem.vue:89
#: src/views/site/ngx_conf/directive/DirectiveEditorItem.vue:96
#: src/views/site/ngx_conf/LocationEditor.vue:89
msgid "Yes"
msgstr "نعم"
Expand Down
Loading

0 comments on commit 5911462

Please sign in to comment.