Skip to content
GitLab
Explore
Projects
Groups
Snippets
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
m4lab_tv1
User Account
Commits
4990ada1
Commit
4990ada1
authored
4 years ago
by
Rosanny Sihombing
Browse files
Options
Download
Email Patches
Plain Diff
update createNewPages and add updateProject
parent
d3c70373
master
MLAB-677
devel
reset-jul13
reset-merge
testing
5 merge requests
!143
updating yml config
,
!91
Prepare prod
,
!90
Testing
,
!89
Testing
,
!70
Mlab 383
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
routes/gitlab.js
+50
-12
routes/gitlab.js
with
50 additions
and
12 deletions
+50
-12
routes/gitlab.js
+
50
-
12
View file @
4990ada1
...
...
@@ -27,15 +27,14 @@ var gitlab = {
callback
(
res
)
})
},
// todo: fixing callback
createNewPages
:
function
(
newPagesdata
,
callback
)
{
createNewPages
:
function
(
newPagesData
,
newLogoFile
,
callback
)
{
let
data
=
new
formData
()
data
.
append
(
'
avatar
'
,
fs
.
createReadStream
(
new
Pagesdata
.
avatar
))
data
.
append
(
'
avatar
'
,
fs
.
createReadStream
(
new
LogoFile
))
let
dataConfig
=
{
method
:
'
post
'
,
url
:
'
https://transfer.hft-stuttgart.de/gitlab/api/v4/projects/user/
'
+
newPages
d
ata
.
g
itlabUserId
+
'
?name=
'
+
newPages
d
ata
.
n
ame
+
'
&description=
'
+
newPages
d
ata
.
description
+
'
&tag_list=website
'
+
url
:
'
https://transfer.hft-stuttgart.de/gitlab/api/v4/projects/user/
'
+
newPages
D
ata
.
g
etOwnerGitlabId
()
+
'
?name=
'
+
newPages
D
ata
.
getN
ame
()
+
'
&description=
'
+
newPages
D
ata
.
getDesc
()
+
'
&tag_list=website
'
+
'
&use_custom_template=true&template_name=page_basic
'
,
headers
:
{
'
Authorization
'
:
'
Bearer
'
+
config
.
gitlab
.
token_readWriteProjects
,
...
...
@@ -45,13 +44,52 @@ var gitlab = {
}
axios
(
dataConfig
)
.
then
(
function
(
response
)
{
callback
(
response
.
data
)
.
then
(
response
=>
{
let
res
=
{
error
:
false
,
data
:
response
.
data
}
callback
(
res
)
})
.
catch
(
err
=>
{
console
.
log
(
err
)
let
res
=
{
error
:
true
,
data
:
err
.
response
.
data
}
callback
(
res
)
})
},
updateProject
:
function
(
updatedProjectData
,
newLogoFile
,
callback
){
console
.
log
(
updatedProjectData
)
let
data
=
new
formData
()
if
(
newLogoFile
)
{
data
.
append
(
'
avatar
'
,
fs
.
createReadStream
(
newLogoFile
))
}
let
dataConfig
=
{
method
:
'
put
'
,
url
:
'
https://transfer.hft-stuttgart.de/gitlab/api/v4/projects/
'
+
updatedProjectData
.
getId
()
+
'
?name=
'
+
updatedProjectData
.
getName
()
+
'
&description=
'
+
updatedProjectData
.
getDesc
(),
headers
:
{
'
Authorization
'
:
'
Bearer
'
+
config
.
gitlab
.
token_readWriteProjects
,
...
data
.
getHeaders
()
},
data
:
data
}
axios
(
dataConfig
)
.
then
(
response
=>
{
let
res
=
{
error
:
false
,
data
:
response
.
data
}
callback
(
res
)
})
.
catch
(
err
=>
{
console
.
log
(
err
)
let
res
=
{
error
:
true
,
data
:
err
.
response
.
data
}
callback
(
res
)
})
.
catch
(
function
(
err
)
{
if
(
err
)
callback
(
err
.
response
.
data
)
})
},
getUserProjects
:
function
(
gitlabUserId
,
callback
)
{
axios
.
get
(
'
https://transfer.hft-stuttgart.de/gitlab/api/v4/users/
'
+
gitlabUserId
+
'
/projects?private_token=
'
+
...
...
@@ -65,7 +103,7 @@ var gitlab = {
.
catch
(
err
=>
{
let
res
=
{
error
:
true
,
data
:
err
}
data
:
err
.
message
}
callback
(
res
)
})
},
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Snippets