<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">(function () {
    angular.module('myApp').service('$fileManager', ['$state', '$stateParams', '$rootScope', '$Vpdt', '$https',
        function ($state, $stateParams, $rootScope, $Vpdt, $https) {
            var $fileManager = {};
            // checkUseFileByCode() dĂ¹ng Ä‘á»ƒ kiá»ƒm tra Ä‘Æ°á»ng dáº«n file cĂ³ pháº£i sá»­ dá»¥ng dáº¡ng mĂ£ hay khĂ´ng
            $fileManager.checkUseFileByCode = function (path) {
                var check = false;
                if (path) {
                    var arr_path = path.split(":");
                    arr_path.forEach(function (item) {
                        if (item.indexOf("http") == -1) { check = true; return check }
                    });

                }
                return check;
            }

            $fileManager.getPrefixSplit = function() {
                return "___";
            }

            $fileManager.clear_time_in_pathfile = function (path) {
                var index = 0; 
                if (String(path).toLowerCase().indexOf('am-') != -1)
                    index = String(path).toLowerCase().indexOf('am-') + 3;
                if (String(path).toLowerCase().indexOf('pm-') != -1)
                    index = String(path).toLowerCase().indexOf('pm-') + 3;
                path = path.substring(index);
                return path
            }


            $fileManager.generateAPIViewFile = function (params) {
                if (!params.name) params.name = "";
                if (!params.path) params.path = "";
                if (!params.type) params.type = "view";
                if (!params.encoded) params.encoded = false;
                if (!params.validate_time) params.validate_time = 'no_validate_time';
                //endcode
                if(params.type =='view_in_window') params.type = 'view';
                var path_encode = params.path;
                if (!params.encoded) path_encode = $Vpdt.b64EncodeUnicode(params.path);
                var refresh_token = $Vpdt.b64EncodeUnicode($Vpdt.getRefreshToken());
                var validate_time_encode = $Vpdt.b64EncodeUnicode(params.validate_time);
                // var apiViewFile = ApiDomain + "/api/mongo-file/xem-file/" + params.name + "?path=" + params.path + "&amp;type=" + params.type;
                var apiViewFile = ApiDomain + "/api/file/view-file/" + refresh_token + "/" + validate_time_encode + "/" + params.type + "/" + params.name +"?path=" + path_encode + '#toolbar=1';
                return encodeURI(apiViewFile);
            }

            $fileManager.generateViewDocument= function (params) {
                if (!params.name) params.name = "";
                if (!params.path) params.path = "";
                if (!params.type) params.type = "view";
                if(params.type =='view_in_window') params.type = 'view';
                var path_encode = $Vpdt.b64EncodeUnicode(params.path);
                url = window.location.origin;
                url += '/view-document';
                url += '?name=' + params.name;
                url += '&amp;path=' + path_encode;
                url += '&amp;type=' + params.type;
                url += '&amp;encoded=true';
                return encodeURI(url);
            }

            $fileManager.getSeparatorFileCode = function () {
                return "___";
            }

            $fileManager.getFileNameUseFileCode = function (path) {
                path = path.split($fileManager.getSeparatorFileCode());
                return path[path.length - 1];
            }

            $fileManager.getCodeUseFileCode = function (path) {
                path = path.split($fileManager.getSeparatorFileCode());
                return path[0];
            }



            // getFileResultObjectToString() dĂ¹ng Ä‘á»ƒ kiá»ƒm tra giáº£i mĂ£ object file thĂ&nbsp;nh chuá»—i file
            $fileManager.getFileResultObjectToString = function (obj) {
                var stringFileResult = "";
                var stringFileError = "";
                if (typeof obj !== 'object') return { id: -1, data: "", error: "Dá»¯ liá»‡u khĂ´ng pháº£i lĂ&nbsp; object" };
                if (!obj) return { id: -1, data: "", error: "KhĂ´ng cĂ³ dá»¯ liá»‡u!" };
                try {
                    if (obj.id &gt; 0) {
                        var data = obj.data;
                        data.forEach(function (item) {
                            if (item.ma_file_kc &gt; 0) {
                                if (item.type_save_file == 1 || item.type_save_file == 2) {
                                    stringFileResult += ':' + item.ma_file_kc;
                                } else {
                                    stringFileResult += ':' + item.path;
                                }
                               
                            } else {
                                stringFileError +=  item.fileName + ", chi tiáº¿t: " + item.message + "&lt;/br&gt;";
                            }
                        });

                    } else {
                        return { id: -1, data: obj.data, error: obj.message }
                    }

                    if (stringFileResult.length &gt; 0) {
                        stringFileResult = stringFileResult.substring(1);
                    }
                    if (stringFileError.length &gt; 0) {
                        stringFileError = stringFileError;
                    }
                    return { id: 1, data: stringFileResult, error: stringFileError }
                } catch (e) {
                    return { id: -1, data: "", error: e.message }
                }
            }

            $fileManager.getPathFile = function (path, callback) {
                if (!path || path == "null" || path == "undefined") { callback(path); return };
                if (!$fileManager.checkUseFileByCode(path)) { callback(path); return};
                var kq = "";
                 $Vpdt.Api2({
                    api: '/api/file/get-path-file?'
                        + 'path_filecode=' + path,
                    method: 'GET'
                }, function (res) {
                    callback(res)
                });
            }

            $fileManager.delete_file = function (path, callback) {
                callback({id:1});
				return;
				var refresh_token = $Vpdt.getRefreshToken();
                refresh_token = $Vpdt.b64EncodeUnicode(refresh_token);
                $Vpdt.Api2({
                    api: '/api/file/delete/' + refresh_token
                        + '?path=' + path,
                    method: 'DELETE'
                }, function (res) {
                        callback(res);
                });
            }
            $fileManager.delete_pathfile = function (path, path_delete) {
                if ($fileManager.checkUseFileByCode(path_delete)) { path_delete = $fileManager.getCodeUseFileCode(path_delete) }
                path = path.replace(path_delete, '') + '';
                path = path.replace('::', ':');
                if (path[0] == ':')
                    path = path.substring(1);
                var n = path.length;
                if (path[n - 1] == ':')
                    path = path.substring(0, n - 1);
                return path;
            }
            return $fileManager;
        }]);
})();</pre></body></html>