diff --git a/backend/Temp/alc_runtime.js b/backend/Temp/alc_runtime.js new file mode 100644 index 0000000..886fc1f --- /dev/null +++ b/backend/Temp/alc_runtime.js @@ -0,0 +1,2 @@ +test() +{} \ No newline at end of file diff --git a/backend/app/api/api_v1/routers/kintone.py b/backend/app/api/api_v1/routers/kintone.py index 22c29a8..c616622 100644 --- a/backend/app/api/api_v1/routers/kintone.py +++ b/backend/app/api/api_v1/routers/kintone.py @@ -7,7 +7,8 @@ import httpx import deepdiff import app.core.config as c import os - +from app.db.session import SessionLocal +from app.db.crud import get_flows kinton_router = r = APIRouter() @@ -242,7 +243,20 @@ def updateappjscss(app,uploads): print(data) r = httpx.put(url,headers=headers,data=json.dumps(data)) return r.json() - + +def createappjs(app): + db = SessionLocal() + flows = get_flows(db,app) + db.close() + content={} + for flow in flows: + content[flow.eventid] = {'flowid':flow.flowid,'name':flow.name,'content':flow.content} + js = 'const flow=' + json.dumps(content) + fpath = '{}\\alc_setting_{}.js'.format('Temp',app) + file = open(fpath,'w') + file.write(js) + file.close() + return fpath @r.post("/test",) async def test(file:UploadFile= File(...),app:str=None): @@ -488,3 +502,21 @@ async def updateprocessfromexcel(app:str): return result +@r.post("/createjstokintone",) +async def createjstokintone(app:str): + + try: + jscs=[] + files=[] + files.append(createappjs(app)) + files.append('Temp\\alc_runtime.js.js') + for file in files: + upload = uploadkintonefiles(file) + if upload.get('fileKey') != None: + jscs.append({ app + '.js':upload['fileKey']}) + appjscs = updateappjscss(app,jscs) + if appjscs.get("revision") != None: + deoployappfromkintone(app,appjscs["revision"]) + return appjscs + except Exception as e: + raise HTTPException(status_code=400, detail=f"Error occurred : {str(e)}") \ No newline at end of file