前端APIのURL参数化対応およびバックエンドのBugFix
This commit is contained in:
@@ -8,7 +8,7 @@ import deepdiff
|
||||
import app.core.config as config
|
||||
import os
|
||||
from app.db.session import SessionLocal
|
||||
from app.db.crud import get_flows,get_activedomain
|
||||
from app.db.crud import get_flows_by_app,get_activedomain
|
||||
from app.core.auth import get_current_active_user,get_current_user
|
||||
|
||||
kinton_router = r = APIRouter()
|
||||
@@ -258,19 +258,17 @@ def updateappjscss(app,uploads,c:config.KINTONE_ENV):
|
||||
|
||||
def createappjs(app):
|
||||
db = SessionLocal()
|
||||
flows = get_flows(db,app)
|
||||
flows = get_flows_by_app(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',encoding="utf-8")
|
||||
file.write(js)
|
||||
file.close()
|
||||
js = 'const alcflow=' + json.dumps(content)
|
||||
fpath = os.path.join("Temp",f"alc_setting_{app}.js")
|
||||
with open(fpath,'w') as file:
|
||||
file.write(js)
|
||||
return fpath
|
||||
|
||||
|
||||
@r.post("/test",)
|
||||
async def test(file:UploadFile= File(...),app:str=None):
|
||||
if file.filename.endswith('.xlsx'):
|
||||
@@ -340,7 +338,14 @@ async def jscss(app:str,files:t.List[UploadFile] = File(...),env = Depends(getki
|
||||
return appjscs
|
||||
except Exception as e:
|
||||
raise HTTPException(status_code=400, detail=f"Error occurred while update file {file.filename}: {str(e)}")
|
||||
|
||||
|
||||
@r.get("/app")
|
||||
async def app(app:str,c:config.KINTONE_ENV=Depends(getkintoneenv)):
|
||||
headers={config.API_V1_AUTH_KEY:c.API_V1_AUTH_VALUE}
|
||||
url = f"{c.BASE_URL}{config.API_V1_STR}/app.json"
|
||||
params ={"id":app}
|
||||
r = httpx.get(url,headers=headers,params=params)
|
||||
return r.json()
|
||||
|
||||
@r.get("/allapps")
|
||||
async def allapps(c:config.KINTONE_ENV=Depends(getkintoneenv)):
|
||||
@@ -401,7 +406,7 @@ async def createappfromexcel(files:t.List[UploadFile] = File(...),env = Depends(
|
||||
app = updateappsettingstokintone(result["app"],{"description":desc},env)
|
||||
if app.get("revision") != None:
|
||||
result["revision"] = app["revision"]
|
||||
app = addfieldstokintone(result["app"],env,fields)
|
||||
app = addfieldstokintone(result["app"],fields,env)
|
||||
if len(processes)> 0:
|
||||
app = updateprocesstokintone(result["app"],processes,env)
|
||||
if app.get("revision") != None:
|
||||
@@ -410,8 +415,7 @@ async def createappfromexcel(files:t.List[UploadFile] = File(...),env = Depends(
|
||||
except Exception as e:
|
||||
raise HTTPException(status_code=400, detail=f"Error occurred while parsing file {file.filename}: {str(e)}")
|
||||
else:
|
||||
raise HTTPException(status_code=400, detail=f"File {file.filename} is not an Excel file")
|
||||
|
||||
raise HTTPException(status_code=400, detail=f"File {file.filename} is not an Excel file")
|
||||
return result
|
||||
|
||||
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
KAB_BACKEND_URL="http://127.0.0.1:8000/api/v1/"
|
||||
KAB_BACKEND_URL="http://127.0.0.1:8000/"
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ export default {
|
||||
]
|
||||
const rows = reactive([])
|
||||
onMounted(async () => {
|
||||
await api.get('http://127.0.0.1:8000/api/kintone/1').then(res =>{
|
||||
await api.get('api/kintone/1').then(res =>{
|
||||
res.data.forEach((item) =>
|
||||
{
|
||||
rows.push({name:item.name,desc:item.desc,content:item.content});
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
import { AppInfo, AppSeed } from './models';
|
||||
import { ref, defineComponent, watch, onMounted , toRefs } from 'vue';
|
||||
import { api } from 'boot/axios';
|
||||
import { promises } from 'dns';
|
||||
import { useAuthStore } from 'src/stores/useAuthStore';
|
||||
|
||||
export default defineComponent({
|
||||
props: {
|
||||
@@ -44,12 +44,13 @@ export default defineComponent({
|
||||
},
|
||||
setup(props) {
|
||||
const { app } = toRefs(props);
|
||||
const authStore = useAuthStore();
|
||||
const appinfo = ref<AppInfo>({
|
||||
appId: "",
|
||||
name: "",
|
||||
description: ""
|
||||
});
|
||||
const link= ref('https://mfu07rkgnb7c.cybozu.com/k/' + app.value);
|
||||
const link= ref(`${authStore.currentDomain.kintoneUrl}/k/${app.value}`);
|
||||
const getAppInfo = async (appId:string|undefined) => {
|
||||
if(!appId){
|
||||
return;
|
||||
@@ -59,7 +60,7 @@ export default defineComponent({
|
||||
let retry =0;
|
||||
while(retry<=3 && result && result.appId!==appId){
|
||||
await new Promise(resolve => setTimeout(resolve, 1000));
|
||||
const response = await api.get('app', {
|
||||
const response = await api.get('api/v1/app', {
|
||||
params:{
|
||||
app: appId
|
||||
}
|
||||
@@ -73,7 +74,7 @@ export default defineComponent({
|
||||
|
||||
watch(app, async (newApp) => {
|
||||
appinfo.value = await getAppInfo(newApp);
|
||||
link.value = 'https://mfu07rkgnb7c.cybozu.com/k/' + newApp;
|
||||
link.value = `${authStore.currentDomain.kintoneUrl}/k/${newApp}`;
|
||||
}, { immediate: true });
|
||||
|
||||
const linkClick=(ev : MouseEvent)=>{
|
||||
@@ -82,7 +83,7 @@ export default defineComponent({
|
||||
};
|
||||
onMounted(async ()=>{
|
||||
appinfo.value = await getAppInfo(app.value);
|
||||
link.value = 'https://mfu07rkgnb7c.cybozu.com/k/' + app.value;
|
||||
link.value = `${authStore.currentDomain.kintoneUrl}/k/${app.value}`;
|
||||
});
|
||||
|
||||
return {
|
||||
|
||||
@@ -22,7 +22,7 @@ export default {
|
||||
]
|
||||
const rows = reactive([])
|
||||
onMounted( () => {
|
||||
api.get('allapps').then(res =>{
|
||||
api.get('api/v1/allapps').then(res =>{
|
||||
res.data.apps.forEach((item) =>
|
||||
{
|
||||
rows.push({id:item.appId,name:item.name,creator:item.creator.name,createdate:item.createdAt});
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
style="max-width: 400px"
|
||||
:url="uploadUrl"
|
||||
:label="title"
|
||||
:headers="headers"
|
||||
accept=".csv,.xlsx"
|
||||
v-on:rejected="onRejected"
|
||||
v-on:uploaded="onUploadFinished"
|
||||
@@ -15,7 +16,10 @@
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { createUploaderComponent, useQuasar } from 'quasar';
|
||||
import { useAuthStore } from 'src/stores/useAuthStore';
|
||||
import { ref } from 'vue';
|
||||
const $q=useQuasar();
|
||||
const authStore = useAuthStore();
|
||||
const emit =defineEmits(['uploaded']);
|
||||
/**
|
||||
* ファイルアップロードを拒否する時の処理
|
||||
@@ -67,9 +71,12 @@
|
||||
title: string;
|
||||
uploadUrl:string;
|
||||
}
|
||||
|
||||
const headers = ref([{name:"Authorization",value:'Bearer ' + authStore.token}]);
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
title:"設計書から導入する(csv or excel)",
|
||||
uploadUrl: `${process.env.KAB_BACKEND_URL}createappfromexcel`
|
||||
uploadUrl: `${process.env.KAB_BACKEND_URL}api/v1/createappfromexcel`
|
||||
|
||||
});
|
||||
</script>
|
||||
<style lang="scss">
|
||||
|
||||
@@ -23,7 +23,7 @@ export default {
|
||||
]
|
||||
const rows = reactive([])
|
||||
onMounted( () => {
|
||||
api.get(`http://127.0.0.1:8000/api/domains/testtenant`).then(res =>{
|
||||
api.get(`api/domains/testtenant`).then(res =>{
|
||||
res.data.forEach((item) =>
|
||||
{
|
||||
rows.push({id:item.id,tenantid:item.tenantid,name:item.name,url:item.url,kintoneuser:item.kintoneuser});
|
||||
|
||||
@@ -22,7 +22,7 @@ export default {
|
||||
]
|
||||
const rows = reactive([])
|
||||
onMounted( () => {
|
||||
api.get('appfields', {
|
||||
api.get('api/v1/appfields', {
|
||||
params:{
|
||||
app: props.appId
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
style="font-size: 2em"
|
||||
/>
|
||||
<div class="col-7 self-center ellipsis">
|
||||
<a :href="!store.appInfo?'':`https://mfu07rkgnb7c.cybozu.com/k/${store.appInfo?.appId}`" target="_blank" title="Kiontoneへ">
|
||||
<a :href="!store.appInfo?'':`${authStore.currentDomain.kintoneUrl}/k/${store.appInfo?.appId}`" target="_blank" title="Kiontoneへ">
|
||||
{{ store.appInfo?.name }}
|
||||
</a>
|
||||
</div>
|
||||
@@ -33,6 +33,7 @@ import {AppInfo} from '../../types/ActionTypes'
|
||||
import ShowDialog from '../../components/ShowDialog.vue';
|
||||
import AppSelect from '../../components/AppSelect.vue';
|
||||
import { useFlowEditorStore } from 'stores/flowEditor';
|
||||
import { useAuthStore } from 'src/stores/useAuthStore';
|
||||
export default defineComponent({
|
||||
name: 'AppSelector',
|
||||
emits:[
|
||||
@@ -45,6 +46,7 @@ export default defineComponent({
|
||||
setup(props, context) {
|
||||
|
||||
const store = useFlowEditorStore();
|
||||
const authStore=useAuthStore();
|
||||
const appDg = ref();
|
||||
const showSelectApp=ref(false);
|
||||
|
||||
@@ -67,6 +69,7 @@ export default defineComponent({
|
||||
}
|
||||
return {
|
||||
store,
|
||||
authStore,
|
||||
showSelectApp,
|
||||
showAppDialog,
|
||||
closeDg,
|
||||
|
||||
@@ -2,13 +2,14 @@ import { api } from 'boot/axios';
|
||||
|
||||
export class Auth
|
||||
{
|
||||
|
||||
async login(user:string,pwd:string):Promise<boolean>
|
||||
{
|
||||
const params = new URLSearchParams();
|
||||
params.append('username', user);
|
||||
params.append('password', pwd);
|
||||
try{
|
||||
const result = await api.post(`http://127.0.0.1:8000/api/token`,params);
|
||||
const result = await api.post(`api/token`,params);
|
||||
console.info(result);
|
||||
localStorage.setItem('Token', result.data.access_token);
|
||||
return true;
|
||||
|
||||
@@ -8,7 +8,7 @@ export class FlowCtrl
|
||||
{
|
||||
const flows:ActionFlow[]=[];
|
||||
try{
|
||||
const result = await api.get(`http://127.0.0.1:8000/api/flows/${appId}`);
|
||||
const result = await api.get(`api/flows/${appId}`);
|
||||
//console.info(result.data);
|
||||
if(!result.data || !Array.isArray(result.data)){
|
||||
return [];
|
||||
@@ -26,7 +26,7 @@ export class FlowCtrl
|
||||
|
||||
async SaveFlow(jsonData:any):Promise<boolean>
|
||||
{
|
||||
const result = await api.post('http://127.0.0.1:8000/api/flow',jsonData);
|
||||
const result = await api.post('api/flow',jsonData);
|
||||
console.info(result.data)
|
||||
return true;
|
||||
}
|
||||
@@ -37,7 +37,7 @@ export class FlowCtrl
|
||||
*/
|
||||
async UpdateFlow(jsonData:any):Promise<boolean>
|
||||
{
|
||||
const result = await api.put('http://127.0.0.1:8000/api/flow/' + jsonData.flowid,jsonData);
|
||||
const result = await api.put('api/flow/' + jsonData.flowid,jsonData);
|
||||
console.info(result.data)
|
||||
return true;
|
||||
}
|
||||
@@ -48,7 +48,7 @@ export class FlowCtrl
|
||||
*/
|
||||
async depoly(appid:string):Promise<boolean>
|
||||
{
|
||||
const result = await api.post(`http://127.0.0.1:8000/api/v1/createjstokintone?app=${appid}`);
|
||||
const result = await api.post(`api/v1/createjstokintone?app=${appid}`);
|
||||
console.info(result.data);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@ const columns = [
|
||||
|
||||
const getDomain = () => {
|
||||
loading.value = true;
|
||||
api.get(`http://127.0.0.1:8000/api/domains/testtenant`).then(res => {
|
||||
api.get(`api/domains/testtenant`).then(res => {
|
||||
rows.length = 0;
|
||||
res.data.forEach((item) => {
|
||||
rows.push({ id:item.id,tenantid: item.tenantid,name: item.name, url: item.url, user: item.kintoneuser, password: item.kintonepwd });
|
||||
@@ -153,7 +153,7 @@ onMounted(() => {
|
||||
}
|
||||
|
||||
const deleteDomain = () => {
|
||||
api.delete(`http://127.0.0.1:8000/api/domain/`+ editId.value).then(() =>{
|
||||
api.delete(`api/domain/${editId.value}`).then(() =>{
|
||||
getDomain();
|
||||
})
|
||||
editId.value = 0;
|
||||
@@ -183,7 +183,7 @@ onMounted(() => {
|
||||
const onSubmit = () => {
|
||||
if(editId.value !== 0)
|
||||
{
|
||||
api.put(`http://127.0.0.1:8000/api/domain`,{
|
||||
api.put(`api/domain`,{
|
||||
'id': editId.value,
|
||||
'tenantid': tenantid.value,
|
||||
'name': name.value,
|
||||
@@ -198,7 +198,7 @@ onMounted(() => {
|
||||
}
|
||||
else
|
||||
{
|
||||
api.post(`http://127.0.0.1:8000/api/domain`,{
|
||||
api.post(`api/domain`,{
|
||||
'id': 0,
|
||||
'tenantid': tenantid.value,
|
||||
'name': name.value,
|
||||
|
||||
@@ -223,7 +223,7 @@ const newDomain = () => {
|
||||
|
||||
|
||||
const activeDomain = (id:number) => {
|
||||
api.put(`http://127.0.0.1:8000/api/activedomain/`+ id).then(() =>{
|
||||
api.put(`api/activedomain/`+ id).then(() =>{
|
||||
getDomain();
|
||||
})
|
||||
};
|
||||
@@ -234,7 +234,7 @@ const deleteConfirm = (row:object) => {
|
||||
};
|
||||
|
||||
const deleteDomain = () => {
|
||||
api.delete(`http://127.0.0.1:8000/api/domain/`+ editId.value+'/1').then(() =>{
|
||||
api.delete(`api/domain/`+ editId.value+'/1').then(() =>{
|
||||
getDomain();
|
||||
})
|
||||
editId.value = 0;
|
||||
@@ -248,16 +248,16 @@ const closeDg = (val:string) => {
|
||||
{
|
||||
dodmainids.push(domains[key].id);
|
||||
}
|
||||
api.post(`http://127.0.0.1:8000/api/domain`, dodmainids).then(() =>{getDomain();});
|
||||
api.post(`api/domain`, dodmainids).then(() =>{getDomain();});
|
||||
}
|
||||
|
||||
};
|
||||
const getDomain = () => {
|
||||
api.get(`http://127.0.0.1:8000/api/activedomain`).then(res => {
|
||||
api.get(`api/activedomain`).then(res => {
|
||||
activedomainid.value = res.data.id;
|
||||
authStore.changedomain(res.data.name);
|
||||
});
|
||||
api.get(`http://127.0.0.1:8000/api/domain`).then(res => {
|
||||
api.get(`api/domain`).then(res => {
|
||||
rows.length = 0;
|
||||
res.data.forEach((item) => {
|
||||
rows.push({ id:item.id,name: item.name, url: item.url, kintoneuser: item.kintoneuser, kintonepwd: item.kintonepwd});
|
||||
|
||||
@@ -28,7 +28,7 @@ export const useAuthStore = defineStore({
|
||||
params.append('username', username);
|
||||
params.append('password', password);
|
||||
try{
|
||||
const result = await api.post(`http://127.0.0.1:8000/api/token`,params);
|
||||
const result = await api.post(`api/token`,params);
|
||||
console.info(result);
|
||||
this.token =result.data.access_token;
|
||||
localStorage.setItem('token', result.data.access_token);
|
||||
@@ -44,7 +44,7 @@ export const useAuthStore = defineStore({
|
||||
}
|
||||
},
|
||||
async getCurrentDomain():Promise<IDomainInfo>{
|
||||
const activedomain = await api.get(`http://127.0.0.1:8000/api/activedomain`);
|
||||
const activedomain = await api.get(`api/activedomain`);
|
||||
return {
|
||||
id:activedomain.data.id,
|
||||
domainName:activedomain.data.name,
|
||||
@@ -52,7 +52,7 @@ export const useAuthStore = defineStore({
|
||||
}
|
||||
},
|
||||
async getUserDomains():Promise<IDomainInfo[]>{
|
||||
const resp = await api.get(`http://127.0.0.1:8000/api/domain`);
|
||||
const resp = await api.get(`api/domain`);
|
||||
const domains =resp.data as any[];
|
||||
return domains.map(data=>{
|
||||
return {
|
||||
@@ -72,7 +72,7 @@ export const useAuthStore = defineStore({
|
||||
if(domain.id===this.currentDomain.id){
|
||||
return;
|
||||
}
|
||||
await api.put(`http://127.0.0.1:8000/api/activedomain/${domain.id}`);
|
||||
await api.put(`api/activedomain/${domain.id}`);
|
||||
this.currentDomain=domain;
|
||||
localStorage.setItem('currentDomain',JSON.stringify(this.currentDomain));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user