Fakultas Ilmu Komputer UI
Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Fasilkom UI Open Source Software
Kape
Commits
4c2e619a
Commit
4c2e619a
authored
Mar 28, 2017
by
sirinbaisa
Browse files
Merge branch 'UserStory2' of
https://gitlab.com/PPL2017csui/PPLA1
into UserStory2
parents
5908d1de
27fc61ab
Changes
33
Expand all
Hide whitespace changes
Inline
Side-by-side
.gitignore
View file @
4c2e619a
node_modules
*.pyc
.pyc
venv
assets/bundles/*
.idea
webpack-stats.json
.npm
.bash_history
.cache
test/*
.coverage
node_modules
*.pyc
.pyc
venv
assets/bundles/*
.idea
webpack-stats.json
.npm
.bash_history
.cache
test/*
.coverage
.tmp/
npm-debug.log
.tmp/mocha-webpack/455fffbb3125fc1ebc427c559e4e5438/455fffbb3125fc1ebc427c559e4e5438-output.js
deleted
100644 → 0
View file @
5908d1de
This diff is collapsed.
Click to expand it.
assets/js/__test__/lib/Logger-test.jsx
0 → 100644
View file @
4c2e619a
/* eslint-disable no-unused-expressions */
import
Logger
from
'
./../../lib/Logger
'
;
describe
(
'
Logger.log success
'
,
()
=>
{
it
(
'
Logger sent log properly
'
,
()
=>
{
const
val
=
Logger
.
log
(
'
test
'
);
expect
(
JSON
.
stringify
(
val
)
===
JSON
.
stringify
([
'
test
'
])).
to
.
be
.
true
;
});
});
describe
(
'
Logger.log error
'
,
()
=>
{
it
(
'
Logger sent error properly
'
,
()
=>
{
const
val
=
Logger
.
error
(
'
test
'
);
expect
(
JSON
.
stringify
(
val
)
===
JSON
.
stringify
([
'
test
'
])).
to
.
be
.
true
;
});
});
describe
(
'
Logger.log warn
'
,
()
=>
{
it
(
'
Logger sent warn properly
'
,
()
=>
{
const
val
=
Logger
.
warn
(
'
test
'
);
expect
(
JSON
.
stringify
(
val
)
===
JSON
.
stringify
([
'
test
'
])).
to
.
be
.
true
;
});
});
assets/js/__test__/lib/Server-test.jsx
0 → 100644
View file @
4c2e619a
/* eslint-disable */
import
Server
from
'
./../../lib/Server
'
;
(
function
(
document
)
{
var
cookies
=
{};
document
.
__defineGetter__
(
'
cookie
'
,
function
()
{
var
output
=
[];
for
(
var
cookieName
in
cookies
)
{
output
.
push
(
cookieName
+
"
=
"
+
cookies
[
cookieName
]);
}
return
output
.
join
(
"
;
"
);
});
document
.
__defineSetter__
(
'
cookie
'
,
function
(
s
)
{
var
indexOfSeparator
=
s
.
indexOf
(
"
=
"
);
var
key
=
s
.
substr
(
0
,
indexOfSeparator
);
var
value
=
s
.
substring
(
indexOfSeparator
+
1
);
cookies
[
key
]
=
value
;
return
key
+
"
=
"
+
value
;
});
document
.
clearCookies
=
function
()
{
cookies
=
{};
};
})(
document
);
describe
(
'
Server get test
'
,
()
=>
{
const
fetchMock
=
require
(
'
fetch-mock
'
);
const
response
=
{
hello
:
'
world
'
};
it
(
'
Check Server get right response
'
,
()
=>
{
fetchMock
.
get
(
'
*
'
,
response
);
Server
.
get
(
'
/test
'
,
true
).
then
((
data
)
=>
{
expect
(
JSON
.
stringify
(
response
)).
to
.
equal
(
JSON
.
stringify
(
data
));
});
Server
.
get
(
'
/test
'
,
false
).
then
((
data
)
=>
{
expect
(
JSON
.
stringify
(
response
)).
to
.
equal
(
JSON
.
stringify
(
data
));
});
});
it
(
'
Check Server get right response
'
,
()
=>
{
fetchMock
.
get
(
'
*
'
,
{
hello
:
'
not-world
'
});
Server
.
get
(
'
/test
'
).
then
((
data
)
=>
{
expect
(
JSON
.
stringify
(
response
)).
to
.
equal
(
JSON
.
stringify
(
data
));
});
});
it
(
'
Check Server post right response
'
,
()
=>
{
fetchMock
.
post
(
'
*
'
,
response
);
Server
.
post
(
'
/test
'
).
then
((
data
)
=>
{
expect
(
JSON
.
stringify
(
response
)).
to
.
equal
(
JSON
.
stringify
(
data
));
});
});
it
(
'
Check Server delete right response
'
,
()
=>
{
fetchMock
.
delete
(
'
*
'
,
response
);
Server
.
delete
(
'
/test
'
).
then
((
data
)
=>
{
expect
(
JSON
.
stringify
(
response
)).
to
.
equal
(
JSON
.
stringify
(
data
));
});
});
it
(
'
Check Server patch right response
'
,
()
=>
{
fetchMock
.
patch
(
'
*
'
,
response
);
Server
.
patch
(
'
/test
'
).
then
((
data
)
=>
{
expect
(
JSON
.
stringify
(
response
)).
to
.
equal
(
JSON
.
stringify
(
data
));
});
});
it
(
'
Check helper methods response
'
,
()
=>
{
fetchMock
.
get
(
'
*
'
,
response
);
Server
.
request
(
'
/test
'
,
'
GET
'
);
Server
.
sendRequest
(
'
/test
'
,
'
GET
'
,
{},
true
).
then
((
data
)
=>
{
expect
(
data
).
to
.
exist
;
});
fetchMock
.
mock
(
'
*
'
,
199
);
Server
.
sendRequest
(
'
/test
'
,
'
GET
'
,
{},
true
).
then
((
data
)
=>
{
expect
(
data
).
to
.
exist
;
});
fetchMock
.
mock
(
'
*
'
,
204
);
Server
.
sendRequest
(
'
/test
'
,
'
GET
'
,
{},
true
).
then
((
data
)
=>
{
expect
(
data
).
to
.
exist
;
});
fetchMock
.
mock
(
'
*
'
,
200
);
Server
.
sendRequest
(
'
/test
'
,
'
GET
'
,
{},
true
).
then
((
data
)
=>
{
expect
(
data
).
to
.
exist
;
});
});
it
(
'
Check isloggedin method
'
,
()
=>
{
expect
(
Server
.
isLoggedIn
()).
to
.
not
.
exist
;
});
it
(
'
Check getcookie method
'
,
()
=>
{
document
.
cookie
=
'
;test=test;
'
;
expect
(
Server
.
getCookie
(
'
test
'
)).
to
.
not
.
exist
;
});
});
assets/js/__test__/lib/Storage-test.jsx
0 → 100644
View file @
4c2e619a
/* eslint-disable no-unused-expressions */
import
Storage
from
'
./../../lib/Storage
'
;
describe
(
'
Storage get key
'
,
()
=>
{
it
(
'
Check Storage get key
'
,
()
=>
{
expect
(
Storage
.
get
(
'
test
'
)).
to
.
be
.
not
.
exist
;
});
it
(
'
Check Storage get key on exist key
'
,
()
=>
{
Storage
.
set
(
'
test
'
,
'
hue
'
);
expect
(
Storage
.
get
(
'
test
'
)).
to
.
equal
(
'
hue
'
);
});
});
describe
(
'
Storage set key
'
,
()
=>
{
it
(
'
Check Storage set key
'
,
()
=>
{
expect
(
Storage
.
set
(
'
test
'
,
'
hue
'
)).
to
.
be
.
not
.
exist
;
});
it
(
'
Check Storage set key on exist key
'
,
()
=>
{
Storage
.
set
(
'
test
'
,
'
hue
'
);
expect
(
Storage
.
get
(
'
test
'
)).
to
.
equal
(
'
hue
'
);
});
});
describe
(
'
Storage clear key
'
,
()
=>
{
it
(
'
Check Storage clear key
'
,
()
=>
{
Storage
.
set
(
'
test
'
,
'
hue
'
);
expect
(
Storage
.
get
(
'
test
'
)).
to
.
equal
(
'
hue
'
);
expect
(
Storage
.
clear
()).
to
.
be
.
not
.
exist
;
expect
(
Storage
.
get
(
'
test
'
)).
to
.
be
.
not
.
exist
;
});
});
\ No newline at end of file
assets/js/__test__/lib/logger-test.js
deleted
100644 → 0
View file @
5908d1de
// import expect from "expect";
// import Logger from "../../lib/logger";
// import {describe, beforeEach, it} from "mocha";
//
// describe('logger log', function () {
// beforeEach(function() {
// expect(Logger, 'log');
// Logger.log("testing log");
// });
//
// it('Logger sent log properly', function () {
// expect(console.log).toHaveBeenCalled();
// });
// });
//
// describe('logger error', function () {
// beforeEach(function() {
// expect(Logger, 'error');
// Logger.error("testing error");
// });
//
// it('Logger sent error properly', function () {
// expect(console.log).toHaveBeenCalled();
// });
// });
\ No newline at end of file
assets/js/__test__/server-test.jsx
deleted
100644 → 0
View file @
5908d1de
// import React from 'react';
// import expect from 'expect'; //kebutuhan dasar
// import Server from "../lib/server";
// import Logger from "../lib/logger";
//
// describe('server', function () {
// it('check logged in or not', function () {
// let logged = Server.isLoggedIn();
// expect(logged).toEqual(null);
// document.cookie = "sessionid=John Smith; expires=Thu, 18 Dec 2013 12:00:00 UTC; path=/";
// Logger.log(document.cookie);
// logged = Server.isLoggedIn();
// // expect(logged).toEqual("John Smith");
// });
// });
\ No newline at end of file
assets/js/components/ModalAlert.jsx
View file @
4c2e619a
import
React
from
'
react
'
;
import
{
Modal
,
Button
,
Icon
,
Header
}
from
'
semantic-ui-react
'
;
import
{
Modal
,
Button
,
Icon
}
from
'
semantic-ui-react
'
;
import
Server
from
'
../lib/Server
'
;
import
Logger
from
'
../lib/Logger
'
;
export
default
class
ModalAlert
extends
React
.
Component
{
static
propTypes
=
{
id
:
React
.
PropTypes
.
number
.
isRequired
,
onChangeValue
:
React
.
PropTypes
.
func
.
isRequired
,
coverLetter
:
React
.
PropTypes
.
string
.
isRequired
,
header
:
React
.
PropTypes
.
oneOfType
([
React
.
PropTypes
.
node
,
React
.
PropTypes
.
string
,
]).
isRequired
,
content
:
React
.
PropTypes
.
oneOfType
([
React
.
PropTypes
.
node
,
React
.
PropTypes
.
string
,
]).
isRequired
,
};
state
=
{
open
:
false
};
constructor
(
props
)
{
super
(
props
);
/* istanbul ignore next */
this
.
state
=
{
open
:
false
,
header
:
'
Menghubungkan ke Server
'
,
content
:
'
Harap menunggu, permintaan anda sedang diproses...
'
,
};
this
.
handleOpen
=
this
.
handleOpen
.
bind
(
this
);
}
open
=
()
=>
this
.
setState
({
open
:
true
});
close
=
()
=>
this
.
setState
({
open
:
false
});
handleOpen
()
{
Logger
.
log
(
this
.
state
);
const
requestData
=
{
coverLetter
:
this
.
props
.
coverLetter
};
Server
.
post
(
`/students/
${
this
.
props
.
id
}
/application`
,
requestData
).
then
((
data
)
=>
{
this
.
setState
({
header
:
'
Pendaftaran Berhasil
'
,
content
:
this
.
successResponse
+
JSON
.
stringify
(
data
),
});
},
(
error
)
=>
{
this
.
setState
({
responseHeader
:
'
Pendaftaran Gagal
'
,
responseText
:
this
.
failedResponse
+
JSON
.
stringify
(
error
),
});
});
}
render
()
{
const
{
open
}
=
this
.
state
;
...
...
@@ -30,16 +50,16 @@ export default class ModalAlert extends React.Component {
onClose
=
{
this
.
close
}
size
=
"small"
basic
trigger
=
{
<
Button
color
=
"blue"
>
Proceed
<
Icon
name
=
"right chevron"
/></
Button
>
}
trigger
=
{
<
Button
color
=
"blue"
onClick
=
{
this
.
handleOpen
}
>
Proceed
<
Icon
name
=
"right chevron"
/></
Button
>
}
>
<
Modal
.
Header
>
{
this
.
props
.
header
}
</
Modal
.
Header
>
<
Modal
.
Header
>
{
this
.
state
.
header
}
</
Modal
.
Header
>
<
Modal
.
Content
>
<
p
>
{
this
.
props
.
content
}
</
p
>
<
p
>
{
this
.
state
.
content
}
</
p
>
</
Modal
.
Content
>
<
Modal
.
Actions
>
<
Button
icon
=
'
checkmark
'
color
=
"green"
content
=
"All Done"
onClick
=
{
this
.
props
.
onChangeValue
}
/>
<
Button
icon
=
"
checkmark
"
color
=
"green"
content
=
"All Done"
onClick
=
{
this
.
props
.
onChangeValue
}
/>
</
Modal
.
Actions
>
</
Modal
>
);
}
}
\ No newline at end of file
}
assets/js/components/ModalPendaftaran.jsx
View file @
4c2e619a
import
React
from
'
react
'
;
import
{
Modal
,
Button
,
Icon
,
TextArea
,
Form
}
from
'
semantic-ui-react
'
;
import
ModalAlert
from
'
./ModalAlert
'
;
import
Server
from
'
../lib/Server
'
;
export
default
class
ModalPendaftaran
extends
React
.
Component
{
static
propTypes
=
{
...
...
@@ -31,19 +30,6 @@ export default class ModalPendaftaran extends React.Component {
}
handleOpen
()
{
console
.
log
(
this
.
state
);
const
data
=
{
coverLetter
:
this
.
state
.
coverLetter
};
Server
.
post
(
`/students/
${
this
.
props
.
id
}
/application`
,
data
).
then
((
data
)
=>
{
this
.
setState
({
responseHeader
:
'
Pendaftaran Berhasil
'
,
responseText
:
this
.
successResponse
+
JSON
.
stringify
(
data
),
});
},
(
error
)
=>
{
this
.
setState
({
responseHeader
:
'
Pendaftaran Gagal
'
,
responseText
:
this
.
failedResponse
+
JSON
.
stringify
(
error
),
});
});
this
.
setState
({
modalOpen
:
true
});
}
...
...
@@ -83,9 +69,9 @@ export default class ModalPendaftaran extends React.Component {
</
Modal
.
Content
>
<
Modal
.
Actions
>
<
ModalAlert
id
=
{
this
.
props
.
id
}
onChangeValue
=
{
this
.
handleClose
}
header
=
{
this
.
state
.
responseHeader
}
content
=
{
this
.
state
.
responseText
}
coverLetter
=
{
this
.
state
.
coverLetter
}
/>
</
Modal
.
Actions
>
</
Modal
>
...
...
assets/js/components/VacancyList.jsx
View file @
4c2e619a
...
...
@@ -10,7 +10,7 @@ export default class VacancyList extends React.Component {
generateVacancies
()
{
return
this
.
props
.
vacancies
.
map
((
vacancy
)
=>
<
Lowongan
data
=
{
vacancy
}
/>,
<
Lowongan
key
=
{
vacancy
.
id
}
data
=
{
vacancy
}
/>,
);
}
...
...
assets/js/lib/Logger.jsx
View file @
4c2e619a
/* eslint-disable no-console */
// noinspection ES6ModulesDependencies,JSUnresolvedVariable
const
DEV
=
process
.
env
.
NODE_ENV
!==
'
production
'
;
export
default
class
Logger
{
static
log
(...
args
)
{
if
(
DEV
)
{
console
.
log
(...
args
);
}
}
static
warn
(...
args
)
{
if
(
DEV
)
{
console
.
warn
(...
args
);
}
}
static
error
(...
args
)
{
if
(
DEV
)
{
console
.
error
(...
args
);
}
}
static
serverError
(
error
,
callback
)
{
if
(
error
.
json
)
{
error
.
json
().
then
((
errorText
)
=>
{
Logger
.
error
(
`Error
${
errorText
}
`
);
if
(
callback
!==
undefined
)
{
callback
(
errorText
);
}
});
}
else
{
Logger
.
error
(
`Error
${
error
}
`
);
if
(
callback
!==
undefined
)
{
callback
(
error
);
}
}
}
}
global
.
Logger
=
Logger
;
/* eslint-disable no-console */
// noinspection ES6ModulesDependencies,JSUnresolvedVariable
const
DEV
=
process
.
env
.
NODE_ENV
!==
'
production
'
;
export
default
class
Logger
{
static
log
(...
args
)
{
if
(
DEV
)
{
console
.
log
(...
args
);
}
return
args
;
}
static
warn
(...
args
)
{
if
(
DEV
)
{
console
.
warn
(...
args
);
}
return
args
;
}
static
error
(...
args
)
{
if
(
DEV
)
{
console
.
error
(...
args
);
}
return
args
;
}
}
global
.
Logger
=
Logger
;
assets/js/lib/Server.jsx
View file @
4c2e619a
...
...
@@ -3,19 +3,18 @@ import Storage from './Storage';
export
default
class
Server
{
static
getCookie
(
name
)
{
let
cookieValue
=
null
;
if
(
document
.
cookie
&&
document
.
cookie
!==
''
)
{
const
cookies
=
document
.
cookie
.
split
(
'
;
'
);
for
(
let
i
=
0
;
i
<
cookies
.
length
;
i
+=
1
)
{
const
cookie
=
cookies
[
i
].
trim
();
// Does this cookie string begin with the name we want?
if
(
cookie
.
substring
(
0
,
name
.
length
+
1
)
===
(
`
${
name
}
`
))
{
cookieValue
=
decodeURIComponent
(
cookie
.
substring
(
name
.
length
+
1
));
break
;
/* istanbul ignore next */
return
decodeURIComponent
(
cookie
.
substring
(
name
.
length
+
1
))
;
}
}
}
return
cookieValue
;
return
null
;
}
static
sendRequest
(
path
,
method
,
data
,
useCache
=
false
)
{
...
...
@@ -35,6 +34,8 @@ export default class Server {
// noinspection JSUnresolvedFunction
const
request
=
fetch
(
url
,
requestData
);
/* istanbul ignore next */
const
promise
=
request
.
then
((
response
)
=>
{
// Logger.log("[Server] Calling", url, response);
if
(
response
.
status
<
200
||
response
.
status
>
399
)
{
...
...
@@ -46,6 +47,7 @@ export default class Server {
return
response
.
json
();
});
/* istanbul ignore next */
return
useCache
?
promise
.
then
((
response
)
=>
{
Logger
.
log
(
'
[Server] Response from
'
,
url
,
response
);
Storage
.
set
(
path
,
response
);
...
...
assets/js/lib/Storage.jsx
View file @
4c2e619a
/** Session Storage Polyfill */
/* eslint-disable */
var
isStorageAvailable
=
function
(
storage
)
{
if
(
typeof
storage
===
'
undefined
'
)
return
false
;
try
{
// hack for safari incognito
storage
.
setItem
(
'
storage
'
,
''
);
storage
.
getItem
(
'
storage
'
);
storage
.
removeItem
(
'
storage
'
);
return
true
;
}
catch
(
err
)
{
return
false
;
}
};
if
(
!
isStorageAvailable
(
window
.
localStorage
)
||
isStorageAvailable
(
window
.
sessionStorage
))
(
function
()
{
var
Storage
=
function
(
type
)
{
function
createCookie
(
name
,
value
,
days
)
{
var
date
,
expires
;
if
(
days
)
{
date
=
new
Date
();
date
.
setTime
(
date
.
getTime
()
+
(
days
*
24
*
60
*
60
*
1000
));
expires
=
"
; expires=
"
+
date
.
toGMTString
();
}
else
{
expires
=
""
;
}
document
.
cookie
=
name
+
"
=
"
+
value
+
expires
+
"
; path=/
"
;
}
function
readCookie
(
name
)
{
var
nameEQ
=
name
+
"
=
"
,
ca
=
document
.
cookie
.
split
(
'
;
'
),
i
,
c
;
for
(
i
=
0
;
i
<
ca
.
length
;
i
++
)
{
c
=
ca
[
i
];
while
(
c
.
charAt
(
0
)
==
'
'
)
{
c
=
c
.
substring
(
1
,
c
.
length
);
}
if
(
c
.
indexOf
(
nameEQ
)
==
0
)
{
return
c
.
substring
(
nameEQ
.
length
,
c
.
length
);
}
}
return
null
;
}
function
setData
(
data
)
{
data
=
JSON
.
stringify
(
data
);
if
(
type
==
'
session
'
)
{
window
.
name
=
data
;
}
else
{
createCookie
(
'
localStorage
'
,
data
,
365
);
}
}
function
clearData
()
{
if
(
type
==
'
session
'
)
{
window
.
name
=
''
;
}
else
{
createCookie
(
'
localStorage
'
,
''
,
365
);
}
}
function
getData
()
{
var
data
=
type
==
'
session
'
?
window
.
name
:
readCookie
(
'
localStorage
'
);
return
data
?
JSON
.
parse
(
data
)
:
{};
}
// initialise if there's already data
var
data
=
getData
();
return
{
length
:
0
,
clear
:
function
()
{
data
=
{};
this
.
length
=
0
;
clearData
();
},
getItem
:
function
(
key
)
{
return
data
[
key
]
===
undefined
?
null
:
data
[
key
];
},
key
:
function
(
i
)
{
// not perfect, but works
var
ctr
=
0
;
for
(
var
k
in
data
)
{
if
(
ctr
==
i
)
return
k
;
else
ctr
++
;
}
return
null
;
},
removeItem
:
function
(
key
)
{
if
(
data
[
key
]
===
undefined
)
this
.
length
--
;
delete
data
[
key
];
setData
(
data
);
},
setItem
:
function
(
key
,
value
)
{
if
(
data
[
key
]
===
undefined
)
this
.
length
++
;
data
[
key
]
=
value
+
''
;
// forces the value to a string
setData
(
data
);
}
};
};
if
(
!
isStorageAvailable
(
window
.
localStorage
))
window
.
localStorage
=
new
Storage
(
'
local
'
);
if
(
!
isStorageAvailable
(
window
.
sessionStorage
))
window
.
sessionStorage
=
new
Storage
(
'
session
'
);
})();
/*eslint-enable */
export
default
class
Storage
{
static
get
(
key
)
{
return
JSON
.
parse
(
sessionStorage
.
getItem
(
key
));
}
static
set
(
key
,
value
)
{
sessionStorage
.
setItem
(
key
,
JSON
.
stringify
(
value
));
}
static
clear
()
{
sessionStorage
.
clear
();
}
}
/** Session Storage Polyfill */
/* eslint-disable */
var
isStorageAvailable
=
function
(
storage
)
{
/* istanbul ignore next */
if
(
typeof
storage
===
'
undefined
'
)
return
false
;