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
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Romain Courteaud
slapos.core
Commits
03cfb3d1
Commit
03cfb3d1
authored
May 23, 2012
by
Thomas Lechauve
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
New feature: Bang an instance
parent
abb1aea3
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
108 additions
and
16 deletions
+108
-16
jquery.slapos/src/jquery.slapos.js
jquery.slapos/src/jquery.slapos.js
+14
-3
vifib/index.html
vifib/index.html
+18
-7
vifib/static/js/core.js
vifib/static/js/core.js
+68
-3
vifib/static/js/jquery.slapos.js
vifib/static/js/jquery.slapos.js
+5
-0
vifib/static/js/urlHandler.js
vifib/static/js/urlHandler.js
+3
-3
No files found.
jquery.slapos/src/jquery.slapos.js
View file @
03cfb3d1
...
...
@@ -100,7 +100,9 @@
return
this
.
each
(
function
()
{
$
(
this
).
slapos
(
'
discovery
'
,
function
(
access
)
{
if
(
access
.
hasOwnProperty
(
methodName
))
{
var
url
=
args
.
url
||
access
[
methodName
].
url
;
var
url
=
access
[
methodName
].
url
.
replace
(
/{
(\w
+
)
}/
,
function
(
matchedText
,
$1
)
{
return
""
+
args
[
$1
]
});
$
.
extend
(
args
,
{
'
url
'
:
url
});
$this
.
slapos
(
'
request
'
,
access
[
methodName
].
method
,
...
...
@@ -129,13 +131,22 @@
},
instanceInfo
:
function
(
url
,
args
)
{
url
=
decodeURIComponent
(
url
);
$
.
extend
(
args
,
{
'
url
'
:
url
});
$
.
extend
(
args
,
{
'
instance_url
'
:
decodeURIComponent
(
url
)});
return
$
(
this
).
slapos
(
'
prepareRequest
'
,
'
instance_info
'
,
args
);
},
instanceRequest
:
function
(
args
)
{
return
$
(
this
).
slapos
(
'
prepareRequest
'
,
'
request_instance
'
,
args
);
},
instanceBang
:
function
(
url
,
args
)
{
$
.
extend
(
args
,
{
'
instance_url
'
:
decodeURIComponent
(
url
)});
return
$
(
this
).
slapos
(
'
prepareRequest
'
,
'
instance_bang
'
,
args
);
},
instanceCertificate
:
function
(
url
,
args
)
{
$
.
extend
(
args
,
{
'
instance_url
'
:
decodeURIComponent
(
url
)});
return
$
(
this
).
slapos
(
'
prepareRequest
'
,
'
instance_certificate
'
,
args
);
}
};
...
...
vifib/index.html
View file @
03cfb3d1
...
...
@@ -39,6 +39,15 @@
<
/article
>
</script>
<script
id=
"form.bang.instance"
type=
"text/html"
>
<
form
class
=
"
form-horizontal
"
id
=
"
form-bang
"
>
<
label
>
Why
do
you
want
to
bang
this
instance
?
<
/label
>
<
input
class
=
"
input-large
"
name
=
"
log
"
type
=
"
text
"
>
<
button
class
=
"
btn btn-primary
"
type
=
"
submit
"
name
=
"
submit
"
>
Bang
<
/button
>
<
button
class
=
"
btn
"
>
Cancel
<
/button
>
<
/form
>
</script>
<script
id=
"form.new.instance"
type=
"text/html"
>
<
article
>
<
form
class
=
"
form-horizontal
"
>
...
...
@@ -51,7 +60,7 @@
<
/div
>
<
/div
>
<
div
class
=
"
control-group
"
>
<
label
class
=
"
control-label
"
>
Software
release
<
/label
>
>
<
label
class
=
"
control-label
"
>
Software
release
<
/label
>
<
div
class
=
"
controls
"
>
<
input
type
=
"
text
"
class
=
"
input-xlarge
"
required
name
=
"
software_release
"
/>
<
/div
>
...
...
@@ -73,15 +82,17 @@
<script
id=
"instance"
type=
"text/html"
>
{{
!
Service
page
template
}}
<
article
>
<
div
class
=
"
subnav
"
>
<
ul
class
=
"
nav nav-pills
"
>
{{
#
actions
}}
<
li
><
a
href
=
"
{{ url }}
"
>
{{
name
}}
<
/a></
li
>
{{
/
actions
}}
<
/ul
>
<
/div
>
<
form
class
=
"
form-horizontal
"
id
=
"
instance-form
"
>
<
fieldset
>
<
legend
>
{{
title
}}
<
div
class
=
"
pull-right
"
>
<
div
class
=
"
btn
"
>
Bang
<
/div
>
<
div
class
=
"
btn
"
>
Destroy
<
/div
>
<
/div
>
<
/legend
>
<
div
class
=
"
control-group
"
>
<
label
class
=
"
control-label
"
>
Reference
<
/label
>
...
...
@@ -133,7 +144,6 @@
<
/textarea
>
<
/fieldset
>
<
/form
>
<
/article
>
</script>
<script
id=
"instance.stop_requested"
type=
"text/html"
>
...
...
@@ -229,6 +239,7 @@
<script
type=
"text/javascript"
src=
"static/js/jquery-1.7.2.js"
></script>
<script
type=
"text/javascript"
src=
"static/js/bootstrap-alert.js"
></script>
<script
type=
"text/javascript"
src=
"static/js/bootstrap-modal.js"
></script>
<script
type=
"text/javascript"
src=
"static/js/spin.js"
></script>
<script
type=
"text/javascript"
src=
"static/js/jquery-spin.js"
></script>
<script
type=
"text/javascript"
src=
"static/js/ICanHaz.min.js"
></script>
...
...
vifib/static/js/core.js
View file @
03cfb3d1
...
...
@@ -8,6 +8,7 @@
var
routes
=
{
'
/instance
'
:
'
requestInstance
'
,
'
/instance/:url
'
:
'
showInstance
'
,
'
/instance/:url/bang
'
:
'
showBangInstance
'
,
'
/computers
'
:
'
listComputers
'
,
'
/instances
'
:
'
listInstances
'
,
'
/invoices
'
:
'
listInvoices
'
...
...
@@ -25,6 +26,21 @@
});
},
/* Based on ben alman code
* https://raw.github.com/cowboy/jquery-misc/master/jquery.ba-serializeobject.js
*/
serializeObject
=
function
()
{
var
obj
=
{};
$
.
each
(
$
(
this
).
serializeArray
(),
function
(
i
,
o
)
{
var
k
=
o
.
name
,
v
=
o
.
value
;
obj
[
k
]
=
obj
[
k
]
===
undefined
?
v
:
$
.
isArray
(
obj
[
k
])
?
obj
[
k
].
concat
(
v
)
:
[
obj
[
k
],
v
];
});
return
obj
;
},
getDate
=
function
()
{
var
today
=
new
Date
();
return
[
today
.
getFullYear
(),
today
.
getMonth
(),
today
.
getDay
()].
join
(
'
/
'
)
+
...
...
@@ -100,7 +116,7 @@
},
genInstanceUrl
:
function
(
uri
)
{
return
location
.
href
.
split
(
'
#
'
)[
0
]
+
'
#/instance/
'
+
encodeURIComponent
(
uri
);
return
$
.
genHash
([
'
instance
'
,
encodeURIComponent
(
uri
)]
);
},
extractInstanceURIFromHref
:
function
()
{
...
...
@@ -108,7 +124,13 @@
},
extractInstanceURIFromHashtag
:
function
()
{
return
decodeURIComponent
(
window
.
location
.
hash
.
split
(
'
/
'
).
pop
());
var
loc
=
window
.
location
.
hash
.
split
(
'
/
'
),
i
=
$
.
inArray
(
"
instance
"
,
loc
);
return
(
i
!==
-
1
&&
loc
.
length
>
i
)
?
decodeURIComponent
(
loc
[
i
+
1
])
:
""
;
},
genBangUrl
:
function
(
uri
)
{
return
$
.
genHash
([
"
instance
"
,
encodeURIComponent
(
uri
),
"
bang
"
]);
},
authenticate
:
function
(
data
)
{
...
...
@@ -143,6 +165,9 @@
$
(
this
).
slapos
(
'
instanceInfo
'
,
uri
,
{
success
:
function
(
infos
)
{
infos
.
status
=
$
(
this
).
vifib
(
'
getRender
'
,
'
instance.
'
+
infos
.
status
);
infos
.
actions
=
[
{
name
:
"
Bang
"
,
url
:
methods
.
genBangUrl
(
decodeURIComponent
(
uri
))}
];
$
(
this
).
vifib
(
'
render
'
,
'
instance
'
,
infos
);
var
form
=
$
(
this
).
find
(
"
#instance-form
"
);
form
.
vifib
(
'
prepareForm
'
);
...
...
@@ -158,6 +183,7 @@
prepareForm
:
function
()
{
$
(
this
).
vifib
(
'
bindStopStartButtons
'
);
$
(
"
#bangInstance
"
).
click
();
$
(
this
).
vifib
(
'
refresh
'
,
methods
.
refreshInstanceForm
,
30
);
},
...
...
@@ -185,6 +211,31 @@
return
false
;
},
showBangInstance
:
function
()
{
var
statusCode
=
{
400
:
bad_request
,
401
:
redirect
,
402
:
payment
,
404
:
notFound
,
500
:
serverError
,
};
return
this
.
each
(
function
()
{
$
(
this
).
vifib
(
"
render
"
,
'
form.bang.instance
'
);
$
(
this
).
find
(
"
#form-bang
"
).
submit
(
function
()
{
var
data
=
$
(
this
).
serializeObject
(),
uri
=
methods
.
extractInstanceURIFromHashtag
();
$
(
this
).
slapos
(
'
instanceBang
'
,
uri
,
{
data
:
data
,
statusCode
:
statusCode
,
success
:
function
()
{
$
.
redirect
([
'
instance
'
,
encodeURIComponent
(
uri
)]);
}
});
return
false
;
});
});
},
changeStatusInstance
:
function
(
status
)
{
var
uri
=
methods
.
extractInstanceURIFromHashtag
(),
data
=
$
(
this
).
vifib
(
'
extractInstanceInfo
'
);
...
...
@@ -325,7 +376,6 @@
popup
:
function
(
message
,
state
)
{
state
=
state
||
'
error
'
;
console
.
log
(
$
(
this
));
return
this
.
each
(
function
()
{
$
(
this
).
prepend
(
ich
.
error
({
'
message
'
:
message
,
...
...
@@ -363,6 +413,21 @@
$
.
error
(
'
Method
'
+
method
+
'
does not exist on jQuery.vifib
'
);
}
};
/* Thanks to Ben Alman
* https://raw.github.com/cowboy/jquery-misc/master/jquery.ba-serializeobject.js
*/
$
.
fn
.
serializeObject
=
function
(){
var
obj
=
{};
$
.
each
(
this
.
serializeArray
(),
function
(
i
,
o
){
var
n
=
o
.
name
,
v
=
o
.
value
;
obj
[
n
]
=
obj
[
n
]
===
undefined
?
v
:
$
.
isArray
(
obj
[
n
]
)
?
obj
[
n
].
concat
(
v
)
:
[
obj
[
n
],
v
];
});
return
obj
;
};
})(
jQuery
);
$
(
'
#main
'
).
vifib
();
vifib/static/js/jquery.slapos.js
View file @
03cfb3d1
...
...
@@ -139,6 +139,11 @@
return
$
(
this
).
slapos
(
'
prepareRequest
'
,
'
request_instance
'
,
args
);
},
instanceBang
:
function
(
url
,
args
)
{
$
.
extend
(
args
,
{
'
instance_url
'
:
decodeURIComponent
(
url
)});
return
$
(
this
).
slapos
(
'
prepareRequest
'
,
'
instance_bang
'
,
args
);
},
instanceCertificate
:
function
(
url
,
args
)
{
$
.
extend
(
args
,
{
'
instance_url
'
:
decodeURIComponent
(
url
)});
return
$
(
this
).
slapos
(
'
prepareRequest
'
,
'
instance_certificate
'
,
args
);
...
...
vifib/static/js/urlHandler.js
View file @
03cfb3d1
...
...
@@ -34,7 +34,7 @@ $.extractAuth = function (hashTag) {
};
$
.
genHash
=
function
(
url
)
{
return
'
/
'
+
url
.
join
(
'
/
'
);
return
'
#
/
'
+
url
.
join
(
'
/
'
);
};
/* Pub / Sub Pattern
...
...
@@ -55,10 +55,10 @@ $.publish = function() {
// Event Handlers
$
.
hashHandler
=
function
(){
$
.
publish
(
'
urlChange
'
,
$
.
parseHash
(
window
.
location
.
hash
.
substr
(
1
)));
};
$
.
redirectHandler
=
function
(
e
,
url
){
window
.
location
.
hash
=
$
.
genHash
(
[
url
]
);
};
$
.
redirectHandler
=
function
(
e
,
url
){
window
.
location
.
hash
=
$
.
genHash
(
url
);
};
// redirections manager
$
.
redirect
=
function
(
url
){
$
.
publish
(
'
redirect
'
,
url
);
};
$
.
redirect
=
function
(
url
){
$
.
publish
(
'
redirect
'
,
[
url
]
);
};
$
.
subscribe
(
'
redirect
'
,
$
.
redirectHandler
)
$
(
window
).
bind
(
'
hashchange
'
,
$
.
hashHandler
);
...
...
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