Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
17
Merge Requests
17
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
nexedi
slapos.core
Commits
e5ff2cc2
Commit
e5ff2cc2
authored
May 03, 2012
by
Thomas Lechauve
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Authentication added when send request to REST API
parent
d0b7358f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
136 additions
and
118 deletions
+136
-118
jQuery/static/js/slapOs.js
jQuery/static/js/slapOs.js
+136
-118
No files found.
jQuery/static/js/slapOs.js
View file @
e5ff2cc2
;(
function
(
$
)
{
;(
function
(
$
)
{
var
methods
=
{
var
methods
=
{
defaults
:
{
init
:
function
(
options
){
host
:
''
var
settings
=
$
.
extend
({
},
'
host
'
:
''
,
'
access_token
'
:
''
,
init
:
function
(
options
){
'
clientID
'
:
''
var
settings
=
$
.
extend
({
},
options
);
'
host
'
:
''
},
options
);
return
this
.
each
(
function
(){
return
this
.
each
(
function
(){
methods
[
'
store
'
]
=
Modernizr
.
localstorage
?
methods
.
lStore
:
methods
.
cStore
;
methods
[
'
store
'
]
=
Modernizr
.
localstorage
?
methods
.
lStore
:
methods
.
cStore
;
$
(
this
).
slapos
(
'
store
'
,
'
host
'
,
settings
.
host
);
for
(
var
setting
in
settings
){
});
$
(
this
).
slapos
(
'
store
'
,
setting
,
settings
[
setting
]);
},
}
});
/* Local storage method */
},
lStore
:
function
(
name
,
value
){
if
(
Modernizr
.
localstorage
)
return
value
==
undefined
?
window
.
localStorage
[
name
]
:
window
.
localStorage
[
name
]
=
value
;
return
false
;
},
/* Cookie storage method */
cStore
:
function
(
name
,
value
){
if
(
value
!=
undefined
){
document
.
cookie
=
name
+
"
=
"
+
value
+
"
;domain=
"
+
window
.
location
.
hostname
+
"
;path=
"
+
window
.
location
.
pathname
;
}
else
{
var
i
,
x
,
y
,
cookies
=
document
.
cookie
.
split
(
'
;
'
);
for
(
i
=
0
;
i
<
cookies
.
length
;
i
++
){
x
=
cookies
[
i
].
substr
(
0
,
cookies
[
i
].
indexOf
(
'
=
'
));
y
=
cookies
[
i
].
substr
(
cookies
[
i
].
indexOf
(
'
=
'
)
+
1
);
x
=
x
.
replace
(
/^
\s
+|
\s
+$/g
,
""
);
if
(
x
==
name
)
return
unescape
(
y
);
}
}
},
statusDefault
:
function
(){
/* Getters & Setters shortcuts */
return
{
access_token
:
function
(
value
){
0
:
function
(){
console
.
error
(
"
status error code: 0
"
);
},
return
$
(
this
).
slapos
(
'
store
'
,
'
access_token
'
,
value
);
404
:
function
(){
console
.
error
(
"
status error code: Not Found !
"
);
}
},
}
host
:
function
(
value
){
},
return
$
(
this
).
slapos
(
'
store
'
,
'
host
'
,
value
);
},
request
:
function
(
type
,
url
,
callback
,
statusEvent
,
data
){
clientID
:
function
(
value
){
data
=
data
||
''
;
return
$
(
this
).
slapos
(
'
store
'
,
'
clientID
'
,
value
);
statusEvent
=
statusEvent
||
this
.
statusDefault
;
},
return
this
.
each
(
function
(){
$
.
ajax
({
/* Local storage method */
url
:
methods
.
store
(
'
host
'
)
+
url
,
lStore
:
function
(
name
,
value
)
{
dataType
:
'
json
'
,
if
(
Modernizr
.
localstorage
)
data
:
data
,
return
value
==
undefined
?
window
.
localStorage
[
name
]
:
window
.
localStorage
[
name
]
=
value
;
context
:
$
(
this
),
return
false
;
type
:
type
,
},
statusCode
:
statusEvent
,
success
:
callback
/* Cookie storage method */
});
cStore
:
function
(
name
,
value
){
});
if
(
value
!=
undefined
){
},
document
.
cookie
=
name
+
"
=
"
+
value
+
"
;domain=
"
+
window
.
location
.
hostname
+
"
;path=
"
+
window
.
location
.
pathname
;
}
else
{
newInstance
:
function
(
data
,
callback
,
statusEvent
){
var
i
,
x
,
y
,
cookies
=
document
.
cookie
.
split
(
'
;
'
);
return
$
(
this
).
slapos
(
'
request
'
,
'
POST
'
,
'
/request
'
,
callback
,
statusEvent
,
data
);
for
(
i
=
0
;
i
<
cookies
.
length
;
i
++
){
},
x
=
cookies
[
i
].
substr
(
0
,
cookies
[
i
].
indexOf
(
'
=
'
));
y
=
cookies
[
i
].
substr
(
cookies
[
i
].
indexOf
(
'
=
'
)
+
1
);
deleteInstance
:
function
(
id
,
callback
,
statusEvent
){
x
=
x
.
replace
(
/^
\s
+|
\s
+$/g
,
""
);
return
$
(
this
).
slapos
(
'
request
'
,
'
DELETE
'
,
'
/instance/
'
+
id
,
callback
,
statusEvent
);
if
(
x
==
name
)
return
unescape
(
y
);
},
}
}
getInstance
:
function
(
id
,
callback
,
statusEvent
){
},
return
$
(
this
).
slapos
(
'
request
'
,
'
GET
'
,
'
/instance/
'
+
id
,
callback
,
statusEvent
);
},
statusDefault
:
function
(){
return
{
getInstanceCert
:
function
(
id
,
callback
,
statusEvent
){
0
:
function
(){
console
.
error
(
"
status error code: 0
"
);
},
return
$
(
this
).
slapos
(
'
request
'
,
'
GET
'
,
'
/instance/
'
+
id
+
'
/certificate
'
,
callback
,
statusEvent
);
404
:
function
(){
console
.
error
(
"
status error code: Not Found !
"
);
}
},
}
},
bangInstance
:
function
(
id
,
log
,
callback
,
statusEvent
){
return
$
(
this
).
slapos
(
'
request
'
,
'
POST
'
,
'
/instance/
'
+
id
+
'
/bang
'
,
callback
,
statusEvent
,
log
);
request
:
function
(
type
,
url
,
callback
,
statusEvent
,
data
)
{
},
data
=
data
||
''
;
statusEvent
=
statusEvent
||
this
.
statusDefault
;
editInstance
:
function
(
id
,
data
,
callback
,
statusEvent
){
return
this
.
each
(
function
(){
return
$
(
this
).
slapos
(
'
request
'
,
'
PUT
'
,
'
/instance/
'
+
id
,
callback
,
statusEvent
,
data
);
$
.
ajax
({
},
url
:
"
http://
"
+
$
(
this
).
slapos
(
'
host
'
)
+
url
,
type
:
type
,
newComputer
:
function
(
data
,
callback
,
statusEvent
){
contentType
:
'
application/octet-stream
'
,
return
$
(
this
).
slapos
(
'
request
'
,
'
POST
'
,
'
/computer
'
,
callback
,
statusEvent
,
data
);
data
:
JSON
.
stringify
(
data
),
},
dataType
:
'
json
'
,
context
:
$
(
this
),
getComputer
:
function
(
id
,
callback
,
statusEvent
){
beforeSend
:
function
(
xhr
){
return
$
(
this
).
slapos
(
'
request
'
,
'
GET
'
,
'
/computer/
'
+
id
,
callback
,
statusEvent
);
if
(
$
(
this
).
slapos
(
"
access_token
"
)
)
{
},
xhr
.
setRequestHeader
(
"
Authorization
"
,
$
(
this
).
slapos
(
"
store
"
,
"
token_type
"
)
+
"
"
+
$
(
this
).
slapos
(
"
access_token
"
));
xhr
.
setRequestHeader
(
"
Accept
"
,
"
application/json
"
);
editComputer
:
function
(
id
,
data
,
callback
,
statusEvent
){
}
return
$
(
this
).
slapos
(
'
request
'
,
'
PUT
'
,
'
/computer/
'
+
id
,
callback
,
statusEvent
,
data
);
},
},
statusCode
:
statusEvent
,
success
:
callback
newSoftware
:
function
(
computerId
,
data
,
callback
,
statusEvent
){
});
return
$
(
this
).
slapos
(
'
request
'
,
'
POST
'
,
'
/computer/
'
+
computerId
+
'
/supply
'
,
callback
,
statusEvent
,
data
);
});
},
},
bangComputer
:
function
(
id
,
log
,
callback
,
statusEvent
){
newInstance
:
function
(
data
,
callback
,
statusEvent
){
return
$
(
this
).
slapos
(
'
request
'
,
'
POST
'
,
'
/computer/
'
+
id
+
'
/bang
'
,
callback
,
statusEvent
,
log
);
return
$
(
this
).
slapos
(
'
request
'
,
'
POST
'
,
'
/instance
'
,
callback
,
statusEvent
,
data
);
},
},
computerReport
:
function
(
id
,
data
,
callback
,
statusEvent
){
deleteInstance
:
function
(
id
,
callback
,
statusEvent
){
return
$
(
this
).
slapos
(
'
request
'
,
'
POST
'
,
'
/computer/
'
+
id
+
'
/report
'
,
callback
,
statusEvent
,
data
);
return
$
(
this
).
slapos
(
'
request
'
,
'
DELETE
'
,
'
/instance/
'
+
id
,
callback
,
statusEvent
);
}
},
};
getInstance
:
function
(
id
,
callback
,
statusEvent
){
$
.
fn
.
slapos
=
function
(
method
){
return
$
(
this
).
slapos
(
'
request
'
,
'
GET
'
,
'
/instance/
'
+
id
,
callback
,
statusEvent
);
if
(
methods
[
method
]
)
{
},
return
methods
[
method
].
apply
(
this
,
Array
.
prototype
.
slice
.
call
(
arguments
,
1
));
}
else
if
(
typeof
method
===
'
object
'
||
!
method
)
{
getInstanceCert
:
function
(
id
,
callback
,
statusEvent
){
return
methods
.
init
.
apply
(
this
,
arguments
);
return
$
(
this
).
slapos
(
'
request
'
,
'
GET
'
,
'
/instance/
'
+
id
+
'
/certificate
'
,
callback
,
statusEvent
);
}
else
{
},
$
.
error
(
'
Method
'
+
method
+
'
does not exist on jQuery.slapos
'
);
}
bangInstance
:
function
(
id
,
log
,
callback
,
statusEvent
){
};
return
$
(
this
).
slapos
(
'
request
'
,
'
POST
'
,
'
/instance/
'
+
id
+
'
/bang
'
,
callback
,
statusEvent
,
log
);
})(
jQuery
);
},
\ No newline at end of file
editInstance
:
function
(
id
,
data
,
callback
,
statusEvent
){
return
$
(
this
).
slapos
(
'
request
'
,
'
PUT
'
,
'
/instance/
'
+
id
,
callback
,
statusEvent
,
data
);
},
newComputer
:
function
(
data
,
callback
,
statusEvent
){
return
$
(
this
).
slapos
(
'
request
'
,
'
POST
'
,
'
/computer
'
,
callback
,
statusEvent
,
data
);
},
getComputer
:
function
(
id
,
callback
,
statusEvent
){
return
$
(
this
).
slapos
(
'
request
'
,
'
GET
'
,
'
/computer/
'
+
id
,
callback
,
statusEvent
);
},
editComputer
:
function
(
id
,
data
,
callback
,
statusEvent
){
return
$
(
this
).
slapos
(
'
request
'
,
'
PUT
'
,
'
/computer/
'
+
id
,
callback
,
statusEvent
,
data
);
},
newSoftware
:
function
(
computerId
,
data
,
callback
,
statusEvent
){
return
$
(
this
).
slapos
(
'
request
'
,
'
POST
'
,
'
/computer/
'
+
computerId
+
'
/supply
'
,
callback
,
statusEvent
,
data
);
},
bangComputer
:
function
(
id
,
log
,
callback
,
statusEvent
){
return
$
(
this
).
slapos
(
'
request
'
,
'
POST
'
,
'
/computer/
'
+
id
+
'
/bang
'
,
callback
,
statusEvent
,
log
);
},
computerReport
:
function
(
id
,
data
,
callback
,
statusEvent
){
return
$
(
this
).
slapos
(
'
request
'
,
'
POST
'
,
'
/computer/
'
+
id
+
'
/report
'
,
callback
,
statusEvent
,
data
);
}
};
$
.
fn
.
slapos
=
function
(
method
){
if
(
methods
[
method
]
)
{
return
methods
[
method
].
apply
(
this
,
Array
.
prototype
.
slice
.
call
(
arguments
,
1
));
}
else
if
(
typeof
method
===
'
object
'
||
!
method
)
{
return
methods
.
init
.
apply
(
this
,
arguments
);
}
else
{
$
.
error
(
'
Method
'
+
method
+
'
does not exist on jQuery.slapos
'
);
}
};
})(
jQuery
);
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