From ef8a46fec4ce8c82e5bf090bb47e57885c08dd1a Mon Sep 17 00:00:00 2001 From: Mario Romano Date: Thu, 14 Jul 2016 14:16:22 +0100 Subject: [PATCH 1/9] fast deploy on aws --- .../.ebextensions/deploy_npm.config | 18 +++++ demo-shell-ng2/app.js | 77 +++++++++++++++++++ demo-shell-ng2/package.json | 7 +- 3 files changed, 101 insertions(+), 1 deletion(-) create mode 100644 demo-shell-ng2/.ebextensions/deploy_npm.config create mode 100644 demo-shell-ng2/app.js diff --git a/demo-shell-ng2/.ebextensions/deploy_npm.config b/demo-shell-ng2/.ebextensions/deploy_npm.config new file mode 100644 index 0000000000..7abdb9c83f --- /dev/null +++ b/demo-shell-ng2/.ebextensions/deploy_npm.config @@ -0,0 +1,18 @@ +files: + "/opt/elasticbeanstalk/hooks/appdeploy/pre/50npm.sh" : + mode: "000775" + owner: root + group: root + content: | + #!/bin/bash + function error_exit + { + eventHelper.py --msg "$1" --severity ERROR + exit $2 + } + + export HOME=/home/ec2-user + echo "export home" + + sudo curl -sL https://rpm.nodesource.com/setup_6.x | sudo -E bash - + sudo yum install -y nodejs diff --git a/demo-shell-ng2/app.js b/demo-shell-ng2/app.js new file mode 100644 index 0000000000..db02f7ac17 --- /dev/null +++ b/demo-shell-ng2/app.js @@ -0,0 +1,77 @@ +var port = process.env.PORT || 3000, + http = require('http'), + fs = require('fs'), + url = require('url'), + mime = require('mime'), + html = fs.readFileSync('index.html'); + +var log = function(entry) { + fs.appendFileSync('/tmp/sample-app.log', new Date().toISOString() + ' - ' + entry + '\n'); +}; + +var server = http.createServer(function (req, res) { + + // Parse the request containing file name + var pathname = url.parse(req.url).pathname; + + // Print the name of the file for which request is made. + console.log("Request for " + pathname + " received."); + + if (req.method === 'POST') { + var body = ''; + + req.on('data', function(chunk) { + body += chunk; + }); + + req.on('end', function() { + if (req.url === '/') { + log('Received message: ' + body); + } else if (req.url = '/scheduled') { + log('Received task ' + req.headers['x-aws-sqsd-taskname'] + ' scheduled at ' + req.headers['x-aws-sqsd-scheduled-at']); + } + + res.writeHead(200, 'OK', {'Content-Type': 'text/plain'}); + res.end(); + }); + } else { + var filename = pathname.substr(1); + if(filename === ''){ + filename = 'index.html'; + } + // Read the requested file content from file system + fs.readFile(filename, function (err, data) { + if (err) { + console.log(err, filename); + // HTTP Status: 404 : NOT FOUND + // Content Type: text/plain + res.writeHead(404, {'Content-Type': 'text/html'}); + }else{ + //Page found + // HTTP Status: 200 : OK + // Content Type: text/plain + var type = mime.lookup(filename); + console.log('type',type); + if (!res.getHeader('content-type')) { + var charset = mime.charsets.lookup(type); + res.setHeader('Content-Type', type + (charset ? '; charset=' + charset : '')); + } + if(type.indexOf('image') > -1){ + var img = fs.readFileSync(pathname.substr(1)); + res.end(img, 'binary'); + }else{ + res.write(data.toString()); + } + // Write the content of the file to response body + } + // Send the response body + res.end(); + }); + } +}); + +// Listen on port 3000, IP defaults to 127.0.0.1 +server.listen(port); + +// Put a friendly message on the terminal +console.log('Server running at http://127.0.0.1:' + port + '/'); diff --git a/demo-shell-ng2/package.json b/demo-shell-ng2/package.json index b74ae133fe..b897f975c2 100644 --- a/demo-shell-ng2/package.json +++ b/demo-shell-ng2/package.json @@ -7,6 +7,7 @@ "postinstall": "typings install", "clean": "rimraf node_modules typings", "start": "npm run tslint && concurrently \"npm run tsc:w\" \"license-check\" \"npm run serve\" ", + "aws": "node app.js", "tsc": "tsc", "tsc:w": "tsc -w", "serve": "wsrv -o -s -l -p 3000 -x ./server/versions.js", @@ -66,15 +67,18 @@ "reflect-metadata": "0.1.3", "rxjs": "5.0.0-beta.6", "zone.js": "0.6.12", - "rimraf": "2.5.2", "material-design-icons": "2.2.3", "material-design-lite": "1.1.3", "ng2-translate": "2.2.0", "pdfjs-dist": "1.5.258", "flag-icon-css": "2.3.0", +<<<<<<< HEAD "alfresco-js-api": "0.2.1", +======= + "alfresco-js-api": "0.1.0", +>>>>>>> fast deploy on aws "ng2-alfresco-core": "0.2.0", "ng2-alfresco-datatable": "0.2.0", "ng2-alfresco-documentlist": "0.2.0", @@ -89,6 +93,7 @@ "devDependencies": { "concurrently": "2.0.0", "license-check": "1.1.5", + "mime": "^1.3.4", "tslint": "3.8.1", "typescript": "1.8.10", "typings": "1.0.4", From 8fae7d1c345359dfad1db951ec87fce8e9f72543 Mon Sep 17 00:00:00 2001 From: Mario Romano Date: Thu, 14 Jul 2016 20:50:38 +0100 Subject: [PATCH 2/9] redirect to index.html - single page --- demo-shell-ng2/app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/demo-shell-ng2/app.js b/demo-shell-ng2/app.js index db02f7ac17..87f3660c7a 100644 --- a/demo-shell-ng2/app.js +++ b/demo-shell-ng2/app.js @@ -36,7 +36,7 @@ var server = http.createServer(function (req, res) { }); } else { var filename = pathname.substr(1); - if(filename === ''){ + if(filename === '' || filename.indexOf('.') === -1){ filename = 'index.html'; } // Read the requested file content from file system From 520310735b74d0e420a7bef5905381fa62bc72d8 Mon Sep 17 00:00:00 2001 From: Mario Romano Date: Thu, 14 Jul 2016 20:51:10 +0100 Subject: [PATCH 3/9] set host url in the left menu bar --- demo-shell-ng2/app/app.component.html | 5 +++++ demo-shell-ng2/app/app.component.ts | 1 + 2 files changed, 6 insertions(+) diff --git a/demo-shell-ng2/app/app.component.html b/demo-shell-ng2/app/app.component.html index da422e7ec5..1bebaaa88c 100644 --- a/demo-shell-ng2/app/app.component.html +++ b/demo-shell-ng2/app/app.component.html @@ -61,6 +61,11 @@ + Configurations +
diff --git a/demo-shell-ng2/app/app.component.ts b/demo-shell-ng2/app/app.component.ts index 580ddaa81e..6c00463c70 100644 --- a/demo-shell-ng2/app/app.component.ts +++ b/demo-shell-ng2/app/app.component.ts @@ -61,6 +61,7 @@ declare var document: any; export class AppComponent { translate: AlfrescoTranslationService; searchTerm: string = ''; + hostecm: string = 'http://localhost:8080'; ecmHost: string = 'http://localhost:8080'; bpmHost: string = 'http://localhost:9999'; From 41faaabe7459fae45f0b1829372bf0c1d67b2018 Mon Sep 17 00:00:00 2001 From: Mario Romano Date: Tue, 26 Jul 2016 17:33:53 +0100 Subject: [PATCH 4/9] #354 update readme with button --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index 3d2a490a25..5b0ecbaa05 100644 --- a/README.md +++ b/README.md @@ -82,5 +82,13 @@ To generate your Alfresco Angular 2 application you can use the following Yeoman - [Yeoman Generator Angular 2 Alfresco application](https://github.com/Alfresco/generator-ng2-alfresco-app) +## Amazon AWS Elastic Beanstalk fast deploy +

+ AmazonWebservices Logo.svg +

+ +To deploy directly on your AWS instance our demo shell click the button below: + + From c544cdce7d24d85ca545e63bc2d252fcb5127c48 Mon Sep 17 00:00:00 2001 From: Mario Romano Date: Tue, 26 Jul 2016 17:39:54 +0100 Subject: [PATCH 5/9] #354 update readme aws logo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5b0ecbaa05..ffc3c33f66 100644 --- a/README.md +++ b/README.md @@ -85,7 +85,7 @@ To generate your Alfresco Angular 2 application you can use the following Yeoman ## Amazon AWS Elastic Beanstalk fast deploy

- AmazonWebservices Logo.svg + AmazonWebservices Logo.svg

To deploy directly on your AWS instance our demo shell click the button below: From ddcae60d8aaa94d67408d7b585bdb716536df75e Mon Sep 17 00:00:00 2001 From: Mario Romano Date: Tue, 26 Jul 2016 17:53:00 +0100 Subject: [PATCH 6/9] fix rebase --- demo-shell-ng2/package.json | 5 ----- 1 file changed, 5 deletions(-) diff --git a/demo-shell-ng2/package.json b/demo-shell-ng2/package.json index b897f975c2..9c1d2e0581 100644 --- a/demo-shell-ng2/package.json +++ b/demo-shell-ng2/package.json @@ -73,12 +73,7 @@ "ng2-translate": "2.2.0", "pdfjs-dist": "1.5.258", "flag-icon-css": "2.3.0", -<<<<<<< HEAD - "alfresco-js-api": "0.2.1", -======= - "alfresco-js-api": "0.1.0", ->>>>>>> fast deploy on aws "ng2-alfresco-core": "0.2.0", "ng2-alfresco-datatable": "0.2.0", "ng2-alfresco-documentlist": "0.2.0", From eb944b801ed9d1bad48ea62731e3db220efa238d Mon Sep 17 00:00:00 2001 From: Mario Romano Date: Thu, 28 Jul 2016 10:23:52 +0100 Subject: [PATCH 7/9] #354 fix serve icons --- demo-shell-ng2/app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/demo-shell-ng2/app.js b/demo-shell-ng2/app.js index 87f3660c7a..f897a59bcc 100644 --- a/demo-shell-ng2/app.js +++ b/demo-shell-ng2/app.js @@ -56,7 +56,7 @@ var server = http.createServer(function (req, res) { var charset = mime.charsets.lookup(type); res.setHeader('Content-Type', type + (charset ? '; charset=' + charset : '')); } - if(type.indexOf('image') > -1){ + if(type.indexOf('image') > -1 || type.indexOf('font') > -1){ var img = fs.readFileSync(pathname.substr(1)); res.end(img, 'binary'); }else{ From 469f793289c77acd99fc4a5cfc9e5741b3d015d2 Mon Sep 17 00:00:00 2001 From: Mario Romano Date: Tue, 2 Aug 2016 10:48:53 +0100 Subject: [PATCH 8/9] #354 change s3 app version --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ffc3c33f66..ea86bb2d88 100644 --- a/README.md +++ b/README.md @@ -90,5 +90,5 @@ To generate your Alfresco Angular 2 application you can use the following Yeoman To deploy directly on your AWS instance our demo shell click the button below: - + From 10adff15a93be46866ff58cc5cc6fd5d55b40898 Mon Sep 17 00:00:00 2001 From: Mario Romano Date: Tue, 2 Aug 2016 11:11:22 +0100 Subject: [PATCH 9/9] dix merge demo shell --- demo-shell-ng2/app/app.component.html | 5 ----- demo-shell-ng2/app/app.component.ts | 1 - 2 files changed, 6 deletions(-) diff --git a/demo-shell-ng2/app/app.component.html b/demo-shell-ng2/app/app.component.html index 1bebaaa88c..da422e7ec5 100644 --- a/demo-shell-ng2/app/app.component.html +++ b/demo-shell-ng2/app/app.component.html @@ -61,11 +61,6 @@ - Configurations -
diff --git a/demo-shell-ng2/app/app.component.ts b/demo-shell-ng2/app/app.component.ts index 6c00463c70..580ddaa81e 100644 --- a/demo-shell-ng2/app/app.component.ts +++ b/demo-shell-ng2/app/app.component.ts @@ -61,7 +61,6 @@ declare var document: any; export class AppComponent { translate: AlfrescoTranslationService; searchTerm: string = ''; - hostecm: string = 'http://localhost:8080'; ecmHost: string = 'http://localhost:8080'; bpmHost: string = 'http://localhost:9999';