Browse Source

Added active flag to endpoints

master
Shyim 7 years ago
parent
commit
e271d1bfb4
  1. 2
      README.md
  2. 7
      public/theme/src/components/ReCast/Endpoints/EditEndpoint.vue
  3. 2
      public/theme/src/components/ReCast/Streams/EditStream.vue
  4. 2
      public/theme/src/components/ReCast/Streams/List.vue
  5. 1
      src/Controller/Streams.php
  6. 24
      src/Entity/Endpoint.php
  7. 13
      src/Repository/StreamsRepository.php

2
README.md

@ -10,7 +10,7 @@ ReCast is a multi platform streaming tool written in PHP and uses nginx RTMP. Yo
* Checkout this project, copy .env.dist to .env and adjust the settings * Checkout this project, copy .env.dist to .env and adjust the settings
* Run ```composer install --no-dev -o``` * Run ```composer install --no-dev -o```
* Generate JWT Keys, following [Documentation](https://github.com/lexik/LexikJWTAuthenticationBundle/blob/HEAD/Resources/doc/index.md#installation) * Generate JWT Keys, following [Documentation](https://github.com/lexik/LexikJWTAuthenticationBundle/blob/HEAD/Resources/doc/index.md#installation)
* Create the database ```php bin/console doctrine:schema:create``` * Create the database ```php bin/console doctrine:migrations:migrate```
* Go to ``public/theme``, run ``npm install`` and copy the generated files to public (``cp -R static ..``) * Go to ``public/theme``, run ``npm install`` and copy the generated files to public (``cp -R static ..``)
* Create a new crontab entry which runs every minute ```php bin/console recast:cron``` * Create a new crontab entry which runs every minute ```php bin/console recast:cron```
* Create a new user with ```php bin/console recast:create:user``` * Create a new user with ```php bin/console recast:create:user```

7
public/theme/src/components/ReCast/Endpoints/EditEndpoint.vue

@ -9,6 +9,10 @@
<card> <card>
<fg-input label="Name" v-model="endpoint.name"></fg-input> <fg-input label="Name" v-model="endpoint.name"></fg-input>
<div class="form-group">
<p-checkbox v-model="endpoint.active">Active</p-checkbox>
</div>
<div class="form-group"> <div class="form-group">
<label class="control-label"> <label class="control-label">
Type Type
@ -51,6 +55,7 @@
return { return {
endpoint: { endpoint: {
name: '', name: '',
active: false,
type: 'Mixer', type: 'Mixer',
server: '', server: '',
streamKey: '', streamKey: '',
@ -74,7 +79,7 @@
methods: { methods: {
save: function () { save: function () {
this.axios.post('/streams/' + this.$route.params.streamId + '/endpoints/update', this.endpoint).then(() => { this.axios.post('/streams/' + this.$route.params.streamId + '/endpoints/update', this.endpoint).then(() => {
this.$router.push('/ucp/streams/' + this.$route.params.streamId + '/endpoints'); this.$router.push('/ucp/streams/' + this.$route.params.streamId + '/');
}) })
} }
}, },

2
public/theme/src/components/ReCast/Streams/EditStream.vue

@ -24,6 +24,7 @@
<table class="table"> <table class="table">
<thead class="thead-dark"> <thead class="thead-dark">
<tr> <tr>
<th>Active</th>
<th>Name</th> <th>Name</th>
<th>Service</th> <th>Service</th>
<th>Location</th> <th>Location</th>
@ -32,6 +33,7 @@
</thead> </thead>
<tbody> <tbody>
<tr v-for="endpoint in endpoints"> <tr v-for="endpoint in endpoints">
<td><i class="fa fa-circle" :class="endpoint.active ? 'text-success' : 'text-danger'" aria-hidden="true"></i></td>
<td>{{ endpoint.name }}</td> <td>{{ endpoint.name }}</td>
<td>{{ endpoint.type }}</td> <td>{{ endpoint.type }}</td>
<td>{{ endpoint.server }}</td> <td>{{ endpoint.server }}</td>

2
public/theme/src/components/ReCast/Streams/List.vue

@ -10,6 +10,7 @@
<thead class="thead-dark"> <thead class="thead-dark">
<tr> <tr>
<th>Live</th> <th>Live</th>
<th>Active</th>
<th>Name</th> <th>Name</th>
<th>Endpoints</th> <th>Endpoints</th>
<th>Action</th> <th>Action</th>
@ -18,6 +19,7 @@
<tbody> <tbody>
<tr v-for="stream in streams"> <tr v-for="stream in streams">
<td><i class="fa fa-circle" :class="stream.live ? 'text-success' : 'text-danger'" aria-hidden="true"></i></td> <td><i class="fa fa-circle" :class="stream.live ? 'text-success' : 'text-danger'" aria-hidden="true"></i></td>
<td><i class="fa fa-circle" :class="stream.active ? 'text-success' : 'text-danger'" aria-hidden="true"></i></td>
<td>{{ stream.name }}</td> <td>{{ stream.name }}</td>
<td>{{ getProviders(stream) }}</td> <td>{{ getProviders(stream) }}</td>
<td> <td>

1
src/Controller/Streams.php

@ -208,6 +208,7 @@ class Streams extends Controller
$endpoint = !empty($requestBody['id']) ? $this->endpointRepository->find($requestBody['id']) : new Endpoint(); $endpoint = !empty($requestBody['id']) ? $this->endpointRepository->find($requestBody['id']) : new Endpoint();
$endpoint->setName($requestBody['name']); $endpoint->setName($requestBody['name']);
$endpoint->setActive($requestBody['active']);
$endpoint->setType($requestBody['type']); $endpoint->setType($requestBody['type']);
$endpoint->setServer($requestBody['server']); $endpoint->setServer($requestBody['server']);
$endpoint->setStreamKey($requestBody['streamKey']); $endpoint->setStreamKey($requestBody['streamKey']);

24
src/Entity/Endpoint.php

@ -21,6 +21,12 @@ class Endpoint implements \JsonSerializable
*/ */
private $id; private $id;
/**
* @ORM\Column(type="boolean", nullable=false, options={"default": true})
* @var bool
*/
private $active;
/** /**
* @ORM\Column(type="string", length=255) * @ORM\Column(type="string", length=255)
* @var string * @var string
@ -60,6 +66,24 @@ class Endpoint implements \JsonSerializable
return $this->id; return $this->id;
} }
/**
* @return bool
* @author Soner Sayakci <shyim@posteo.de>
*/
public function isActive(): bool
{
return $this->active;
}
/**
* @param bool $active
* @author Soner Sayakci <shyim@posteo.de>
*/
public function setActive(bool $active): void
{
$this->active = $active;
}
/** /**
* @return string * @return string
* @author Soner Sayakci <shyim@posteo.de> * @author Soner Sayakci <shyim@posteo.de>

13
src/Repository/StreamsRepository.php

@ -42,8 +42,17 @@ class StreamsRepository extends ServiceEntityRepository
* @return Streams[] * @return Streams[]
* @author Soner Sayakci <shyim@posteo.de> * @author Soner Sayakci <shyim@posteo.de>
*/ */
public function getActiveStreams() public function getActiveStreams(): array
{ {
return $this->findBy(['active' => true]); $qb = $this->createQueryBuilder('streams')
->addSelect('endpoints')
->addSelect('user')
->leftJoin('streams.endpoints', 'endpoints')
->leftJoin('streams.user', 'user')
->andWhere('streams.active = true')
->andWhere('endpoints.active = true')
->getQuery();
return $qb->getResult();
} }
} }

Loading…
Cancel
Save