1
0
mirror of https://github.com/sasjs/server.git synced 2026-01-03 21:10:05 +00:00

fix(appstream): app logo + improvements

This commit is contained in:
Saad Jutt
2022-03-22 03:55:51 +05:00
parent 98a00ec7ac
commit df6003df94
10 changed files with 70 additions and 22 deletions

View File

@@ -17,13 +17,20 @@ const style = `<style>
border-radius: 10px 10px 0 0;
text-align: center;
}
.app-container .app img{
width: 100%;
}
</style>`
const defaultAppLogo = '/sasjs-logo.svg'
const singleAppStreamHtml = (streamServiceName: string, logo?: string) =>
` <a class="app" href="${streamServiceName}">
<img src="${logo ?? defaultAppLogo}" />
const singleAppStreamHtml = (
streamServiceName: string,
appLoc: string,
logo?: string
) =>
` <a class="app" href="${streamServiceName}" title="${appLoc}">
<img src="${logo ? streamServiceName + '/' + logo : defaultAppLogo}" />
${streamServiceName}
</a>`
@@ -36,12 +43,11 @@ export const appStreamHtml = (appStreamConfig: AppStreamConfig) => `
<body>
<h1>App Stream</h1>
<div class="app-container">
${Object.entries(appStreamConfig).map(([streamServiceName, entry]) =>
singleAppStreamHtml(streamServiceName, entry.logo)
)}
<a class="app" href="#"><img src="/sasjs-logo.svg" />App Name here</a>
<a class="app" href="#"><img src="/sasjs-logo.svg" />App Name here</a>
<a class="app" href="#"><img src="/sasjs-logo.svg" />App Name here</a>
${Object.entries(appStreamConfig)
.map(([streamServiceName, entry]) =>
singleAppStreamHtml(streamServiceName, entry.appLoc, entry.streamLogo)
)
.join('')}
</div>
</body>
</html>`

View File

@@ -17,6 +17,7 @@ export const publishAppStream = async (
appLoc: string,
streamWebFolder: string,
streamServiceName?: string,
streamLogo?: string,
addEntryToFile: boolean = true
) => {
const driveFilesPath = getTmpFilesFolderPath()
@@ -37,8 +38,19 @@ export const publishAppStream = async (
? Object.keys(process.appStreamConfig).length
: 0
if (!streamServiceName || process.appStreamConfig[streamServiceName]) {
if (!streamServiceName) {
streamServiceName = `AppStreamName${appCount + 1}`
} else {
const alreadyDeployed = process.appStreamConfig[streamServiceName]
if (alreadyDeployed) {
if (alreadyDeployed.appLoc === appLoc) {
// redeploying to same streamServiceName
} else {
// trying to deploy to another existing streamServiceName
// assign new streamServiceName
streamServiceName = `${streamServiceName}-${appCount + 1}`
}
}
}
router.use(`/${streamServiceName}`, express.static(pathToDeployment))
@@ -47,7 +59,7 @@ export const publishAppStream = async (
streamServiceName,
appLoc,
streamWebFolder,
undefined,
streamLogo,
addEntryToFile
)
@@ -56,7 +68,9 @@ export const publishAppStream = async (
'Serving Stream App: ',
`http://localhost:${sasJsPort}/AppStream/${streamServiceName}`
)
return { streamServiceName }
}
return {}
}
export default router