isite 2022.8.2 → 2022.8.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -173,22 +173,26 @@ module.exports = function (site) {
173
173
 
174
174
  site.createDir(site.dir + '/../../uploads');
175
175
 
176
- site.post({ name: '/api/upload/image/:category', public: true }, (req, res) => {
177
- site.createDir(site.options.upload_dir + '/' + req.params.category, () => {
178
- site.createDir(site.options.upload_dir + '/' + req.params.category + '/images', () => {
176
+ site.post({ name: '/x-api/upload/image', public: true }, (req, res) => {
177
+ site.createDir(site.options.upload_dir + '/' + req.headers['folder'], () => {
178
+ site.createDir(site.options.upload_dir + '/' + req.headers['folder'] + '/images', () => {
179
179
  let response = {
180
+ image: {},
180
181
  done: !0,
181
182
  };
182
183
  let file = req.files.fileToUpload;
183
184
  if (file) {
184
- let newName = 'image_' + new Date().getTime().toString().replace('.', '_') + '.png';
185
- let newpath = site.options.upload_dir + '/' + req.params.category + '/images/' + newName;
185
+ let newName = 'image_' + (new Date().getTime().toString() + Math.random()).replaceAll('.', '_') + site.path.extname(file.originalFilename);
186
+ let newpath = site.path.resolve(site.options.upload_dir + '/' + req.headers['folder'] + '/images/' + newName);
186
187
  site.mv(file.filepath, newpath, function (err) {
187
188
  if (err) {
188
189
  response.error = err;
189
190
  response.done = !1;
191
+ } else {
192
+ response.image.path = newpath;
193
+ response.image.url = '/x-api/image/' + req.headers['folder'] + '/' + newName;
194
+ response.image.size = file.size;
190
195
  }
191
- response.image_url = '/api/image/' + req.params.category + '/' + newName;
192
196
  res.json(response);
193
197
  });
194
198
  } else {
@@ -200,15 +204,16 @@ module.exports = function (site) {
200
204
  });
201
205
  });
202
206
 
203
- site.get({ name: '/api/image/:category/:name', public: true }, (req, res) => {
207
+ site.get({ name: '/x-api/image/:category/:name', public: true }, (req, res) => {
204
208
  res.set('Cache-Control', 'public, max-age=2592000');
205
209
  res.download(site.options.upload_dir + '/' + req.params.category + '/images/' + req.params.name);
206
210
  });
207
211
 
208
- site.post({ name: '/api/upload/file/:category', public: true }, (req, res) => {
209
- site.createDir(site.options.upload_dir + '/' + req.params.category, () => {
210
- site.createDir(site.options.upload_dir + '/' + req.params.category + '/files', () => {
212
+ site.post({ name: '/x-api/upload/file', public: true }, (req, res) => {
213
+ site.createDir(site.options.upload_dir + '/' + req.headers['folder'], () => {
214
+ site.createDir(site.options.upload_dir + '/' + req.headers['folder'] + '/files', () => {
211
215
  let response = {
216
+ file: {},
212
217
  done: !0,
213
218
  };
214
219
  let file = req.files.fileToUpload;
@@ -218,17 +223,15 @@ module.exports = function (site) {
218
223
  res.json(response);
219
224
  return;
220
225
  }
221
- let newName = 'file_' + new Date().getTime() + '.' + site.path.extname(file.name);
222
- let newpath = site.options.upload_dir + '/' + req.params.category + '/files/' + newName;
226
+ let newName = 'file_' + (new Date().getTime().toString() + Math.random()).replaceAll('.', '_') + site.path.extname(file.originalFilename);
227
+ let newpath = site.path.resolve(site.options.upload_dir + '/' + req.headers['folder'] + '/files/' + newName);
223
228
  site.mv(file.filepath, newpath, function (err) {
224
229
  if (err) {
225
230
  response.error = err;
226
231
  response.done = !1;
227
232
  }
228
- response.file = {};
229
- response.file.url = '/api/file/' + req.params.category + '/' + newName;
230
- response.file.name = file.originalFilename;
231
- response.file.mimetype = file.mimetype;
233
+ response.file.path = newpath;
234
+ response.file.url = '/x-api/file/' + req.headers['folder'] + '/' + newName;
232
235
  response.file.size = file.size;
233
236
  res.json(response);
234
237
  });
@@ -236,7 +239,7 @@ module.exports = function (site) {
236
239
  });
237
240
  });
238
241
 
239
- site.get({ name: '/api/file/:category/:name', public: true }, (req, res) => {
242
+ site.get({ name: '/x-api/file/:category/:name', public: true }, (req, res) => {
240
243
  res.download(site.options.upload_dir + '/' + req.params.category + '/files/' + req.params.name);
241
244
  });
242
245
 
@@ -22,6 +22,12 @@
22
22
  float: right;
23
23
  margin-right: -1.5em;
24
24
  }
25
+ label {
26
+ float: left;
27
+ }
28
+ .ar label {
29
+ float: right;
30
+ }
25
31
  i-checkbox,
26
32
  i-radio {
27
33
  align-self: center;
@@ -31,6 +37,19 @@ i-radio {
31
37
  i-button {
32
38
  display: contents;
33
39
  }
40
+ i-file {
41
+ padding: 10px !important;
42
+ border: 1px dashed var(--theme-color);
43
+ margin: 10px;
44
+ height: fit-content;
45
+ }
46
+ i-file button {
47
+ max-width: 100px;
48
+ }
49
+ i-file .view button {
50
+ width: 40px;
51
+ height: 40px;
52
+ }
34
53
  .dropdown-content {
35
54
  top: 55px;
36
55
  }
@@ -1,48 +1,50 @@
1
- .image{
2
- width : 400px;
3
- height: 300px;
4
- border-radius: 10px;
1
+ .image {
2
+ width: 400px;
3
+ height: 300px;
4
+ border-radius: 10px;
5
5
  }
6
- .logo{
7
- width : 48px;
8
- height: 48px;
9
- border-radius: 5px;
6
+ .logo {
7
+ width: 48px;
8
+ height: 48px;
9
+ border-radius: 5px;
10
10
  }
11
11
 
12
-
13
- i-image img{
14
- width : 200px;
15
- height: 200px;
16
- border:var(--i-image-border);
17
- padding: 5px;
18
- transition: all .5s ease;
19
- -moz-transition: all .5s ease;
20
- -webkit-transition: all .5s ease;
21
- -ms-transition: all .5s ease;
12
+ i-image {
13
+ width: auto !important;
14
+ height: auto !important;
22
15
  }
23
-
24
- i-image.full img{
25
- width : 100%;
26
- height: auto;
27
- border:var(--i-image-border);
28
- padding: 5px;
16
+ i-image img {
17
+ width: 150px;
18
+ height: 150px;
19
+ transition: all 0.5s ease;
20
+ -moz-transition: all 0.5s ease;
21
+ -webkit-transition: all 0.5s ease;
22
+ -ms-transition: all 0.5s ease;
23
+ background-image: url('/images/no.jpg');
24
+ background-size: contain;
29
25
  }
30
26
 
31
- i-image.logo img{
32
- width : 48px;
33
- height: 48px;
27
+ i-image.full img {
28
+ width: 100%;
29
+ height: auto;
30
+ border: var(--i-image-border);
31
+ padding: 5px;
34
32
  }
35
33
 
36
- i-image.photo img{
37
- width : 128px;
38
- height: 128px;
34
+ i-image.logo img {
35
+ width: 48px;
36
+ height: 48px;
39
37
  }
40
38
 
41
- i-image.hover img:hover{
42
- transform: scale(1.1);
39
+ i-image.photo img {
40
+ width: 128px;
41
+ height: 128px;
43
42
  }
44
43
 
45
- i-image[view] img{
46
- border:var(--i-image-view-border);
44
+ i-image.hover img:hover {
45
+ transform: scale(1.1);
47
46
  }
48
47
 
48
+ i-image[view] img {
49
+ border: var(--i-image-view-border);
50
+ }
@@ -0,0 +1,19 @@
1
+ <div class="row">
2
+ <label class="col"> {{label}} </label>
3
+ <button ng-hide="ngModel" class="btn btn-primary col">
4
+ <i class="fas fa-upload"></i>
5
+ </button>
6
+ <div class="row">
7
+ <input class="hidden" type="file" name="fileToUpload" />
8
+ <div class="progress row">
9
+ <div class="progress-bar progress-bar-striped progress-bar-animated" role="progressbar" aria-valuenow="{{value}}" aria-valuemin="0" aria-valuemax="100" style="width: {{value}}%"></div>
10
+ </div>
11
+ </div>
12
+
13
+ <div class="view" ng-show="ngModel">
14
+ <a class="link" href="{{ngModel.url}}"> {{ngModel.name}} </a> <span class="blue"> [ size {{ngModel.size / 1000}} kb ] </span>
15
+ <button class="btn btn-danger" ng-click="ngModel = null">
16
+ <i class="fas fa-times"></i>
17
+ </button>
18
+ </div>
19
+ </div>
@@ -15,6 +15,7 @@ app.directive('iControl', function () {
15
15
  },
16
16
  link: function ($scope, element, attrs, ctrl) {
17
17
  attrs.type = attrs.type || 'text';
18
+ $scope.id2 = $scope.id2 || 'input_' + Math.random().toString().replace('0.', '');
18
19
 
19
20
  if (typeof attrs.disabled !== 'undefined') {
20
21
  attrs.disabled = 'disabled';
@@ -30,8 +31,8 @@ app.directive('iControl', function () {
30
31
  },
31
32
  template: `
32
33
  <div class="mb-3 {{class2}}">
33
- <label for="id2" class="form-label">{{label}}</label>
34
- <input id="id2" ng-disabled="disabled" autofocus v="{{v}}" type="{{type}}" ng-model="ngModel" ng-change="ngChange()" ngKeydown="ngKeydown()" class="form-control" placeholder="{{placeholder}}" aria-label="{{label}}" />
34
+ <label for="{{id2}}" class="form-label">{{label}}</label>
35
+ <input id="{{id2}}" ng-disabled="disabled" autofocus v="{{v}}" type="{{type}}" ng-model="ngModel" ng-change="ngChange()" ngKeydown="ngKeydown()" class="form-control" placeholder="{{placeholder}}" aria-label="{{label}}" />
35
36
  <div class="invalid-feedback">
36
37
 
37
38
  </div>
@@ -40,7 +41,43 @@ app.directive('iControl', function () {
40
41
  };
41
42
  });
42
43
 
43
- app.directive('iCheckbox', function () {
44
+ app.directive('iTextarea', function () {
45
+ return {
46
+ restrict: 'E',
47
+ require: 'ngModel',
48
+ scope: {
49
+ v: '@',
50
+ label: '@',
51
+ id2: '@',
52
+ disabled: '@',
53
+ rows: '@',
54
+ ngModel: '=',
55
+ ngChange: '&',
56
+ },
57
+ link: function ($scope, element, attrs, ctrl) {
58
+ if (typeof attrs.disabled !== 'undefined') {
59
+ attrs.disabled = 'disabled';
60
+ } else {
61
+ attrs.disabled = '';
62
+ }
63
+ $scope.rows = $scope.rows || 4;
64
+ $scope.id2 = $scope.id2 || 'input_' + Math.random().toString().replace('0.', '');
65
+ $(element)
66
+ .find('textarea')
67
+ .focus(() => {
68
+ $('.popup').hide();
69
+ });
70
+ },
71
+ template: `
72
+ <div class="mb-3">
73
+ <label for="{{id2}}" class="form-label">{{label}}</label>
74
+ <textarea ng-disabled="disabled" class="form-control" id="{{id2}}" ng-model="ngModel" ng-change="ngChange()" v="{{v}}" rows="{{rows}}"></textarea>
75
+ </div>
76
+ `,
77
+ };
78
+ });
79
+
80
+ app.directive('iCheckbox', function ($timeout) {
44
81
  return {
45
82
  restrict: 'E',
46
83
  require: 'ngModel',
@@ -57,10 +94,17 @@ app.directive('iCheckbox', function () {
57
94
  $scope.disabled = '';
58
95
  }
59
96
  $scope.id2 = $scope.id2 || 'input_' + Math.random().toString().replace('0.', '');
97
+ $scope.changed = function () {
98
+ $timeout(() => {
99
+ if ($scope.ngChange) {
100
+ $scope.ngChange();
101
+ }
102
+ }, 100);
103
+ };
60
104
  },
61
105
  template: `
62
106
  <div class="form-check">
63
- <input ng-change="ngChange()" ng-disabled="disabled" class="form-check-input" type="checkbox" ng-model="ngModel" id="{{id2}}">
107
+ <input ng-change="changed()" ng-disabled="disabled" class="form-check-input" type="checkbox" ng-model="ngModel" id="{{id2}}">
64
108
  <label class="form-check-label" for="{{id2}}">
65
109
  {{label}}
66
110
  </label>
@@ -108,34 +152,40 @@ app.directive('iButton', function () {
108
152
  scope: {
109
153
  label: '@',
110
154
  type: '@',
111
- busy: '@',
155
+ loading: '@',
112
156
  click: '&',
113
157
  fa: '@',
114
158
  },
115
159
  link: function ($scope, element, attrs, ctrl) {
116
- attrs.type = attrs.type || '';
117
- if (attrs.type.like('*exit*') || attrs.type.like('*close*')) {
118
- attrs.fa = 'times';
119
- } else if (attrs.type.like('*view*') || attrs.type.like('*details*')) {
120
- attrs.fa = 'file';
121
- } else if (attrs.type.like('*add*') || attrs.type.like('*new*')) {
122
- attrs.fa = 'plus-circle';
123
- } else if (attrs.type.like('*update*') || attrs.type.like('*edit*')) {
124
- attrs.fa = 'edit';
125
- } else if (attrs.type.like('*save*')) {
126
- attrs.fa = 'save';
127
- } else if (attrs.type.like('*delete*') || attrs.type.like('*remove*')) {
128
- attrs.fa = 'trash';
129
- } else if (attrs.type.like('*print*')) {
130
- attrs.fa = 'print';
131
- } else if (attrs.type.like('*search*')) {
132
- attrs.fa = 'search';
133
- } else if (attrs.type.like('*export*') || attrs.type.like('*excel*')) {
134
- attrs.fa = 'table';
160
+ $scope.type = $scope.type || '';
161
+ if ($scope.type.like('*exit*') || $scope.type.like('*close*')) {
162
+ $scope.fa = 'times';
163
+ } else if ($scope.type.like('*view*') || $scope.type.like('*details*')) {
164
+ $scope.fa = 'file';
165
+ } else if ($scope.type.like('*add*') || $scope.type.like('*new*')) {
166
+ $scope.fa = 'plus-circle';
167
+ } else if ($scope.type.like('*update*') || $scope.type.like('*edit*')) {
168
+ $scope.fa = 'edit';
169
+ } else if ($scope.type.like('*save*')) {
170
+ $scope.fa = 'save';
171
+ } else if ($scope.type.like('*delete*') || $scope.type.like('*remove*')) {
172
+ $scope.fa = 'trash';
173
+ } else if ($scope.type.like('*print*')) {
174
+ $scope.fa = 'print';
175
+ } else if ($scope.type.like('*search*')) {
176
+ $scope.fa = 'search';
177
+ } else if ($scope.type.like('*export*') || $scope.type.like('*excel*')) {
178
+ $scope.fa = 'table';
135
179
  } else {
136
180
  $scope.class = 'btn-primary';
137
181
  }
138
-
182
+ $scope.$watch('loading', (loading) => {
183
+ if (loading === 'true' ) {
184
+ $scope.busy = true
185
+ } else {
186
+ $scope.busy = false
187
+ }
188
+ });
139
189
  },
140
190
  template: `
141
191
  <button class="btn {{class}}" type="button" ng-click="click()" ng-disabled="busy">
@@ -294,6 +344,108 @@ app.directive('iList', [
294
344
  };
295
345
  },
296
346
  ]);
347
+ app.directive('iChecklist', [
348
+ '$interval',
349
+ '$timeout',
350
+ function ($interval, $timeout) {
351
+ return {
352
+ restrict: 'E',
353
+ required: 'ngModel',
354
+ scope: {
355
+ label: '@',
356
+ primary: '@',
357
+ display: '@',
358
+ class2: '@',
359
+ ngModel: '=',
360
+ items: '=',
361
+ like: '&',
362
+ ngChange: '&',
363
+ },
364
+ link: function ($scope, element, attrs, ctrl) {
365
+ $scope.primary = $scope.primary || 'id';
366
+ $scope.display = $scope.display || 'name';
367
+ $scope.class2 = $scope.class2 || 'col3';
368
+ $scope.selectedItems = [];
369
+
370
+ $scope.$watch('ngModel', (ngModel) => {
371
+ $scope.reload();
372
+ });
373
+
374
+ $scope.reload = function () {
375
+ $scope.selectedItems = [];
376
+
377
+ if ($scope.ngModel) {
378
+ $scope.ngModel.forEach((mitem) => {
379
+ $scope.selectedItems.push(mitem);
380
+ });
381
+
382
+ if ($scope.items) {
383
+ $scope.items.forEach((mitem) => {
384
+ let exist = !1;
385
+ $scope.selectedItems.forEach((sitem) => {
386
+ if (mitem[$scope.primary] === sitem[$scope.primary]) {
387
+ exist = !0;
388
+ }
389
+ });
390
+ if (exist) {
391
+ mitem.$selected = !0;
392
+ } else {
393
+ mitem.$selected = !1;
394
+ }
395
+ });
396
+ }
397
+ }
398
+ if (!$scope.ngModel) {
399
+ $scope.selectedItems = [];
400
+ if ($scope.items) {
401
+ $scope.items.forEach((mitem) => {
402
+ mitem.$selected = !1;
403
+ });
404
+ }
405
+ }
406
+ };
407
+
408
+ $scope.change = function (item) {
409
+ if (item.$selected) {
410
+ let exsits = !1;
411
+ $scope.selectedItems.forEach((sitem) => {
412
+ if (sitem[$scope.primary] === item[$scope.primary]) {
413
+ exsits = !0;
414
+ }
415
+ });
416
+ if (!exsits) {
417
+ let nitem = { ...item };
418
+ delete nitem.$selected;
419
+ delete nitem.$$hashKey;
420
+ $scope.selectedItems.push(nitem);
421
+ }
422
+ } else {
423
+ $scope.selectedItems.forEach((sitem, index) => {
424
+ if (sitem[$scope.primary] === item[$scope.primary]) {
425
+ $scope.selectedItems.splice(index, 1);
426
+ }
427
+ });
428
+ }
429
+
430
+ $scope.ngModel = $scope.selectedItems;
431
+ $timeout(() => {
432
+ if ($scope.ngChange) {
433
+ $scope.ngChange();
434
+ }
435
+ }, 100);
436
+ };
437
+ },
438
+ template: `
439
+ <div class="check-list">
440
+ <label class="title margin"> {{label}} </label>
441
+ <div class="row">
442
+ <i-checkbox class="{{class2}}" label="{{item[display]}}" ng-repeat="item in items" ng-model="item.$selected" ng-change="change(item);"></i-checkbox>
443
+ </div>
444
+ </div>
445
+ `,
446
+ };
447
+ },
448
+ ]);
297
449
  app.directive('iDate', function () {
298
450
  return {
299
451
  link: function (scope, element, attrs) {
@@ -938,136 +1090,6 @@ app.directive('iFulldate', [
938
1090
  },
939
1091
  ]);
940
1092
 
941
- app.directive('iTextarea', function () {
942
- return {
943
- restrict: 'E',
944
- require: 'ngModel',
945
- scope: {
946
- v: '@',
947
- label: '@',
948
- disabled: '@',
949
- rows: '@',
950
- ngModel: '=',
951
- ngChange: '&',
952
- },
953
- link: function (scope, element, attrs, ctrl) {
954
- if (typeof attrs.disabled !== 'undefined') {
955
- attrs.disabled = 'disabled';
956
- } else {
957
- attrs.disabled = '';
958
- }
959
- scope.rows = scope.rows || 4;
960
-
961
- $(element)
962
- .find('textarea')
963
- .focus(() => {
964
- $('.popup').hide();
965
- });
966
- },
967
- template: `
968
- <div class="control">
969
- <label> {{label}} </label>
970
- <textarea ng-disabled="disabled" rows="{{rows}}" v="{{v}}" ng-model="ngModel" ng-change="ngChange()"></textarea>
971
- </div>
972
- `,
973
- };
974
- });
975
-
976
-
977
-
978
- app.directive('iChecklist', [
979
- '$interval',
980
- function ($interval) {
981
- return {
982
- restrict: 'E',
983
- required: 'ngModel',
984
- scope: {
985
- label: '@',
986
- primary: '@',
987
- display: '@',
988
- ngModel: '=',
989
- items: '=',
990
- like: '&',
991
- },
992
- link: function ($scope, element, attrs, ctrl) {
993
- attrs.primary = attrs.primary || 'id';
994
-
995
- $scope.selectedItems = [];
996
-
997
- $scope.$watch('ngModel', (ngModel) => {
998
- $scope.reload();
999
- });
1000
-
1001
- $scope.reload = function () {
1002
- $scope.selectedItems = [];
1003
-
1004
- if ($scope.ngModel) {
1005
- $scope.ngModel.forEach((mitem) => {
1006
- $scope.selectedItems.push(mitem);
1007
- });
1008
-
1009
- if ($scope.items) {
1010
- $scope.items.forEach((mitem) => {
1011
- let exist = !1;
1012
- $scope.selectedItems.forEach((sitem) => {
1013
- if (mitem[$scope.primary] === sitem[$scope.primary]) {
1014
- exist = !0;
1015
- }
1016
- });
1017
- if (exist) {
1018
- mitem.$selected = !0;
1019
- } else {
1020
- mitem.$selected = !1;
1021
- }
1022
- });
1023
- }
1024
- }
1025
- if (!$scope.ngModel) {
1026
- $scope.selectedItems = [];
1027
- if ($scope.items) {
1028
- $scope.items.forEach((mitem) => {
1029
- mitem.$selected = !1;
1030
- });
1031
- }
1032
- }
1033
- };
1034
-
1035
- $scope.change = function (item) {
1036
- item.$selected = !item.$selected;
1037
-
1038
- if (item.$selected) {
1039
- let exsits = !1;
1040
- $scope.selectedItems.forEach((sitem) => {
1041
- if (sitem[$scope.primary] === item[$scope.primary]) {
1042
- exsits = !0;
1043
- }
1044
- });
1045
- if (!exsits) {
1046
- $scope.selectedItems.push(item);
1047
- }
1048
- } else {
1049
- $scope.selectedItems.forEach((sitem, index) => {
1050
- if (sitem[$scope.primary] === item[$scope.primary]) {
1051
- $scope.selectedItems.splice(index, 1);
1052
- }
1053
- });
1054
- }
1055
-
1056
- $scope.ngModel = $scope.selectedItems;
1057
- };
1058
- },
1059
- template: `
1060
- <div class="row padding check-list">
1061
- <label class="title"> {{label}} </label>
1062
- <div ng-repeat="item in items" ng-click="change(item);ngChange($event , item);" class="selector" ng-class="{'selected' : item.$selected , 'un-selected' : !item.$selected }" >
1063
- <i ng-show="!item.$selected" class="fa fa-square"></i> <i ng-show="item.$selected" class="fa fa-check"></i> {{item[display]}}
1064
- </div>
1065
- </div>
1066
- `,
1067
- };
1068
- },
1069
- ]);
1070
-
1071
1093
  app.directive('iChecklist2', [
1072
1094
  '$interval',
1073
1095
  function ($interval) {
@@ -1216,41 +1238,62 @@ app.directive('iFile', [
1216
1238
  required: 'ngModel',
1217
1239
  scope: {
1218
1240
  label: '@',
1219
- type: '@',
1241
+ folder: '@',
1220
1242
  ngModel: '=',
1221
1243
  ngClick: '&',
1222
1244
  onSelected: '&',
1223
1245
  },
1224
- link: function (scope, element, attrs, ctrl) {
1225
- scope.type = scope.type || 'bg-green';
1226
-
1246
+ link: function ($scope, element, attrs, ctrl) {
1247
+ $scope.label = $scope.label || 'Select File to Upload';
1227
1248
  let input = $(element).find('input')[0];
1228
- let a = $(element).find('a')[0];
1229
-
1249
+ let button = $(element).find('button')[0];
1250
+ if (attrs.view === '') {
1251
+ $scope.viewOnly = !0;
1252
+ }
1253
+ let progress = $(element).find('.progress')[0];
1254
+ $(progress).hide();
1255
+ $scope.folder = $scope.folder || 'default';
1256
+ $scope.id = Math.random().toString().replace('.', '_');
1230
1257
  if (attrs.view !== '') {
1231
- a.addEventListener('click', function () {
1258
+ button.addEventListener('click', function () {
1232
1259
  input.click();
1233
1260
  });
1234
1261
  }
1235
1262
 
1236
1263
  input.addEventListener('change', function () {
1237
- scope.ngModel = this.files[0].path;
1238
- scope.onSelected(this.files[0].path);
1239
- scope.$applyAsync();
1264
+ isite.uploadFile(
1265
+ this.files,
1266
+ {
1267
+ folder: $scope.folder,
1268
+ },
1269
+ (err, file, e) => {
1270
+ if (e) {
1271
+ $(progress).show();
1272
+ $scope.value = (e.loaded / e.total) * 100;
1273
+ $scope.max = e.total;
1274
+ if ($scope.value === 100) {
1275
+ $(progress).hide();
1276
+ }
1277
+ }
1278
+
1279
+ if (file) {
1280
+ $scope.ngModel = file;
1281
+ console.log(file);
1282
+ }
1283
+ }
1284
+ );
1285
+ $scope.ngModel = this.files[0].path;
1286
+ $scope.onSelected(this.files[0].path);
1287
+ $scope.$applyAsync();
1240
1288
  });
1241
1289
 
1242
- scope.$watch('ngModel', (ngModel) => {
1290
+ $scope.$watch('ngModel', (ngModel) => {
1243
1291
  if (ngModel) {
1244
1292
  a.setAttribute('url', ngModel);
1245
1293
  }
1246
1294
  });
1247
1295
  },
1248
- template: `
1249
- <form class="form text-center pointer">
1250
- <input class="hidden" type="file" name="file" />
1251
- <a class="btn {{type}}" ngClick="ngClick()" url="{{ngModel}}"> {{label}} </a>
1252
- </form>
1253
- `,
1296
+ template: `/*##client-side/sub/i-file.content.html*/`,
1254
1297
  };
1255
1298
  },
1256
1299
  ]);
@@ -1263,16 +1306,16 @@ app.directive('iImage', [
1263
1306
  restrict: 'E',
1264
1307
  required: 'ngModel',
1265
1308
  scope: {
1266
- category: '@',
1309
+ folder: '@',
1267
1310
  ngModel: '=',
1268
1311
  ngClick: '&',
1269
1312
  },
1270
- link: function (scope, element, attrs, ctrl) {
1271
- scope.category = scope.category || 'default';
1313
+ link: function ($scope, element, attrs, ctrl) {
1314
+ $scope.folder = $scope.folder || 'default';
1272
1315
 
1273
1316
  let input = $(element).find('input')[0];
1274
1317
  let img = $(element).find('img')[0];
1275
- let progress = $(element).find('progress')[0];
1318
+ let progress = $(element).find('.progress')[0];
1276
1319
  $(progress).hide();
1277
1320
 
1278
1321
  if (attrs.view !== '') {
@@ -1285,34 +1328,39 @@ app.directive('iImage', [
1285
1328
  isite.uploadImage(
1286
1329
  this.files,
1287
1330
  {
1288
- category: scope.category,
1331
+ folder: $scope.folder,
1289
1332
  },
1290
- (err, image_url, e) => {
1333
+ (err, image, e) => {
1291
1334
  if (e) {
1292
1335
  $(progress).show();
1293
- progress.value = e.loaded;
1294
- progress.max = e.total;
1336
+ $scope.value = (e.loaded / e.total) * 100;
1337
+ $scope.max = e.total;
1338
+ if ($scope.value === 100) {
1339
+ $(progress).hide();
1340
+ }
1295
1341
  }
1296
1342
 
1297
- if (image_url) {
1298
- scope.ngModel = image_url;
1343
+ if (image) {
1344
+ $scope.ngModel = image;
1299
1345
  }
1300
1346
  }
1301
1347
  );
1302
1348
  });
1303
1349
 
1304
- scope.$watch('ngModel', (ngModel) => {
1350
+ $scope.$watch('ngModel', (ngModel) => {
1305
1351
  if (ngModel) {
1306
- img.setAttribute('src', ngModel);
1352
+ img.setAttribute('src', ngModel.url);
1307
1353
  }
1308
1354
  });
1309
1355
  },
1310
1356
  template: `
1311
- <form class="form text-center pointer">
1312
- <input class="hidden" type="file" name="file" />
1313
- <img class="bg-white" ng-src="{{ngModel}}" ngClick="ngClick()" onerror="this.src='/images/no.jpg'" />
1314
- <progress class="row"></progress>
1315
- </form>
1357
+ <div class=" text-center pointer">
1358
+ <input class="hidden" type="file" name="fileToUpload" accept="image/*"/>
1359
+ <img class="rounded" ng-src="{{ngModel.url}}" ngClick="ngClick()" onerror="this.src='/images/no.jpg'" />
1360
+ <div class="progress row">
1361
+ <div class="progress-bar progress-bar-striped progress-bar-animated" role="progressbar" aria-valuenow="{{value}}" aria-valuemin="0" aria-valuemax="100" style="width: {{value}}%"></div>
1362
+ </div>
1363
+ </div>
1316
1364
  `,
1317
1365
  };
1318
1366
  },
@@ -71,10 +71,11 @@ app.service('isite', [
71
71
  var fd = new FormData();
72
72
  fd.append('fileToUpload', files[0]);
73
73
  $http
74
- .post('/api/upload/image/' + options.category, fd, {
74
+ .post('/x-api/upload/image' , fd, {
75
75
  withCredentials: !0,
76
76
  headers: {
77
77
  'Content-Type': undefined,
78
+ folder: options.folder,
78
79
  },
79
80
  uploadEventHandlers: {
80
81
  progress: function (e) {
@@ -86,7 +87,7 @@ app.service('isite', [
86
87
  .then(
87
88
  function (res) {
88
89
  if (res.data && res.data.done) {
89
- callback(null, res.data.image_url);
90
+ callback(null, res.data.image);
90
91
  }
91
92
  },
92
93
  function (error) {
@@ -98,7 +99,7 @@ app.service('isite', [
98
99
  this.uploadFile = function (files, options, callback) {
99
100
  options = Object.assign(
100
101
  {
101
- category: 'default',
102
+ folder: 'default',
102
103
  },
103
104
  options
104
105
  );
@@ -107,10 +108,11 @@ app.service('isite', [
107
108
  var fd = new FormData();
108
109
  fd.append('fileToUpload', files[0]);
109
110
  $http
110
- .post('/api/upload/file/' + options.category, fd, {
111
+ .post('/x-api/upload/file', fd, {
111
112
  withCredentials: !0,
112
113
  headers: {
113
114
  'Content-Type': undefined,
115
+ folder: options.folder,
114
116
  },
115
117
  uploadEventHandlers: {
116
118
  progress: function (e) {
@@ -122,10 +124,7 @@ app.service('isite', [
122
124
  .then(
123
125
  function (res) {
124
126
  if (res.data && res.data.done && res.data.file) {
125
- callback(null, {
126
- name: res.data.file.name,
127
- url: res.data.file.url,
128
- });
127
+ callback(null, res.data.file);
129
128
  }
130
129
  },
131
130
  function (error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isite",
3
- "version": "2022.08.02",
3
+ "version": "2022.08.03",
4
4
  "description": "Create Enterprise Multi-Language Web Site [Fast and Easy] ",
5
5
  "main": "index.js",
6
6
  "repository": {