OWL ITS + 탐지시스템(인터넷 진흥원)
박지현
2022-02-22 302112b8c095984fe054bb357cbbd2ef3d88e844
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
/**
 * Created by wisestone on 2018-01-17.
 */
'use strict';
 
define([
        'app',
        'angular'
    ],
    function (app, angular) {
        app.controller('hostingFieldImportExcelController', ['$scope', '$rootScope', '$log', '$resourceProvider', '$uibModalInstance', '$injector', '$controller', '$tableProvider', 'HostingField', 'SweetAlert', '$filter', '$timeout',
            function ($scope, $rootScope, $log, $resourceProvider, $uibModalInstance, $injector, $controller, $tableProvider, HostingField, SweetAlert, $filter, $timeout) {
 
                $scope.fn = {
                    cancel : cancel,    //  팝업 창 닫기
                    formSubmit : formSubmit,    //  폼 전송
                    formCheck : formCheck,  //  폼 체크
                    onFileSelect : onFileSelect, //  파일 업로드
                };
 
                $scope.vm = {
                    form : {
                        file : "",   //  업로드하는 Excel File
                        fileName : ""
                    },
                    tab : "VIDEO"
                };
 
                //  파일 업로드
                function onFileSelect($files) {
                    $scope.vm.form.file = $files;
 
                    if ($files.length > 0) {
                        $scope.vm.form.fileName = $files[0].name;
                    }
                    else {
                        $scope.vm.form.fileName = "";
                    }
                }
 
                //  폼 체크
                function formCheck() {
                    if ($scope.vm.form.file.length < 1) {
                        return true;
                    }
                    return false;
                }
 
                //  폼 전송
                function formSubmit() {
                    $rootScope.spinner = true;
 
                    HostingField.importExcel({
                        method : "POST",
                        file : $scope.vm.form.file,
                        //      data 속성으로 별도의 데이터 전송
                        fileFormDataName : "file"
                    })
                    .then(function (result) {
                        if (result.data.message.status === "success") {
                            $timeout(function () {
                                SweetAlert.success($filter("translate")("hostingField.succeededHostingFieldRegistration"), result.data.message.message); // 등록 성공
                                $scope.fn.cancel();
                                $rootScope.$broadcast("getHostingFieldList");
                                $rootScope.spinner = false;
                            }, 1000);
                        }
                        else {
                            SweetAlert.error($filter("translate")("hostingField.failedHostingFieldRegistration"), result.data.message.message); // 등록 실패
                            $rootScope.spinner = false;
                        }
                    });
                }
 
                function cancel() {
                    $rootScope.$broadcast("closeLayer");    //  팝업이 열리고 나서 js-multi, js-single 등에서 body 이벤트가 날아가는 현상 수정
                    $uibModalInstance.dismiss('cancel');
                }
            }]);
    });