@simitgroup/simpleapp-generator 1.0.23 → 1.0.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +48 -0
- package/dist/createproject.js +1 -1
- package/dist/createproject.js.map +1 -1
- package/dist/framework.js +37 -25
- package/dist/framework.js.map +1 -1
- package/dist/generate.js +38 -16
- package/dist/generate.js.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/processors/jsonschemabuilder.js +9 -9
- package/dist/processors/jsonschemabuilder.js.map +1 -1
- package/package.json +1 -1
- package/src/framework.ts +50 -36
- package/src/generate.ts +37 -21
- package/src/index.ts +2 -1
- package/src/processors/jsonschemabuilder.ts +9 -9
- package/src/type.ts +1 -0
- package/templates/basic/apischema.eta +8 -4
- package/templates/basic/controller.eta +21 -5
- package/templates/basic/jsonschema.eta +2 -0
- package/templates/basic/model.eta +4 -7
- package/templates/basic/module.eta +2 -0
- package/templates/basic/pageindex.vue.eta +28 -15
- package/templates/basic/pageindexwithid.vue.eta +13 -1
- package/templates/basic/service.eta +11 -9
- package/templates/basic/simpleappclient.eta +9 -8
- package/templates/basic/type.eta +2 -1
- package/templates/nest/SimpleAppController.eta +5 -5
- package/templates/nest/SimpleAppService.eta +87 -31
- package/templates/nest/TenantMiddleware.eta +39 -0
- package/templates/nest/User.eta +115 -0
- package/templates/nest/app.module.eta +24 -4
- package/templates/nest/inputvalidation-exception.eta +6 -0
- package/templates/nest/nest.env.eta +12 -1
- package/templates/nest/nest.main.eta +14 -3
- package/templates/nest/oauth2-redirect.eta +79 -0
- package/templates/nuxt/components.crudsimple.vue.eta +60 -48
- package/templates/nuxt/components.debugdocdata.vue.eta +12 -4
- package/templates/nuxt/components.eventmonitor.vue.eta +17 -11
- package/templates/nuxt/components.menus.vue.eta +14 -12
- package/templates/nuxt/composables.getautocomplete.ts.eta +19 -8
- package/templates/nuxt/composables.getmenus.ts.eta +27 -9
- package/templates/nuxt/env.eta +12 -0
- package/templates/nuxt/layouts.default.vue.eta +10 -3
- package/templates/nuxt/nuxt.config.ts.eta +10 -6
- package/templates/nuxt/pages.[xorg].index.vue.eta +19 -0
- package/templates/nuxt/pages.index.vue.eta +17 -1
- package/templates/nuxt/pages.login.vue.eta +20 -0
- package/templates/nuxt/plugins.simpleapp.ts.eta +12 -4
- package/templates/nuxt/server.api.auth.logout.ts.eta +12 -0
- package/templates/nuxt/server.api.auth[...].ts.eta +144 -0
- package/templates/nuxt/server.api.ts.eta +33 -19
- package/src/createproject.ts +0 -121
- package/src/index2.ts-old +0 -132
- package/src/installdependency.sh +0 -5
- package/src/installnest.ts +0 -0
- package/src/installnuxt.ts +0 -0
- package/templates/basic/backend.config.eta +0 -1
- package/templates/basic/beforesave.eta +0 -7
- package/templates/basic/controller2.eta +0 -86
- package/templates/basic/frontend.config.eta +0 -1
- package/templates/basic/model-converter.etabackup +0 -21
- package/templates/basic/readme.eta +0 -3
- package/templates/basic/service.etabackupe +0 -106
- package/templates/basic/type.etabackup +0 -23
- package/templates/basic/uischema.eta +0 -13
|
@@ -1,32 +1,10 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="simpleapp-crudsimple">
|
|
3
|
-
<button class="bg-primary" type="reset" @click="newData">New</button>
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
<SimpleAppDatatable
|
|
7
|
-
@row-dblclick="editRecord"
|
|
8
|
-
v-model="recordlist"
|
|
9
|
-
:setting="{}"
|
|
10
|
-
:columns="listColumns"
|
|
11
|
-
></SimpleAppDatatable>
|
|
12
|
-
|
|
13
|
-
<DebugDocumentData v-model="data"/>
|
|
14
|
-
</div>
|
|
15
|
-
|
|
16
|
-
<Dialog v-model:visible="visible" modal header="Header" class="crudsimple-dialog" :autoZIndex="false" :style="{zIndex:100, width: '80vw' }">
|
|
17
|
-
<SimpleAppForm :document="obj" :title="title" #default="o">
|
|
18
|
-
<div class="simpleapp-tool-bar" >
|
|
19
|
-
<button class="bg-default" :disabled="disabled" @click="newData" type="reset">New</button>
|
|
20
|
-
<button class="bg-primary" :disabled="disabled" @click="saveData" type="submit">Save</button>
|
|
21
|
-
<button class="bg-danger" :disabled="disabled" @click="deleteData($event)">Delete</button>
|
|
22
|
-
<ProgressSpinner v-if="disabled==true" style="width: 2rem; height: 2rem" ></ProgressSpinner>
|
|
23
|
-
<ConfirmPopup></ConfirmPopup>
|
|
24
|
-
</div>
|
|
25
|
-
<slot :data="o.data" :getField="o.getField" name="default"></slot>
|
|
26
|
-
</SimpleAppForm>
|
|
27
|
-
</Dialog>
|
|
28
|
-
</template>
|
|
29
1
|
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* This file was automatically generated by simpleapp generator during initialization.
|
|
4
|
+
* DO NOT MODIFY IT BY HAND.
|
|
5
|
+
* last change 2023-09-09
|
|
6
|
+
* author: Ks Tan
|
|
7
|
+
*/
|
|
30
8
|
|
|
31
9
|
import { SimpleAppClient } from '@simitgroup//simpleapp-vue-component/src/SimpleAppClient';
|
|
32
10
|
import SimpleAppForm from '@simitgroup/simpleapp-vue-component/src/components/SimpleAppForm.vue';
|
|
@@ -34,7 +12,6 @@ import SimpleAppDatatable from '@simitgroup/simpleapp-vue-component/src/componen
|
|
|
34
12
|
import Dialog from 'primevue/dialog';
|
|
35
13
|
import axios from 'axios'
|
|
36
14
|
import ProgressSpinner from 'primevue/progressspinner';
|
|
37
|
-
|
|
38
15
|
import ConfirmPopup from 'primevue/confirmpopup';
|
|
39
16
|
import { useConfirm } from "primevue/useconfirm";
|
|
40
17
|
|
|
@@ -42,6 +19,7 @@ const confirm = useConfirm();
|
|
|
42
19
|
const props = defineProps<{
|
|
43
20
|
document:SimpleAppClient<any,any>
|
|
44
21
|
listColumns:string[]
|
|
22
|
+
path:string
|
|
45
23
|
title:string
|
|
46
24
|
}>()
|
|
47
25
|
const visible = ref(false)
|
|
@@ -49,14 +27,12 @@ const obj = props.document
|
|
|
49
27
|
const data = obj.getReactiveData()
|
|
50
28
|
const disabled=ref(false)
|
|
51
29
|
const recordlist = ref();
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}
|
|
59
|
-
|
|
30
|
+
const router = useRouter()
|
|
31
|
+
const route = useRoute()
|
|
32
|
+
const filters = ref()
|
|
33
|
+
defineShortcuts({
|
|
34
|
+
'ctrl_i': () => newData()
|
|
35
|
+
})
|
|
60
36
|
const refresh = () => {
|
|
61
37
|
obj.list().then((res:any) => {
|
|
62
38
|
recordlist.value = res;
|
|
@@ -64,23 +40,26 @@ const refresh = () => {
|
|
|
64
40
|
});
|
|
65
41
|
};
|
|
66
42
|
const newData = () => {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
43
|
+
router.push({ path: `${props.path}` })
|
|
44
|
+
obj.setNew()
|
|
45
|
+
visible.value=true;
|
|
70
46
|
};
|
|
71
47
|
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
|
|
48
|
+
const triggerEdit = (event: any) => {
|
|
49
|
+
let id = event.data._id.toString()
|
|
50
|
+
router.push({ path: `${props.path}/${id}` })
|
|
51
|
+
};
|
|
52
|
+
const editRecord = (id:string) => {
|
|
53
|
+
obj.getById(id);
|
|
75
54
|
visible.value=true
|
|
76
55
|
};
|
|
77
56
|
|
|
78
57
|
const saveData = () => {
|
|
79
58
|
disabled.value=true
|
|
80
59
|
if (data.value._id == "") {
|
|
81
|
-
obj.create().then(()=>{visible.value=false}).
|
|
60
|
+
obj.create().then(()=>{visible.value=false}).finally(() => refresh());
|
|
82
61
|
} else {
|
|
83
|
-
obj.update().then(()=>visible.value=false).
|
|
62
|
+
obj.update().then(()=>visible.value=false).finally(() => refresh());
|
|
84
63
|
}
|
|
85
64
|
};
|
|
86
65
|
const deleteData = (event:Event) => {
|
|
@@ -97,14 +76,47 @@ const deleteData = (event:Event) => {
|
|
|
97
76
|
});
|
|
98
77
|
},
|
|
99
78
|
reject: () => {
|
|
100
|
-
setCsrf()
|
|
101
79
|
console.log("Cancel delete")
|
|
102
80
|
}
|
|
103
|
-
})
|
|
104
|
-
|
|
81
|
+
})
|
|
105
82
|
};
|
|
83
|
+
|
|
84
|
+
if (route.params.id) {
|
|
85
|
+
const recordid:string = route.params.id.toString()
|
|
86
|
+
editRecord(recordid)
|
|
87
|
+
}
|
|
88
|
+
|
|
106
89
|
refresh();
|
|
107
90
|
</script>
|
|
91
|
+
|
|
92
|
+
<template>
|
|
93
|
+
<div class="simpleapp-crudsimple">
|
|
94
|
+
<button class="bg-primary" @click="newData" v-tooltip="'Add new(ctrl+i)'" >New</button>
|
|
95
|
+
<SimpleAppDatatable
|
|
96
|
+
@row-dblclick="triggerEdit"
|
|
97
|
+
v-model="recordlist"
|
|
98
|
+
:setting="{}"
|
|
99
|
+
:columns="listColumns"
|
|
100
|
+
>
|
|
101
|
+
</SimpleAppDatatable>
|
|
102
|
+
|
|
103
|
+
<DebugDocumentData v-model="data"/>
|
|
104
|
+
</div>
|
|
105
|
+
|
|
106
|
+
<Dialog v-model:visible="visible" modal header="Header" class="crudsimple-dialog" :autoZIndex="false" :style="{zIndex:100, width: '80vw' }">
|
|
107
|
+
<SimpleAppForm :document="obj" :title="title" #default="o">
|
|
108
|
+
<div class="simpleapp-tool-bar" >
|
|
109
|
+
<button class="bg-default" :disabled="disabled" @click="newData" type="button">New</button>
|
|
110
|
+
<button class="bg-primary" :disabled="disabled" @click="saveData" type="submit">Save</button>
|
|
111
|
+
<button class="bg-danger" :disabled="disabled" @click="deleteData($event)" type="button">Delete</button>
|
|
112
|
+
<ProgressSpinner v-if="disabled==true" style="width: 2rem; height: 2rem" ></ProgressSpinner>
|
|
113
|
+
<ConfirmPopup></ConfirmPopup>
|
|
114
|
+
</div>
|
|
115
|
+
<slot :data="o.data" :getField="o.getField" name="default"></slot>
|
|
116
|
+
</SimpleAppForm>
|
|
117
|
+
</Dialog>
|
|
118
|
+
</template>
|
|
119
|
+
|
|
108
120
|
<style scoped>
|
|
109
121
|
.crudsimple-dialog{
|
|
110
122
|
z-index: 100;
|
|
@@ -1,14 +1,22 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* This file was automatically generated by simpleapp generator during initialization.
|
|
4
|
+
* DO NOT MODIFY IT BY HAND.
|
|
5
|
+
* last change 2023-09-09
|
|
6
|
+
* author: Ks Tan
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
const modelValue = defineModel()
|
|
10
|
+
const isdebug = ref(useRuntimeConfig().public.DEBUGDATA)
|
|
11
|
+
</script>
|
|
1
12
|
<template>
|
|
2
|
-
<div class="floatright">
|
|
13
|
+
<div class="floatright" v-if="isdebug=='1'">
|
|
3
14
|
<h3>data in json</h3>
|
|
4
15
|
<pre>
|
|
5
16
|
{{ modelValue }}
|
|
6
17
|
</pre>
|
|
7
18
|
</div>
|
|
8
19
|
</template>
|
|
9
|
-
<script setup lang="ts">
|
|
10
|
-
const modelValue = defineModel()
|
|
11
|
-
</script>
|
|
12
20
|
<style scoped>
|
|
13
21
|
.floatright{
|
|
14
22
|
position: fixed;
|
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<Toast group="default"/>
|
|
3
|
-
<Toast group="list">
|
|
4
|
-
<template #message="p">
|
|
5
|
-
<ol>
|
|
6
|
-
<li v-for="(item,index) in p.message.detail" :key="index">{{item.instancePath}} {{ item.message }}</li>
|
|
7
|
-
</ol>
|
|
8
|
-
</template>
|
|
9
|
-
</Toast>
|
|
10
|
-
</template>
|
|
11
1
|
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* This file was automatically generated by simpleapp generator during initialization.
|
|
4
|
+
* DO NOT MODIFY IT BY HAND.
|
|
5
|
+
* last change 2023-09-09
|
|
6
|
+
* author: Ks Tan
|
|
7
|
+
*/
|
|
12
8
|
|
|
13
9
|
import { useToast, } from 'primevue/usetoast';
|
|
14
10
|
import type { ToastMessageOptions } from 'primevue/toast';
|
|
@@ -76,4 +72,14 @@ const prepareMsg=(data:any,msgtype:string):string=>{
|
|
|
76
72
|
|
|
77
73
|
}
|
|
78
74
|
|
|
79
|
-
</script>
|
|
75
|
+
</script>
|
|
76
|
+
<template>
|
|
77
|
+
<Toast group="default"/>
|
|
78
|
+
<Toast group="list">
|
|
79
|
+
<template #message="p">
|
|
80
|
+
<ol>
|
|
81
|
+
<li v-for="(item,index) in p.message.detail" :key="index">{{item.instancePath}} {{ item.message }}</li>
|
|
82
|
+
</ol>
|
|
83
|
+
</template>
|
|
84
|
+
</Toast>
|
|
85
|
+
</template>
|
|
@@ -1,18 +1,20 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* This file was automatically generated by simpleapp generator during initialization.
|
|
4
|
+
* You may modify it by hand
|
|
5
|
+
* last change 2023-09-10
|
|
6
|
+
* author: Ks Tan
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
// import MegaMenu from 'primevue/megamenu';
|
|
10
|
+
import Menubar from 'primevue/menubar';
|
|
11
|
+
const route = useRoute()
|
|
12
|
+
const menus = getMenus(route.params.xorg)
|
|
13
|
+
</script>
|
|
1
14
|
<template>
|
|
2
15
|
<header>
|
|
3
16
|
<!-- <MegaMenu :model="getMenus()" orientation="horizontal" /> -->
|
|
4
|
-
<Menubar :model="
|
|
5
|
-
<template #start>
|
|
6
|
-
<h1>[Logo Container]</h1>
|
|
7
|
-
</template>
|
|
8
|
-
<template #end>
|
|
9
|
-
<InputText placeholder="Search" type="text" />
|
|
10
|
-
</template>
|
|
17
|
+
<Menubar :model="menus">
|
|
11
18
|
</Menubar>
|
|
12
19
|
</header>
|
|
13
20
|
</template>
|
|
14
|
-
<script setup lang="ts">
|
|
15
|
-
// import MegaMenu from 'primevue/megamenu';
|
|
16
|
-
import Menubar from 'primevue/menubar';
|
|
17
|
-
|
|
18
|
-
</script>
|
|
@@ -1,17 +1,28 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* This file was automatically generated by simpleapp generator during initialization.
|
|
3
|
+
* DO NOT MODIFY IT BY HAND.
|
|
4
|
+
* last change 2023-09-09
|
|
5
|
+
* author: Ks Tan
|
|
6
|
+
*/
|
|
7
|
+
|
|
2
8
|
import * as o from "../simpleapp/openapi";
|
|
3
|
-
|
|
9
|
+
import axios from 'axios'
|
|
4
10
|
const getAutoComplete = (apiname: string): any => {
|
|
11
|
+
const { csrf } = useCsrf()
|
|
12
|
+
axios.defaults.headers.common = {"CSRF-TOKEN": csrf};
|
|
13
|
+
const route = useRoute();
|
|
14
|
+
|
|
5
15
|
const config: o.Configuration = {
|
|
6
|
-
basePath: useRuntimeConfig().public.APP_URL
|
|
16
|
+
basePath: `${useRuntimeConfig().public.APP_URL}/api/${route.params.xorg}`,
|
|
7
17
|
isJsonMime: () => true,
|
|
8
18
|
};
|
|
9
19
|
const docsOpenapi: any = {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
20
|
+
'category' : new o.CATApi(config),
|
|
21
|
+
'leadtype' : new o.LEADTApi(config),
|
|
22
|
+
'level' : new o.LVLApi(config),
|
|
23
|
+
'product' : new o.PRDApi(config),
|
|
24
|
+
'studentgroup' : new o.STGApi(config),
|
|
25
|
+
};
|
|
15
26
|
if (!docsOpenapi[apiname]) {
|
|
16
27
|
console.error(
|
|
17
28
|
`api for '${apiname}' does not exists, most probably define wrong x-foreignkey`,
|
|
@@ -1,9 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
/**
|
|
2
|
+
* This file was automatically generated by simpleapp generator during initialization.
|
|
3
|
+
* DO NOT MODIFY IT BY HAND.
|
|
4
|
+
* last change 2023-09-10
|
|
5
|
+
* author: Ks Tan
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
export const getMenus =()=>{
|
|
9
|
+
|
|
10
|
+
const route = useRoute();
|
|
11
|
+
const xorg = route.params.xorg
|
|
12
|
+
let data =[];
|
|
13
|
+
if(xorg){
|
|
14
|
+
data =[
|
|
15
|
+
{label: 'Home',icon: 'pi pi-fw pi-home', url:'/'},
|
|
16
|
+
{label: 'Cruds',icon: 'pi pi-fw pi-pencil',items:[
|
|
17
|
+
<% for(let i=0;i<it.length; i++){ %>
|
|
18
|
+
<% let obj = it[i]%>
|
|
19
|
+
{label: '<%=obj.docname.toLowerCase()%>', to:`/${xorg}/<%=obj.docname.toLowerCase()%>`},
|
|
20
|
+
<%}%>
|
|
21
|
+
]},
|
|
22
|
+
]
|
|
23
|
+
}else{
|
|
24
|
+
data= [{label: 'Home',icon: 'pi pi-fw pi-home', url:'/'},]
|
|
25
|
+
}
|
|
26
|
+
return data
|
|
27
|
+
}
|
package/templates/nuxt/env.eta
CHANGED
|
@@ -3,3 +3,15 @@ PORT=<%=it.frontendPort%>
|
|
|
3
3
|
SIMPLEAPP_BACKEND_URL=http://localhost:<%=it.backendPort%>
|
|
4
4
|
|
|
5
5
|
APP_URL=http://localhost:<%=it.frontendPort%>
|
|
6
|
+
|
|
7
|
+
DEBUGDATA=1
|
|
8
|
+
|
|
9
|
+
OAUTH2_CONFIGURL=<%=it.keycloaksetting.OAUTH2_CONFIGURL%>
|
|
10
|
+
|
|
11
|
+
OAUTH2_CLIENTID=<%=it.keycloaksetting.OAUTH2_CLIENTID%>
|
|
12
|
+
|
|
13
|
+
OAUTH2_CLIENTSECRET=<%=it.keycloaksetting.OAUTH2_CLIENTSECRET%>
|
|
14
|
+
|
|
15
|
+
AUTH_SECRET_KEY=<%=it.keycloaksetting.AUTH_SECRET_KEY%>
|
|
16
|
+
|
|
17
|
+
AUTH_ORIGIN=http://localhost:<%=it.frontendPort%>
|
|
@@ -1,10 +1,17 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
/**
|
|
3
|
+
* This file was automatically generated by simpleapp generator during initialization.
|
|
4
|
+
* You may modify it
|
|
5
|
+
* last change 2023-09-09
|
|
6
|
+
* author: Ks Tan
|
|
7
|
+
*/
|
|
8
|
+
|
|
1
9
|
|
|
10
|
+
import Menus from '~/components/Menus.vue'
|
|
11
|
+
</script>
|
|
2
12
|
<template>
|
|
3
13
|
<div>
|
|
4
14
|
<Menus />
|
|
5
15
|
<slot></slot>
|
|
6
16
|
</div>
|
|
7
17
|
</template>
|
|
8
|
-
<script lang="ts" setup>
|
|
9
|
-
import Menus from '~/components/Menus.vue'
|
|
10
|
-
</script>
|
|
@@ -4,6 +4,7 @@ export default defineNuxtConfig({
|
|
|
4
4
|
public:{
|
|
5
5
|
SIMPLEAPP_BACKEND_URL: process.env.SIMPLEAPP_BACKEND_URL,
|
|
6
6
|
APP_URL: process.env.APP_URL,
|
|
7
|
+
DEBUGDATA: process.env.DEBUGDATA,
|
|
7
8
|
}
|
|
8
9
|
},
|
|
9
10
|
vite: {
|
|
@@ -18,17 +19,19 @@ tailwindcss: {
|
|
|
18
19
|
// Options
|
|
19
20
|
},
|
|
20
21
|
modules: [
|
|
21
|
-
|
|
22
|
-
"nuxt-security",
|
|
23
|
-
'@nuxtjs/tailwindcss',
|
|
22
|
+
'@sidebase/nuxt-auth',
|
|
23
|
+
"nuxt-security",
|
|
24
24
|
'@vueuse/nuxt',
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
'@nuxt/ui'
|
|
27
26
|
],
|
|
28
|
-
|
|
27
|
+
auth: {
|
|
28
|
+
globalAppMiddleware: true
|
|
29
|
+
},
|
|
29
30
|
security: {
|
|
30
31
|
csrf: true,
|
|
31
32
|
},
|
|
33
|
+
ssr: true,
|
|
34
|
+
|
|
32
35
|
css: [
|
|
33
36
|
"primevue/resources/themes/lara-light-blue/theme.css",
|
|
34
37
|
'primeicons/primeicons.css'
|
|
@@ -38,5 +41,6 @@ tailwindcss: {
|
|
|
38
41
|
transpile: ["primevue"]
|
|
39
42
|
},
|
|
40
43
|
|
|
44
|
+
|
|
41
45
|
|
|
42
46
|
})
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
/**
|
|
3
|
+
* This file was automatically generated by simpleapp generator during initialization.
|
|
4
|
+
* You may modify it for your need
|
|
5
|
+
* last change 2023-09-09
|
|
6
|
+
* author: Ks Tan
|
|
7
|
+
*/
|
|
8
|
+
</script>
|
|
9
|
+
<template>
|
|
10
|
+
<div>
|
|
11
|
+
<h1>index page</h1>
|
|
12
|
+
<ul>
|
|
13
|
+
<li><NuxtLink :external="true" to="/MS0xLTE" >MS0xLTE (1-1-1)</NuxtLink></li>
|
|
14
|
+
<li><NuxtLink :external="true" to="/Mi0yLTI" >Mi0yLTI (2-2-2)</NuxtLink></li>
|
|
15
|
+
</ul>
|
|
16
|
+
|
|
17
|
+
</div>
|
|
18
|
+
|
|
19
|
+
</template>
|
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
/**
|
|
3
|
+
* This file was automatically generated by simpleapp generator during initialization.
|
|
4
|
+
* You may modify it for your need
|
|
5
|
+
* last change 2023-09-09
|
|
6
|
+
* author: Ks Tan
|
|
7
|
+
*/
|
|
8
|
+
</script>
|
|
1
9
|
<template>
|
|
2
|
-
<div>
|
|
10
|
+
<div>
|
|
11
|
+
<h1>index page</h1>
|
|
12
|
+
<ul>
|
|
13
|
+
<li><NuxtLink :external="true" to="/MS0xLTE" >MS0xLTE (1-1-1)</NuxtLink></li>
|
|
14
|
+
<li><NuxtLink :external="true" to="/Mi0yLTI" >Mi0yLTI (2-2-2)</NuxtLink></li>
|
|
15
|
+
</ul>
|
|
16
|
+
|
|
17
|
+
</div>
|
|
18
|
+
|
|
3
19
|
</template>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<NuxtPage />
|
|
3
|
+
</template>
|
|
4
|
+
<script setup lang="ts">
|
|
5
|
+
definePageMeta({
|
|
6
|
+
name: 'Login',
|
|
7
|
+
auth: false,
|
|
8
|
+
})
|
|
9
|
+
|
|
10
|
+
// const route = useRoute();
|
|
11
|
+
const { signIn } = useAuth()
|
|
12
|
+
onMounted(async () => {
|
|
13
|
+
let callbackUrl = '/';
|
|
14
|
+
// if(route.params.redirect) {
|
|
15
|
+
// callbackUrl = <string>route.params.redirect;
|
|
16
|
+
// }
|
|
17
|
+
await signIn('keycloak', { callbackUrl: callbackUrl })
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
</script>
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file was automatically generated by simpleapp generator during initialization.
|
|
3
|
+
* DO NOT MODIFY IT BY HAND.
|
|
4
|
+
* last change 2023-09-09
|
|
5
|
+
* author: Ks Tan
|
|
6
|
+
*/
|
|
1
7
|
import { defineNuxtPlugin } from "#app";
|
|
2
8
|
import axios from 'axios'
|
|
3
9
|
import PrimeVue from "primevue/config";
|
|
@@ -27,15 +33,15 @@ import SimpleAppDatatable from '@simitgroup/simpleapp-vue-component/src/componen
|
|
|
27
33
|
import mitt from 'mitt'
|
|
28
34
|
import ToastService from 'primevue/toastservice';
|
|
29
35
|
import ConfirmationService from 'primevue/confirmationservice';
|
|
36
|
+
import Tooltip from 'primevue/tooltip';
|
|
30
37
|
//import Quill from 'quill'
|
|
31
38
|
const emitter = mitt()
|
|
32
39
|
|
|
33
40
|
|
|
34
41
|
|
|
35
42
|
export default defineNuxtPlugin((nuxtApp) => {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
43
|
+
const { csrf } = useCsrf()
|
|
44
|
+
axios.defaults.headers.common = {"CSRF-TOKEN": csrf};
|
|
39
45
|
nuxtApp.vueApp.use(PrimeVue, { ripple: true });
|
|
40
46
|
nuxtApp.vueApp
|
|
41
47
|
.component("SimpleAppAutocomplete",SimpleAppAutocomplete)
|
|
@@ -61,7 +67,9 @@ export default defineNuxtPlugin((nuxtApp) => {
|
|
|
61
67
|
.component("SimpleAppValue",SimpleAppValue)
|
|
62
68
|
.component("SimpleFieldContainer",SimpleFieldContainer)
|
|
63
69
|
//.component("Quill",Quill) // cause problem in ssr mode
|
|
64
|
-
.use(ToastService)
|
|
70
|
+
.use(ToastService)
|
|
71
|
+
.use(ConfirmationService)
|
|
72
|
+
.directive('tooltip', Tooltip)
|
|
65
73
|
;
|
|
66
74
|
return {
|
|
67
75
|
provide: {
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// give keycloak for
|
|
2
|
+
export default defineEventHandler(async (event) => {
|
|
3
|
+
const path = `${
|
|
4
|
+
process.env.OAUTH2_CONFIGURL
|
|
5
|
+
}/protocol/openid-connect/logout?redirect_uri=${encodeURIComponent(
|
|
6
|
+
process.env.AUTH_ORIGIN ?? ""
|
|
7
|
+
)}`;
|
|
8
|
+
|
|
9
|
+
return {
|
|
10
|
+
path: path
|
|
11
|
+
}
|
|
12
|
+
});
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file was automatically generated by simpleapp generator during initialization.
|
|
3
|
+
* DO NOT MODIFY IT BY HAND.
|
|
4
|
+
* last change 2023-09-09
|
|
5
|
+
* author: Ks Tan
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
import axios from 'axios';
|
|
10
|
+
import { getServerSession } from '#auth'
|
|
11
|
+
import type { Session } from 'next-auth';
|
|
12
|
+
|
|
13
|
+
export default defineEventHandler(async (event) => {
|
|
14
|
+
let session:any=null
|
|
15
|
+
// console.log('---------hihi---------')
|
|
16
|
+
|
|
17
|
+
try {
|
|
18
|
+
session = await getServerSession(event)
|
|
19
|
+
|
|
20
|
+
} catch (error) {
|
|
21
|
+
return sendRedirect(event, '/login', 401)
|
|
22
|
+
}
|
|
23
|
+
// console.log(session)
|
|
24
|
+
return new Promise<any>(async (resolve, reject) => {
|
|
25
|
+
if(!session) {
|
|
26
|
+
//if(!session || !session.accessToken) {
|
|
27
|
+
reject({ statusMessage: 'Unauthorized', statusCode: 401 });
|
|
28
|
+
throw createError({ statusMessage: 'Unauthorized', statusCode: 401 })
|
|
29
|
+
}
|
|
30
|
+
// console.log("------hihi------")
|
|
31
|
+
const seperateSymbol = '.';
|
|
32
|
+
// const seperateSymbol = '&';
|
|
33
|
+
const xOrg = event.context.params?.xorg ?? ''
|
|
34
|
+
const documentLink = event.context.params?._ ?? ''
|
|
35
|
+
// const platform = event.context.params?.platform ?? ''
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
// console.error("event.context???",event.context)
|
|
39
|
+
const accessToken = session?.accessToken;
|
|
40
|
+
|
|
41
|
+
// const allowPlatform = ['report-api', 'cloudapi'];
|
|
42
|
+
// if(!key || !platform || !allowPlatform.includes(platform) || !accessToken) {
|
|
43
|
+
// reject({ statusMessage: 'Unauthorized', statusCode: 401 });
|
|
44
|
+
// // throw createError({ statusMessage: 'Unauthorized', statusCode: 401 })
|
|
45
|
+
// }
|
|
46
|
+
|
|
47
|
+
// let tenantKey = '', organizationKey = '';
|
|
48
|
+
// let xOrg = '';
|
|
49
|
+
|
|
50
|
+
// if(key !== 'system') {
|
|
51
|
+
// [tenantKey, organizationKey] = key.split(seperateSymbol);
|
|
52
|
+
// xOrg = `${tenantKey}/${organizationKey}/`;
|
|
53
|
+
// }
|
|
54
|
+
|
|
55
|
+
// if(key === 'system' && platform == 'cloudapi') {
|
|
56
|
+
// // xOrg = 'MC0wLTA'
|
|
57
|
+
// }
|
|
58
|
+
|
|
59
|
+
let forwardData: any = {};
|
|
60
|
+
|
|
61
|
+
const req = event.node.req;
|
|
62
|
+
|
|
63
|
+
if(req.method == 'POST' || req.method == 'PUT') {
|
|
64
|
+
|
|
65
|
+
forwardData = await readBody(event);
|
|
66
|
+
} else {
|
|
67
|
+
forwardData = getQuery(event);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// if(typeof forwardData === "object" && "_branch" in forwardData) {
|
|
71
|
+
// xOrg = xOrg + forwardData._branch;
|
|
72
|
+
// delete forwardData._branch;
|
|
73
|
+
// }
|
|
74
|
+
|
|
75
|
+
const frontEndRes = event.node.res;
|
|
76
|
+
const url = process.env.SIMPLEAPP_BACKEND_URL + '/' + documentLink;
|
|
77
|
+
// console.warn('backend server-----',url,'xorg',xOrg,'documentLink',documentLink)
|
|
78
|
+
const axiosConfig: any = {
|
|
79
|
+
method: req.method,
|
|
80
|
+
url: url,
|
|
81
|
+
headers: {
|
|
82
|
+
Authorization: `Bearer ${accessToken}`,
|
|
83
|
+
'X-Org': xOrg,
|
|
84
|
+
},
|
|
85
|
+
data: forwardData,
|
|
86
|
+
params: forwardData,
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// if(key === 'system') {
|
|
90
|
+
// axiosConfig.headers["X-Global"] = true;
|
|
91
|
+
// delete axiosConfig.headers["X-Org"];
|
|
92
|
+
// }
|
|
93
|
+
|
|
94
|
+
// if(otherLink.includes('avatar')) {
|
|
95
|
+
// axiosConfig.responseType = 'arraybuffer';
|
|
96
|
+
// // axiosConfig.headers['Acceptable'] = 'text/html,image/avif,image/webp,image/apng';
|
|
97
|
+
// }
|
|
98
|
+
|
|
99
|
+
axios(axiosConfig).then((res) => {
|
|
100
|
+
if (res.headers['content-type'] === 'image/png') {
|
|
101
|
+
// Set the response headers for the image
|
|
102
|
+
frontEndRes.setHeader('Content-Type', 'image/png');
|
|
103
|
+
frontEndRes.setHeader('Content-Disposition', 'inline');
|
|
104
|
+
|
|
105
|
+
// Send the image data as the response body
|
|
106
|
+
frontEndRes.end(Buffer.from(res.data, 'binary'));
|
|
107
|
+
} else {
|
|
108
|
+
// For non-image responses, set the Content-Type header and send the response body
|
|
109
|
+
// setHeader(event, 'Content-type', <string>res.headers['Content-Type']);
|
|
110
|
+
|
|
111
|
+
frontEndRes.statusCode = res.status;
|
|
112
|
+
if(res.statusText) {
|
|
113
|
+
frontEndRes.statusMessage = res.statusText;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
resolve(res.data);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
}).catch((error) => {
|
|
120
|
+
// console.log("==============================================================")
|
|
121
|
+
// console.log('@@@@@@@@@@@@@ API error', error)
|
|
122
|
+
// console.log("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@")
|
|
123
|
+
// console.log('######### response', error.response)
|
|
124
|
+
// console.log('#####################################')
|
|
125
|
+
// console.log(axiosConfig);
|
|
126
|
+
// console.log('#####################################')
|
|
127
|
+
|
|
128
|
+
if (error.response?.status && error.response.status == '401') {
|
|
129
|
+
return reject({ statusMessage: 'Unauthorized', statusCode: 401 });
|
|
130
|
+
// throw createError({ statusMessage: 'Unauthorized', statusCode: 401 })
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// reject(error.data)
|
|
134
|
+
reject({ statusMessage: error.response.statusText, statusCode: error.response.status });
|
|
135
|
+
// resolve({ status: 'ok' })
|
|
136
|
+
// throw createError({ statusMessage: 'Bad Requests', statusCode: 404 })
|
|
137
|
+
})
|
|
138
|
+
|
|
139
|
+
// resolve({
|
|
140
|
+
// status: 'ok'
|
|
141
|
+
// })
|
|
142
|
+
})
|
|
143
|
+
|
|
144
|
+
})
|