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
8c40c5eb
Commit
8c40c5eb
authored
Jul 01, 2015
by
Evren Kutar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dosyalar okunabilirlik prensibine göre düzenlendi
parent
7ef6d9b3
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
48 additions
and
31 deletions
+48
-31
app.js
app/app.js
+3
-3
auth_service.js
app/components/auth/auth_service.js
+4
-4
auth_test.js
app/components/auth/auth_test.js
+10
-4
staff_controller.js
app/components/staff/staff_controller.js
+4
-4
staff_controller_test.js
app/components/staff/staff_controller_test.js
+1
-1
form_service.js
app/zetalib/forms/form_service.js
+6
-4
form_service_test.js
app/zetalib/forms/form_service_test.js
+14
-5
general.js
app/zetalib/general.js
+1
-1
general_test.js
app/zetalib/general_test.js
+5
-5
No files found.
app/app.js
View file @
8c40c5eb
...
...
@@ -28,7 +28,7 @@ var app = angular.module(
* the lines below are config of oclazyload
* turn debug false when production
*/
config
([
'$ocLazyLoadProvider'
,
function
(
$ocLazyLoadProvider
)
{
config
([
'$ocLazyLoadProvider'
,
function
(
$ocLazyLoadProvider
)
{
$ocLazyLoadProvider
.
config
({
// todo: turn debug false on prod
debug
:
true
...
...
@@ -38,11 +38,11 @@ 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
()
{
var
dev
=
"http://127.0.0.1:3000/api/"
;
var
prod
=
""
;
var
ENV
=
"dev"
;
// change to prod in production
return
ENV
==
"dev"
?
{
url
:
dev
}
:
{
url
:
prod
};
return
ENV
==
"dev"
?
{
url
:
dev
}
:
{
url
:
prod
};
//return "http://127.0.0.1:3000/api/";
})()).
/**
...
...
app/components/auth/auth_service.js
View file @
8c40c5eb
...
...
@@ -15,15 +15,15 @@ auth.factory('LoginService', function ($http, $rootScope, $location, $log, $cook
loginService
.
login
=
function
(
credentials
)
{
// TODO: change this getParams var to service to use app-wide
var
getParams
=
"?"
;
for
(
var
k
in
credentials
){
getParams
+=
k
+
"="
+
credentials
[
k
]
+
"&"
;
for
(
var
k
in
credentials
)
{
getParams
+=
k
+
"="
+
credentials
[
k
]
+
"&"
;
}
return
$http
.
get
(
RESTURL
.
url
+
'login'
+
getParams
)
.
then
(
function
(
res
)
{
$log
.
info
(
res
.
data
[
0
]);
res
.
data
=
res
.
data
[
0
];
if
(
res
.
data
.
success
){
if
(
res
.
data
.
success
)
{
$rootScope
.
loggedInUser
=
true
;
$location
.
path
(
"/dashboard"
);
var
session
=
Session
.
create
(
res
.
data
.
id
,
res
.
data
.
user
.
id
,
...
...
@@ -48,7 +48,7 @@ auth.factory('LoginService', function ($http, $rootScope, $location, $log, $cook
loginService
.
indexOf
(
Session
.
userRole
)
!==
-
1
);
};
loginService
.
isValidEmail
=
function
(
email
)
{
loginService
.
isValidEmail
=
function
(
email
)
{
var
re
=
/^
([\w
-
]
+
(?:\.[\w
-
]
+
)
*
)
@
((?:[\w
-
]
+
\.)
*
\w[\w
-
]{0,66})\.([
a-z
]{2,6}(?:\.[
a-z
]{2})?)
$/i
;
return
re
.
test
(
email
);
};
...
...
app/components/auth/auth_test.js
View file @
8c40c5eb
...
...
@@ -54,22 +54,28 @@ describe('zaerp.auth module', function () {
}])
);
it
(
'ensures user can log in'
,
function
()
{
it
(
'ensures user can log in'
,
function
()
{
// todo: after backend api ready implement this
});
it
(
'should get login success'
,
inject
(
function
(
LoginService
,
$httpBackend
,
$location
,
RESTURL
)
{
inject
(
function
(
LoginService
,
$httpBackend
,
$location
,
RESTURL
)
{
// use httpBackend to imitate login api
$httpBackend
.
expectGET
(
RESTURL
.
url
+
'login?email=test@test.com&password=password&'
)
// todo: with real api change response data from list to obj
.
respond
(
200
,
[{
'id'
:
1
,
'user'
:
{
'id'
:
12
,
'role'
:
'admin'
},
'success'
:
true
}]);
.
respond
(
200
,
[{
'id'
:
1
,
'user'
:
{
'id'
:
12
,
'role'
:
'admin'
},
'success'
:
true
}]);
var
cred
=
{
email
:
'test@test.com'
,
password
:
'password'
};
LoginService
.
login
(
cred
)
.
then
(
function
(
data
)
{
.
then
(
function
(
data
)
{
expect
(
data
).
not
.
toBe
(
null
);
// after login path need to be change dashboard
expect
(
$location
.
path
()).
toBe
(
'/dashboard'
);
...
...
app/components/staff/staff_controller.js
View file @
8c40c5eb
...
...
@@ -8,7 +8,7 @@
'use strict'
;
var
staff
=
angular
.
module
(
'zaerp.staff'
,
[
'ngRoute'
,
'schemaForm'
,
'formService'
]);
var
staff
=
angular
.
module
(
'zaerp.staff'
,
[
'ngRoute'
,
'schemaForm'
,
'formService'
]);
/**
...
...
@@ -16,8 +16,8 @@ var staff = angular.module('zaerp.staff',['ngRoute','schemaForm', 'formService']
* which provide a form with form generator.
*/
staff
.
controller
(
'StaffAddEditCtrl'
,
function
(
$scope
,
$http
,
$log
,
Generator
,
$routeParams
)
{
Generator
.
get_form
(
'add_staff'
,
$routeParams
).
then
(
function
(
d
)
{
staff
.
controller
(
'StaffAddEditCtrl'
,
function
(
$scope
,
$http
,
$log
,
Generator
,
$routeParams
)
{
Generator
.
get_form
(
'add_staff'
,
$routeParams
).
then
(
function
(
d
)
{
$scope
.
schema
=
d
.
schema
;
$scope
.
form
=
d
.
form
;
$scope
.
model
=
d
.
model
?
d
.
model
:
{};
...
...
@@ -29,7 +29,7 @@ staff.controller('StaffAddEditCtrl', function($scope, $http, $log, Generator, $r
}
);
});
$scope
.
onSubmit
=
function
(
form
)
{
$scope
.
onSubmit
=
function
(
form
)
{
$scope
.
$broadcast
(
'schemaFormValidate'
);
if
(
form
.
$valid
)
{
// todo: implement form diff here
...
...
app/components/staff/staff_controller_test.js
View file @
8c40c5eb
...
...
@@ -12,7 +12,7 @@ describe('staff controller module', function () {
var
$controller
;
beforeEach
(
inject
(
function
(
_$controller_
)
{
beforeEach
(
inject
(
function
(
_$controller_
)
{
$controller
=
_$controller_
;
}));
...
...
app/zetalib/forms/form_service.js
View file @
8c40c5eb
...
...
@@ -16,7 +16,7 @@ form_generator.factory('Generator', function ($http, $q, $log, $timeout, RESTURL
return
form_items
;
};
generator
.
get_form
=
function
(
url
,
getParams
)
{
if
(
getParams
){
if
(
getParams
)
{
// if form for edit then url will be
var
params
=
""
;
for
(
var
k
in
getParams
)
{
...
...
@@ -37,7 +37,7 @@ form_generator.factory('Generator', function ($http, $q, $log, $timeout, RESTURL
// todo: cover all other exceptions (4xx, 5xx)
});
};
generator
.
isValidEmail
=
function
(
email
)
{
generator
.
isValidEmail
=
function
(
email
)
{
var
re
=
/^
([\w
-
]
+
(?:\.[\w
-
]
+
)
*
)
@
((?:[\w
-
]
+
\.)
*
\w[\w
-
]{0,66})\.([
a-z
]{2,6}(?:\.[
a-z
]{2})?)
$/i
;
return
re
.
test
(
email
);
};
...
...
@@ -58,7 +58,9 @@ form_generator.factory('Generator', function ($http, $q, $log, $timeout, RESTURL
$scope
.
$broadcast
(
'schemaFormValidate'
);
//if ($scope.form.$valid) {
// todo: change post url, this is not correct!
$http
.
post
(
'http://127.0.0.1:3000/api/add_student'
,
$scope
.
model
).
then
(
function
(
res
){
$log
.
info
(
res
);});
$http
.
post
(
'http://127.0.0.1:3000/api/add_student'
,
$scope
.
model
).
then
(
function
(
res
)
{
$log
.
info
(
res
);
});
//}
};
return
generator
;
...
...
app/zetalib/forms/form_service_test.js
View file @
8c40c5eb
...
...
@@ -18,7 +18,11 @@ describe('form service module', function () {
function
(
Generator
)
{
expect
(
Generator
.
generate
).
not
.
toBe
(
null
);
var
form_json
=
{
email
:
'test@test.com'
,
id
:
2
,
name
:
'travolta'
};
var
form_json
=
{
email
:
'test@test.com'
,
id
:
2
,
name
:
'travolta'
};
var
form_generated
=
Generator
.
generate
(
form_json
);
expect
(
form_generated
).
toEqual
(
form_json
);
...
...
@@ -26,24 +30,29 @@ describe('form service module', function () {
);
it
(
'should group form'
,
inject
([
'Generator'
,
function
(
Generator
)
{
function
(
Generator
)
{
expect
(
Generator
.
group
).
not
.
toBe
(
null
);
var
group_json
=
{
group_objects
:
{
1
:[
'email'
,
'name'
],
2
:[
'password'
]}};
var
group_json
=
{
group_objects
:
{
1
:
[
'email'
,
'name'
],
2
:
[
'password'
]
}
};
var
grouped_form
=
Generator
.
group
(
group_json
);
expect
(
grouped_form
).
toEqual
(
group_json
);
}])
);
it
(
'should get form'
,
inject
(
function
(
Generator
,
$httpBackend
,
RESTURL
)
{
inject
(
function
(
Generator
,
$httpBackend
,
RESTURL
)
{
$httpBackend
.
expectGET
(
RESTURL
.
url
+
'student/add?email=test@test.com&'
)
.
respond
(
200
,
[{
form
:
'form'
}]);
var
cred
=
{
email
:
'test@test.com'
};
Generator
.
get_form
(
'student/add'
,
cred
)
.
then
(
function
(
data
)
{
.
then
(
function
(
data
)
{
expect
(
data
).
toEqual
({
form
:
'form'
});
});
...
...
app/zetalib/general.js
View file @
8c40c5eb
...
...
@@ -13,7 +13,7 @@
*/
var
general
=
angular
.
module
(
'general'
,
[]);
general
.
factory
(
'FormDiff'
,
function
()
{
general
.
factory
(
'FormDiff'
,
function
()
{
/**
* function to return diff of models of submitted form
* @type {{}}
...
...
app/zetalib/general_test.js
View file @
8c40c5eb
...
...
@@ -19,17 +19,17 @@ describe('general module', function () {
// test cases - testing for success
var
same_json
=
[
{
email
:
'test@test.com'
,
id
:
2
,
name
:
'travolta'
},
{
email
:
'test@test.com'
,
id
:
2
,
name
:
'travolta'
}
{
email
:
'test@test.com'
,
id
:
2
,
name
:
'travolta'
},
{
email
:
'test@test.com'
,
id
:
2
,
name
:
'travolta'
}
];
// test cases - testing for failure
var
different_json
=
[
{
email
:
'test@test.com'
,
id
:
2
,
name
:
'travolta'
},
{
email
:
'test1@test.com'
,
id
:
2
,
name
:
'john'
}
{
email
:
'test@test.com'
,
id
:
2
,
name
:
'travolta'
},
{
email
:
'test1@test.com'
,
id
:
2
,
name
:
'john'
}
];
var
diff
=
{
email
:
'test1@test.com'
,
name
:
'john'
};
var
diff
=
{
email
:
'test1@test.com'
,
name
:
'john'
};
var
nodiff
=
{};
var
same
=
FormDiff
.
get_diff
(
same_json
[
0
],
same_json
[
1
]);
...
...
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