Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Old test #151

Open
wants to merge 26 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
fa838f9
take back code (only upload) from home-upload
Landeers Jun 23, 2016
5aeaf80
move error message
Landeers Jun 23, 2016
617441f
continue dev on upload
Landeers Jun 23, 2016
99302a1
delete relica of upload into participation form
Landeers Jun 23, 2016
0401ffd
upload works if no error
Landeers Jun 23, 2016
3eec65f
compact progress bar
Landeers Jun 23, 2016
0e50e90
remove file if xhr error (s3)
Landeers Jun 23, 2016
209e9b8
Improve google analytics support
touilleMan Jun 12, 2016
c415f57
fix s3 error content-encding
Landeers Jun 23, 2016
72c420f
Merge branch 'prod_fix'
Landeers Aug 10, 2016
678b704
Add error message display in participation view
touilleMan Sep 6, 2016
9037400
Merge branch 'localites_no_delete'
Landeers Sep 21, 2016
55c71b6
Merge branch 'localites_no_delete'
Landeers Sep 21, 2016
060e752
fix conflit
Landeers Sep 23, 2016
cf3ce21
Merge branch 'fix_bug_grille_stock'
Landeers Sep 23, 2016
69a6c71
Merge branch 'hot_fix_grillestoc'
Landeers Sep 23, 2016
8485258
Merge branch 'htofix'
Landeers Sep 23, 2016
cb31b39
Merge branch 'update_file_format'
Landeers Oct 5, 2016
a5c1d71
update upload, lest informations printed on html
Landeers Oct 24, 2016
4cb9f2c
update upload
Landeers Nov 24, 2016
a4e0d86
Merge remote-tracking branch 'origin/participation_bis'
Landeers Nov 28, 2016
9be739c
Merge branch 'participation'
Landeers Nov 29, 2016
385ca53
Merge branch 'prod_fix'
Landeers Dec 19, 2016
1937b53
change location when create new participation
Landeers Dec 19, 2016
0e67c1f
Merge branch 'fix_prod_auth'
Landeers Jan 5, 2017
f530b38
Merge branch 'prod'
touilleMan Jun 9, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');

ga('create', 'UA-XXXXX-X');
ga('send', 'pageview');
</script>

<script src='//maps.googleapis.com/maps/api/js?libraries=drawing,geometry'></script>
Expand Down Expand Up @@ -141,6 +140,7 @@
<script src="scripts/views/participation/modal/modal_participation.js"></script>
<script src="scripts/views/actualite/actualite_ctrl.js"></script>
<script src="scripts/views/donnee/donnee_ctrl.js"></script>
<script src="scripts/views/participation_upload/upload_ctrl.js"></script>

<script src="scripts/xin/tools.js"></script>
<script src="scripts/xin/services/geolocation_srv.js"></script>
Expand Down
5 changes: 4 additions & 1 deletion app/scripts/app.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
###
angular
.module('vigiechiroApp', [
'angulartics',
'angulartics.google.analytics',
'ngAnimate',
'ngRoute',
'ngSanitize',
Expand All @@ -30,7 +32,8 @@ angular
'siteViews'
'participationViews',
'actualiteViews',
'donneeViews'
'donneeViews',
'uploadParticipationViews'
])

.run (Backend, SETTINGS) ->
Expand Down
1 change: 1 addition & 0 deletions app/scripts/settings.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ angular.module('appSettings', [])
.constant 'SETTINGS',
API_DOMAIN: 'http://localhost:8080'
FRONT_DOMAIN: 'http://localhost:9000'
S3_BUCKET_URL: 'https://vigiechiro.s3.amazonaws.com/'
BASE_TITLE: 'Vigiechiro'
4 changes: 3 additions & 1 deletion app/scripts/views/participation/display_participation.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
<a class="btn btn-default" href="#/sites/{{participation.site._id}}">
Voir le site {{ participation.site.titre }}
</a>

