Compare commits
4 Commits
dev
...
feature-ap
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a3375c4526 | ||
|
|
1028327a37 | ||
|
|
f5b5607297 | ||
| dd814993f1 |
@@ -1,4 +1,5 @@
|
||||
from fastapi import Query, Request,Depends, APIRouter, UploadFile,HTTPException,File
|
||||
from app.core.operation import log_operation
|
||||
from app.db import Base,engine
|
||||
from app.db.session import get_db
|
||||
from app.db.crud import *
|
||||
@@ -7,6 +8,9 @@ from typing import List, Optional
|
||||
from app.core.auth import get_current_active_user,get_current_user
|
||||
from app.core.apiexception import APIException
|
||||
|
||||
import httpx
|
||||
import app.core.config as config
|
||||
|
||||
platform_router = r = APIRouter()
|
||||
|
||||
|
||||
@@ -17,11 +21,40 @@ platform_router = r = APIRouter()
|
||||
)
|
||||
async def apps_list(
|
||||
request: Request,
|
||||
user = Depends(get_current_user),
|
||||
db=Depends(get_db),
|
||||
):
|
||||
try:
|
||||
app = get_apps(db)
|
||||
return app
|
||||
platformapps = get_apps(db)
|
||||
domain = get_activedomain(db, user.id)
|
||||
|
||||
kintoneevn = config.KINTONE_ENV(domain)
|
||||
headers={config.API_V1_AUTH_KEY:kintoneevn.API_V1_AUTH_VALUE}
|
||||
url = f"{kintoneevn.BASE_URL}{config.API_V1_STR}/apps.json"
|
||||
offset = 0
|
||||
limit = 100
|
||||
all_apps = []
|
||||
|
||||
while True:
|
||||
r = httpx.get(f"{url}?limit={limit}&offset={offset}", headers=headers)
|
||||
json_data = r.json()
|
||||
apps = json_data.get("apps",[])
|
||||
all_apps.extend(apps)
|
||||
if len(apps)<limit:
|
||||
break
|
||||
offset += limit
|
||||
|
||||
tempapps = platformapps.copy()
|
||||
for papp in tempapps:
|
||||
exist = False
|
||||
for kapp in all_apps:
|
||||
if kapp['appId'] == papp.appid:
|
||||
exist = True
|
||||
break
|
||||
if not exist:
|
||||
platformapps.remove(papp)
|
||||
|
||||
return platformapps
|
||||
except Exception as e:
|
||||
raise APIException('platform:apps',request.url._url,f"Error occurred while get apps:",e)
|
||||
|
||||
@@ -158,7 +191,7 @@ async def flow_list(
|
||||
try:
|
||||
domain = get_activedomain(db, user.id)
|
||||
print("domain=>",domain)
|
||||
flows = get_flows_by_app(db, domain.id, appid)
|
||||
flows = get_flows_by_app(db, domain.url, appid)
|
||||
return flows
|
||||
except Exception as e:
|
||||
raise APIException('platform:flow',request.url._url,f"Error occurred while get flow by appid:",e)
|
||||
@@ -173,7 +206,7 @@ async def flow_create(
|
||||
):
|
||||
try:
|
||||
domain = get_activedomain(db, user.id)
|
||||
return create_flow(db, domain.id, flow)
|
||||
return create_flow(db, domain.url, flow)
|
||||
except Exception as e:
|
||||
raise APIException('platform:flow',request.url._url,f"Error occurred while create flow:",e)
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import base64
|
||||
PROJECT_NAME = "KintoneAppBuilder"
|
||||
|
||||
#SQLALCHEMY_DATABASE_URI = "postgres://kabAdmin:P@ssw0rd!@kintonetooldb.postgres.database.azure.com/dev"
|
||||
SQLALCHEMY_DATABASE_URI = f"postgresql+psycopg2://kabAdmin:P%40ssw0rd!@kintonetooldb.postgres.database.azure.com/postgres"
|
||||
SQLALCHEMY_DATABASE_URI = f"postgresql+psycopg2://kabAdmin:P%40ssw0rd!@kintonetooldb.postgres.database.azure.com/dev_v2"
|
||||
#SQLALCHEMY_DATABASE_URI = "postgres://kabAdmin:P@ssw0rd!@kintonetooldb.postgres.database.azure.com/test"
|
||||
#SQLALCHEMY_DATABASE_URI = "postgres://kabAdmin:P@ssw0rd!@ktune-prod-db.postgres.database.azure.com/postgres"
|
||||
API_V1_STR = "/k/v1"
|
||||
|
||||
@@ -79,16 +79,33 @@ def update_appversion(db: Session, appedit: schemas.AppVersion,userid:int):
|
||||
if app:
|
||||
app.version = app.version + 1
|
||||
db_app = app
|
||||
appver = app.version
|
||||
else:
|
||||
appver = 1
|
||||
db_app = models.App(
|
||||
domainurl = appedit.domainurl,
|
||||
appid=appedit.appid,
|
||||
appname=appedit.appname,
|
||||
version = 1,
|
||||
updateuser= userid
|
||||
)
|
||||
|
||||
)
|
||||
|
||||
db.add(db_app)
|
||||
|
||||
flows = db.query(models.Flow).filter(and_(models.Flow.domainurl == appedit.domainurl,models.App.appid == appedit.appid))
|
||||
for flow in flows:
|
||||
db_flowhistory = models.FlowHistory(
|
||||
flowid = flow.flowid,
|
||||
appid = flow.appid,
|
||||
eventid = flow.eventid,
|
||||
domainurl = flow.domainurl,
|
||||
name = flow.name,
|
||||
content = flow.content,
|
||||
createuser = userid,
|
||||
version = appver
|
||||
)
|
||||
db.add(db_flowhistory)
|
||||
|
||||
db.commit()
|
||||
db.refresh(db_app)
|
||||
return db_app
|
||||
@@ -148,12 +165,12 @@ def get_actions(db: Session):
|
||||
return actions
|
||||
|
||||
|
||||
def create_flow(db: Session, domainid: int, flow: schemas.FlowBase):
|
||||
def create_flow(db: Session, domainurl: str, flow: schemas.FlowBase):
|
||||
db_flow = models.Flow(
|
||||
flowid=flow.flowid,
|
||||
appid=flow.appid,
|
||||
eventid=flow.eventid,
|
||||
domainid=domainid,
|
||||
domainurl=domainurl,
|
||||
name=flow.name,
|
||||
content=flow.content
|
||||
)
|
||||
@@ -200,8 +217,8 @@ def get_flow(db: Session, flowid: str):
|
||||
raise HTTPException(status_code=404, detail="Data not found")
|
||||
return flow
|
||||
|
||||
def get_flows_by_app(db: Session, domainid: int, appid: str):
|
||||
flows = db.query(models.Flow).filter(and_(models.Flow.domainid == domainid,models.Flow.appid == appid)).all()
|
||||
def get_flows_by_app(db: Session,domainurl: str, appid: str):
|
||||
flows = db.query(models.Flow).filter(and_(models.Flow.domainurl == domainurl,models.Flow.appid == appid)).all()
|
||||
if not flows:
|
||||
raise Exception("Data not found")
|
||||
return flows
|
||||
|
||||
@@ -62,10 +62,22 @@ class Flow(Base):
|
||||
flowid = Column(String(100), index=True, nullable=False)
|
||||
appid = Column(String(100), index=True, nullable=False)
|
||||
eventid = Column(String(100), index=True, nullable=False)
|
||||
domainid = Column(Integer,ForeignKey("domain.id"))
|
||||
domainurl = Column(String(200))
|
||||
name = Column(String(200))
|
||||
content = Column(String)
|
||||
|
||||
class FlowHistory(Base):
|
||||
__tablename__ = "flowhistory"
|
||||
|
||||
flowid = Column(String(100), index=True, nullable=False)
|
||||
appid = Column(String(100), index=True, nullable=False)
|
||||
eventid = Column(String(100), index=True, nullable=False)
|
||||
domainurl = Column(String(200))
|
||||
name = Column(String(200))
|
||||
content = Column(String)
|
||||
createuser = Column(Integer,ForeignKey("user.id"))
|
||||
version = Column(Integer)
|
||||
|
||||
class Tenant(Base):
|
||||
__tablename__ = "tenant"
|
||||
|
||||
@@ -119,6 +131,17 @@ class ErrorLog(Base):
|
||||
location = Column(String(500))
|
||||
content = Column(String(5000))
|
||||
|
||||
class OperationLog(Base):
|
||||
__tablename__ = "operationlog"
|
||||
|
||||
tenantid = Column(String(100))
|
||||
domainurl = Column(String(200))
|
||||
userid = Column(Integer,ForeignKey("user.id"))
|
||||
operation = Column(String(200))
|
||||
function = Column(String(200))
|
||||
detail = Column(String(200))
|
||||
user = relationship('User')
|
||||
|
||||
class KintoneFormat(Base):
|
||||
__tablename__ = "kintoneformat"
|
||||
|
||||
|
||||
@@ -118,7 +118,7 @@ class Flow(Base):
|
||||
flowid: str
|
||||
appid: str
|
||||
eventid: str
|
||||
domainid: int
|
||||
domainurl: str
|
||||
name: str = None
|
||||
content: str = None
|
||||
|
||||
|
||||
@@ -7,18 +7,14 @@
|
||||
<q-icon v-if="prop.node.eventId" name="play_circle" :color="prop.node.hasFlow ? 'green' : 'grey'" size="16px"
|
||||
class="q-mr-sm">
|
||||
</q-icon>
|
||||
<div class="no-wrap"
|
||||
:class="selectedEvent && prop.node.eventId === selectedEvent.eventId ? 'selected-node' : ''">{{prop.node.label }}
|
||||
</div>
|
||||
<div class="no-wrap" :class="getSelectedClass(prop.node)">{{ prop.node.label }}</div>
|
||||
<q-space></q-space>
|
||||
<!-- <q-icon v-if="prop.node.hasFlow" name="delete" color="negative" size="16px" class="q-mr-sm"></q-icon> -->
|
||||
</div>
|
||||
</template>
|
||||
<template v-slot:header-CHANGE="prop">
|
||||
<div class="row col items-start no-wrap event-node">
|
||||
<div class="no-wrap"
|
||||
:class="selectedEvent && prop.node.eventId === selectedEvent.eventId ? 'selected-node' : ''"
|
||||
>{{ prop.node.label }}</div>
|
||||
<div class="no-wrap" :class="getSelectedClass(prop.node)">{{ prop.node.label }}</div>
|
||||
<q-space></q-space>
|
||||
<q-icon name="add_circle" color="primary" size="16px" class="q-mr-sm"
|
||||
@click="addChangeEvent(prop.node)"></q-icon>
|
||||
@@ -27,7 +23,7 @@
|
||||
<template v-slot:header-DELETABLE="prop">
|
||||
<div class="row col items-start event-node" @click="onSelected(prop.node)">
|
||||
<q-icon v-if="prop.node.eventId" name="play_circle" :color="prop.node.hasFlow ? 'green' : 'grey'" size="16px" class="q-mr-sm" />
|
||||
<div class="no-wrap" :class="selectedEvent && prop.node.eventId === selectedEvent.eventId ? 'selected-node' : ''" >{{ prop.node.label}}</div>
|
||||
<div class="no-wrap" :class="getSelectedClass(prop.node)">{{ prop.node.label }}</div>
|
||||
<q-space></q-space>
|
||||
<q-icon name="delete_forever" color="negative" size="16px" @click="deleteEvent(prop.node)"></q-icon>
|
||||
</div>
|
||||
@@ -42,7 +38,7 @@
|
||||
import { QTree, useQuasar } from 'quasar';
|
||||
import { ActionFlow, RootAction } from 'src/types/ActionTypes';
|
||||
import { useFlowEditorStore } from 'stores/flowEditor';
|
||||
import { defineComponent, ref,watchEffect } from 'vue';
|
||||
import { defineComponent, ref, watchEffect } from 'vue';
|
||||
import { IKintoneEvent, IKintoneEventGroup, IKintoneEventNode, kintoneEvent } from '../../types/KintoneEvents';
|
||||
import FieldSelect from '../FieldSelect.vue';
|
||||
import ShowDialog from '../ShowDialog.vue';
|
||||
@@ -80,6 +76,11 @@ export default defineComponent({
|
||||
const isFieldChange = (node: IKintoneEventNode) => {
|
||||
return node.header == 'EVENT' && node.eventId.indexOf(".change.") > -1;
|
||||
}
|
||||
|
||||
const getSelectedClass = (node: IKintoneEventNode) => {
|
||||
return store.selectedEvent && node.eventId === store.selectedEvent.eventId ? 'selected-node' : '';
|
||||
};
|
||||
|
||||
//フィールド値変更イベント追加
|
||||
const closeDg = (val: string) => {
|
||||
if (val == 'OK') {
|
||||
@@ -132,7 +133,7 @@ export default defineComponent({
|
||||
const screen = store.eventTree.findEventById(node.parentId);
|
||||
|
||||
let flow = store.findFlowByEventId(node.eventId);
|
||||
let screenName = screen !== null ? screen.label : "";
|
||||
let screenName = screen !== null ? screen.label : '';
|
||||
let nodeLabel = node.label;
|
||||
// if(isFieldChange(node)){
|
||||
// screenName=nodeLabel;
|
||||
@@ -159,6 +160,7 @@ export default defineComponent({
|
||||
tree,
|
||||
showDialog,
|
||||
isFieldChange,
|
||||
getSelectedClass,
|
||||
onSelected,
|
||||
selectedEvent,
|
||||
addChangeEvent,
|
||||
|
||||
@@ -47,11 +47,18 @@ const essentialLinks: EssentialLinkProps[] = [
|
||||
link: '/',
|
||||
target: '_self'
|
||||
},
|
||||
// {
|
||||
// title: 'フローエディター',
|
||||
// caption: 'イベントを設定する',
|
||||
// icon: 'account_tree',
|
||||
// link: '/#/FlowChart',
|
||||
// target: '_self'
|
||||
// },
|
||||
{
|
||||
title: 'フローエディター',
|
||||
caption: 'イベントを設定する',
|
||||
icon: 'account_tree',
|
||||
link: '/#/FlowChart',
|
||||
title: 'アプリ管理',
|
||||
caption: 'アプリを管理する',
|
||||
icon: 'widgets',
|
||||
link: '/#/app',
|
||||
target: '_self'
|
||||
},
|
||||
// {
|
||||
|
||||
93
frontend/src/pages/AppManagement.vue
Normal file
93
frontend/src/pages/AppManagement.vue
Normal file
@@ -0,0 +1,93 @@
|
||||
<template>
|
||||
<div class="q-pa-md">
|
||||
<div class="q-gutter-sm row items-start">
|
||||
<q-breadcrumbs>
|
||||
<q-breadcrumbs-el icon="widgets" label="アプリ管理" />
|
||||
</q-breadcrumbs>
|
||||
</div>
|
||||
<q-table title="Treats" :rows="rows" :columns="columns" row-key="id" :filter="filter" :loading="loading" :pagination="pagination">
|
||||
|
||||
<template v-slot:top>
|
||||
<q-btn disabled color="primary" :disable="loading" label="新規" @click="addRow" />
|
||||
<q-space />
|
||||
<q-input borderless dense filled debounce="300" v-model="filter" placeholder="検索">
|
||||
<template v-slot:append>
|
||||
<q-icon name="search" />
|
||||
</template>
|
||||
</q-input>
|
||||
</template>
|
||||
|
||||
<template v-slot:body-cell-actions="p">
|
||||
<q-td :props="p">
|
||||
<q-btn-group flat>
|
||||
<q-btn flat color="primary" padding="xs" size="1em" icon="edit_note" @click="editFlow(p.row)" />
|
||||
<q-btn disabled flat color="primary" padding="xs" size="1em" icon="history" @click="showHistory(p.row)" />
|
||||
<q-btn disabled flat color="negative" padding="xs" size="1em" icon="delete_outline" @click="removeRow(p.row)" />
|
||||
</q-btn-group>
|
||||
</q-td>
|
||||
</template>
|
||||
|
||||
</q-table>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted, reactive } from 'vue';
|
||||
import { api } from 'boot/axios';
|
||||
import { useAuthStore } from 'stores/useAuthStore';
|
||||
import { useFlowEditorStore } from 'stores/flowEditor';
|
||||
import { router } from 'src/router';
|
||||
|
||||
const authStore = useAuthStore();
|
||||
|
||||
const columns = [
|
||||
{ name: 'id', label: 'アプリID', field: 'id', align: 'left', sortable: true },
|
||||
{ name: 'name', label: 'アプリ名', field: 'name', align: 'left', sortable: true },
|
||||
{ name: 'url', label: 'URL', field: 'url', align: 'left', sortable: true },
|
||||
{ name: 'user', label: 'ログイン名', field: 'user', align: 'left', },
|
||||
{ name: 'version', label: 'バージョン', field: 'version', align: 'left', },
|
||||
{ name: 'actions', label: '操作', field: 'actions' }
|
||||
];
|
||||
|
||||
const pagination = ref({ sortBy: 'id', descending: true, rowsPerPage: 20 });
|
||||
const loading = ref(false);
|
||||
const filter = ref('');
|
||||
const rows = ref([]);
|
||||
const store = useFlowEditorStore();
|
||||
|
||||
const tenantid = ref(authStore.currentDomain.id);
|
||||
|
||||
const getApps = async () => {
|
||||
loading.value = true;
|
||||
const result = await api.get('api/apps');
|
||||
rows.value = result.data.map((item) => {
|
||||
return { id: item.appid, name: item.appname, url: item.domainurl, user: item.user.email, version: item.version }
|
||||
});
|
||||
loading.value = false;
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
await getApps();
|
||||
})
|
||||
|
||||
const addRow = () => {
|
||||
return
|
||||
}
|
||||
|
||||
const removeRow = (row) => {
|
||||
return
|
||||
}
|
||||
|
||||
const showHistory = (row) => {
|
||||
return
|
||||
}
|
||||
|
||||
const editFlow = (row) => {
|
||||
store.setApp({
|
||||
appId: row.id,
|
||||
name: row.name
|
||||
});
|
||||
router.push('/FlowChart');
|
||||
};
|
||||
</script>
|
||||
@@ -290,20 +290,8 @@ const onSaveAllFlow= async ()=>{
|
||||
}
|
||||
|
||||
const fetchData = async () => {
|
||||
await store.loadFlow();
|
||||
drawerLeft.value = true;
|
||||
if (store.appInfo === undefined) return;
|
||||
const flowCtrl = new FlowCtrl();
|
||||
const actionFlows = await flowCtrl.getFlows(store.appInfo?.appId);
|
||||
if (actionFlows && actionFlows.length > 0) {
|
||||
store.setFlows(actionFlows);
|
||||
}
|
||||
if (actionFlows && actionFlows.length == 1) {
|
||||
store.selectFlow(actionFlows[0]);
|
||||
}
|
||||
const root = actionFlows[0].getRoot();
|
||||
if (root) {
|
||||
store.setActiveNode(root);
|
||||
}
|
||||
}
|
||||
|
||||
const onClearFilter=()=>{
|
||||
|
||||
@@ -27,6 +27,7 @@ const routes: RouteRecordRaw[] = [
|
||||
{ path: 'domain', component: () => import('pages/TenantDomain.vue') },
|
||||
{ path: 'userdomain', component: () => import('pages/UserDomain.vue')},
|
||||
{ path: 'user', component: () => import('pages/UserManagement.vue')},
|
||||
{ path: 'app', component: () => import('pages/AppManagement.vue')},
|
||||
{ path: 'condition', component: () => import('pages/conditionPage.vue') }
|
||||
],
|
||||
},
|
||||
|
||||
@@ -64,7 +64,9 @@ export const useFlowEditorStore = defineStore('flowEditor', {
|
||||
this.selectedFlow = flow;
|
||||
if(flow!==undefined){
|
||||
const eventId = flow.getRoot()?.name;
|
||||
this.selectedEvent=this.eventTree.findEventById(eventId) as IKintoneEvent;
|
||||
this.selectedEvent = this.eventTree.findEventById(eventId) as IKintoneEvent;
|
||||
} else {
|
||||
this.selectedEvent = undefined;
|
||||
}
|
||||
},
|
||||
setActiveNode(node: IActionNode) {
|
||||
@@ -86,8 +88,8 @@ export const useFlowEditorStore = defineStore('flowEditor', {
|
||||
//eventTreeにバンドする
|
||||
this.eventTree.bindFlows(actionFlows);
|
||||
if (actionFlows === undefined || actionFlows.length === 0) {
|
||||
this.flows = [];
|
||||
this.selectedFlow = undefined;
|
||||
this.setFlows([]);
|
||||
this.selectFlow(undefined);
|
||||
this.expandedScreen =[];
|
||||
return;
|
||||
}
|
||||
@@ -95,6 +97,11 @@ export const useFlowEditorStore = defineStore('flowEditor', {
|
||||
if (actionFlows && actionFlows.length > 0) {
|
||||
this.selectFlow(actionFlows[0]);
|
||||
}
|
||||
const root = actionFlows[0].getRoot();
|
||||
if (root) {
|
||||
this.setActiveNode(root);
|
||||
}
|
||||
|
||||
const expandEventIds = actionFlows.map((flow) => flow.getRoot()?.name);
|
||||
const expandScreens:string[]=[];
|
||||
expandEventIds.forEach((eventid)=>{
|
||||
|
||||
Reference in New Issue
Block a user