@kigi/components 1.5.10-beta.4 → 1.5.11
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.
- package/package.json +4 -5
- package/src/components/index.ts +0 -2
- package/src/components/mbg-image-upload/helpers/firebase.ts +55 -79
- package/src/components/mbg-select-multi-list/mbg-select-multi-list.ts +3 -1
- package/src/index.html +1 -8
- package/src/index.ts +2 -14
- package/src/components/mbg-image-upload-crop/image-upload-crop.html +0 -24
- package/src/components/mbg-image-upload-crop/image-upload-crop.scss +0 -76
- package/src/components/mbg-image-upload-crop/image-upload-crop.ts +0 -50
- package/src/components/mbg-image-upload-crop/index.ts +0 -9
- package/src/components/mbg-image-upload-crop/interfaces/config-image-upload-crop.interface.ts +0 -9
- package/src/components/mbg-image-upload-crop/modals/upload-image-crop-modal/index.ts +0 -31
- package/src/components/mbg-image-upload-crop/modals/upload-image-crop-modal/upload-image-crop-modal.html +0 -70
- package/src/components/mbg-image-upload-crop/modals/upload-image-crop-modal/upload-image-crop-modal.scss +0 -140
- package/src/components/mbg-image-upload-crop/modals/upload-image-crop-modal/upload-image-crop-modal.ts +0 -151
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kigi/components",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.11",
|
|
4
4
|
"description": "@kigi/components",
|
|
5
5
|
"main": "src/components/index.ts",
|
|
6
6
|
"scripts": {
|
|
@@ -38,7 +38,6 @@
|
|
|
38
38
|
"@syncfusion/ej2-navigations": "^17.4.43",
|
|
39
39
|
"@syncfusion/ej2-splitbuttons": "^17.4.43",
|
|
40
40
|
"@types/node": "^10.10.1",
|
|
41
|
-
"ace-builds": "1.3.3",
|
|
42
41
|
"angular": "1.7.9",
|
|
43
42
|
"angular-animate": "^1.7.9",
|
|
44
43
|
"angular-bootstrap": "^0.12.2",
|
|
@@ -51,10 +50,9 @@
|
|
|
51
50
|
"angular-ui-bootstrap": "^2.5.6",
|
|
52
51
|
"angular-vs-repeat": "^2.0.14",
|
|
53
52
|
"cep-promise": "^3.0.3",
|
|
54
|
-
"cropperjs": "^1.5.12",
|
|
55
53
|
"croppie": "^2.6.2",
|
|
56
54
|
"detect-browser": "^3.0.1",
|
|
57
|
-
"firebase": "7.16.0",
|
|
55
|
+
"firebase": "^7.16.0",
|
|
58
56
|
"fuse.js": "^3.4.6",
|
|
59
57
|
"grpc": "1.20.2",
|
|
60
58
|
"highcharts": "^6.1.0",
|
|
@@ -73,7 +71,8 @@
|
|
|
73
71
|
"progressbar.js": "^1.0.1",
|
|
74
72
|
"raphael": "^2.2.8",
|
|
75
73
|
"sugarss": "^2.0.0",
|
|
76
|
-
"webcamjs": "^1.0.25"
|
|
74
|
+
"webcamjs": "^1.0.25",
|
|
75
|
+
"ace-builds": "1.3.3"
|
|
77
76
|
},
|
|
78
77
|
"devDependencies": {
|
|
79
78
|
"@types/angular": "^1.6.27",
|
package/src/components/index.ts
CHANGED
|
@@ -84,7 +84,6 @@ import { mbgTextEditorModule } from './mbg-text-editor'
|
|
|
84
84
|
import 'jodit/src/langs/pt_br.js'
|
|
85
85
|
import { NgMaskIe } from '../helpers/ie-directive/ie-directive'
|
|
86
86
|
import { mbgAceEditorModule } from './mbg-ace-editor'
|
|
87
|
-
import { mbgImageUploadCropModule } from './mbg-image-upload-crop'
|
|
88
87
|
|
|
89
88
|
if (!window['$']) {
|
|
90
89
|
window['$'] = $
|
|
@@ -101,7 +100,6 @@ const mbgComponentsModule = angular
|
|
|
101
100
|
ngSanitize,
|
|
102
101
|
ngAnimate,
|
|
103
102
|
mbgImageUploadModule,
|
|
104
|
-
mbgImageUploadCropModule,
|
|
105
103
|
mbgInputCnpjModule,
|
|
106
104
|
mbgInputCpfModule,
|
|
107
105
|
mbgInputCpfCnpjModule,
|
|
@@ -2,90 +2,66 @@ import firebase from 'firebase/app'
|
|
|
2
2
|
import 'firebase/storage'
|
|
3
3
|
|
|
4
4
|
export namespace ImageUploadFirebase {
|
|
5
|
-
|
|
5
|
+
const URL_FIREBASE = 'https://firebasestorage.googleapis.com/v0/b/bucket/o/id?alt=media'
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
export function getStorage(): any {
|
|
8
|
+
return window['firebase'] ? window['firebase'].storage() : firebase.storage()
|
|
9
|
+
}
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
11
|
+
export function guid() {
|
|
12
|
+
const s4 = () => Math.floor((1 + Math.random()) * 0x10000)
|
|
13
|
+
.toString(16)
|
|
14
|
+
.substring(1)
|
|
15
|
+
return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4()
|
|
16
|
+
}
|
|
18
17
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
18
|
+
export async function removeFiles(files) {
|
|
19
|
+
files.forEach((file) => {
|
|
20
|
+
if (file) {
|
|
21
|
+
const storageRef = getStorage().ref().child(file.idStorage)
|
|
22
|
+
storageRef.delete()
|
|
23
|
+
}
|
|
24
|
+
})
|
|
25
|
+
}
|
|
27
26
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
export async function upload(files: Array<string>, folder = '') {
|
|
28
|
+
return await Promise.all(files.map(async (base64) => {
|
|
29
|
+
const imageID = this.guid()
|
|
30
|
+
const storageRef = getStorage().ref().child(folder ? `${folder}/${imageID}` : imageID)
|
|
31
|
+
const response = await storageRef.putString(base64, 'data_url')
|
|
32
|
+
const imageURL = folder ? URL_FIREBASE.replace(/bucket/g, response.metadata.bucket).replace(/id/g, `${folder}%2F${response.metadata.name}`)
|
|
33
|
+
: URL_FIREBASE.replace(/bucket/g, response.metadata.bucket).replace(/id/g, response.metadata.name)
|
|
34
|
+
const image = { url: imageURL, idStorage: imageID }
|
|
35
|
+
return image
|
|
36
|
+
}))
|
|
37
|
+
}
|
|
38
|
+
export function uploadFile(file: File, config: { onProgress, onPause, onResume, onError, onSuccess }, folder = '') {
|
|
31
39
|
const imageID = this.guid()
|
|
32
|
-
const storageRef = getStorage()
|
|
33
|
-
|
|
34
|
-
.child(folder ? `${folder}/${imageID}` : imageID)
|
|
35
|
-
const response = await storageRef.putString(base64, 'data_url')
|
|
36
|
-
const imageURL = folder
|
|
37
|
-
? URL_FIREBASE.replace(/bucket/g, response.metadata.bucket).replace(
|
|
38
|
-
/id/g,
|
|
39
|
-
`${folder}%2F${response.metadata.name}`,
|
|
40
|
-
)
|
|
41
|
-
: URL_FIREBASE.replace(/bucket/g, response.metadata.bucket).replace(
|
|
42
|
-
/id/g,
|
|
43
|
-
response.metadata.name,
|
|
44
|
-
)
|
|
45
|
-
const image = { url: imageURL, idStorage: imageID }
|
|
46
|
-
return image
|
|
47
|
-
}),
|
|
48
|
-
)
|
|
49
|
-
}
|
|
50
|
-
export function uploadFile(
|
|
51
|
-
file: File,
|
|
52
|
-
config: { onProgress; onPause; onResume; onError; onSuccess },
|
|
53
|
-
folder = '',
|
|
54
|
-
) {
|
|
55
|
-
const imageID = this.guid()
|
|
56
|
-
const storageRef = getStorage()
|
|
57
|
-
.ref()
|
|
58
|
-
.child(folder ? `${folder}/${imageID}` : imageID)
|
|
59
|
-
const uploadTask = storageRef.put(file)
|
|
40
|
+
const storageRef = getStorage().ref().child(folder ? `${folder}/${imageID}` : imageID)
|
|
41
|
+
const uploadTask = storageRef.put(file)
|
|
60
42
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
}
|
|
74
|
-
},
|
|
75
|
-
(e) => {
|
|
76
|
-
config.onError()
|
|
77
|
-
},
|
|
78
|
-
() => {
|
|
79
|
-
uploadTask.snapshot.ref
|
|
80
|
-
.getDownloadURL()
|
|
81
|
-
.then((downloadURL) => {
|
|
82
|
-
config.onSuccess({ fileName: file.name, fileURL: downloadURL, fileSize: file.size })
|
|
83
|
-
})
|
|
84
|
-
.catch(() => {
|
|
43
|
+
uploadTask.on('state_changed', (snapshot) => {
|
|
44
|
+
const progress = (snapshot.bytesTransferred / snapshot.totalBytes) * 100
|
|
45
|
+
config.onProgress(progress)
|
|
46
|
+
switch (snapshot.state) {
|
|
47
|
+
case firebase.storage.TaskState.PAUSED:
|
|
48
|
+
config.onPause()
|
|
49
|
+
break
|
|
50
|
+
case firebase.storage.TaskState.RUNNING:
|
|
51
|
+
config.onResume()
|
|
52
|
+
break
|
|
53
|
+
}
|
|
54
|
+
}, (e) => {
|
|
85
55
|
config.onError()
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
56
|
+
}, () => {
|
|
57
|
+
uploadTask.snapshot.ref.getDownloadURL()
|
|
58
|
+
.then((downloadURL) => {
|
|
59
|
+
config.onSuccess({ fileName: file.name, fileURL: downloadURL, fileSize: file.size })
|
|
60
|
+
})
|
|
61
|
+
.catch(() => {
|
|
62
|
+
config.onError()
|
|
63
|
+
})
|
|
64
|
+
})
|
|
65
|
+
return uploadTask
|
|
66
|
+
}
|
|
91
67
|
}
|
|
@@ -112,6 +112,8 @@ export class MbgSelectMultiListController {
|
|
|
112
112
|
|
|
113
113
|
searchNgModel() {
|
|
114
114
|
this.$timeout(() => {
|
|
115
|
+
const search = (this.label || '').split(',')
|
|
116
|
+
const keys = search.map((word) => word.trim())
|
|
115
117
|
const dataModel = JSON.parse(JSON.stringify(this.ngModel))
|
|
116
118
|
const options = {
|
|
117
119
|
shouldSort: true,
|
|
@@ -120,7 +122,7 @@ export class MbgSelectMultiListController {
|
|
|
120
122
|
distance: 100,
|
|
121
123
|
maxPatternLength: 32,
|
|
122
124
|
minMatchCharLength: 1,
|
|
123
|
-
keys
|
|
125
|
+
keys,
|
|
124
126
|
}
|
|
125
127
|
const fuse = new Fuse(dataModel, options)
|
|
126
128
|
const result = fuse.search(this.inputValueResult)
|
package/src/index.html
CHANGED
|
@@ -982,8 +982,7 @@
|
|
|
982
982
|
{{teste}}
|
|
983
983
|
</div> -->
|
|
984
984
|
<div style="padding: 100px">
|
|
985
|
-
|
|
986
|
-
<!-- <div class="panel panel-default">
|
|
985
|
+
<div class="panel panel-default">
|
|
987
986
|
<div class="panel-heading">Ace Editor</div>
|
|
988
987
|
<div class="panel-body">
|
|
989
988
|
<mbg-ace-editor ng-model="aceEditor"
|
|
@@ -1000,14 +999,8 @@
|
|
|
1000
999
|
<mbg-input-text ng-model="asdasdasd"
|
|
1001
1000
|
ng-change="hhhsss($event)"></mbg-input-text>
|
|
1002
1001
|
</div>
|
|
1003
|
-
</div> -->
|
|
1004
|
-
|
|
1005
|
-
<div>
|
|
1006
|
-
<mbg-image-upload-crop ng-model="imgCrop"
|
|
1007
|
-
config="configImgCrop"></mbg-image-upload-crop>
|
|
1008
1002
|
</div>
|
|
1009
1003
|
|
|
1010
|
-
|
|
1011
1004
|
</div>
|
|
1012
1005
|
</body>
|
|
1013
1006
|
|
package/src/index.ts
CHANGED
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import * as angular from 'angular'
|
|
4
4
|
import components from './components'
|
|
5
|
-
import
|
|
6
|
-
import 'firebase/firestore'
|
|
5
|
+
import { initializeApp } from 'firebase/app'
|
|
7
6
|
import './assets/angular-locale_pt-br.js'
|
|
8
7
|
import * as dataDocument from './assets/data-default.json'
|
|
9
8
|
import { MbgAlert } from './helpers/services/mbg-alert'
|
|
@@ -14,7 +13,7 @@ const sizeJson = require('./json/sizes.json')
|
|
|
14
13
|
const genderJson = require('./json/gender.json')
|
|
15
14
|
const mockData = require('./json/MOCK_DATA.json')
|
|
16
15
|
|
|
17
|
-
|
|
16
|
+
initializeApp({
|
|
18
17
|
apiKey: 'AIzaSyB0aH7e6XjWJ-xViji3CuXHBbLuWRALC78',
|
|
19
18
|
authDomain: 'app-kigi.firebaseapp.com',
|
|
20
19
|
databaseURL: 'https://app-kigi-default-rtdb.firebaseio.com',
|
|
@@ -31,17 +30,6 @@ const module = angular.module('demo', ['ngLocale', components]).controller('demo
|
|
|
31
30
|
'$http',
|
|
32
31
|
'mbgAlert',
|
|
33
32
|
($scope, $timeout, $http, mbgAlert: MbgAlert) => {
|
|
34
|
-
$scope.imgCrop = 'https://i.pinimg.com/originals/c3/a5/b3/c3a5b332f9716abb1c67da38a12595e8.jpg'
|
|
35
|
-
$scope.configImgCrop = {
|
|
36
|
-
aspectRatio: 16 / 9,
|
|
37
|
-
minCropBoxWidth: 200,
|
|
38
|
-
minCropBoxHeight: 100,
|
|
39
|
-
minCanvasHeight: 200,
|
|
40
|
-
minContainerHeight: 100,
|
|
41
|
-
height: '124px',
|
|
42
|
-
// width: '300px',
|
|
43
|
-
}
|
|
44
|
-
|
|
45
33
|
$scope.configDocument = {
|
|
46
34
|
document: dataDocument,
|
|
47
35
|
preview: true,
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
<div class="image-upload-crop-wrapper"
|
|
2
|
-
ng-style="{ 'width': $ctrl.config.width ? $ctrl.config.width : '200px', 'height': $ctrl.config.height ? $ctrl.config.height : '84px'}">
|
|
3
|
-
<div class="upload-item"
|
|
4
|
-
ng-style="{'cursor': $ctrl.ngModel ? 'default' : 'pointer'}"
|
|
5
|
-
ng-click="!$ctrl.ngModel && $ctrl.openModal()">
|
|
6
|
-
<div class="preview-image-crop"
|
|
7
|
-
ng-show="$ctrl.ngModel"
|
|
8
|
-
ng-click="$ctrl.openModal()">
|
|
9
|
-
<img ng-show="$ctrl.ngModel"
|
|
10
|
-
ng-style="{ 'object-fit': 'contain', 'width': '100%'}"
|
|
11
|
-
src="{{$ctrl.ngModel}}">
|
|
12
|
-
</div>
|
|
13
|
-
<div class="icon-upload-image-crop">
|
|
14
|
-
<i ng-show="!$ctrl.ngModel"
|
|
15
|
-
class="fas fa-cloud-upload-alt"></i>
|
|
16
|
-
<div class="buttons"
|
|
17
|
-
ng-class="{'remove': $ctrl.ngModel}">
|
|
18
|
-
<a ng-click="$ctrl.removeImage($event)">{{$ctrl.ngModel ? 'Remover' : ''}}</a>
|
|
19
|
-
<a ng-click="$ctrl.openModal()">{{$ctrl.ngModel ? 'Alterar' : 'Fazer upload'}}</a>
|
|
20
|
-
</div>
|
|
21
|
-
</div>
|
|
22
|
-
|
|
23
|
-
</div>
|
|
24
|
-
</div>
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
.image-upload-crop-wrapper {
|
|
2
|
-
.upload-item {
|
|
3
|
-
padding: 4px;
|
|
4
|
-
border: 1px dashed #9c9c9c;
|
|
5
|
-
border-radius: 4px;
|
|
6
|
-
display: flex;
|
|
7
|
-
flex-direction: column;
|
|
8
|
-
width: 100%;
|
|
9
|
-
transition: all 300ms ease-in-out;
|
|
10
|
-
height: 100%;
|
|
11
|
-
margin-top: 10px;
|
|
12
|
-
position: relative;
|
|
13
|
-
text-align: center;
|
|
14
|
-
align-items: center;
|
|
15
|
-
justify-content: center;
|
|
16
|
-
|
|
17
|
-
i {
|
|
18
|
-
font-size: 24px;
|
|
19
|
-
margin-top: 4px;
|
|
20
|
-
margin-bottom: 4px;
|
|
21
|
-
color: #4d4d4d;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
label {
|
|
25
|
-
position: absolute;
|
|
26
|
-
top: -17px;
|
|
27
|
-
left: 0;
|
|
28
|
-
font-weight: 500;
|
|
29
|
-
font-size: 12px;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
a {
|
|
33
|
-
text-align: center;
|
|
34
|
-
font-size: 12px;
|
|
35
|
-
margin-top: 2px;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
.preview-image-crop {
|
|
39
|
-
height: calc(100% - 24px);
|
|
40
|
-
cursor: pointer;
|
|
41
|
-
|
|
42
|
-
img {
|
|
43
|
-
width: auto;
|
|
44
|
-
height: 100%;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
.icon-upload-image-crop {
|
|
49
|
-
width: 100%;
|
|
50
|
-
display: flex;
|
|
51
|
-
flex-direction: column;
|
|
52
|
-
justify-content: center;
|
|
53
|
-
align-items: center;
|
|
54
|
-
|
|
55
|
-
.buttons {
|
|
56
|
-
width: 100%;
|
|
57
|
-
display: flex;
|
|
58
|
-
justify-content: center;
|
|
59
|
-
|
|
60
|
-
a {
|
|
61
|
-
cursor: pointer;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
.remove {
|
|
66
|
-
justify-content: space-around;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
&:hover {
|
|
70
|
-
background: #e4e4e4;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
.gap-12 {
|
|
74
|
-
gap: 12px;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import './image-upload-crop.scss'
|
|
2
|
-
import template from './image-upload-crop.html'
|
|
3
|
-
import { IConfigImageUploadCrop } from './interfaces/config-image-upload-crop.interface'
|
|
4
|
-
import { UploadImageCropModal } from './modals/upload-image-crop-modal'
|
|
5
|
-
|
|
6
|
-
class ImageUploadCropController {
|
|
7
|
-
public config: IConfigImageUploadCrop
|
|
8
|
-
public ngModel: string
|
|
9
|
-
|
|
10
|
-
constructor(
|
|
11
|
-
public $scope,
|
|
12
|
-
public $element,
|
|
13
|
-
public $timeout,
|
|
14
|
-
public uploadImageCropModal: UploadImageCropModal,
|
|
15
|
-
) {}
|
|
16
|
-
|
|
17
|
-
$onInit() {
|
|
18
|
-
this.config = this.config || {
|
|
19
|
-
aspectRatio: 1 / 1,
|
|
20
|
-
minCropBoxWidth: 200,
|
|
21
|
-
minCropBoxHeight: 200,
|
|
22
|
-
minCanvasHeight: 100,
|
|
23
|
-
minContainerHeight: 100,
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
removeImage(e) {
|
|
28
|
-
e.stopPropagation()
|
|
29
|
-
this.ngModel = ''
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
openModal() {
|
|
33
|
-
this.uploadImageCropModal.open(this.config, this.ngModel).then((url) => {
|
|
34
|
-
if (url) {
|
|
35
|
-
this.ngModel = url
|
|
36
|
-
}
|
|
37
|
-
})
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const imageUploadCrop = {
|
|
42
|
-
bindings: {
|
|
43
|
-
ngModel: '=?',
|
|
44
|
-
config: '=?',
|
|
45
|
-
},
|
|
46
|
-
controller: ImageUploadCropController,
|
|
47
|
-
template,
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export { imageUploadCrop }
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import * as angular from 'angular'
|
|
2
|
-
import { imageUploadCrop } from './image-upload-crop'
|
|
3
|
-
import { uploadImageCropModalModule } from './modals/upload-image-crop-modal'
|
|
4
|
-
|
|
5
|
-
const mbgImageUploadCropModule = angular
|
|
6
|
-
.module('mbg.components.imageUploadCrop', [uploadImageCropModalModule])
|
|
7
|
-
.component('mbgImageUploadCrop', imageUploadCrop).name
|
|
8
|
-
|
|
9
|
-
export { mbgImageUploadCropModule }
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import * as angular from 'angular'
|
|
2
|
-
import './upload-image-crop-modal.scss'
|
|
3
|
-
import { UploadImageCropModalController } from './upload-image-crop-modal'
|
|
4
|
-
import UploadImageCropModalTemplate from './upload-image-crop-modal.html'
|
|
5
|
-
import { IConfigImageUploadCrop } from '../../interfaces/config-image-upload-crop.interface'
|
|
6
|
-
|
|
7
|
-
export class UploadImageCropModal {
|
|
8
|
-
constructor(public $uibModal) {}
|
|
9
|
-
|
|
10
|
-
open(cropOptions: IConfigImageUploadCrop, image: string) {
|
|
11
|
-
const modalInstance = this.$uibModal.open({
|
|
12
|
-
template: UploadImageCropModalTemplate,
|
|
13
|
-
controller: UploadImageCropModalController,
|
|
14
|
-
controllerAs: '$ctrl',
|
|
15
|
-
animation: true,
|
|
16
|
-
backdrop: 'static',
|
|
17
|
-
size: 'md',
|
|
18
|
-
resolve: {
|
|
19
|
-
cropOptions: () => cropOptions,
|
|
20
|
-
image: () => image,
|
|
21
|
-
},
|
|
22
|
-
})
|
|
23
|
-
return modalInstance.result
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const uploadImageCropModalModule = angular
|
|
28
|
-
.module(`mbg.modals.uploadImageCropModal`, [])
|
|
29
|
-
.service('uploadImageCropModal', UploadImageCropModal).name
|
|
30
|
-
|
|
31
|
-
export { uploadImageCropModalModule }
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
<div class="upload-image-crop-modal-wrapper">
|
|
2
|
-
<div class="head-logo">
|
|
3
|
-
<h1>Imagem</h1>
|
|
4
|
-
|
|
5
|
-
</div>
|
|
6
|
-
<div class="body-logo">
|
|
7
|
-
<div class="image-container-crop">
|
|
8
|
-
<input type="file"
|
|
9
|
-
multiple="false"
|
|
10
|
-
onchange="angular.element(this).scope().$ctrl.onSelectFiles(event)"
|
|
11
|
-
id="chooseFileLogo" />
|
|
12
|
-
|
|
13
|
-
<div ng-show="!$ctrl.file"
|
|
14
|
-
ng-click="$ctrl.chooseFileLogo()"
|
|
15
|
-
ondrop="angular.element(this).scope().$ctrl.onDropFile(event)"
|
|
16
|
-
ondragover="angular.element(this).scope().$ctrl.onDragOver(event)"
|
|
17
|
-
class="flex flex-column justify-center align-center image-drap-drop-container">
|
|
18
|
-
<div class="flex flex-column align-center justify-center">
|
|
19
|
-
<i ng-show="!$ctrl.image"
|
|
20
|
-
class="fas fa-cloud-upload-alt"></i>
|
|
21
|
-
<label ng-show="$ctrl.image"
|
|
22
|
-
style="font-weight: 500;">Imagem atual</label>
|
|
23
|
-
<img ng-if="$ctrl.image"
|
|
24
|
-
style="max-height: 200px;max-width: 400px; object-fit: contain;"
|
|
25
|
-
class="m-b-24"
|
|
26
|
-
src="{{$ctrl.image}}"></i>
|
|
27
|
-
|
|
28
|
-
<label ng-show="$ctrl.image">Arraste e solte uma imagem ou clique aqui para editar</label>
|
|
29
|
-
<label ng-show="!$ctrl.image">Arraste e solte uma imagem ou clique aqui para adicionar</label>
|
|
30
|
-
</div>
|
|
31
|
-
</div>
|
|
32
|
-
<div class="relative-content"
|
|
33
|
-
ng-if="$ctrl.file">
|
|
34
|
-
<button type="button"
|
|
35
|
-
class="stop-upload"
|
|
36
|
-
ng-click="$ctrl.resetFile()">
|
|
37
|
-
<i class="fas fa-times"></i>
|
|
38
|
-
</button>
|
|
39
|
-
<img ng-src="{{ $ctrl.file }}"
|
|
40
|
-
class="crop-image-original"
|
|
41
|
-
ng-init="$ctrl.createCropier()"
|
|
42
|
-
alt="Logo" />
|
|
43
|
-
</div>
|
|
44
|
-
</div>
|
|
45
|
-
<div class="row">
|
|
46
|
-
<div class="col-md-12">
|
|
47
|
-
<p style="margin-bottom: 0px">Tamanho ideal em pixels: ({{$ctrl.cropOptions.minCropBoxWidth}} x
|
|
48
|
-
{{$ctrl.cropOptions.minCropBoxHeight}})px
|
|
49
|
-
</p>
|
|
50
|
-
</div>
|
|
51
|
-
</div>
|
|
52
|
-
<div class="row m-t-24">
|
|
53
|
-
<div class="col-md-12 flex flex-column align-center justify-center">
|
|
54
|
-
<mbg-btn-form ng-click="$ctrl.save()"
|
|
55
|
-
ng-disabled="$ctrl.loading"
|
|
56
|
-
loading="$ctrl.loading"
|
|
57
|
-
label="Confirmar"></mbg-btn-form>
|
|
58
|
-
<label class="error-label"
|
|
59
|
-
ng-class="{'active': $ctrl.activeError}">{{$ctrl.labelError}}</label>
|
|
60
|
-
<div class="flex align-center">
|
|
61
|
-
<a class="cancel-link"
|
|
62
|
-
target="_self"
|
|
63
|
-
ng-disabled="$ctrl.loading"
|
|
64
|
-
ng-click="$ctrl.closeModal()">Cancelar</a>
|
|
65
|
-
</div>
|
|
66
|
-
</div>
|
|
67
|
-
</div>
|
|
68
|
-
|
|
69
|
-
</div>
|
|
70
|
-
</div>
|
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
.upload-image-crop-modal-wrapper {
|
|
2
|
-
display: flex;
|
|
3
|
-
flex-direction: column;
|
|
4
|
-
width: 100%;
|
|
5
|
-
|
|
6
|
-
.relative-content {
|
|
7
|
-
position: relative;
|
|
8
|
-
max-height: 400px;
|
|
9
|
-
|
|
10
|
-
.stop-upload {
|
|
11
|
-
z-index: 1000;
|
|
12
|
-
position: absolute;
|
|
13
|
-
top: 4px;
|
|
14
|
-
right: 4px;
|
|
15
|
-
background: #fff;
|
|
16
|
-
border-radius: 50%;
|
|
17
|
-
font-size: 21px;
|
|
18
|
-
width: 34px;
|
|
19
|
-
height: 34px;
|
|
20
|
-
border: 2px solid #595959;
|
|
21
|
-
color: #666;
|
|
22
|
-
transform: scale(0.8);
|
|
23
|
-
transition: all 300ms ease;
|
|
24
|
-
|
|
25
|
-
&:hover {
|
|
26
|
-
transform: scale(0.9);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
.cropper-container {
|
|
32
|
-
width: 100% !important;
|
|
33
|
-
height: 368px !important;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
.head-logo {
|
|
37
|
-
padding: 0 24px;
|
|
38
|
-
h1 {
|
|
39
|
-
color: var(--neutral1);
|
|
40
|
-
font-size: 24px;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
.body-logo {
|
|
44
|
-
flex: 1;
|
|
45
|
-
position: relative;
|
|
46
|
-
padding: 0 24px;
|
|
47
|
-
padding-bottom: 24px;
|
|
48
|
-
}
|
|
49
|
-
.image-container-crop {
|
|
50
|
-
width: 100%;
|
|
51
|
-
background: #f5f5f5;
|
|
52
|
-
height: 368px;
|
|
53
|
-
border-radius: 5px;
|
|
54
|
-
overflow: hidden;
|
|
55
|
-
cursor: pointer;
|
|
56
|
-
}
|
|
57
|
-
#chooseFileLogo {
|
|
58
|
-
display: none;
|
|
59
|
-
}
|
|
60
|
-
.crop-image-original {
|
|
61
|
-
display: block;
|
|
62
|
-
max-width: 100%;
|
|
63
|
-
}
|
|
64
|
-
.image-drap-drop-container {
|
|
65
|
-
height: 100%;
|
|
66
|
-
|
|
67
|
-
i {
|
|
68
|
-
font-size: 68px;
|
|
69
|
-
color: #666;
|
|
70
|
-
}
|
|
71
|
-
label {
|
|
72
|
-
font-size: 16px;
|
|
73
|
-
margin: 14px 4px;
|
|
74
|
-
cursor: pointer;
|
|
75
|
-
}
|
|
76
|
-
button {
|
|
77
|
-
margin-top: 18px;
|
|
78
|
-
height: 44px;
|
|
79
|
-
padding: 0 24px;
|
|
80
|
-
border-radius: 41px;
|
|
81
|
-
background: var(--contrast);
|
|
82
|
-
color: #fff;
|
|
83
|
-
border: none;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
.flex {
|
|
88
|
-
display: flex;
|
|
89
|
-
.flex-1 {
|
|
90
|
-
flex: 1;
|
|
91
|
-
}
|
|
92
|
-
.fit-content {
|
|
93
|
-
min-height: fit-content;
|
|
94
|
-
}
|
|
95
|
-
&.flex-row {
|
|
96
|
-
flex-direction: row;
|
|
97
|
-
}
|
|
98
|
-
&.flex-column {
|
|
99
|
-
flex-direction: column;
|
|
100
|
-
}
|
|
101
|
-
&.align-center {
|
|
102
|
-
align-items: center;
|
|
103
|
-
}
|
|
104
|
-
&.align-end {
|
|
105
|
-
align-items: flex-end;
|
|
106
|
-
}
|
|
107
|
-
&.align-start {
|
|
108
|
-
align-items: flex-start;
|
|
109
|
-
}
|
|
110
|
-
&.align-between {
|
|
111
|
-
align-items: space-between;
|
|
112
|
-
}
|
|
113
|
-
&.justify-center {
|
|
114
|
-
justify-content: center;
|
|
115
|
-
}
|
|
116
|
-
&.justify-end {
|
|
117
|
-
justify-content: flex-end;
|
|
118
|
-
}
|
|
119
|
-
&.justify-start {
|
|
120
|
-
justify-content: flex-start;
|
|
121
|
-
}
|
|
122
|
-
&.justify-between {
|
|
123
|
-
justify-content: space-between;
|
|
124
|
-
}
|
|
125
|
-
&.justify-around {
|
|
126
|
-
justify-content: space-around;
|
|
127
|
-
}
|
|
128
|
-
&.wrap {
|
|
129
|
-
flex-wrap: wrap;
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
.m-t-24 {
|
|
133
|
-
margin-top: 24px;
|
|
134
|
-
}
|
|
135
|
-
.cancel-link {
|
|
136
|
-
margin: 18px 24px 0px 24px;
|
|
137
|
-
color: var(--neutral2);
|
|
138
|
-
cursor: pointer;
|
|
139
|
-
}
|
|
140
|
-
}
|
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
// import { MobiEVendiService } from 'modules/mobi-store/services/mobi-e-vendi-service'
|
|
2
|
-
import 'cropperjs/dist/cropper.css'
|
|
3
|
-
// import Cropper from 'cropperjs'
|
|
4
|
-
import Cropper from 'cropperjs/dist/cropper.esm'
|
|
5
|
-
import { UtilMbgFunctions } from '../../../../helpers/util-mbg-functions'
|
|
6
|
-
import { UtilUID } from '../../../../helpers/util-uid'
|
|
7
|
-
import { MbgImageUploadService } from '../../../mbg-image-upload/services/mbg-image-upload-service'
|
|
8
|
-
import firebase from 'firebase/app'
|
|
9
|
-
import 'firebase/storage'
|
|
10
|
-
// import { UtilUID } from 'modules/helpers/namespaces/util-uid'
|
|
11
|
-
// import { SessionStorage } from 'modules/helpers/namespaces/sessionstorage'
|
|
12
|
-
// import { HelperNotificationService } from 'modules/helpers/services/notification.service'
|
|
13
|
-
|
|
14
|
-
class UploadImageCropModalController {
|
|
15
|
-
private file
|
|
16
|
-
private cropper: Cropper
|
|
17
|
-
private loading
|
|
18
|
-
private activeError: boolean
|
|
19
|
-
private labelError: string
|
|
20
|
-
|
|
21
|
-
constructor(
|
|
22
|
-
public $timeout,
|
|
23
|
-
public $scope,
|
|
24
|
-
public $uibModalInstance,
|
|
25
|
-
public cropOptions,
|
|
26
|
-
public image,
|
|
27
|
-
public mbgImageUploadService: MbgImageUploadService,
|
|
28
|
-
) {}
|
|
29
|
-
|
|
30
|
-
$onInit() {
|
|
31
|
-
this.$scope.$on('$destroy', () => {
|
|
32
|
-
this.destroyCropier()
|
|
33
|
-
})
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
closeModal() {
|
|
37
|
-
this.$uibModalInstance.close()
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
async onFileSelect(file) {
|
|
41
|
-
const base64 = await this.toBase64(file)
|
|
42
|
-
this.$timeout(() => {
|
|
43
|
-
this.file = base64
|
|
44
|
-
})
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
createCropier() {
|
|
48
|
-
this.$timeout(() => {
|
|
49
|
-
const image: any = document.querySelector('.crop-image-original')
|
|
50
|
-
this.cropper = new Cropper(
|
|
51
|
-
image,
|
|
52
|
-
Object.assign(
|
|
53
|
-
{
|
|
54
|
-
dragMode: 'move',
|
|
55
|
-
},
|
|
56
|
-
this.cropOptions,
|
|
57
|
-
),
|
|
58
|
-
)
|
|
59
|
-
})
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
toBase64 = (file) => {
|
|
63
|
-
return new Promise((resolve, reject) => {
|
|
64
|
-
const reader = new FileReader()
|
|
65
|
-
reader.readAsDataURL(file)
|
|
66
|
-
reader.onload = () => resolve(reader.result)
|
|
67
|
-
reader.onerror = (error) => reject(error)
|
|
68
|
-
})
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
onDropFile(ev) {
|
|
72
|
-
ev.preventDefault()
|
|
73
|
-
const dataTransfer = ev.dataTransfer
|
|
74
|
-
if (dataTransfer.files && dataTransfer.files.length > 0) {
|
|
75
|
-
const file = dataTransfer.files[0]
|
|
76
|
-
this.onFileSelect(file)
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
onDragOver(ev) {
|
|
81
|
-
ev.preventDefault()
|
|
82
|
-
ev.dataTransfer.dropEffect = 'move'
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
chooseFileLogo() {
|
|
86
|
-
const input: any = document.querySelector('#chooseFileLogo')
|
|
87
|
-
input.value = ''
|
|
88
|
-
input.click()
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
resetFile() {
|
|
92
|
-
this.file = null
|
|
93
|
-
const input: any = document.querySelector('#chooseFileLogo')
|
|
94
|
-
input.value = ''
|
|
95
|
-
this.destroyCropier()
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
onSelectFiles(ev) {
|
|
99
|
-
const files = ev.target.files
|
|
100
|
-
if (files && files.length > 0) {
|
|
101
|
-
this.onFileSelect(files[0])
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
destroyCropier() {
|
|
106
|
-
if (this.cropper) {
|
|
107
|
-
this.cropper.destroy()
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
dismiss() {
|
|
112
|
-
this.$uibModalInstance.close(false)
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
async save() {
|
|
116
|
-
try {
|
|
117
|
-
this.loading = true
|
|
118
|
-
this.activeError = false
|
|
119
|
-
const URL_FIREBASE = 'https://firebasestorage.googleapis.com/v0/b/bucket/o/id?alt=media'
|
|
120
|
-
const base64 = this.cropper.getCroppedCanvas().toDataURL()
|
|
121
|
-
const imageID = UtilUID.generete()
|
|
122
|
-
|
|
123
|
-
const storageRef = (window['firebase'] ? window['firebase'].storage() : firebase.storage())
|
|
124
|
-
.ref()
|
|
125
|
-
.child(imageID)
|
|
126
|
-
const response = await storageRef.putString(base64, 'data_url')
|
|
127
|
-
const imageURL = URL_FIREBASE.replace(/bucket/g, response.metadata.bucket).replace(
|
|
128
|
-
/id/g,
|
|
129
|
-
response.metadata.name,
|
|
130
|
-
)
|
|
131
|
-
|
|
132
|
-
this.$uibModalInstance.close(imageURL)
|
|
133
|
-
} catch (e) {
|
|
134
|
-
console.log(e)
|
|
135
|
-
this.loading = false
|
|
136
|
-
this.activeError = true
|
|
137
|
-
this.labelError = 'Erro ao salvar a imagem, tente novamente!'
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
UploadImageCropModalController[`$inject`] = [
|
|
143
|
-
'$timeout',
|
|
144
|
-
'$scope',
|
|
145
|
-
'$uibModalInstance',
|
|
146
|
-
'cropOptions',
|
|
147
|
-
'image',
|
|
148
|
-
'mbgImageUploadService',
|
|
149
|
-
]
|
|
150
|
-
|
|
151
|
-
export { UploadImageCropModalController }
|