Skip to content
This repository has been archived by the owner on Aug 6, 2018. It is now read-only.

Commit

Permalink
Fixes upload and view in cp, and adds spinner to upload. Fixes #20, f…
Browse files Browse the repository at this point in the history
…ixes #10
  • Loading branch information
bHelland committed Jun 3, 2015
1 parent 24d9059 commit 4776007
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 37 deletions.
51 changes: 34 additions & 17 deletions resources/mediaflow-ng.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,23 +54,6 @@ mediaflow.controller('MediaFlowCtrl', function ($scope, $http, $upload) {
});
});
};

$scope.onFileSelect = function($files) {
$scope.spin = true;
for (var i = 0; i < $files.length; i++) {
var $file = $files[i];
$scope.upload = $upload.upload({
url: '/admin/mediaflow/upload',
file: $file
}).then(function(args) {
$scope.media.unshift(args.data);
$scope.spin = false;
}, function(args) {
console.log('err', args);
$scope.spin = false;
});
}
}
});


Expand Down Expand Up @@ -123,6 +106,23 @@ mediaflow.controller('MediaFlowFieldCtrl', function ($scope, $http, $upload) {
if (!$el) { return; }
$el.click();
};

$scope.onFileSelect = function($files) {
$scope.spin = true;
for (var i = 0; i < $files.length; i++) {
var $file = $files[i];
$scope.upload = $upload.upload({
url: '/admin/mediaflow/upload',
file: $file
}).then(function(args) {
$scope.media.unshift(args.data);
$scope.spin = false;
}, function(args) {
console.log('err', args);
$scope.spin = false;
});
}
}
});

mediaflow.controller('MediaFlowBrowseCtrl', function ($scope, $http, $upload) {
Expand All @@ -148,4 +148,21 @@ mediaflow.controller('MediaFlowBrowseCtrl', function ($scope, $http, $upload) {
timeout = setTimeout(updateMedia, 250, searchText);
}
});

$scope.onFileSelect = function($files) {
$scope.spin = true;
for (var i = 0; i < $files.length; i++) {
var $file = $files[i];
$scope.upload = $upload.upload({
url: '/admin/mediaflow/upload',
file: $file
}).then(function(args) {
$scope.media.unshift(args.data);
$scope.spin = false;
}, function(args) {
console.log('err', args);
$scope.spin = false;
});
}
}
});
8 changes: 8 additions & 0 deletions resources/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,14 @@
border-width: 10px;
margin-left: -10px; }

.mediaflow-upload-cell {
width: 150px; }
.mediaflow-upload-cell .buttons .mediaflow-upload-button.btn {
margin-top: 3px; }

.mediaflow-spinner {
left: 128px; }

.cropper-menu {
margin: 0 0 10px 0;
clear: both; }
Expand Down
9 changes: 9 additions & 0 deletions resources/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,15 @@
margin-left: -10px;
}
}
.mediaflow-upload-cell {
width: 150px;
.buttons .mediaflow-upload-button.btn {
margin-top: 3px;
}
}
.mediaflow-spinner {
left:128px;
}

.cropper-menu {
margin: 0 0 10px 0;
Expand Down
45 changes: 25 additions & 20 deletions templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,6 @@
{% set hasSidebar = true %}

{% set sidebar %}
<div class="buttons first">
<input type="file"
multiple="multiple"
name="assets-upload"
style="display: none;">
<div class="btn submit assets-upload-button"
data-icon=""
style="position: relative; overflow: hidden;"
role="button"
>
<label for="mediaflow_file_upload">Upload files</label>
<input style="display:none"
id="mediaflow_file_upload"
type="file"
ng-file-select="onFileSelect($files)"
multiple
>
</div>
</div>
<nav>
<ul>
<li>
Expand All @@ -43,6 +24,28 @@
<table class="inputs fullwidth">
<tbody>
<tr>
<td class="mediaflow-upload-cell">
<div class="buttons first">
<input type="file"
multiple="multiple"
name="assets-upload"
style="display: none;">

<div class="btn submit assets-upload-button mediaflow-upload-button"
data-icon=""
style="position: relative; overflow: hidden;"
role="button"
>
<label for="mediaflow_file_upload">Upload files</label>
<input style="display:none"
id="mediaflow_file_upload"
type="file"
ng-file-select="onFileSelect($files)"
multiple
>
</div>
</div>
</td>
<td>
<div class="texticon search icon">
<input class="text nicetext fullwidth" type="search" autocomplete="off" ng-model="searchText"
Expand All @@ -60,7 +63,7 @@
</tr>
</tbody>
</table>
<div class="spinner hidden" ng-class="{hidden: !spin}"></div>
<div class="spinner hidden mediaflow-spinner" ng-class="{hidden: !spin}"></div>
</div>

<div class="elements" ng-show="view==='list'">
Expand Down Expand Up @@ -107,6 +110,8 @@
{% endraw %}

{% includeJsResource "mediaflow/angularjs-file-upload.js" %}
{% includeJsResource "mediaflow/jcrop.js" %}
{% includeJsResource "mediaflow/ng-image-crop.js" %}
{% includeJsResource "mediaflow/mediaflow-ng.js" %}
{% includeCssResource "mediaflow/style.css" %}
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular.min.js"></script>
Expand Down

0 comments on commit 4776007

Please sign in to comment.