Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
itminedu
okeanos-LoD
Commits
13986f47
Commit
13986f47
authored
Nov 06, 2015
by
Steve Laskaridis
Browse files
Merge pull request #213 from efikalti/ember-delete
Delete app/instance
parents
3c4ee220
9d428bcd
Changes
10
Show whitespace changes
Inline
Side-by-side
webapp/frontend/app/controllers/lambda-app.js
View file @
13986f47
...
...
@@ -2,6 +2,10 @@ import Ember from "ember";
export
default
Ember
.
Controller
.
extend
({
failure
:
false
,
session
:
Ember
.
inject
.
service
(
'
session
'
),
failed_delete
:
false
,
success_delete
:
false
,
message
:
''
,
actions
:
{
withdraw
:
function
()
{
...
...
@@ -21,7 +25,50 @@ export default Ember.Controller.extend({
close_alert
:
function
()
{
var
alert
=
document
.
getElementById
(
'
alert
'
);
this
.
set
(
'
failed_delete
'
,
false
);
alert
.
hidden
=
true
;
},
delete_app
:
function
(
app_id
)
{
if
(
confirm
(
"
Are you sure you want to delete this application?
"
))
{
var
_this
=
this
;
var
host
=
this
.
store
.
adapterFor
(
'
upload-app
'
).
get
(
'
host
'
),
namespace
=
this
.
store
.
adapterFor
(
'
upload-app
'
).
namespace
,
postUrl
=
[
host
,
namespace
].
join
(
'
/
'
);
postUrl
=
postUrl
+
app_id
+
'
/
'
;
const
headers
=
{};
this
.
get
(
'
session
'
).
authorize
(
'
authorizer:django
'
,
(
headerName
,
headerValue
)
=>
{
headers
[
headerName
]
=
headerValue
;
});
Ember
.
$
.
ajax
({
url
:
postUrl
,
headers
:
headers
,
method
:
'
DELETE
'
,
processData
:
false
,
contentType
:
false
,
success
:
function
(){
_this
.
store
.
unloadAll
(
'
lambda-app
'
);
_this
.
set
(
'
message
'
,
'
Your request to delete the application was successfully sent to the server.
'
);
_this
.
set
(
"
success_delete
"
,
true
);
Ember
.
run
.
later
((
function
()
{
_this
.
set
(
"
success_delete
"
,
false
);
_this
.
transitionToRoute
(
'
dashboard
'
);
}),
3000
);
},
statusCode
:
{
500
:
function
()
{
_this
.
set
(
'
failed_delete
'
,
true
);
_this
.
set
(
'
message
'
,
"
Your request to delete the application was rejected.Please try again later when the status of the instance has changed.
"
);
}
},
error
:
function
(
response
)
{
_this
.
set
(
'
failed_delete
'
,
true
);
_this
.
set
(
'
message
'
,
response
.
responseJSON
.
errors
[
0
].
detail
);
}
});
}
},
},
});
webapp/frontend/app/controllers/lambda-apps/index.js
View file @
13986f47
...
...
@@ -2,6 +2,11 @@ import Ember from 'ember';
import
pagedArray
from
'
ember-cli-pagination/computed/paged-array
'
;
export
default
Ember
.
ArrayController
.
extend
({
success_delete
:
false
,
failed_delete
:
false
,
message
:
''
,
error
:
false
,
session
:
Ember
.
inject
.
service
(
'
session
'
),
queryParams
:
[
"
page
"
,
"
perPage
"
],
page
:
1
,
...
...
@@ -21,4 +26,54 @@ export default Ember.ArrayController.extend({
pagedContent
:
pagedArray
(
'
content
'
,
{
pageBinding
:
"
page
"
,
perPageBinding
:
"
perPage
"
}),
totalPagesBinding
:
"
pagedContent.totalPages
"
,
actions
:{
delete_app
:
function
(
app_id
)
{
if
(
confirm
(
"
Are you sure you want to delete this application?
"
))
{
var
_this
=
this
;
var
host
=
this
.
store
.
adapterFor
(
'
upload-app
'
).
get
(
'
host
'
),
namespace
=
this
.
store
.
adapterFor
(
'
upload-app
'
).
namespace
,
postUrl
=
[
host
,
namespace
].
join
(
'
/
'
);
postUrl
=
postUrl
+
app_id
+
'
/
'
;
const
headers
=
{};
this
.
get
(
'
session
'
).
authorize
(
'
authorizer:django
'
,
(
headerName
,
headerValue
)
=>
{
headers
[
headerName
]
=
headerValue
;
});
Ember
.
$
.
ajax
({
url
:
postUrl
,
headers
:
headers
,
method
:
'
DELETE
'
,
processData
:
false
,
contentType
:
false
,
success
:
function
(){
_this
.
set
(
'
success_delete
'
,
true
);
_this
.
set
(
'
message
'
,
'
Your request to delete the application was successfully sent to the server.
'
);
_this
.
store
.
unloadAll
(
'
lambda-app
'
);
Ember
.
run
.
later
((
function
()
{
_this
.
set
(
"
success_delete
"
,
false
);
}),
4000
);
},
statusCode
:
{
500
:
function
()
{
_this
.
set
(
'
failed_delete
'
,
true
);
_this
.
set
(
'
message
'
,
"
Your request to delete the application was rejected.Please try again later when the status of the instance has changed.
"
);
}
},
error
:
function
(
response
)
{
_this
.
set
(
'
failed_delete
'
,
true
);
_this
.
set
(
'
message
'
,
response
.
responseJSON
.
errors
[
0
].
detail
);
}
});
}
},
close_alert
:
function
()
{
var
alert
=
document
.
getElementById
(
'
alert
'
);
alert
.
hidden
=
true
;
this
.
set
(
'
failed_delete
'
,
false
);
}
},
});
webapp/frontend/app/controllers/lambda-instance.js
View file @
13986f47
import
Ember
from
"
ember
"
;
export
default
Ember
.
Controller
.
extend
({
session
:
Ember
.
inject
.
service
(
'
session
'
),
failed_delete
:
false
,
success_delete
:
false
,
message
:
''
,
actions
:
{
close_alert
:
function
()
{
var
alert
=
document
.
getElementById
(
'
alert
'
);
alert
.
hidden
=
true
;
this
.
set
(
'
failed_delete
'
,
false
);
},
close_app_alert
:
function
()
{
...
...
@@ -29,5 +34,45 @@ export default Ember.Controller.extend({
_this
.
set
(
"
app_request
"
,
false
);
}),
3000
);
},
delete_instance
:
function
(
instance_id
)
{
if
(
confirm
(
"
Are you sure you want to delete this lambda instance?
"
))
{
var
_this
=
this
;
var
host
=
this
.
store
.
adapterFor
(
'
upload-app
'
).
get
(
'
host
'
),
postUrl
=
host
+
'
/api/lambda-instances/
'
+
instance_id
+
'
/
'
;
const
headers
=
{};
this
.
get
(
'
session
'
).
authorize
(
'
authorizer:django
'
,
(
headerName
,
headerValue
)
=>
{
headers
[
headerName
]
=
headerValue
;
});
Ember
.
$
.
ajax
({
url
:
postUrl
,
headers
:
headers
,
method
:
'
DELETE
'
,
processData
:
false
,
contentType
:
false
,
success
:
function
(){
_this
.
store
.
unloadAll
(
'
lambda-instance
'
);
_this
.
set
(
'
success_delete
'
,
true
);
_this
.
set
(
'
message
'
,
'
Your request to delete the lambda instance was successfully sent to the server.
'
);
Ember
.
run
.
later
((
function
()
{
_this
.
set
(
"
success_delete
"
,
false
);
_this
.
transitionToRoute
(
'
dashboard
'
);
}),
3000
);
},
statusCode
:
{
500
:
function
()
{
_this
.
set
(
'
failed_delete
'
,
true
);
_this
.
set
(
'
message
'
,
"
Your request to delete the instance was rejected.Please try again later when the status of the instance has changed.
"
);
}
},
error
:
function
(
response
)
{
_this
.
set
(
'
failed_delete
'
,
true
);
_this
.
set
(
'
message
'
,
response
.
responseJSON
.
errors
[
0
].
detail
);
}
});
}
},
}
});
webapp/frontend/app/controllers/lambda-instances/index.js
View file @
13986f47
...
...
@@ -2,6 +2,10 @@ import Ember from 'ember';
import
pagedArray
from
'
ember-cli-pagination/computed/paged-array
'
;
export
default
Ember
.
ArrayController
.
extend
({
success_delete
:
false
,
failed_delete
:
false
,
session
:
Ember
.
inject
.
service
(
'
session
'
),
message
:
''
,
queryParams
:
[
"
page
"
,
"
perPage
"
],
page
:
1
,
...
...
@@ -23,6 +27,7 @@ export default Ember.ArrayController.extend({
totalPagesBinding
:
"
pagedContent.totalPages
"
,
actions
:
{
start_stop
:
function
()
{
var
_this
=
this
;
...
...
@@ -30,11 +35,52 @@ export default Ember.ArrayController.extend({
_this
.
set
(
"
request
"
,
false
);
}),
4000
);
},
delete_instance
:
function
(
instance_id
)
{
if
(
confirm
(
"
Are you sure you want to delete this lambda instance?
"
))
{
var
_this
=
this
;
var
host
=
this
.
store
.
adapterFor
(
'
upload-app
'
).
get
(
'
host
'
),
postUrl
=
host
+
'
/api/lambda-instances/
'
+
instance_id
+
'
/
'
;
const
headers
=
{};
this
.
get
(
'
session
'
).
authorize
(
'
authorizer:django
'
,
(
headerName
,
headerValue
)
=>
{
headers
[
headerName
]
=
headerValue
;
});
Ember
.
$
.
ajax
({
url
:
postUrl
,
headers
:
headers
,
method
:
'
DELETE
'
,
processData
:
false
,
contentType
:
false
,
success
:
function
(){
_this
.
store
.
unloadAll
(
'
lambda-instance
'
);
_this
.
set
(
'
success_delete
'
,
true
);
_this
.
set
(
'
message
'
,
'
Your request to delete the lambda instance was successfully sent to the server.
'
);
Ember
.
run
.
later
((
function
()
{
_this
.
set
(
"
success_delete
"
,
false
);
}),
4000
);
},
statusCode
:
{
500
:
function
()
{
_this
.
set
(
'
failed_delete
'
,
true
);
_this
.
set
(
'
message
'
,
"
Your request to delete the instance was rejected.Please try again later when the status of the instance has changed.
"
);
}
},
error
:
function
(
response
)
{
_this
.
set
(
'
failed_delete
'
,
true
);
_this
.
set
(
'
message
'
,
response
.
responseJSON
.
errors
[
0
].
detail
);
}
});
}
},
close_alert
:
function
()
{
var
alert
=
document
.
getElementById
(
'
alert
'
);
alert
.
hidden
=
true
;
this
.
set
(
'
failed_delete
'
,
false
);
},
},
});
webapp/frontend/app/routes/lambda-apps/index.js
View file @
13986f47
...
...
@@ -3,13 +3,19 @@ import ENV from 'frontend/config/environment';
import
AuthenticatedRouteMixin
from
'
ember-simple-auth/mixins/authenticated-route-mixin
'
;
export
default
Ember
.
Route
.
extend
(
AuthenticatedRouteMixin
,
{
beforeModel
:
function
(
transition
)
{
this
.
_super
(
transition
);
this
.
store
.
unloadAll
(
'
lambda-app
'
);
},
model
:
function
(
params
)
{
this
.
poll
=
Ember
.
run
.
later
(
this
,
function
()
{
this
.
model
(
params
).
then
(
function
()
{
}.
bind
(
this
));
},
ENV
.
refresh_interval
);
return
this
.
store
.
findAll
(
'
lambda-app
'
,
params
);
return
this
.
store
.
findAll
(
'
lambda-app
'
,
params
,
{
reload
:
true
}
);
},
deactivate
:
function
()
{
...
...
webapp/frontend/app/routes/lambda-instances/index.js
View file @
13986f47
...
...
@@ -18,7 +18,7 @@ export default Ember.Route.extend(AuthenticatedRouteMixin, {
},
ENV
.
refresh_interval
);
var
hash
=
{
instances
:
this
.
store
.
findAll
(
'
lambda-instance
'
,
params
),
instances
:
this
.
store
.
findAll
(
'
lambda-instance
'
,
params
,
{
reload
:
true
}
),
apps
:
this
.
store
.
peekAll
(
'
lambda-app
'
),
};
if
(
this
.
store
.
peekAll
(
'
instance-action
'
).
get
(
'
length
'
)
===
0
)
{
...
...
webapp/frontend/app/templates/lambda-app.hbs
View file @
13986f47
<!-- Content Header (Page header) -->
<section
class=
"content-header"
>
<!-- Main content -->
<section
class=
"content"
>
<section
class=
"content-header"
>
<h1>
Dashboard
<small>
Lambda Application Details
</small>
</h1>
</section>
</section>
{{#if
failed_delete
}}
<div
class=
"alert alert-dismissable alert-danger"
id=
"alert"
>
<button
type=
"button"
class=
"close"
{{
action
"close_alert"
}}
>
×
</button>
{{
message
}}
</div>
{{/if}}
{{#if
success_delete
}}
<div
class=
"alert alert-dismissable alert-success"
id=
"alert"
>
<button
type=
"button"
class=
"close"
{{
action
"close_alert"
}}
>
×
</button>
{{
message
}}
</div>
{{/if}}
<!-- Main content -->
<section
class=
"content"
>
<!-- TOP DATA -->
<div
class=
"row"
>
<div
class=
"col-xs-12"
>
...
...
@@ -20,6 +35,7 @@
<small>
ID:
{{
model
.
application
.
id
}}
</small>
</div>
</div>
<!-- /.box-header -->
<div
class=
"box-body"
>
<div
class=
"row "
>
...
...
@@ -34,8 +50,7 @@
actions you may take depending on the
<i>
status
</i>
of the Application.
</div>
<a
href=
"delete-application.html"
class=
"btn btn-danger pull-right"
style=
"margin-right: 15px;"
><i
class=
"fa fa-close"
></i>
Delete
</a>
<button
name=
"del-btn"
id=
"del-btn"
class=
"btn btn-danger btn-primary pull-right"
{{
action
"delete_app"
model
.
application
.
id
}}
>
Delete
</button>
{{#if
(
compare
model
.
application
.
status_code
'=='
'0'
)
}}
{{#
link-to
'deploy-app-1'
model
.
application
.
id
}}
<button
class=
"btn btn-primary pull-right"
...
...
webapp/frontend/app/templates/lambda-apps/index.hbs
View file @
13986f47
...
...
@@ -45,6 +45,20 @@
</div>
<!--col-xs-12-->
</div>
{{#if
failed_delete
}}
<div
class=
"alert alert-dismissable alert-danger"
id=
"alert"
>
<button
type=
"button"
class=
"close"
{{
action
"close_alert"
}}
>
×
</button>
{{
message
}}
</div>
{{/if}}
{{#if
success_delete
}}
<div
class=
"alert alert-dismissable alert-success"
id=
"alert"
>
<button
type=
"button"
class=
"close"
{{
action
"close_alert"
}}
>
×
</button>
{{
message
}}
</div>
{{/if}}
<div
class=
"row"
>
<div
class=
"col-xs-12"
>
<div
class=
"box"
>
...
...
@@ -93,13 +107,13 @@
<td>
{{
lambda-application
.
status_detail
}}
</td>
<td>
{{
lower-case
lambda-application
.
app_type
}}
</td>
<td>
<button
name=
"del-btn"
id=
"del-btn"
class=
"btn btn-danger btn-xs"
{{
action
"delete_app"
lambda-application
.
id
}}
>
Delete
</button>
</td>
<td>
{{#
link-to
'lambda-app'
lambda-application
.
id
}}
<button
class=
"btn btn-info btn-xs"
><i
class=
"fa fa-file-code-o"
></i>
Details
</button>
{{/
link-to
}}
</td>
<td>
{{
delete-lambda-app
lambdaApp
=
lambda-application
}}
</td>
<td>
{{#if
(
compare
lambda-application
.
status_code
'=='
'0'
)
}}
...
...
webapp/frontend/app/templates/lambda-instance.hbs
View file @
13986f47
...
...
@@ -23,6 +23,18 @@
{{
message
}}
</div>
{{/if}}
{{#if
failed_delete
}}
<div
class=
"alert alert-dismissable alert-danger"
id=
"alert"
>
<button
type=
"button"
class=
"close"
{{
action
"close_alert"
}}
>
×
</button>
{{
message
}}
</div>
{{/if}}
{{#if
success_delete
}}
<div
class=
"alert alert-dismissable alert-success"
id=
"alert"
>
<button
type=
"button"
class=
"close"
{{
action
"close_alert"
}}
>
×
</button>
{{
message
}}
</div>
{{/if}}
<!-- TOP DATA -->
<div
class=
"row"
>
...
...
@@ -45,7 +57,8 @@
actions you may take depending on the
<i>
status
</i>
of the lambda instance.
</div>
<a
href=
"delete-instance.html"
class=
"btn btn-danger pull-right"
style=
"margin-right: 15px;"
><i
class=
"fa fa-close"
></i>
Delete
</a>
<button
name=
"del-btn"
id=
"del-btn"
class=
"btn btn-danger btn-primary pull-right"
{{
action
"delete_instance"
model
.
instance
.
id
}}
>
Delete
</button>
{{#if
(
compare
model
.
instance
.
status_code
'=='
'0'
)
}}
{{#
link-to
'deploy-app-2'
model
.
instance
.
id
}}
<button
class=
"btn btn-primary pull-right"
...
...
webapp/frontend/app/templates/lambda-instances/index.hbs
View file @
13986f47
...
...
@@ -59,6 +59,20 @@
{{
message
}}
</div>
{{/if}}
{{#if
failed_delete
}}
<div
class=
"alert alert-dismissable alert-danger"
id=
"alert"
>
<button
type=
"button"
class=
"close"
{{
action
"close_alert"
}}
>
×
</button>
{{
message
}}
</div>
{{/if}}
{{#if
success_delete
}}
<div
class=
"alert alert-dismissable alert-success"
id=
"alert"
>
<button
type=
"button"
class=
"close"
{{
action
"close_alert"
}}
>
×
</button>
{{
message
}}
</div>
{{/if}}
<div
class=
"row"
>
<div
class=
"col-xs-12"
>
...
...
@@ -112,7 +126,9 @@
<a
class=
"btn btn-info btn-xs"
title=
"View Details"
alt=
"View Details"
><i
class=
"fa fa-file-code-o"
></i>
Details
</a>
{{/
link-to
}}
</td>
<td>
{{
delete-lambda-instance
lambdaInstance
=
lambda-instance
}}
</td>
<td>
<button
name=
"del-btn"
id=
"del-btn"
class=
"btn btn-danger btn-xs"
{{
action
"delete_instance"
lambda-instance
.
id
}}
>
Delete
</button>
</td>
{{#if
(
compare
lambda-instance
.
status_code
'=='
'0'
)
}}
{{#
tool-tip
}}
<td>
...
...
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