Skip to content

Commit

Permalink
addded some development helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
janCstoffregen committed Oct 31, 2018
1 parent 98da3f1 commit 91b52a0
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 25 deletions.
1 change: 0 additions & 1 deletion README.md
Expand Up @@ -65,7 +65,6 @@ Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.
- add routes in app.js
- create new service for mongodb in frontend, like mongodbAction.service.ts
- test route in backend with console.log (without backend operations at first, bc it's easier.)
- in frontend, replace service (example for action in dashboard)
- add mongoose Schema, instantiate it in backend/routes and assign req.body to mongoose object
- save data to the database (ref tutorial 53)
- check if it worked with mongo shell, again in 53
Expand Down
Expand Up @@ -52,14 +52,20 @@ export class PageSetLandingPageComponent implements OnInit {

ngOnInit() {
this.actionID = this.route.snapshot.queryParams.actionID;
this.checkIfPageSetExists( this.actionID );
console.log(this.actionID);
if ( this.actionID ) {
this.checkIfPageSetExists( this.actionID );
}

}

checkIfPageSetExists(actionID: number ) {
// next step: this service should send request to MongoDB instead of fake backend.
this.actionService.getById( actionID )
.subscribe(
data => {
this.action = data;
console.log(this.action);
if (this.action && this.action.hasPageSet ) {
console.log('Instantiate Page Set');
console.log(this.action);
Expand Down Expand Up @@ -87,35 +93,54 @@ export class PageSetLandingPageComponent implements OnInit {
console.log(error);
});
} else {
this.pageSet = {};
console.log('No page set for this action yet');
this.pageSet.hash = this.generateHashService.generateHash();
this.pageSet.title = 'Example pageSet';
this.pageSet.linkToImage = 'https://c8.alamy.com/' +
'comp/DX9AP3/' +
'open-book-vintage-accessories-old-letters-pages-photo-frames-glasses-DX9AP3.jpg';
this.pageSet.description = 'Dies als Beispiel für eine PageSet bei NIE-OS\n' +
' Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy\n' +
' eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.\n' +
' At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea\n' +
' takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet,\n' +
' consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et\n' +
' dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo\n' +
' dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem\n' +
' ipsum dolor sit amet.';
console.log(this.pageSet);
console.log(this.action);
console.log('Save page set and then add page set - hash to action and update action.');
this.createPageSetAndLinkToActionService.createOrUpdate(
this.pageSet,
this.action
);
this.initializeTemplatePageSet();
}
},
error => {
console.log(error);
this.pageSet = {};
console.log('No page set for this action yet');
this.pageSet.hash = this.generateHashService.generateHash();
this.pageSet.title = 'Action not found --> replace action service';
this.pageSet.linkToImage = 'https://c8.alamy.com/' +
'comp/DX9AP3/' +
'open-book-vintage-accessories-old-letters-pages-photo-frames-glasses-DX9AP3.jpg';
this.pageSet.description = 'Dies als Beispiel für eine PageSet bei NIE-OS\n' +
' Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy\n' +
' eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.\n' +
' At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea\n' +
' takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet,\n' +
' consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et\n' +
' dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo\n' +
' dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem\n' +
' ipsum dolor sit amet.';
});
}
initializeTemplatePageSet() {
this.pageSet = {};
console.log('No page set for this action yet');
this.pageSet.hash = this.generateHashService.generateHash();
this.pageSet.title = 'Example pageSet';
this.pageSet.linkToImage = 'https://c8.alamy.com/' +
'comp/DX9AP3/' +
'open-book-vintage-accessories-old-letters-pages-photo-frames-glasses-DX9AP3.jpg';
this.pageSet.description = 'Dies als Beispiel für eine PageSet bei NIE-OS\n' +
' Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy\n' +
' eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.\n' +
' At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea\n' +
' takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet,\n' +
' consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et\n' +
' dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo\n' +
' dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem\n' +
' ipsum dolor sit amet.';
console.log(this.pageSet);
console.log(this.action);
console.log('Save page set and then add page set - hash to action and update action.');
this.createPageSetAndLinkToActionService.createOrUpdate(
this.pageSet,
this.action
);
}

generateDescription() {
if ( this.pageSet && this.pageSet.description ) {
Expand Down

0 comments on commit 91b52a0

Please sign in to comment.