Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
openfaas-faas
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Team Jaz CS 598 CCC Final Project
openfaas-faas
Commits
e6eec64c
Commit
e6eec64c
authored
7 years ago
by
Alex Ellis
Browse files
Options
Downloads
Patches
Plain Diff
UI: allow binary download
Signed-off-by:
Alex Ellis
<
alexellis2@gmail.com
>
parent
5c8bb37b
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
gateway/assets/index.html
+2
-2
2 additions, 2 deletions
gateway/assets/index.html
gateway/assets/script/bootstrap.js
+51
-28
51 additions, 28 deletions
gateway/assets/script/bootstrap.js
with
53 additions
and
30 deletions
gateway/assets/index.html
+
2
−
2
View file @
e6eec64c
...
...
@@ -133,10 +133,10 @@
<div
layout-gt-sm=
"row"
>
<md-input-container
class=
"md-block"
flex-gt-sm
>
<md-radio-group
ng-model=
"invocation.contentType"
>
<md-radio-group
ng-model=
"invocation.contentType"
layout=
"row"
layout-align=
"start center"
>
<md-radio-button
value=
"text"
class=
"md-primary"
>
Text
</md-radio-button>
<md-radio-button
value=
"json"
>
JSON
</md-radio-button>
<md-radio-button
value=
"binary"
>
Binary
</md-radio-button>
<md-radio-button
value=
"binary"
>
Download
</md-radio-button>
</md-radio-group>
</md-input-container>
</div>
...
...
This diff is collapsed.
Click to expand it.
gateway/assets/script/bootstrap.js
+
51
−
28
View file @
e6eec64c
...
...
@@ -27,7 +27,8 @@ app.controller("home", ['$scope', '$log', '$http', '$location', '$timeout', '$md
envProcess
:
""
,
network
:
""
,
service
:
""
,
envVars
:
{}
envVars
:
{},
labels
:
{}
};
$scope
.
invocation
.
request
=
""
;
...
...
@@ -56,7 +57,7 @@ app.controller("home", ['$scope', '$log', '$http', '$location', '$timeout', '$md
data
:
$scope
.
invocation
.
request
,
method
:
"
POST
"
,
headers
:
{
"
Content-Type
"
:
requestContentType
},
responseType
:
$scope
.
invocation
.
contentType
responseType
:
$scope
.
invocation
.
contentType
==
"
binary
"
?
"
arraybuffer
"
:
$scope
.
invocation
.
contentType
};
$scope
.
invocationInProgress
=
true
;
...
...
@@ -65,44 +66,64 @@ app.controller("home", ['$scope', '$log', '$http', '$location', '$timeout', '$md
$scope
.
roundTripDuration
=
""
;
$scope
.
invocationStart
=
new
Date
().
getTime
()
var
tryDownload
=
function
(
data
,
filename
)
{
var
caught
;
var
linkElement
=
document
.
createElement
(
'
a
'
);
try
{
var
blob
=
new
Blob
([
data
],
{
type
:
"
binary/octet-stream
"
});
var
url
=
window
.
URL
.
createObjectURL
(
blob
);
linkElement
.
setAttribute
(
'
href
'
,
url
);
linkElement
.
setAttribute
(
"
download
"
,
filename
);
var
clickEvent
=
new
MouseEvent
(
"
click
"
,
{
"
view
"
:
window
,
"
bubbles
"
:
true
,
"
cancelable
"
:
false
});
linkElement
.
dispatchEvent
(
clickEvent
);
}
catch
(
ex
)
{
caught
=
ex
;
}
return
caught
;
}
$http
(
options
)
.
success
(
function
(
data
,
status
,
headers
)
{
console
.
log
(
headers
());
var
headerMap
=
headers
();
if
(
$scope
.
invocation
.
contentType
==
"
binary
"
)
{
$scope
.
invocationResponse
=
"
Bytes received:
"
+
data
.
length
;
var
linkElement
=
document
.
createElement
(
'
a
'
);
try
{
var
blob
=
new
Blob
([
data
],
{
type
:
"
binary/octet-stream
"
});
var
url
=
window
.
URL
.
createObjectURL
(
blob
);
var
filename
=
uuidv4
();
linkElement
.
setAttribute
(
'
href
'
,
url
);
linkElement
.
setAttribute
(
"
download
"
,
filename
);
var
clickEvent
=
new
MouseEvent
(
"
click
"
,
{
"
view
"
:
window
,
"
bubbles
"
:
true
,
"
cancelable
"
:
false
});
linkElement
.
dispatchEvent
(
clickEvent
);
}
catch
(
ex
)
{
console
.
log
(
ex
);
$scope
.
invocationResponse
=
ex
;
var
filename
=
uuidv4
();
if
(
$scope
.
selectedFunction
.
labels
)
{
var
ext
=
$scope
.
selectedFunction
.
labels
[
"
com.openfaas.ui.ext
"
];
if
(
ext
&&
ext
.
length
>
0
)
{
filename
=
filename
+
""
+
ext
;
}
}
var
caught
=
tryDownload
(
data
,
filename
);
if
(
caught
)
{
console
.
log
(
caught
);
$scope
.
invocationResponse
=
caught
}
else
{
$scope
.
invocationResponse
=
data
.
byteLength
+
"
byte(s) received
"
;
}
}
else
{
var
response
=
{
"
data
"
:
data
};
if
(
typeof
response
.
data
==
'
object
'
)
{
$scope
.
invocationResponse
=
JSON
.
stringify
(
response
.
data
,
null
,
2
);
if
(
typeof
data
==
'
object
'
)
{
$scope
.
invocationResponse
=
JSON
.
stringify
(
data
,
null
,
2
);
}
else
{
$scope
.
invocationResponse
=
response
.
data
;
$scope
.
invocationResponse
=
data
;
}
}
$scope
.
invocationInProgress
=
false
;
$scope
.
invocationStatus
=
response
.
status
;
$scope
.
invocationStatus
=
status
;
var
now
=
new
Date
().
getTime
();
$scope
.
roundTripDuration
=
(
now
-
$scope
.
invocationStart
)
/
1000
;
showPostInvokedToast
(
"
Success
"
);
...
...
@@ -187,6 +208,7 @@ app.controller("home", ['$scope', '$log', '$http', '$location', '$timeout', '$md
$scope
.
item
.
envProcess
=
func
.
fprocess
;
$scope
.
item
.
network
=
func
.
network
;
$scope
.
item
.
envVars
=
func
.
environment
;
$scope
.
item
.
labels
=
func
.
labels
;
$scope
.
selectedFunc
=
func
;
}
...
...
@@ -219,6 +241,7 @@ app.controller("home", ['$scope', '$log', '$http', '$location', '$timeout', '$md
item
.
envProcess
=
""
;
item
.
network
=
""
;
item
.
envVars
=
{};
item
.
labels
=
{};
$scope
.
validationError
=
""
;
$scope
.
closeDialog
();
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment