Commit 1e6446c2 authored by Evren Kutar's avatar Evren Kutar

v0.0.3.1

parametric backendurl for development purpose
gruntfile improvements
parent e696a566
...@@ -65,7 +65,7 @@ module.exports = function (grunt) { ...@@ -65,7 +65,7 @@ module.exports = function (grunt) {
}, },
dev: { dev: {
src: ['app/components/**/*.html', 'app/shared/templates/**/*.html'], src: ['app/components/**/*.html', 'app/shared/templates/**/*.html'],
dest: 'tmp/templates.js' dest: 'app/tmp/templates.js'
} }
}, },
copy: { copy: {
...@@ -98,7 +98,7 @@ module.exports = function (grunt) { ...@@ -98,7 +98,7 @@ module.exports = function (grunt) {
//'app/components/**/*controller.js', //'app/components/**/*controller.js',
//'app/components/**/*service.js', //'app/components/**/*service.js',
"app/app.js", "dist/app.js",
"app/app_routes.js", "app/app_routes.js",
"app/zetalib/interceptors.js", "app/zetalib/interceptors.js",
"app/zetalib/general.js", "app/zetalib/general.js",
...@@ -196,7 +196,7 @@ module.exports = function (grunt) { ...@@ -196,7 +196,7 @@ module.exports = function (grunt) {
}, },
watch: { watch: {
dev: { dev: {
files: ['app/**/*.js', 'app/components/**/*.html', 'index.html'], files: ['app/**/*.js', 'app/components/**/*.html', 'index.html', 'Gruntfile.js', '!app/tmp/*.js', '!app/app.js'],
tasks: ['env:dev', 'preprocess:dev', 'html2js:dev'], tasks: ['env:dev', 'preprocess:dev', 'html2js:dev'],
options: { options: {
atBegin: false atBegin: false
...@@ -253,12 +253,16 @@ module.exports = function (grunt) { ...@@ -253,12 +253,16 @@ module.exports = function (grunt) {
}, },
preprocess: { preprocess: {
dev: { dev: {
src: 'index.html', files: {
dest: 'app/index.html' 'app/index.html': 'app/main.html',
'app/app.js': 'app/main.js',
}
}, },
prod: { prod: {
src: 'index.html', files: {
dest: 'dist/index.html', 'dist/index.html': 'app/main.html',
'dist/app.js': 'app/main.js',
},
options: { options: {
context: { context: {
name: '<%= pkg.name %>', name: '<%= pkg.name %>',
...@@ -269,8 +273,10 @@ module.exports = function (grunt) { ...@@ -269,8 +273,10 @@ module.exports = function (grunt) {
} }
}, },
prod_branch: { prod_branch: {
src: 'index.html', files: {
dest: 'dist/<%= grunt.branchname %>/index.html', 'dist/<%= grunt.branchname %>/index.html': 'app/main.html',
'dist/<%= grunt.branchname %>/app.js': 'app/main.js',
},
options: { options: {
context: { context: {
name: '<%= pkg.name %>', name: '<%= pkg.name %>',
...@@ -303,13 +309,13 @@ module.exports = function (grunt) { ...@@ -303,13 +309,13 @@ module.exports = function (grunt) {
grunt.registerTask('i18n', ['nggettext_extract', 'nggettext_compile']); grunt.registerTask('i18n', ['nggettext_extract', 'nggettext_compile']);
grunt.registerTask('default', [ grunt.registerTask('default', [
'bower', 'bower',
'env:prod',
'preprocess:prod',
'nggettext_compile', 'nggettext_compile',
'concat:js', 'concat:js',
'concat:css', 'concat:css',
'concat:components', 'concat:components',
'copy:prod', 'copy:prod',
'env:prod',
'preprocess:prod',
'html2js:prod', 'html2js:prod',
'uglify:dist' 'uglify:dist'
]); ]);
......
...@@ -24,15 +24,29 @@ var app = angular.module( ...@@ -24,15 +24,29 @@ var app = angular.module(
//'ulakbus.version', //'ulakbus.version',
'schemaForm', 'schemaForm',
'gettext', 'gettext',
'templates-prod' 'templates-dev',
]). ]).
/** /**
* RESTURL is the url of rest api to talk * RESTURL is the url of rest api to talk
* Based on the environment it changes from dev to prod * Based on the environment it changes from dev to prod
*/ */
constant("RESTURL", (function () { constant("RESTURL", (function () {
//return {url: "http://127.0.0.1:9001/"}; // todo: below backendurl definition is for development purpose and will be deleted
return {url: "http://api.ulakbus.net/"}; var backendurl = "http://api.ulakbus.net";
if (document.cookie.indexOf("backendurl") > -1){
var cookiearray = document.cookie.split(';');
angular.forEach(cookiearray, function(item){
if(item.indexOf("backendurl")){
backendurl = item.split('=')[1];
}
});
}
if (location.href.indexOf("backendurl") > -1){
var urlfromqstr = location.href.split('?')[1].split('=')[1];
backendurl = decodeURIComponent(urlfromqstr.replace(/\+/g, " "));
document.cookie = "backendurl="+backendurl;
}
return {url: backendurl};
})()). })()).
/** /**
* USER_ROLES and AUTH_EVENTS are constant for auth functions * USER_ROLES and AUTH_EVENTS are constant for auth functions
......
...@@ -7,30 +7,74 @@ ...@@ -7,30 +7,74 @@
'use strict'; 'use strict';
$script([ var app = angular.module(
"bower_components/angular/angular.js", 'ulakbus', [
"bower_components/oclazyload/dist/ocLazyLoad.js", 'ui.bootstrap',
"bower_components/angular-route/angular-route.js", 'angular-loading-bar',
"bower_components/angular-cookies/angular-cookies.js", 'ngRoute',
"bower_components/angular-resource/angular-resource.js", 'ngSanitize',
"bower_components/angular-sanitize/angular-sanitize.js", 'ngCookies',
"bower_components/tv4/tv4.js", 'general',
"bower_components/objectpath/lib/ObjectPath.js", 'formService',
"bower_components/angular-schema-form/dist/schema-form.js", 'ulakbus.dashboard',
"bower_components/angular-schema-form/dist/bootstrap-decorator.js", 'ulakbus.auth',
"bower_components/angular-schema-form-datepicker/bootstrap-datepicker.js", //'ulakbus.staff',
"app.js", //'ulakbus.student',
"app_routes.js", 'ulakbus.crud',
"zetalib/interceptors.js", //'ulakbus.version',
"zetalib/general.js", 'schemaForm',
"zetalib/forms/form_service.js", 'gettext',
"components/auth/auth_controller.js", // @if NODE_ENV='PRODUCTION'
"components/auth/auth_service.js", 'templates-prod',
"components/dashboard/dashboard.js", // @endif
"components/staff/staff_controller.js", // @if NODE_ENV='DEVELOPMENT'
"components/student/student_controller.js", 'templates-dev',
"components/dashboard/dashboard.js" // @endif
], function() { ]).
// when all is done, execute bootstrap angular application /**
angular.bootstrap(document, ['ulakbus']); * RESTURL is the url of rest api to talk
}); * Based on the environment it changes from dev to prod
\ No newline at end of file */
constant("RESTURL", (function () {
// todo: below backendurl definition is for development purpose and will be deleted
var backendurl = "http://api.ulakbus.net";
if (document.cookie.indexOf("backendurl") > -1){
var cookiearray = document.cookie.split(';');
angular.forEach(cookiearray, function(item){
if(item.indexOf("backendurl")){
backendurl = item.split('=')[1];
}
});
}
if (location.href.indexOf("backendurl") > -1){
var urlfromqstr = location.href.split('?')[1].split('=')[1];
backendurl = decodeURIComponent(urlfromqstr.replace(/\+/g, " "));
document.cookie = "backendurl="+backendurl;
}
return {url: backendurl};
})()).
/**
* USER_ROLES and AUTH_EVENTS are constant for auth functions
*/
constant("USER_ROLES", {
all: "*",
admin: "admin",
student: "student",
staff: "staff",
dean: "dean"
}).
constant('AUTH_EVENTS', {
loginSuccess: 'auth-login-success',
loginFailed: 'auth-login-failed',
logoutSuccess: 'auth-logout-success',
sessionTimeout: 'auth-session-timeout',
notAuthenticated: 'auth-not-authenticated',
notAuthorized: 'auth-not-authorized'
});
// test the code with strict di mode to see if it works when minified
//angular.bootstrap(document, ['ulakbus'], {
// strictDi: true
//});
...@@ -112,8 +112,6 @@ form_generator.factory('Generator', function ($http, $q, $log, $location, $modal ...@@ -112,8 +112,6 @@ form_generator.factory('Generator', function ($http, $q, $log, $location, $modal
url: scope.url url: scope.url
}; };
debugger;
scope[k.type][k.title].model = scope.model[v] != null ? scope.model[v] : {}; scope[k.type][k.title].model = scope.model[v] != null ? scope.model[v] : {};
angular.forEach(k.schema , function (item) { angular.forEach(k.schema , function (item) {
...@@ -141,8 +139,6 @@ form_generator.factory('Generator', function ($http, $q, $log, $location, $modal ...@@ -141,8 +139,6 @@ form_generator.factory('Generator', function ($http, $q, $log, $location, $modal
// lengthModels is length of the listnode models. if greater than 0 show records on template // lengthModels is length of the listnode models. if greater than 0 show records on template
scope[k.type][k.title]['lengthModels'] = scope.model[k.title] ? 1 : 0; scope[k.type][k.title]['lengthModels'] = scope.model[k.title] ? 1 : 0;
console.log(scope[k.type][k.title]['lengthModels']);
debugger;
} }
}); });
...@@ -200,7 +196,6 @@ form_generator.factory('Generator', function ($http, $q, $log, $location, $modal ...@@ -200,7 +196,6 @@ form_generator.factory('Generator', function ($http, $q, $log, $location, $modal
}; };
generator.submit = function ($scope) { generator.submit = function ($scope) {
// todo: diff for all submits to recognize form change. if no change returns to view with no submit // todo: diff for all submits to recognize form change. if no change returns to view with no submit
debugger;
var data = { var data = {
"form": $scope.model, "form": $scope.model,
"cmd": $scope.form_params.cmd, "cmd": $scope.form_params.cmd,
......
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment