Skip to content

Commit

Permalink
fix "undefined" error for non-accessible localFiles directory (when s…
Browse files Browse the repository at this point in the history
…etting isnt set)
  • Loading branch information
dularion committed May 7, 2019
1 parent a45fb92 commit 8f753b4
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 22 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
'use strict';

angular.module('streama').controller('modalFileCtrl', [
'$scope', '$uibModalInstance', 'apiService', 'uploadService', 'video', 'localStorageService',
function ($scope, $uibModalInstance, apiService, uploadService, video, localStorageService) {
'$scope', '$uibModalInstance', 'apiService', 'uploadService', 'video', 'localStorageService', '$rootScope',
function ($scope, $uibModalInstance, apiService, uploadService, video, localStorageService, $rootScope) {
$scope.loading = false;
$scope.localFilesEnabled = false;
$scope.localFiles = [];
Expand Down Expand Up @@ -38,6 +38,9 @@ angular.module('streama').controller('modalFileCtrl', [
}

function loadLocalFiles(path) {
if(!_.get($rootScope.getSetting('Local Video Files'), 'value')){
return;
}
apiService.file.localFiles(path).then(function(response) {
localStorageService.set('localFileLastPath', path);
$scope.localFilesEnabled = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,53 +39,59 @@
</div>
<div class="tab-pane" ng-class="{'active': activeTab == 'local'}">

<div>
<div class="form-group">
<input type="text" ng-model="localFileSearch" class="form-control input-sm" placeholder="Search current directory...">
<p ng-if="!$root.getSetting('Local Video Files').value" class="alert alert-warning" role="alert">You dont have a local Directory set up. As an admin, go to the settings page to configure it now.</p>

<div ng-if="$root.getSetting('Local Video Files').value">
<div>
<div class="form-group">
<input type="text" ng-model="localFileSearch" class="form-control input-sm" placeholder="Search current directory...">
</div>
</div>
</div>

<div style="overflow-y: auto; max-height: 200px;">
<div style="overflow-y: auto; max-height: 200px;">
<span class="btn btn-default btn-sm" ng-click="backLocalDirectory()" ng-if="localDir.length > 0">
<span class="ion-android-arrow-back"></span>
</span>
<span>{{ localDir.join('/') }}</span>
<span>{{ localDir.join('/') }}</span>

<table class="table table-striped">
<tr ng-repeat="file in localFiles | orderBy: ['-directory', 'name'] | filter:localFileSearch">
<td>
<table class="table table-striped">
<tr ng-repeat="file in localFiles | orderBy: ['-directory', 'name'] | filter:localFileSearch">
<td>
<span ng-if="file.directory" ng-click="openLocalDirectory(file)">
<span class="ion-folder"></span>
{{ file.name }}
</span>

<span ng-if="!file.directory">
<span ng-if="!file.directory">
<span class="ion-document"></span>
{{ file.name }}
</span>
</td>
</td>

<td>
<td>
<span class="btn btn-success btn-xs" ng-click="addLocalFile(file.path)" ng-if="!file.directory">
Choose
</span>
</td>
</tr>
</table>
</div>
</td>
</tr>
</table>
</div>

<div class="checkbox">
<label>
<input type="checkbox" ng-model="closeOnSelect" ng-click="toggleCloseOnSelect()"> Close Modal on Select
</label>
<div class="checkbox">
<label>
<input type="checkbox" ng-model="closeOnSelect" ng-click="toggleCloseOnSelect()"> Close Modal on Select
</label>
</div>
</div>

</div>
</div>

<h4>Video Files</h4>
<table class="table table-striped" style="font-size: 14px;" ng-show="video.videoFiles.length">
<thead>
<tr>
<th>ID</th>
<th>Name </th>
<th>Type</th>
<th style="width: 86px;">is Default</th>
Expand All @@ -95,6 +101,7 @@ <h4>Video Files</h4>
</thead>
<tbody>
<tr ng-repeat="file in video.videoFiles">
<td>{{file.id}}</td>
<td>{{file.originalFilename}}</td>
<td>{{file.contentType}}</td>
<td class="text-center">
Expand Down Expand Up @@ -122,6 +129,7 @@ <h4>Subtitles</h4>
<table class="table table-striped" style="font-size: 14px;">
<thead>
<tr>
<th>ID</th>
<th>Name</th>
<th>Type</th>
<th>Label</th>
Expand All @@ -131,6 +139,7 @@ <h4>Subtitles</h4>
</thead>
<tbody>
<tr ng-repeat="file in video.subtitles">
<td>{{file.id}}</td>
<td>{{file.originalFilename}}</td>
<td>{{file.contentType}}</td>
<th>
Expand Down

0 comments on commit 8f753b4

Please sign in to comment.