<a class="btn btn-primary" href="#/participations/{{participation._id}}/telechargement">
Uploader les fichiers
</a>
<a class="btn btn-danger" href="" ng-click="delete()">
Supprimer la participation
</a>
Expand Down
2 changes: 1 addition & 1 deletion app/scripts/views/participation/edit_participation.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
<sc-button class="save-participation btn btn-primary"
ng-click="save()"
label="'Sauvegarder'"
wait-for-class="fa fa-spinner fa-spin"
wait-for-class="fa fa-spinner fa-1 fa-pulse"
cancel-wait-for="saveDone">
</sc-button>
43 changes: 2 additions & 41 deletions app/scripts/views/participation/edit_participation_drt.html
Original file line number Diff line number Diff line change
Expand Up @@ -82,48 +82,9 @@
</div>
</div>

<div class="alert alert-warning">Exemple de nom de fichier : {{fileFormatExemple}}</div>
<div class="form-group"
ng-class="{'has-error': participationForm.pieces_jointes.$invalid && !participationForm.$pristine}">
<div class="input-group">
<span class="input-group-addon">Fichiers joints</span>
<div style="padding-right: 1em; border-left: 1px solid #ccc">
<upload-file-directive uploader="fileUploader" regexp="regexp" gzip multiple>
</upload-file-directive>
</div>
</div>
<div class="help-block"
ng-show="submitted && participationForm.pieces_jointes.$error.required">
Champ requis
</div>
<div class="alert alert-danger"
ng-show="submitted && participationForm.pieces_jointes.$error.uploading">
Le transfert des pièces jointes n'est pas terminé
</div>
</div>

<div class="form-group" ng-show="folderAllowed"
ng-class="{'has-error': participationForm.folder.$invalid && !participationForm.$pristine}">
<div class="input-group">
<span class="input-group-addon">Dossier joint</span>
<div style="padding-right: 1em; border-left: 1px solid #ccc">
<upload-file-directive uploader="folderUploader" regexp="regexp" gzip directory>
</upload-file-directive>
</div>
</div>
<span class="help-block"
ng-show="submitted && participationForm.folder.$error.required">
Champ requis
</span>
<span class="help-block"
ng-show="submitted && participationForm.folder.$error.uploading">
Le transfert des pièces jointes n'est pas terminé
</span>
</div>

<div class="form-group"
ng-class="{'has-error': participationForm.configuration.detecteur_enregistreur_numero_serie.$invalid && !participationForm.$pristine}"
ng-if="true">
ng-class="{'has-error': participationForm.configuration.detecteur_enregistreur_numero_serie.$invalid && !participationForm.$pristine}"
ng-if="true">
<div class="input-group">
<label class="input-group-addon" for="configuration.detecteur_enregistreur_numero_serie">
Numéro de série du détecteur enregistreur
Expand Down
66 changes: 7 additions & 59 deletions app/scripts/views/participation/participation_ctrl.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,10 @@ traitement_is_timeout = (participation) ->
participation.traitement.timeout = false


makeRegExp = ($scope, type_site) ->
patt =
'CARRE': /^Cir.+-\d+-Pass\d+-Tron\d+-Chiro_([01]_)?\d+_\d{3}\.(wav|ta|tac)$/
'POINT_FIXE': /^Car.+-\d+-Pass\d+-([A-H][12]|Z[1-9][0-9]*)-.*_\d+_\d+_\d+\.(wav|ta|tac)$/
'ROUTIER': /^Cir.+-\d+-Pass\d+-Tron\d+-Chiro_([01]_)?\d+_\d{3}\.(wav|ta|tac)$/
exemples =
'CARRE': 'Cir270-2009-Pass1-Tron1-Chiro_0_00265_000.wav'
'POINT_FIXE': 'Car170517-2014-Pass1-C1-OB-1_20140702_224038_761.wav'
'ROUTIER': 'Cir270-2009-Pass1-Tron1-Chiro_0_00265_000.wav'
$scope.regexp = [patt[type_site]]
$scope.fileFormatExemple = exemples[type_site]


