Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Single step closure implementation #33

Open
wants to merge 23 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
ce1c058
adding new route to generate xml.
RaviCompro Mar 16, 2017
2e9349d
adding generateXml api handling
Mar 16, 2017
4ffec95
Integrating XML generation code
punit01 Mar 17, 2017
d597864
updating code from js to es6.
RaviCompro Mar 17, 2017
167794e
Merge branch 'jstoes6' into SingleStepCoreEngine
RaviCompro Mar 17, 2017
f493174
updating code from js to es6.
RaviCompro Mar 17, 2017
e947f69
updating code to uplaod a resource file.
RaviCompro Mar 17, 2017
00378f2
Committing IOtranslator changes with class structure
Mar 18, 2017
c1d8b8b
updating code for uploading resources.
RaviCompro Mar 18, 2017
5aaa72e
Merge branch 'uploadfile' into SingleStepCoreEngine
RaviCompro Mar 18, 2017
9d5f31b
Adding support to save dynamically generated XML in resp folder.
punit01 Mar 18, 2017
aaf0bab
updating filepath to save a resource.
RaviCompro Mar 18, 2017
0a1b4a4
updating filestore path.
RaviCompro Mar 18, 2017
ec9efa7
adding a check for task id
RaviCompro Mar 20, 2017
2ae757c
updating as per review feedback.
RaviCompro Mar 20, 2017
0c52ca2
Adding the Skill factory to the branch.
Mar 21, 2017
178779d
Adding the skill specific file with closure implementation
Mar 21, 2017
b757f22
updating code for get ui config api call as per code review feedback.
RaviCompro Mar 21, 2017
849b608
Merge branch 'develop' into SingleStepClosureImplementation
tushar-compro Mar 21, 2017
2440689
Adding the implementation for the single object created.
Mar 21, 2017
c60af46
bringing branch parallel to Develop
Mar 23, 2017
01471ab
Bringing parallel to develop
Mar 23, 2017
1cefcbd
Bringing parallel to develop
Mar 23, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 4 additions & 42 deletions client/app/shared/dropzone/dropzone.component.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Component, ElementRef, ViewChild } from '@angular/core';
import { Component, OnInit, ElementRef, ViewChild } from '@angular/core';
import { BaseComponent } from '../base.component';
import { itemSchema } from '../UIConfig.model';
import { SkillManagerService } from '../../step-builder/step-input-area/skill-manager.service';

