Skip to content
This repository was archived by the owner on Feb 12, 2025. It is now read-only.

Commit

Permalink
Merge pull request #8 from colonelpopcorn/issue/GH-5
Browse files Browse the repository at this point in the history
Issue/gh 5
  • Loading branch information
colonelpopcorn authored Dec 24, 2020
2 parents d2ce9bd + 1f5fd5d commit eb0b68d
Show file tree
Hide file tree
Showing 5 changed files with 216 additions and 138 deletions.
37 changes: 33 additions & 4 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,31 @@ function handleResponse(response) {
});
}

Vue.use(window.VueCodemirror);

var app = new Vue({
el: '#app',
data: {
message: 'Hello Vue!',
streamsLoaded: false,
streams: [],
video: null,
nginxContent: '',
initialNginxContent: '',
confEditorOpen: false,
codeMirrorOpts: {
theme: 'eclipse',
lineNumbers: true,
viewportMargin: Infinity,
mode: 'text/nginx'
}
},
created: function () {
this.getStreams();
},
computed: {
nginxConfUnchanged: vm => vm.initialNginxContent === vm.nginxContent
},
methods: {
getStreams() {
fetchWrapper
Expand All @@ -92,14 +106,29 @@ var app = new Vue({
var hls = new Hls();
hls.loadSource(`${window.location}live/${streamKey}/index.m3u8`);
hls.attachMedia(video);
// hls.on(Hls.Events.MANIFEST_PARSED, function () {
// video.play();
// });
}
},
streamModalClosed() {
// this.video.stop();
this.video = null;
},
async openConfEditor() {
this.confEditorOpen = true;
if (this.nginxContent === '') {
fetchWrapper.get(`${BASE_URL}/nginx-conf`)
.then(res => {
this.initialNginxContent = res.content;
this.nginxContent = this.initialNginxContent;
});
}
},
closeConfEditor() {
this.confEditorOpen = false;
},
submitNewContent() {
fetchWrapper.post(`${BASE_URL}/nginx-conf`, { content: this.nginxContent })
.then(() => this.initialNginxContent = this.nginxContent)
.catch(console.error)

}
},
});
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ require (
github.com/gin-contrib/cors v1.3.1
github.com/gin-gonic/gin v1.6.3
github.com/mattn/go-sqlite3 v2.0.3+incompatible
github.com/xgfone/ngconf v0.1.0
)
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ github.com/ugorji/go v1.1.7 h1:/68gy2h+1mWMrwZFeD1kQialdSzAb432dtpeJ42ovdo=
github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw=
github.com/ugorji/go/codec v1.1.7 h1:2SvQaVZ1ouYrrKKwoSk2pzd4A9evlKJb9oTL+OaLUSs=
github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY=
github.com/xgfone/ngconf v0.1.0 h1:yhezjN8FtUxpKKlJ2vtqH5jD26v6mtwetOzKs/Dmw3s=
github.com/xgfone/ngconf v0.1.0/go.mod h1:HhaOvq2BR0G23lhIGsD89mCG7WjPGaXQklUsNbLcy7k=
golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200116001909-b77594299b42 h1:vEOn+mP2zCOVzKckCZy6YsCtDblrpj/w7B9nxGNELpg=
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
Expand Down
183 changes: 81 additions & 102 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,43 +1,62 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta
name="viewport"
content="width=device-width, initial-scale=1, shrink-to-fit=no"
/>

<title>Stream Manager - Home</title>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />

<!-- Bootstrap core CSS -->
<link
rel="stylesheet"
href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css"
integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk"
crossorigin="anonymous"
/>
<style>
.custom-spinner {
display: block;
position: fixed;
z-index: 1031; /* High z-index so it is on top of the page */
top: 50%;
right: 50%; /* or: left: 50%; */
}
</style>
</head>
<title>Stream Manager - Home</title>

<body>
<div id="app">
<!-- Navigation -->
<nav class="navbar navbar-expand-lg navbar-dark bg-dark static-top">
<div class="container">
<a class="navbar-brand" href="#">Stream Manager</a>
</div>
</nav>
<!-- Bootstrap core CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css"
integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/lib/codemirror.min.css" />
<style>
.custom-spinner {
display: block;
position: fixed;
z-index: 1031;
/* High z-index so it is on top of the page */
top: 50%;
right: 50%;
/* or: left: 50%; */
}

.vue-codemirror {
height: auto;
}
</style>
</head>

<!-- Page Content -->
<body>
<div id="app">
<!-- Navigation -->
<nav class="navbar navbar-expand-lg navbar-dark bg-dark static-top">
<div class="container">
<a class="navbar-brand" @click="closeConfEditor()">Stream Manager</a>
<ul class="navbar-nav mr-auto">
<li class="nav-item active">
<a class="nav-link" @click="openConfEditor()">Conf Editor</a>
</li>
</ul>
</div>
</nav>

<!-- Page Content -->
<div class="container">
<div v-if="confEditorOpen">
<!-- Conf editor -->
<div v-if="nginxContent !== ''">
<codemirror ref="cmEditor" v-model="nginxContent" :options="codeMirrorOpts" />
</div>
<div v-else class="custom-spinner spinner-border" role="status">
<span class="sr-only">Loading...</span>
</div>
<button :disabled="nginxConfUnchanged" type="button" class="btn btn-primary float-right mt-3" @click="submitNewContent()">
Submit
</button>
</div>
<div v-else>
<div v-if="streamsLoaded" id="results-table">
<table class="table">
<thead>
Expand All @@ -53,23 +72,14 @@
<td>{{ stream.streamKey }}</td>
<td>
<div v-if="stream.isValidStream">
<button
type="button"
class="btn btn-danger"
data-toggle="modal"
data-target="#videoModal"
@click="setStreamValue(stream.streamKey)"
>
<button type="button" class="btn btn-danger" data-toggle="modal" data-target="#videoModal"
@click="setStreamValue(stream.streamKey)">
LIVE
</button>
</div>
</td>
<td>
<button
type="button"
class="btn btn-danger"
@click="deleteStream(stream.streamId)"
>
<button type="button" class="btn btn-danger" @click="deleteStream(stream.streamId)">
Delete Stream
</button>
</td>
Expand All @@ -82,48 +92,23 @@
</tbody>
</table>
<!-- Modal -->
<div
class="modal fade"
id="videoModal"
tabindex="-1"
role="dialog"
aria-labelledby="exampleModalCenterTitle"
aria-hidden="true"
>
<div
class="modal-dialog modal-dialog-centered modal-lg"
role="document"
>
<div class="modal fade" id="videoModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle"
aria-hidden="true">
<div class="modal-dialog modal-dialog-centered modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLongTitle">
Stream viewer
</h5>
<button
type="button"
class="close"
data-dismiss="modal"
aria-label="Close"
>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<video
id="video"
controls
preload="auto"
width="768"
height="432"
></video>
<video id="video" controls preload="auto" width="768" height="432"></video>
</div>
<div class="modal-footer">
<button
type="button"
class="btn btn-secondary"
data-dismiss="modal"
@click="streamModalClosed()"
>
<button type="button" class="btn btn-secondary" data-dismiss="modal" @click="streamModalClosed()">
Close
</button>
</div>
Expand All @@ -132,11 +117,7 @@ <h5 class="modal-title" id="exampleModalLongTitle">
</div>
<!-- End Modal -->
<div>
<button
type="button"
class="btn btn-primary"
@click="createStream()"
>
<button type="button" class="btn btn-primary" @click="createStream()">
Create Stream
</button>
</div>
Expand All @@ -146,24 +127,22 @@ <h5 class="modal-title" id="exampleModalLongTitle">
</div>
</div>
</div>
<!-- Bootstrap core JavaScript -->
<script
src="https://code.jquery.com/jquery-3.5.1.slim.min.js"
integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj"
crossorigin="anonymous"
></script>
<script
src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js"
integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo"
crossorigin="anonymous"
></script>
<script
src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js"
integrity="sha384-OgVRvuATP1z7JjHLkuOU7Xw704+h835Lr+6QL9UvYjZE3Ipu6Tp75j7Bh/kR0JKI"
crossorigin="anonymous"
></script>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<script src="https://cdn.jsdelivr.net/npm/hls.js@latest"></script>
<script src="app.js"></script>
</body>
</html>
</div>
<!-- Bootstrap core JavaScript -->
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"
integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj"
crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js"
integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo"
crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js"
integrity="sha384-OgVRvuATP1z7JjHLkuOU7Xw704+h835Lr+6QL9UvYjZE3Ipu6Tp75j7Bh/kR0JKI"
crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<script src="https://cdn.jsdelivr.net/npm/hls.js@latest"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/lib/codemirror.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/vue-codemirror.min.js"></script>
<script src="app.js"></script>
</body>

</html>
Loading

0 comments on commit eb0b68d

Please sign in to comment.