-
Notifications
You must be signed in to change notification settings - Fork 49
/
index.html
82 lines (76 loc) · 3.14 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<!doctype html>
<html class="no-js">
<head>
<meta charset="utf-8">
<title>Container Terminal Example</title>
<meta name="viewport" content="width=device-width">
<style>
* { box-sizing: border-box; }
body { margin: 20px !important; font-family: sans-serif; }
label { display: block !important; }
label span { float: left; width: 100px; margin-top: 2px; }
label .form-control { display: inline !important; width: 300px; }
body > div { margin-top: 15px; }
kubernetes-container-terminal { }
</style>
<link rel="stylesheet" href="bower_components/patternfly/dist/css/patternfly.css">
<link rel="stylesheet" href="bower_components/patternfly/dist/css/patternfly-additions.css">
<link rel="stylesheet" href="dist/xterm.css">
<link rel="stylesheet" href="container-terminal.css">
<script src="bower_components/angular/angular.js"></script>
<script src="dist/xterm.js"></script>
<script src="container-terminal.js"></script>
</head>
<body ng-app="exampleApp">
<kubernetes-container-terminal pod="selfLink" container="containerName" prevent="preventSocket" rows="rows" cols="cols" screen-keys="true" autofocus="true">
</kubernetes-container-terminal>
<div>
<label>
<span>Endpoint</span>
<input type="text" class="form-control" ng-model="baseUrl"/>
</label>
<label>
<span>Pod link</span>
<input type="text" class="form-control" ng-model="selfLink"/>
</label>
<label>
<span>Container</span>
<input type="text" class="form-control" ng-model="containerName"/>
</label>
<label>
<span>Access Token</span>
<input type="text" class="form-control" ng-model="accessToken"/>
</label>
<label>
<span>Rows</span>
<input type="text" class="form-control" ng-model="rows"/>
</label>
<label>
<span>Cols</span>
<input type="text" class="form-control" ng-model="cols"/>
</label>
</div>
<script type="text/javascript">
angular.module('exampleApp', ['kubernetesUI'])
.config(function(kubernetesContainerSocketProvider) {
kubernetesContainerSocketProvider.WebSocketFactory = "CustomWebSockets";
})
.run(function($rootScope) {
$rootScope.baseUrl = "ws://localhost:8080";
$rootScope.selfLink = "/api/v1/namespaces/default/pods/frontend-19kon";
$rootScope.containerName = "";
$rootScope.accessToken = "";
$rootScope.preventSocket = true;
})
/* Our custom WebSocket factory adapts the url */
.factory("CustomWebSockets", function($rootScope) {
return function CustomWebSocket(url, protocols) {
url = $rootScope.baseUrl + url;
if ($rootScope.accessToken)
url += "&access_token=" + $rootScope.accessToken;
return new WebSocket(url, protocols);
};
});
</script>
</body>
</html>