angular.module('participationViews', ['ngRoute', 'textAngular', 'xin_listResource',
'xin_backend', 'xin_session', 'xin_tools',
'xin_uploadFile', 'xin.form', 'modalParticipationViews',
'sc-button'])
'sc-button', 'xin_s3uploadFile'])
.config ($routeProvider) ->
$routeProvider
.when '/participations',
Expand Down Expand Up @@ -246,12 +233,10 @@ angular.module('participationViews', ['ngRoute', 'textAngular', 'xin_listResourc



.controller 'EditParticipationController', ($scope, $routeParams, Backend) ->
.controller 'EditParticipationController', ($scope, $route, $routeParams, Backend) ->
participationResource = null
siteResource = null
$scope.participation = null
$scope.fileUploader = {}
$scope.folderUploader = {}
$scope.site = null
$scope.protocole = null
participationCreated = false
Expand Down Expand Up @@ -355,17 +340,12 @@ angular.module('participationViews', ['ngRoute', 'textAngular', 'xin_listResourc
$scope.canal_enregistrement_direct_error = true
error = true

# Check files
if not $scope.fileUploader.isAllComplete() or
not $scope.folderUploader.isAllComplete()
$scope.participationForm.pieces_jointes = {$error: {uploading: true}}
error = true

if not error
if $scope.participation._id?
# patch participation
participationResource.patch(payload).then(
(participation) -> sendFiles()
(participation) ->
window.location = "#/participations/#{participation._id}"
(error) ->
console.log("Error : participation save "+error)
$scope.saveDone.end?()
Expand All @@ -374,33 +354,17 @@ angular.module('participationViews', ['ngRoute', 'textAngular', 'xin_listResourc
# Post new participation
siteResource.post('participations', payload).then(
(participation) ->
Backend.one("participations", participation._id).get().then (participation) ->
participationResource = participation
sendFiles()
window.location = "#/participations/#{participation._id}"
(error) ->
console.log("Error : participation save "+error)
$scope.saveDone.end?()
$scope.submitError = true
$scope.saveDone.end()
)
else
$scope.saveDone.end?()


sendFiles = (participation) ->
participationCreated = true
payload =
pieces_jointes: $scope.fileUploader.itemsCompleted.concat($scope.folderUploader.itemsCompleted)

if not payload.pieces_jointes.length
window.location = '#/participations/'+participationResource._id
else
participationResource.customPUT(payload, 'pieces_jointes').then(
-> window.location = '#/participations/'+participationResource._id
->
$scope.participation._errors.participation = "Echec de l'enregistrement des pièces jointes."
$scope.saveDone.end?()
)



.directive 'editParticipationDirective', ->
restrict: 'E'
Expand All @@ -409,25 +373,9 @@ angular.module('participationViews', ['ngRoute', 'textAngular', 'xin_listResourc
participation: '='
typeSite: '='
site: '='
fileUploader: '='
folderUploader: '='
link: (scope) ->
scope.localities = []
scope.$watch 'site', (site) ->
if site? and site.localites?
for localite in site.localites
scope.localities.push(localite.nom)

scope.folderAllowed = true
# firefox and IE don't support folder upload
if navigator.userAgent.search("Firefox") != -1
scope.folderAllowed = false
else if navigator.userAgent.search("Edge") != -1
scope.folderAllowed = false
else if navigator.userAgent.search("MSIE") != -1
scope.folderAllowed = false

scope.$watch 'typeSite', (type_site) ->
if not type_site? or type_site == ""
return
makeRegExp(scope, type_site)
37 changes: 37 additions & 0 deletions app/scripts/views/participation_upload/upload.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<div class="spinner" ng-show="participationWaiting">
<i class="fa fa-5x fa-spinner fa-pulse"></i>
</div>

<div class="actionbar">
<sc-button class="btn btn-success"
ng-click="compute()"
label="'Lancer la participation'"
wait-for-class="fa fa-spinner"
cancel-wait-for="">
</sc-button>
<a class="btn btn-default" href="#/participations/{{participation._id}}">
Voir la participation
</a>
</div>

<div class="panel-body">
<div class="text-center">
<div class="page-header text-center">
<h3>Participation du {{ participation.date_debut | xinDate: 'medium' }}
effectuée par {{participation.observateur.pseudo}}</h3>
</div>
</div>

<div class="form-group input-group" ng-if="false">
<span class="input-group-addon">Nombre de fichiers uploadés en parallèle (2~20)</span>
<input class="form-control" type="number"
ng-model="connectionSpeed" min="2" max="20">
</div>

<div class="alert alert-warning">Exemple de nom de fichier : {{fileFormatExemple}}</div>

<upload-file-directive lien-participation="{{participation._id}}"
regex="regexp"
refresh="refresh">
</upload-file-directive>
</div>
76 changes: 76 additions & 0 deletions app/scripts/views/participation_upload/upload_ctrl.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
'use strict'

breadcrumbsGetParticipationDefer = undefined


makeRegExp = ($scope, type_site) ->
patt =
'CARRE': /^Cir.+-\d+-Pass\d+-Tron\d+-Chiro_([01]_)?\d+_\d{3}\.(wav|ta|tac)$/
'POINT_FIXE': /^Car.+-\d+-Pass\d+-([A-H][12]|Z[1-9][0-9]*)-.*_\d+_\d+_\d+\.(wav|ta|tac)$/
'ROUTIER': /^Cir.+-\d+-Pass\d+-Tron\d+-Chiro_([01]_)?\d+_\d{3}\.(wav|ta|tac)$/
exemples =
'CARRE': 'Cir270-2009-Pass1-Tron1-Chiro_0_00265_000.wav'
'POINT_FIXE': 'Car170517-2014-Pass1-C1-OB-1_20140702_224038_761.wav'
'ROUTIER': 'Cir270-2009-Pass1-Tron1-Chiro_0_00265_000.wav'
$scope.regexp = patt[type_site]
$scope.fileFormatExemple = exemples[type_site]


angular.module('uploadParticipationViews', ['ngRoute', 'xin_listResource',
'xin_backend', 'xin_session', 'xin_tools',
'xin_uploadFile'])
.config ($routeProvider) ->
$routeProvider
.when '/participations/:participationId/telechargement',
templateUrl: 'scripts/views/participation_upload/upload.html'
controller: 'AddParticipationFilesController'
breadcrumbs: ngInject ($q, $filter) ->
breadcrumbsDefer = $q.defer()
breadcrumbsGetParticipationDefer = $q.defer()
breadcrumbsGetParticipationDefer.promise.then (participation) ->
breadcrumbsDefer.resolve([
['Participations', '#/participations']
['Participation du ' + $filter('date')(participation.date_debut, 'medium'), '#/participations/' + participation._id]
['Téléchargement', '#/participations/' + participation._id + '/edition']
])
return breadcrumbsDefer.promise



.controller 'AddParticipationFilesController', ($scope, $routeParams, $timeout,
Backend, session) ->
participationResource = null
$scope.participation = null
# $scope.connectionSpeed = 2

# get participation
Backend.one("participations", $routeParams.participationId).get().then(
(participation) ->
$scope.participationWaiting = false

if breadcrumbsGetParticipationDefer?
breadcrumbsGetParticipationDefer.resolve(participation)
breadcrumbsGetParticipationDefer = undefined

participationResource = participation
$scope.participation = participation.plain()
makeRegExp($scope, participation.protocole.type_site)

(error) -> window.location = "#/404"
)

# $scope.$watch 'connectionSpeed', (value) ->
# if value? and value >= 2 and value <= 20
# $scope.fileUploader.connectionSpeed = value
# $scope.folderUploader.connectionSpeed = value

$scope.refresh = ->
$timeout(->
$scope.$apply()
)

$scope.compute = ->
participationResource.post('compute', {}).then(
(result) -> window.location = "#/participations/#{participationResource._id}"
(error) -> window.location = "#/participations/#{participationResource._id}"
)
Loading