Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
U
ulakbus-ui
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ulakbus
ulakbus-ui
Commits
3533ee66
Commit
3533ee66
authored
Jul 08, 2015
by
Evren Kutar
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'backend_implementation'
parents
6c8f81fb
79e6dfb7
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
84 additions
and
143 deletions
+84
-143
app.js
app/app.js
+1
-0
app_routes.js
app/app_routes.js
+11
-12
auth_controller.js
app/components/auth/auth_controller.js
+21
-80
dashboard.js
app/components/dashboard/dashboard.js
+0
-1
staff_controller.js
app/components/staff/staff_controller.js
+31
-40
form_service.js
app/zetalib/forms/form_service.js
+13
-7
interceptors.js
app/zetalib/interceptors.js
+7
-3
No files found.
app/app.js
View file @
3533ee66
...
@@ -97,6 +97,7 @@ var app = angular.module(
...
@@ -97,6 +97,7 @@ var app = angular.module(
$rootScope
.
loggedInUser
=
false
;
$rootScope
.
loggedInUser
=
false
;
console
.
log
(
$rootScope
.
loggedInUser
);
console
.
log
(
$rootScope
.
loggedInUser
);
$location
.
path
(
"/login"
);
$location
.
path
(
"/login"
);
$scope
.
$apply
();
});
});
});
});
}
}
...
...
app/app_routes.js
View file @
3533ee66
...
@@ -167,18 +167,17 @@ app.config(['$routeProvider', function ($routeProvider) {
...
@@ -167,18 +167,17 @@ app.config(['$routeProvider', function ($routeProvider) {
*
*
*/
*/
//$rootScope.loggedInUser ? $rootScope.loggedInUser : false;
$rootScope
.
loggedInUser
?
$rootScope
.
loggedInUser
:
false
;
//$rootScope.$on("$routeChangeStart", function (event, next, current) {
$rootScope
.
$on
(
"$routeChangeStart"
,
function
(
event
,
next
,
current
)
{
// if ($rootScope.loggedInUser == null) {
if
(
$rootScope
.
loggedInUser
==
null
)
{
// // no logged user, redirect to /login
// no logged user, redirect to /login
// console.log($rootScope.loggedInUser);
if
(
next
.
templateUrl
===
"login/login.html"
)
{
// if (next.templateUrl === "login/login.html") {
//
}
else
{
// } else {
$location
.
path
(
"/login"
);
// $location.path("/login");
}
// }
}
// }
});
//});
}).
config
([
'$httpProvider'
,
function
(
$httpProvider
)
{
}).
config
([
'$httpProvider'
,
function
(
$httpProvider
)
{
// to send cookies CORS
// to send cookies CORS
$httpProvider
.
defaults
.
withCredentials
=
true
;
$httpProvider
.
defaults
.
withCredentials
=
true
;
...
...
app/components/auth/auth_controller.js
View file @
3533ee66
...
@@ -7,94 +7,35 @@
...
@@ -7,94 +7,35 @@
'use strict'
;
'use strict'
;
// TODO: clean console log items
// TODO: password hash or not??
// TODO: who field can be removed??
// todo: use zetalib/forms/form_service functions for email validation
var
auth
=
angular
.
module
(
'zaerp.auth'
,
[
'ngRoute'
,
'schemaForm'
,
'ngCookies'
,
'general'
]);
var
auth
=
angular
.
module
(
'zaerp.auth'
,
[
'ngRoute'
,
'schemaForm'
,
'ngCookies'
,
'general'
]);
auth
.
controller
(
'LoginCtrl'
,
function
(
$scope
,
$q
,
$timeout
,
$routeParams
,
Generator
,
LoginService
)
{
auth
.
controller
(
'LoginCtrl'
,
function
(
$scope
,
$
rootScope
,
$
q
,
$timeout
,
$routeParams
,
Generator
,
LoginService
)
{
$scope
.
url
=
'simple_login'
;
$scope
.
url
=
'simple_login'
;
var
form_params
=
{};
if
(
$rootScope
.
loginwfclear
){
form_params
[
'clear_wf'
]
=
1
;
}
else
{
$rootScope
.
loginwfclear
=
1
}
// todo: change simple login when api ready
// todo: change simple login when api ready
Generator
.
get_form
(
$scope
.
url
,
$routeP
arams
).
then
(
function
(
data
){
Generator
.
get_form
(
$scope
.
url
,
form_p
arams
).
then
(
function
(
data
){
var
d
=
data
.
data
.
forms
;
var
d
=
data
.
data
.
forms
;
$scope
.
schema
=
d
.
schema
;
for
(
var
key
in
d
)
$scope
.
form
=
d
.
form
;
$scope
[
key
]
=
d
[
key
];
// model is the init data of the form or in edit templates
$scope
.
model
=
d
.
model
?
d
.
model
:
{};
$scope
.
initialModel
=
angular
.
copy
(
d
.
model
);
// for email validation add asyncvalidator
// for email validation add asyncvalidator
//$scope.form[0].$asyncValidators = Generator.asyncValidators;
//$scope.form[0].$asyncValidators = Generator.asyncValidators;
// add submit button to the form todo: move this to form service
// add submit button to the form todo: move this to form service
$scope
.
form
.
push
(
//$scope.form.push(
{
// {
type
:
"submit"
,
// type: "submit",
title
:
"Save"
// title: "Save"
}
// }
);
//);
$scope
.
form
=
[
"*"
,
{
key
:
"password"
,
type
:
"password"
},
{
type
:
'submit'
,
title
:
'Save'
}
];
});
});
//$scope.schema =
//{
// title: "Login",
// type: "object",
// properties: {
// email: {
// type: "email",
// title: "Email"
// },
// password: {
// type: "string",
// title: "Password"
// },
// remember: {
// type: "boolean",
// title: "Remember me?"
// },
// who: {
// title: "Who are you?",
// type: "string",
// enum: ["student", "stuff", "dean"]
// }
// },
// required: ["email", "password", "who"]
//};
//$scope.model = {
// email: "user@example.com",
// remember: false
//};
//$scope.form = [
// {
// key: "email",
// type: "email",
// validationMessages: {
// 'emailNotValid': 'Email is not valid!'
// },
// $asyncValidators: {
// emailNotValid: function (value) {
// var deferred = $q.defer();
// $timeout(function () {
// if (LoginService.isValidEmail(value)) {
// deferred.resolve();
// } else {
// deferred.reject();
// }
// }, 500);
// return deferred.promise;
// }
// }
// },
// {
// key: "password",
// type: "password"
// },
// "remember",
// "who",
// {
// type: "submit",
// title: "Save"
// }
//];
$scope
.
onSubmit
=
function
(
form
)
{
$scope
.
onSubmit
=
function
(
form
)
{
$scope
.
$broadcast
(
'schemaFormValidate'
);
$scope
.
$broadcast
(
'schemaFormValidate'
);
if
(
form
.
$valid
)
{
if
(
form
.
$valid
)
{
...
...
app/components/dashboard/dashboard.js
View file @
3533ee66
...
@@ -13,5 +13,4 @@ angular.module('zaerp.dashboard', ['ngRoute'])
...
@@ -13,5 +13,4 @@ angular.module('zaerp.dashboard', ['ngRoute'])
.
controller
(
'DashCtrl'
,
function
(
$scope
)
{
.
controller
(
'DashCtrl'
,
function
(
$scope
)
{
$scope
.
testData
=
"<h1>This is main Dashboard</h1>"
;
$scope
.
testData
=
"<h1>This is main Dashboard</h1>"
;
console
.
log
(
22
);
});
});
\ No newline at end of file
app/components/staff/staff_controller.js
View file @
3533ee66
...
@@ -16,50 +16,28 @@ var staff = angular.module('zaerp.staff', ['ngRoute', 'schemaForm', 'formService
...
@@ -16,50 +16,28 @@ var staff = angular.module('zaerp.staff', ['ngRoute', 'schemaForm', 'formService
* which provide a form with form generator.
* which provide a form with form generator.
*/
*/
//staff.controller('StaffAddCtrl', function ($scope, $http, $log, Generator) {
staff
.
controller
(
'StaffAddEditCtrl'
,
function
(
$scope
,
$rootScope
,
$http
,
$log
,
Generator
,
$routeParams
)
{
// Generator.get_form('add_staff', '').then(function (d) {
// $scope.schema = d.schema;
// $scope.form = d.form;
// $scope.model = d.model ? d.model : {};
// $scope.initialModel = angular.copy(d.model);
// $scope.form[0].$asyncValidators = Generator.asyncValidators;
// $scope.form.push(
// {
// type: "submit",
// title: "Save"
// }
// );
// return $scope;
// });
// $scope.onSubmit = function (form) {
// $scope.$broadcast('schemaFormValidate');
// if (form.$valid) {
// Generator.submit('add_staff', $scope);
// }
// }
//});
staff
.
controller
(
'StaffAddEditCtrl'
,
function
(
$scope
,
$http
,
$log
,
Generator
,
$routeParams
)
{
$scope
.
url
=
'personel_duzenle_basitlestirilmis'
;
$scope
.
url
=
'personel_duzenle_basitlestirilmis'
;
var
form_params
=
{};
var
form_params
=
{};
if
(
$routeParams
.
id
)
{
if
(
$routeParams
.
id
)
{
form_params
[
'id'
]
=
$routeParams
.
id
;
form_params
[
'
object_
id'
]
=
$routeParams
.
id
;
form_params
[
'cmd'
]
=
'edit_object'
;
form_params
[
'cmd'
]
=
'edit_object'
;
}
}
else
{
else
{
form_params
[
'cmd'
]
=
'add_object'
;
form_params
[
'cmd'
]
=
'add_object'
;
}
}
form_params
[
'clear_wf'
]
=
1
;
if
(
$rootScope
.
staffwfclear
){
form_params
[
'clear_wf'
]
=
1
;
}
else
{
$rootScope
.
staffwfclear
=
1
}
Generator
.
get_form
(
$scope
.
url
,
form_params
).
then
(
function
(
data
)
{
Generator
.
get_form
(
$scope
.
url
,
form_params
).
then
(
function
(
data
)
{
var
d
=
data
.
data
.
forms
;
var
d
=
data
.
data
.
forms
;
console
.
log
(
d
);
// add form, schema and model to scope object
$scope
.
schema
=
d
.
schema
;
for
(
var
key
in
d
)
$scope
.
form
=
d
.
form
;
$scope
[
key
]
=
d
[
key
];
delete
$scope
.
form
[
0
];
$scope
.
initialModel
=
angular
.
copy
(
$scope
.
model
);
//$scope.form.push({"key": "birth_date", "format": "yyyy-mm-dd"});
$scope
.
model
=
d
.
model
?
d
.
model
:
{};
$scope
.
initialModel
=
angular
.
copy
(
d
.
model
);
//$scope.form.push($asyncValidators: Generator.asyncValidators);
$scope
.
form
.
push
(
$scope
.
form
.
push
(
{
{
type
:
"submit"
,
type
:
"submit"
,
...
@@ -82,17 +60,30 @@ staff.controller('StaffAddEditCtrl', function ($scope, $http, $log, Generator, $
...
@@ -82,17 +60,30 @@ staff.controller('StaffAddEditCtrl', function ($scope, $http, $log, Generator, $
* Staff List Controller
* Staff List Controller
*/
*/
staff
.
controller
(
'StaffListCtrl'
,
function
(
$scope
,
$http
,
RESTURL
)
{
staff
.
controller
(
'StaffListCtrl'
,
function
(
$scope
,
$rootScope
,
Generator
)
{
$http
.
post
(
RESTURL
.
url
+
'personel_duzenle_basitlestirilmis'
).
then
(
function
(
res
)
{
var
form_params
=
{};
$scope
.
staffs
=
res
.
data
;
if
(
$rootScope
.
staffwfclear
){
})
form_params
[
'clear_wf'
]
=
1
;
}
else
{
$rootScope
.
staffwfclear
=
1
}
Generator
.
get_form
(
'personel_duzenle_basitlestirilmis'
,
form_params
)
.
then
(
function
(
res
)
{
$scope
.
staffs
=
res
.
data
;
});
});
});
/**
/**
* Staff Show Controller
* Staff Show Controller
*/
*/
staff
.
controller
(
'StaffShowCtrl'
,
function
(
$scope
,
$http
,
RESTURL
,
$routeParams
)
{
staff
.
controller
(
'StaffShowCtrl'
,
function
(
$scope
,
$rootScope
,
Generator
,
$routeParams
)
{
$http
.
post
(
RESTURL
.
url
+
'personel_duzenle_basitlestirilmis'
).
then
(
function
(
res
)
{
var
form_params
=
{
"object_id"
:
$routeParams
.
id
};
if
(
$rootScope
.
staffwfclear
){
form_params
[
'clear_wf'
]
=
1
;
}
else
{
$rootScope
.
staffwfclear
=
1
}
Generator
.
get_form
(
'personel_duzenle_basitlestirilmis'
,
form_params
).
then
(
function
(
res
)
{
$scope
.
staff
=
res
.
data
[
0
];
$scope
.
staff
=
res
.
data
[
0
];
})
})
});
});
\ No newline at end of file
app/zetalib/forms/form_service.js
View file @
3533ee66
...
@@ -9,6 +9,9 @@ var form_generator = angular.module('formService', ['general']);
...
@@ -9,6 +9,9 @@ var form_generator = angular.module('formService', ['general']);
form_generator
.
factory
(
'Generator'
,
function
(
$http
,
$q
,
$log
,
$timeout
,
RESTURL
,
FormDiff
)
{
form_generator
.
factory
(
'Generator'
,
function
(
$http
,
$q
,
$log
,
$timeout
,
RESTURL
,
FormDiff
)
{
var
generator
=
{};
var
generator
=
{};
generator
.
makeUrl
=
function
(
url
){
return
RESTURL
.
url
+
url
;
};
generator
.
generate
=
function
(
modelObject
)
{
generator
.
generate
=
function
(
modelObject
)
{
return
generator
.
group
(
modelObject
);
return
generator
.
group
(
modelObject
);
};
};
...
@@ -17,11 +20,9 @@ form_generator.factory('Generator', function ($http, $q, $log, $timeout, RESTURL
...
@@ -17,11 +20,9 @@ form_generator.factory('Generator', function ($http, $q, $log, $timeout, RESTURL
};
};
generator
.
get_form
=
function
(
url
,
getParams
)
{
generator
.
get_form
=
function
(
url
,
getParams
)
{
return
$http
return
$http
.
post
(
RESTURL
.
url
+
url
,
getParams
)
.
post
(
generator
.
makeUrl
(
url
)
,
getParams
)
.
success
(
function
(
res
)
{
.
success
(
function
(
res
)
{
if
(
res
.
status
==
200
)
{
return
generator
.
generate
(
res
.
data
);
return
generator
.
generate
(
res
.
data
);
}
// todo: cover all other exceptions (4xx, 5xx)
// todo: cover all other exceptions (4xx, 5xx)
});
});
};
};
...
@@ -43,9 +44,14 @@ form_generator.factory('Generator', function ($http, $q, $log, $timeout, RESTURL
...
@@ -43,9 +44,14 @@ form_generator.factory('Generator', function ($http, $q, $log, $timeout, RESTURL
}
}
};
};
generator
.
submit
=
function
(
$scope
)
{
generator
.
submit
=
function
(
$scope
)
{
var
get_diff
=
FormDiff
.
get_diff
(
$scope
.
model
,
$scope
.
initialModel
);
if
(
$scope
.
object_id
)
{
$log
.
info
(
get_diff
);
var
get_diff
=
FormDiff
.
get_diff
(
$scope
.
model
,
$scope
.
initialModel
);
$http
.
post
(
RESTURL
.
url
+
$scope
.
url
,
get_diff
).
then
(
function
(
res
)
{
var
data
=
{
"object_id"
:
$scope
.
id
,
"form"
:
get_diff
};
}
else
{
data
=
$scope
.
model
;
}
$http
.
post
(
generator
.
makeUrl
(
$scope
.
url
),
data
).
then
(
function
(
res
)
{
// todo: for now fake rest api returns 'ok' no data to
// todo: for now fake rest api returns 'ok' no data to
// manipulate on ui. therefor used just a log
// manipulate on ui. therefor used just a log
$log
.
info
(
res
);
$log
.
info
(
res
);
...
...
app/zetalib/interceptors.js
View file @
3533ee66
...
@@ -15,7 +15,7 @@ app.config(['$httpProvider', function ($httpProvider) {
...
@@ -15,7 +15,7 @@ app.config(['$httpProvider', function ($httpProvider) {
'request'
:
function
(
config
){
'request'
:
function
(
config
){
// todo: delete console logs
// todo: delete console logs
if
(
config
.
method
==
"POST"
){
if
(
config
.
method
==
"POST"
){
console
.
log
(
"post request"
)
}
else
{
}
else
{
}
}
...
@@ -23,9 +23,13 @@ app.config(['$httpProvider', function ($httpProvider) {
...
@@ -23,9 +23,13 @@ app.config(['$httpProvider', function ($httpProvider) {
},
},
'response'
:
function
(
response
)
{
'response'
:
function
(
response
)
{
//Will only be called for HTTP up to 300
//Will only be called for HTTP up to 300
if
(
response
.
data
.
is_login
){
if
(
response
.
data
.
is_login
===
true
){
$rootScope
.
loggedInUser
=
response
.
data
.
is_login
;
$rootScope
.
loggedInUser
=
response
.
data
.
is_login
;
//$location.path("/dashboard");
if
(
$location
.
path
()
===
"/login"
){
$location
.
path
(
'/dashboard'
);
}
else
{
$location
.
replace
();
}
}
}
if
(
response
.
data
.
screen
)
{
if
(
response
.
data
.
screen
)
{
$location
.
path
(
response
.
data
.
screen
);
$location
.
path
(
response
.
data
.
screen
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment