This commit is contained in:
Christian Georgi
2022-03-23 20:30:02 +01:00
parent 7f9474244b
commit 1f8a78fe8a
11 changed files with 1872 additions and 45 deletions

View File

@@ -1 +0,0 @@
Hello World

View File

@@ -7,6 +7,9 @@
"name": "approuter",
"dependencies": {
"@sap/approuter": "^10"
},
"engines": {
"node": "^16"
}
},
"node_modules/@sap/approuter": {

View File

@@ -3,6 +3,9 @@
"dependencies": {
"@sap/approuter": "^10"
},
"engines": {
"node": "^16"
},
"scripts": {
"start": "node node_modules/@sap/approuter/approuter.js"
}

View File

@@ -9,7 +9,8 @@ const books = Vue.createApp ({
return {
list: [],
book: undefined,
order: { quantity:1, succeeded:'', failed:'' }
order: { quantity:1, succeeded:'', failed:'' },
user: {}
}
},
@@ -37,7 +38,7 @@ const books = Vue.createApp ({
book.stock = res.data.stock
books.order = { quantity, succeeded: `Successfully ordered ${quantity} item(s).` }
} catch (e) {
books.order = { quantity, failed: e.response.data.error.message }
books.order = { quantity, failed: e.response.data.error ? e.response.data.error.message : e.response.data }
}
}
@@ -46,3 +47,12 @@ const books = Vue.createApp ({
// initially fill list of books
books.fetch()
// show user info on request
document.addEventListener('keydown', async (event) => {
if (event.key === 'u') {
try {
books.user = (await axios.get('/user/User')).data
} catch (err) { }
}
})

View File

@@ -11,12 +11,19 @@
.rating-stars { color:teal }
.succeeded { color:teal }
.failed { color:red }
.user {text-align: end; color: grey;}
</style>
</head>
<body class="small-container", style="margin-top: 70px;">
<div id='app'>
<div v-if="user.ID && user.ID !== 'anonymous'" class="user">
<div>User: {{ user.ID }}</div>
<div>Locale: {{ user.locale }}</div>
<div>Tenant: {{ user.tenant }}</div>
</div>
<h1> Capire Books </h1>
<input type="text" placeholder="Search..." @input="search">

View File

@@ -1,19 +1,19 @@
{
"welcomeFile": "/app/index.html",
"authenticationMethod": "route",
"routes": [
{
"source": "^/app/(.*)$",
"cacheControl": "no-cache, no-store, must-revalidate",
"target": "$1",
"localDir": ".",
"authenticationType": "xsuaa"
"authenticationType": "xsuaa",
"cacheControl": "no-cache, no-store, must-revalidate"
},
{
"source": "^/api/(.*)$",
"source": "^/(.*)$",
"target": "$1",
"destination": "srv-api",
"authenticationType": "xsuaa",
"target": "$1"
"csrfProtection": false
}
]
}