Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
minerva
core
Commits
8749a01a
Commit
8749a01a
authored
7 years ago
by
Piotr Gawron
Browse files
Options
Downloads
Patches
Plain Diff
send requests methods unified
parent
0b813d6a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!115
Resolve "admin panel should use API"
,
!114
Resolve "admin panel should use API"
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
frontend-js/src/main/js/ServerConnector.js
+19
-14
19 additions, 14 deletions
frontend-js/src/main/js/ServerConnector.js
frontend-js/src/test/js/ServerConnector-test.js
+26
-0
26 additions, 0 deletions
frontend-js/src/test/js/ServerConnector-test.js
with
45 additions
and
14 deletions
frontend-js/src/main/js/ServerConnector.js
+
19
−
14
View file @
8749a01a
...
@@ -55,8 +55,8 @@ ServerConnector.init = function() {
...
@@ -55,8 +55,8 @@ ServerConnector.init = function() {
};
};
ServerConnector
.
registerListenerType
(
"
onDataLoadStart
"
);
ServerConnector
.
registerListenerType
(
"
onDataLoadStart
"
);
ServerConnector
.
registerListenerType
(
"
onDataLoadStop
"
);
ServerConnector
.
registerListenerType
(
"
onDataLoadStop
"
);
ServerConnector
.
init
();
ServerConnector
.
init
();
ServerConnector
.
getMinOverlayColorInt
=
function
()
{
ServerConnector
.
getMinOverlayColorInt
=
function
()
{
var
self
=
this
;
var
self
=
this
;
return
self
.
getLoggedUser
().
then
(
function
(
user
)
{
return
self
.
getLoggedUser
().
then
(
function
(
user
)
{
...
@@ -120,9 +120,12 @@ ServerConnector.readFile = function (url, description) {
...
@@ -120,9 +120,12 @@ ServerConnector.readFile = function (url, description) {
});
});
};
};
ServerConnector
.
_readFile
=
function
(
url
)
{
ServerConnector
.
_readFile
=
function
(
url
)
{
return
new
Promise
(
function
(
resolve
,
reject
)
{
return
new
Promise
(
function
(
resolve
,
reject
)
{
request
.
get
(
url
,
function
(
error
,
response
,
body
)
{
request
({
method
:
"
GET
"
,
url
:
url
},
function
(
error
,
response
,
body
)
{
if
(
error
)
{
if
(
error
)
{
reject
(
error
);
reject
(
error
);
}
else
if
(
response
.
statusCode
!==
200
)
{
}
else
if
(
response
.
statusCode
!==
200
)
{
...
@@ -144,11 +147,12 @@ ServerConnector.sendPostRequest = function (url, params) {
...
@@ -144,11 +147,12 @@ ServerConnector.sendPostRequest = function (url, params) {
self
.
getSessionData
().
setLogin
(
undefined
);
self
.
getSessionData
().
setLogin
(
undefined
);
window
.
location
.
reload
(
false
);
window
.
location
.
reload
(
false
);
}
}
return
new
Promise
(
function
(
resolve
,
reject
)
{
return
new
Promise
(
function
(
resolve
,
reject
)
{
request
.
post
({
request
({
url
:
url
,
method
:
"
POST
"
,
form
:
params
url
:
url
,
},
function
(
error
,
response
,
body
)
{
form
:
params
},
function
(
error
,
response
,
body
)
{
if
(
error
)
{
if
(
error
)
{
reject
(
new
NetworkError
(
error
.
message
,
{
reject
(
new
NetworkError
(
error
.
message
,
{
content
:
body
,
content
:
body
,
...
@@ -174,11 +178,12 @@ ServerConnector.sendPutRequest = function (url, params) {
...
@@ -174,11 +178,12 @@ ServerConnector.sendPutRequest = function (url, params) {
self
.
getSessionData
().
setLogin
(
undefined
);
self
.
getSessionData
().
setLogin
(
undefined
);
window
.
location
.
reload
(
false
);
window
.
location
.
reload
(
false
);
}
}
return
new
Promise
(
function
(
resolve
,
reject
)
{
return
new
Promise
(
function
(
resolve
,
reject
)
{
request
.
put
({
request
({
url
:
url
,
method
:
"
PUT
"
,
form
:
params
url
:
url
,
},
function
(
error
,
response
,
body
)
{
form
:
params
},
function
(
error
,
response
,
body
)
{
if
(
error
)
{
if
(
error
)
{
reject
(
error
);
reject
(
error
);
}
else
if
(
response
.
statusCode
!==
200
)
{
}
else
if
(
response
.
statusCode
!==
200
)
{
...
...
This diff is collapsed.
Click to expand it.
frontend-js/src/test/js/ServerConnector-test.js
+
26
−
0
View file @
8749a01a
...
@@ -266,4 +266,30 @@ describe('ServerConnector', function() {
...
@@ -266,4 +266,30 @@ describe('ServerConnector', function() {
describe
(
'
returnUserOrSystemColor
'
,
function
()
{
it
(
'
user has empty color
'
,
function
()
{
var
systemColor
=
{};
return
ServerConnector
.
returnUserOrSystemColor
(
""
,
Promise
.
resolve
(
systemColor
)).
then
(
function
(
result
)
{
assert
.
ok
(
result
=
systemColor
);
});
});
it
(
'
user has defined color
'
,
function
()
{
var
userColor
=
{};
var
systemColor
=
{};
return
ServerConnector
.
returnUserOrSystemColor
(
userColor
,
Promise
.
resolve
(
systemColor
)).
then
(
function
(
result
)
{
assert
.
ok
(
result
=
userColor
);
});
});
});
describe
(
'
readFile
'
,
function
()
{
it
(
'
check session expired
'
,
function
()
{
ServerConnector
.
getSessionData
().
setToken
(
undefined
);
assert
.
ok
(
ServerConnector
.
getSessionData
().
getLogin
())
return
ServerConnector
.
readFile
(
"
package.json
"
,
"
Downloading projects
"
).
then
(
function
()
{
assert
.
notOk
(
ServerConnector
.
getSessionData
().
getLogin
())
});
});
});
});
});
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment