Add custom JS files from local system in JHipster Angular 2 Application - jhipster

Can you guys suggest me how to add local js files in application
I have tried by adding the local JS file path in index.html like below
<script src="thirdpartyscripts/amcharts.js"></script>
Here **thirdpartyscripts** is my directory.
but getting the error like below.
Error

Copy this folder and file in your target/www folder. Or alternatively use webpack to do this for you in webpack.commons.js. Look at the last line I have added
new CopyWebpackPlugin([
{ from: './node_modules/core-js/client/shim.min.js', to: 'core-js-shim.min.js' },
{ from: './node_modules/swagger-ui/dist', to: 'swagger-ui/dist' },
{ from: './src/main/webapp/swagger-ui/', to: 'swagger-ui' },
{ from: './src/main/webapp/favicon.ico', to: 'favicon.ico' },
{ from: './src/main/webapp/manifest.webapp', to: 'manifest.webapp' },
// { from: './src/main/webapp/sw.js', to: 'sw.js' },
{ from: './src/main/webapp/robots.txt', to: 'robots.txt' },
{ from: './src/main/webapp/thirdparty/sth.js', to: 'thirdparty/sth.js' }
]),

Related

could not resolve Model using modelPaths in objectionjs and ts-jest

Getting this error when running ts-jest.
Error: Member.relationMappings.primaryAssignment: modelClass: could not resolve ./MemberAssignment using modelPaths
primaryAssignment: {
relation: Model.HasOneRelation,
modelClass: path.join(__dirname, 'MemberAssignment'),
join: {
from: 'members.primary_member_assignment_id',
to: 'member_assignments.id',
},
},
Works perfectly fine when using tsc

NextJs: Static export with dynamic routing

I am deploying my Next.js app on Azure and it will throw a 404 on page refresh if I navigate to the module pages e.g www.site.com/overview.
I have followed the guide for deploying on azure here - https://learn.microsoft.com/en-us/azure/static-web-apps/deploy-nextjs.
However it has some conflicting advice, it says to export it using next build && next export and to also dynamically map the routes to avoid the 404 error, however when I do that Next.js throws an error:
Error occurred prerendering page "/modules/emergency-closing". Read more: https://err.sh/next.js/prerender-error
Error:
Error: you provided query values for /modules/emergency-closing which is an auto-exported page. These can not be applied since the page can no longer be re-rendered on the server. To disable auto-export for this page add `getInitialProps`
What is the correct way to export the app and run it on Azure?
next.config.js
const modules = require('./data/modules')
module.exports = {
trailingSlash: true,
async exportPathMap() {
const paths = {
'/': { page: '/' },
}
//
Object.keys(modules).map((module) => {
paths[`/modules/${modules[module].slug}`] = {
page: '/modules/[moduleSlug]',
query: { moduleSlug: modules[module].slug },
}
})
return paths
},
}
modules.js
module.exports = {
overview: {
id: 6,
name: 'overview',
slug: 'overview',
},
'special-features': {
id: 1,
name: 'Special features',
slug: 'special-features',
},
diagnosis: {
id: 3,
name: 'Diagnosis',
slug: 'diagnosis',
},
'emergency-closing': {
id: 4,
name: 'Emergency closing',
slug: 'emergency-closing',
},
'side-window-settings': {
id: 5,
name: 'Side window settings',
slug: 'side-window-settings',
},
}
package.json
"build": "next build && next export",

How to send Email with FileAttachment from local disk

I am using node-ews for sending Email through MicroSoft Exchange using my corporate credendials.
But I cannot figure out how to attach .xlsx files to an email from local disk storage. It seems that there is no simple Path tag.
This is what i have
const ewsArgs = {
attributes: {
MessageDisposition: 'SendAndSaveCopy',
},
SavedItemFolderId: {
DistinguishedFolderId: {
attributes: {
Id: 'sentitems',
},
},
},
Items: {
Message: {
ItemClass: 'IPM.Note',
Subject: 'Subject',
Body: {
attributes: {
BodyType: 'Text',
},
$value: 'Bodytext',
},
ToRecipients: {
Mailbox: {
EmailAddress: 'email#email.ru',
},
},
IsRead: 'false',
Attachments: {
FileAttachment: [{
Name: 'filename.xlsx',
IsInline: false,
ContentType: 'text/xlsx',
ContentLocation: 'filename.xlsx',
}]
}
},
},
};
What am I doing wrong?
Check your contentLocation. You need to give the correct path of the file you want to attach. But you just provided the filename.
Content-Type: application/vnd.ms-excel

gatsby custom source plugin - need help to get all the data

I am working on my first custom source plugin for gatsby, but I am stuck now..
Its working so far that I get the data I need create node, but not for all the data.
the response i get from the api looks like this
{
"section1": {
"date": "...",
"moreinformartion": "...",
},
"section2": [
{
"sub1": {
"information": "..."
}
},
{
"sub2": {
"information": "..."
}
},
{
"sub2": {
"information": "..."
}
}
]
}
But with all the tutorials out there, I was "only" able to get a node for every sub in section2
result.data.roster.forEach(data => {
const node = {
...data,
id: createNodeId(`KILL-setup-${data.character.name}`),
internal: {
type: 'KILLSetup',
contentDigest: createContentDigest(data)
}
};
actions.createNode(node);
});
How can I get 1 node, with all the data inside?

How can I run grunt svgstore?

When I run "grunt svgstore" I get this:
No "svgstore" targets found. Warning: Task "svgstore" failed. Use --force to continue. Aborted due to warnings.
Why?
This is part of my gruntfile (I can't post more).
module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-svgstore');
grunt.initConfig({
svgstore: {
options: {
formatting : {
indent_size : 2
}
},
default: {
files: {
'images/svg/defs.svg': ['images/svg/*.svg'],
},
},
},
},
});
// Default task(s)
grunt.registerTask('default', ['sass_globbing', /*'sprite:icons_dev'*/, 'sass']);
grunt.registerTask('icon_sprite', ['sprite:icons_dev']);
//grunt.registerTask('stage_deploy', ['sass_globbing', 'sprite:flags_dev', 'sprite:icons_dev', 'sass']);
//grunt.registerTask('prod_deploy', ['sass_globbing', 'sprite:flags_prod', 'sprite:icons_prod', 'tinypng', 'sass']);
};
I had a similar problem. Not sure what is the solution but I have solved it after I took a look on sample Gruntfile.js. The only difference I can spot between mine and yours Gruntfile is that I call loadNpmTasks after initConfig.
Take a look here:
module.exports = function(grunt) {
grunt.initConfig({
svgstore: {
options: {
prefix : 'pfx-', // This will prefix each ID
svg: { // will add and overide the the default xmlns="http://www.w3.org/2000/svg" attribute to the resulting SVG
viewBox : '0 0 100 100',
xmlns: 'http://www.w3.org/2000/svg'
},
formatting : {
indent_size : 2
},
symbol : {},
includedemo: true,
cleanup: true,
cleanupdefs: true,
},
default : {
files: {
'export/pfx-icons.svg': ['svgs/*.svg'],
},
},
},
});
grunt.loadNpmTasks('grunt-svgstore');
grunt.registerTask('default', ['svgstore']);
};

Resources