declare var Dropzone: any;
Dropzone.autoDiscover = false;
Expand All @@ -10,56 +9,19 @@ Dropzone.autoDiscover = false;
templateUrl: './dropzone.component.html',
styleUrls: ['./dropzone.component.scss']
})
export class DropzoneComponent extends BaseComponent {
export class DropzoneComponent extends BaseComponent implements OnInit {
@ViewChild('dropzone') dropzoneContainer;
labelConfig: itemSchema = new itemSchema();
width: string;
height: string;
constructor(private elementRef: ElementRef, private skillManager: SkillManagerService) {
constructor(private elementRef: ElementRef){
super();
}
ngOnInit() {
super.ngOnInit();
var self = this;
this.labelConfig.rendererProperties.text = this.compConfig.label;
this.labelConfig.rendererProperties.type = 'ElementHeading';
if (this.compConfig.dim !== undefined) {
this.height = `${this.compConfig.dim['height']}`;
this.width = `${this.compConfig.dim['width']}`;
} else {
this.height = `200px`;
this.width = `100%`;
}
let dropzone = new Dropzone(this.dropzoneContainer.nativeElement, {
url: "/api/file",
init: function () {
self.dropzoneInitializer(this);
}
dictDefaultMessage: this.compConfig.rendererProperties.placeHolder
});

}

dropzoneInitializer(dropzone) {
var self = this;
var reader = new FileReader();
dropzone.on("addedfile", function (file) { //To be Changed from 'addedfile' to 'success' when file starts getting stored on server;
//Read File when it is Dropped
reader.readAsText(file, 'UTF8');
});
reader.onload = function (e) {
//Update Dependencies when contents have been read;
var droppedFile = JSON.parse(e.target['result']);
self.updateDependencies(droppedFile);
}
}

updateDependencies(droppedFile) {
var dependants = this.compConfig.dependants;
for (let i = 0; i < dependants.length; i++) {
let dependantModelReference = dependants[i]['modelReference'];
let dependantRule = dependants[i]['rule'];
this.skillManager[dependantRule](droppedFile, dependantModelReference);
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.row {
margin: 10px;
}
53 changes: 26 additions & 27 deletions client/app/step-builder/step-builder/step-builder.component.html
Original file line number Diff line number Diff line change
@@ -1,41 +1,40 @@
<nav class="navbar navbar-default" id="header">
<nav class="navbar navbar-default">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<div class="row">
<div class="col-md-10">
<div class="row">
<h4><strong>STEP 1</strong>&nbsp;Move the range G5:H6 to the range D5:E6</h4>
</div>
<div class="row">
<span class="tag tag-primary"><span>Task ID:&nbsp;</span> SKL16.XL.04.01.03.T1 </span>&nbsp;<span class="tag tagFontNormal tag-primary"><span >Skill:&nbsp;</span> Move Cell Contents</span> &nbsp; <span class="tag tag-primary"><span>Template:&nbsp;</span> Move Cell Range </span>
</div>
</div>
<div class="col-md-2">
<ul class="nav navbar-nav navbar-right">
<li><button class="btn btn-inverse pull-right" (click)="onClose()">Close</button></li>
</ul>
</div>
<h4><strong>STEP 1</strong>&nbsp;Move the range G5:H6 to the range D5:E6</h4>
</div>
<div class="row">
<span class="tag tagFontNormal tag-primary"><span>Task ID:&nbsp;</span> SKL16.XL.04.01.03.T1 </span>&nbsp;<span class="tag tagFontNormal tag-primary"><span >Skill:&nbsp;</span> Move Cell Contents</span> &nbsp; <span class="tag tagFontNormal tag-primary"><span>Template:&nbsp;</span> Move Cell Range </span>
</div>
</div>
</div>

<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse">
<ul class="nav navbar-nav navbar-right">
<li><button class="btn btn-inverse">Close</button></li>
</ul>
</div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
</nav>
<div class="body-container">
<div id="body">
<div class="row">
<div class="col-lg-12 col-md-12">
<app-step-input-area [stepConfig]="uiConfig" (viewChanged)="setSelectedView($event.viewNumber)" [selectedView]="selectedView"></app-step-input-area>
</div>
<div class="container">
<div class="row">
<div class="col-md-12">
<button (click)="fetchConfig()" class="btn btn-default btn-block">Fetch UI</button>
</div>
</div>
<div class="row">
<app-step-input-area [stepConfig]="uiConfig"></app-step-input-area>
</div>
</div>
<div id="footer">
<div class="row" id="footer">
<div class="col-md-12">
<button class="btn btn-inverse">Preview Step</button>
<button class="btn btn-inverse">Save</button>
<button class="btn btn-primary">Preview Step</button>
<button class="btn btn-primary">Save</button>
<div class="pull-right">
<button class="btn btn-inverse" (click)="setSelectedView(selectedView-1)" [disabled]="selectedView == 1">Previous</button>
<button class="btn btn-inverse" *ngIf="selectedView < uiConfig.views.length" (click)="setSelectedView(selectedView+1)">Next</button>
<button class="btn btn-inverse" *ngIf="selectedView == uiConfig.views.length">Finish</button>
<button class="btn btn-primary">Previous</button>
<button class="btn btn-primary">Next</button>
</div>
</div>
</div>
8 changes: 3 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
"@angular/platform-browser": "^2.3.1",
"@angular/platform-browser-dynamic": "^2.3.1",
"@angular/router": "^3.3.1",
"angular2-jwt": "^0.1.28",
"animate.css": "3.5.1",
"awesome-bootstrap-checkbox": "1.0.0-alpha.4",
"bcryptjs": "^2.3.0",
Expand All @@ -31,15 +30,13 @@
"bootstrap": "4.0.0-alpha.5",
"bootstrap-select": "1.11.2",
"core-js": "^2.4.1",
"dropzone": "^4.3.0",
"express": "^4.14.1",
"font-awesome": "4.7.0",
"glyphicons-halflings": "1.9.0",
"jquery": "^3.1.1",
"jquery-slimscroll": "^1.3.8",
"jsonwebtoken": "^7.3.0",
"jsonwebtoken": "^7.0.0",
"mongoose": "^4.8.4",
"mongoose-unique-validator": "^1.0.4",
"mongoose-unique-validator": "^1.0.2",
"ng2-bootstrap": "^1.3.3",
"pace": "git://github.com/HubSpot/pace.git#v0.7.7",
"passport": "^0.3.2",
Expand All @@ -50,6 +47,7 @@
"validator": "^5.2.0",
"webpack": "^2.2.1",
"widgster": "0.0.3",
"xmldom": "^0.1.27",
"zone.js": "^0.7.2"
},
"devDependencies": {
Expand Down
35 changes: 26 additions & 9 deletions server/config/config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
const path = require('path');
const serverRootPath = path.normalize(__dirname + '/..');
const env = process.env.NODE_ENV || 'development';
const fileStorePath = serverRootPath + '/fileStore/';
const xmlFolderPath = fileStorePath + 'XMLs/';
const env = process.env.NODE_ENV || 'local';


const config = {
local: {
Expand All @@ -9,17 +12,23 @@ const config = {
},
port: process.env.port || 3000,
db: {
url: 'mongodb://localhost:27017/testDB',
url: 'ds137360.mlab.com:37360/ss_testdb',
dbOptions: {
db: {
native_parser: true
},
server: {
poolsize: 10
}
},
user: 'task_builder',
pass: 'task_builder'
}
},
root: serverRootPath
root: serverRootPath,
fileStore: {
baseURL: fileStorePath,
xmlFolderPath: xmlFolderPath
}
},
development: {
app: {
Expand All @@ -39,27 +48,35 @@ const config = {
pass: 'task_builder'
}
},
root: serverRootPath
root: serverRootPath,
fileStore: {
baseURL: fileStorePath,
xmlFolderPath: xmlFolderPath
}
},
production: {
app: {
name: 'Single-Step'
},
port: process.env.port || 3000,
db: {
url: 'mongodb://localhost:27017/testDB',
url: 'ds113650.mlab.com:13650/sims-task-bullder',
dbOptions: {
db: {
native_parser: true
},
server: {
poolsize: 20
},
user: 'test',
pass: 'test'
user: 'task_builder',
pass: 'task_builder'
}
},
root: serverRootPath
root: serverRootPath,
fileStore: {
baseURL: fileStorePath,
xmlFolderPath: xmlFolderPath
}
}
};

Expand Down
5 changes: 3 additions & 2 deletions server/config/db.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,18 @@ try {
}
catch(error) {
console.log(error);
return;
}

const db = mongoose.connection;

db.on('connected', function () {
console.log('Mongoose default connection open');
console.log('Mongoose default connection established.');
});

// When the connection is disconnected
db.on('disconnected', function () {
console.log('Mongoose default connection disconnected');
console.log('Mongoose default connection ended.');
});

exports.db = db;
105 changes: 56 additions & 49 deletions server/controllers/db.controller.js
Original file line number Diff line number Diff line change
@@ -1,50 +1,57 @@
const skillConfigRepoModel = require('../models/skillConfigRepo.model').skill_config_repo;
const taskStepUIModel = require('../models/taskStepUI.model').taskStepUIModel;

module.exports.getUIConfigPath = function(templateId, callback) {
getFilePath(templateId, 'ui_config_path', callback);
};

module.exports.getSkillXMLPath = function(templateId, callback) {
getFilePath(templateId, 'skill_xml_path', callback);
};

module.exports.getIOMapPath = function(templateId, callback) {
getFilePath(templateId, 'io_map_path', callback);
};

module.exports.getSkillModelPath = function(templateId, callback) {
getFilePath(templateId, 'data_model_path', callback);
};

module.exports.getStepUIState = function(taskId, stepIndex, callback) {
let condition = {"task_id": taskId};
let jsonKey = "task_data.step_" + stepIndex;
let map = {"_id": false};
map[jsonKey] = true;

taskStepUIModel.getStepUI(condition, map, (error, data) => {
callback(data, error);
});
};

module.exports.saveStepUIState = function(taskId, stepIndex, stepUIData, callback) {
let updateCriteria = {"task_id": taskId};
let jsonKey = "task_data.step_" + stepIndex;
let updateData = { $set: {}};
updateData.$set[jsonKey] = stepUIData;
let options = { upsert: true };

taskStepUIModel.updateStepUIData(updateCriteria, updateData, options, (error, success) => {
callback(error, success);
});
};

function getFilePath(templateId, fileKey, callback) {
let filterCriteria = {"_id": false};
filterCriteria[fileKey] = true;

skillConfigRepoModel.getFilePath({"template_id": templateId}, filterCriteria, (error, data) => {
callback(data[0][fileKey], error);
});
}
const uiTaskStepModel = require('../models/uiTaskStep.model').uiTaskStepModel;

class DatabaseController {

getUIConfigPath(templateId, callback) {
DatabaseController.getFilePath(templateId, 'ui_config_path', callback);
}

getSkillXMLPath(templateId, callback) {
DatabaseController.getFilePath(templateId, 'skill_xml_path', callback);
}

getIOMapPath(templateId, callback) {
DatabaseController.getFilePath(templateId, 'io_map_path', callback);
}

getSkillModelPath(templateId, callback) {
DatabaseController.getFilePath(templateId, 'data_model_path', callback);
}

getStepUIState(taskId, stepIndex, callback) {
let condition = {"task_id": taskId};
let jsonKey = "task_data.step_" + stepIndex;
let map = {"_id": false};
map[jsonKey] = true;

uiTaskStepModel.getStepUI(condition, map, (error, data) => {
let stepId = "step_" + stepIndex;
let stepUIState = data[0]._doc.task_data[stepId];
callback(error, stepUIState);
});
}

saveStepUIState(taskId, stepIndex, stepUIData, callback) {
let updateCriteria = {"task_id": taskId};
let jsonKey = "task_data.step_" + stepIndex;
let updateData = { $set: {}};
updateData.$set[jsonKey] = stepUIData;
let options = { upsert: true };

uiTaskStepModel.updateStepUIData(updateCriteria, updateData, options, (error, success) => {
callback(error, success);
});
}

static getFilePath(templateId, fileKey, callback) {
let filterCriteria = {"_id": false};
filterCriteria[fileKey] = true;

skillConfigRepoModel.getFilePath({"template_id": templateId}, filterCriteria, (error, data) => {
callback(data[0][fileKey], error);
});
}
}

module.exports = new DatabaseController();
Loading