forked from saburab/angular-schema-form-nwp-file-upload
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
124 lines (117 loc) · 5.05 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
'use strict';
var myApp = angular.module('formApp', [
'schemaForm',
'pascalprecht.translate',
'ngSchemaFormFile'
])
.controller('formController', ['$scope', '$q', '$translate', function($scope, $q, $translate) {
$translate.use('en');
$scope.schema = {
"type": "object",
"title": "Album",
"properties": {
"image": {
"title": "Image (Label coming from form definition)",
"type": "array",
"format": "singlefile",
"x-schema-form": {
"type": "object"
},
"pattern": {
"mimeType": "image/*, !.jpg",
"validationMessage": "Falscher Dateityp: "
},
"maxSize": {
"maximum": "2b",
"validationMessage": "Erlaubte Dateigröße überschritten: ",
"validationMessage2": "Aktuelle Dateigröße: "
},
"maxItems": {
"validationMessage": "Es wurden mehr Dateien hochgeladen als erlaubt."
},
"minItems": {
"validationMessage": "Sie müssen mindestens eine Datei hochladen"
}
},
"images": {
"title": "Images (Labels defined using the translate module)",
"type": "array",
"format": "multifile",
"x-schema-form": {
"type": "array"
},
"pattern": {
"mimeType": "image/*",
"validationMessage": "Falscher Dateityp: "
},
"maxSize": {
"maximum": "2b",
"validationMessage": "Erlaubte Dateigröße überschritten: ",
"validationMessage2": "Aktuelle Dateigröße: "
},
"maxItems": {
"validationMessage": "Es wurden mehr Dateien hochgeladen als erlaubt."
},
"minItems": {
"validationMessage": "Sie müssen mindestens eine Datei hochladen"
}
}
},
"required": [
"images"
]
};
$scope.form = [{
"key": "image",
"type": "nwpFileUpload",
"endpoint": "https://angular-file-upload-cors-srv.appspot.com/upload",
"i18n": {
"add": "Open file browser",
"preview": "Preview Upload",
"filename": "File Name",
"progress": "Progress Status",
"upload": "Upload",
"dragorclick": "Drag and drop your file here or click here"
}
}, {
"key": "images",
"type": "nwpFileUpload",
"endpoint": "https://angular-file-upload-cors-srv.appspot.com/upload"
}];
$scope.model = {};
$scope.submit = function() {
$scope.$broadcast('schemaFormValidate');
if ($scope.myForm.$valid) {
console.log('form valid');
}
};
}])
.config(['$translateProvider', function($translateProvider) {
// Simply register translation table as object hash
$translateProvider.translations('en', {
'modules.upload.dndNotSupported': 'Drag n drop not surpported by your browser',
'modules.attribute.fields.required.caption': 'Required',
'modules.upload.descriptionSinglefile': 'Drop your file here',
'modules.upload.descriptionMultifile': 'Drop your file(s) here',
'buttons.add': 'Open file browser',
'modules.upload.field.filename': 'Filename',
'modules.upload.field.preview': 'Preview',
'modules.upload.multiFileUpload': 'Multifile upload',
'modules.upload.field.progress': 'Progress',
'buttons.upload': 'Upload'
});
$translateProvider.translations('de', {
'modules.upload.dndNotSupported': 'Drag & Drop nicht von Ihrem Browser übertroffen',
'modules.attribute.fields.required.caption': 'Erforderlich',
'modules.upload.descriptionSinglefile': 'Legen Sie Ihre Datei hier ab',
'modules.upload.descriptionMultifile': 'Legen Sie Ihre Datei (en) hier ab',
'buttons.add': 'Öffnen Sie den Dateibrowser',
'modules.upload.field.filename': 'Dateiname',
'modules.upload.field.preview': 'Vorschau',
'modules.upload.multiFileUpload': 'Multi-Upload',
'modules.upload.field.progress': 'PrFortschrittogress',
'buttons.upload': 'Hochladen'
});
$translateProvider.preferredLanguage('en');
$translateProvider.useSanitizeValueStrategy('sanitizeParameters');
}]);