Commit f5640829 authored by Evren Kutar's avatar Evren Kutar

resolves #31

parent fde1e977
......@@ -32,39 +32,45 @@ var app = angular.module(
* RESTURL is the url of rest api to talk
* Based on the environment it changes from dev to prod
*/
constant("RESTURL", (function () {
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){
if (document.cookie.indexOf("backendurl") > -1) {
var cookiearray = document.cookie.split(';');
angular.forEach(cookiearray, function(item){
if(item.indexOf("backendurl") > -1){
angular.forEach(cookiearray, function (item) {
if (item.indexOf("backendurl") > -1) {
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;
window.location.href = window.location.href.split('?')[0];
}
return {url: backendurl};
})()).
})()).
/**
* USER_ROLES and AUTH_EVENTS are constant for auth functions
*/
constant("USER_ROLES", {
constant("USER_ROLES", {
all: "*",
admin: "admin",
student: "student",
staff: "staff",
dean: "dean"
}).
constant('AUTH_EVENTS', {
}).
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
......
......@@ -37,39 +37,45 @@ var app = angular.module(
* RESTURL is the url of rest api to talk
* Based on the environment it changes from dev to prod
*/
constant("RESTURL", (function () {
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){
if (document.cookie.indexOf("backendurl") > -1) {
var cookiearray = document.cookie.split(';');
angular.forEach(cookiearray, function(item){
if(item.indexOf("backendurl") > -1){
angular.forEach(cookiearray, function (item) {
if (item.indexOf("backendurl") > -1) {
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;
window.location.href = window.location.href.split('?')[0];
}
return {url: backendurl};
})()).
})()).
/**
* USER_ROLES and AUTH_EVENTS are constant for auth functions
*/
constant("USER_ROLES", {
constant("USER_ROLES", {
all: "*",
admin: "admin",
student: "student",
staff: "staff",
dean: "dean"
}).
constant('AUTH_EVENTS', {
}).
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
......
......@@ -66,7 +66,14 @@ form_generator.factory('Generator', function ($http, $q, $timeout, RESTURL, Form
scope.form[scope.form.indexOf(k)] = {
type: v.type,
title: v.title,
onClick: function(){scope.model[v]=1;generator.submit(scope);}
onClick: function(){
if (v.cmd) {
scope.model["cmd"] = v.cmd;
} else {
scope.model[k]=1;
}
generator.submit(scope);
}
};
}
......
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