add url and view handler for sysconfig apply, <TESTED - WORKS>
This commit is contained in:
parent
17d10fb339
commit
caaedfa003
Binary file not shown.
Binary file not shown.
@ -28,9 +28,7 @@ def req_edit_state(id, state):
|
||||
|
||||
def req_edit_user(id):
|
||||
inf_s = get_session()
|
||||
|
||||
req_val = id
|
||||
|
||||
req_url = 'http://10.30.1.138:5000/api/client/'+req_val
|
||||
|
||||
req = inf_s.get(req_url)
|
||||
@ -42,5 +40,17 @@ def req_edit_user(id):
|
||||
|
||||
return req.json()
|
||||
|
||||
def req_apply_sys():
|
||||
inf_s = get_session()
|
||||
# http://10.30.1.138:5000/api/apply-wg-config?_=1669872830286
|
||||
req_url = 'http://10.30.1.138:5000/api/apply-wg-config'
|
||||
|
||||
req = inf_s.get(req_url)
|
||||
|
||||
print("-->")
|
||||
print(req)
|
||||
|
||||
return req
|
||||
|
||||
#
|
||||
# http://10.30.1.138:5000/api/client/caivc1vekn84im2m6ec0?_=1669623393468
|
||||
|
@ -12,7 +12,7 @@ from .models import user_model
|
||||
from .utils.html_parser import get_logs, get_profiles
|
||||
import json
|
||||
from .utils.statistics import count_clients, count_traffic, count_connection, count_percentage, count_broken
|
||||
from .utils.reqs_handler import req_edit_state, req_edit_user
|
||||
from .utils.reqs_handler import req_edit_state, req_edit_user, req_apply_sys
|
||||
from django.middleware.csrf import get_token
|
||||
from django.views.decorators.csrf import csrf_exempt
|
||||
|
||||
@ -283,6 +283,16 @@ def wgViewClients(request):
|
||||
|
||||
return HttpResponse(final_data, content_type='application')
|
||||
|
||||
def get_ApplyConfig(request):
|
||||
|
||||
# id = request.GET.get('id', '')
|
||||
# state = request.GET.get('state', '')
|
||||
# print("Edit Request...")
|
||||
|
||||
req_response = req_apply_sys()
|
||||
|
||||
return HttpResponse(req_response)
|
||||
|
||||
def get_EditState(request):
|
||||
|
||||
id = request.GET.get('id', '')
|
||||
@ -297,7 +307,14 @@ def get_EditState(request):
|
||||
|
||||
req_edit_state(id, state)
|
||||
else:
|
||||
print(id)
|
||||
print("[ Bulk handler ]=======")
|
||||
print(request.body)
|
||||
|
||||
target_ids = request.body
|
||||
|
||||
for x in json.loads(target_ids):
|
||||
req_edit_state(str(x), state)
|
||||
print(x)
|
||||
|
||||
final_data = json.dumps({"state":"Success"})
|
||||
|
||||
|
Binary file not shown.
Binary file not shown.
@ -27,5 +27,6 @@ urlpatterns = [
|
||||
path('api2/wgLogs', views.wgViewLogs),
|
||||
path('api2/wgClients', views.wgViewClients),
|
||||
path('api2/wgEditState', views.get_EditState),
|
||||
path('api2/wgSysApply', views.get_ApplyConfig),
|
||||
path('api2/wgEditClient', views.get_EditClient)
|
||||
]
|
||||
|
Loading…
Reference in New Issue
Block a user