|
@@ -84,10 +84,11 @@
|
|
|
}).ajaxStop(()=>{
|
|
|
$('#load').remove();
|
|
|
});
|
|
|
+
|
|
|
$(()=>{
|
|
|
microsoftTeams.appInitialization.notifySuccess();
|
|
|
getGroupList();
|
|
|
-
|
|
|
+ moveItem();
|
|
|
window.oncontextmenu = function () {
|
|
|
return false;
|
|
|
};
|
|
@@ -95,107 +96,81 @@
|
|
|
$('.click-menu').css('display', 'none');
|
|
|
})
|
|
|
|
|
|
-
|
|
|
+ $('.file-content').on('click', function(event){
|
|
|
+ if (event.originalEvent.target === $('.file-content')[0]) {
|
|
|
+ $('.file-content input[type="checkbox"]').prop('checked', false);
|
|
|
+ $('.file-content > div.on').removeClass('on');
|
|
|
+ }
|
|
|
+ })
|
|
|
});
|
|
|
function openFolder(event) {
|
|
|
- if (!$('.panel-item.on')[0]) return;
|
|
|
+ $('.upload-items').css('display', 'none');
|
|
|
+ if (!$('.panel-item.on')[0]) return alertMessage('폴더 업로드', '업로드할 그룹을 선택해 주세요.');
|
|
|
$('#folder-upload').click();
|
|
|
}
|
|
|
|
|
|
function openFile(event) {
|
|
|
- if (!$('.panel-item.on')[0]) return;
|
|
|
+ $('.upload-items').css('display', 'none');
|
|
|
+ if (!$('.panel-item.on')[0]) return alertMessage('파일 업로드', '업로드할 그룹을 선택해 주세요.');
|
|
|
$('#file-upload').click();
|
|
|
}
|
|
|
function allSelect(event) {
|
|
|
const isChecked = $(event.target).is(':checked');
|
|
|
$('.file-content input[type="checkbox"]').prop('checked', isChecked);
|
|
|
+ let method = 'addClass';
|
|
|
+ if (!isChecked) {
|
|
|
+ method = 'removeClass';
|
|
|
+ }
|
|
|
+ $('.file-content > div')[method]('on');
|
|
|
}
|
|
|
|
|
|
function uploadFiles(event) {
|
|
|
const files = event.target.files;
|
|
|
+ if (files.length === 0) return;
|
|
|
const alertTitle = '파일 업로드';
|
|
|
- _formData = new FormData($('<form enctype="multipart/form-data"></form>')[0]);
|
|
|
- if (files && files.length > 100) {
|
|
|
- return alertMessage(alertTitle, '업로드 파일은 최대 100개 까지 가능합니다.<br>업로드 파일 수 : '+ files.length, null);
|
|
|
- }
|
|
|
-
|
|
|
- let siteId = getSitesId();
|
|
|
-
|
|
|
- if (siteId === null) {
|
|
|
- return alertMessage(alertTitle, '선택된 그룹 정보를 찾을 수 없습니다. 생성할 그룹을 선택해주세요.', null);
|
|
|
- }
|
|
|
-
|
|
|
- const groupIndex = _listData.joinedTeams.teams.findIndex(obj => obj.sharePoint.siteId === siteId);
|
|
|
- const pathArr = $('.panel').children();
|
|
|
-
|
|
|
- if (groupIndex >= 0 && $('.panel').children().length === 1) {
|
|
|
- return alertMessage(alertTitle,'채널에는 업로드 할 수 없습니다. 채널 리스트를 먼저 선택해 주세요.');
|
|
|
- }
|
|
|
-
|
|
|
- let sitePath = '/drive/root';
|
|
|
- let filePath = '';
|
|
|
- if (pathArr.length > 1) {
|
|
|
- sitePath += ':';
|
|
|
- for (let ii = 0; ii < pathArr.length; ii++) {
|
|
|
- const path = pathArr.eq(ii).text();
|
|
|
- if (ii !== 0 && path !== " > ") {
|
|
|
- sitePath += "/" + path;
|
|
|
- filePath += "/" +path;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
+ const formData = new FormData($('<form enctype="multipart/form-data"></form>')[0]);
|
|
|
for (let file of files) {
|
|
|
-
|
|
|
let fileName = file.name;
|
|
|
- if (file.name.indexOf('.') > 0) {
|
|
|
- fileName = file.name.substring(0, file.name.lastIndexOf('.'));
|
|
|
- }
|
|
|
-
|
|
|
- _formData.append('file', file);
|
|
|
- _formData.append(fileName + '_path', filePath);
|
|
|
+ formData.append('file', file);
|
|
|
}
|
|
|
|
|
|
- _formData.append('siteId', siteId);
|
|
|
- _formData.append('path', sitePath);
|
|
|
- // _formData.getAll()
|
|
|
- // $('body').append(`<div id="load">
|
|
|
- // <img src="/static/images/Settings.gif" alt="loading">
|
|
|
- // </div>`);
|
|
|
-
|
|
|
- $.ajax({
|
|
|
- method: 'post',
|
|
|
- processData : false,
|
|
|
- contentType : false,
|
|
|
- data : _formData,
|
|
|
- url : '/uploadItems',
|
|
|
- success: (res) => {
|
|
|
- // $('#load').remove();
|
|
|
- let str = res.message;
|
|
|
-
|
|
|
- if (res.error) {
|
|
|
- str += '<br>오류 : ' + res.error;
|
|
|
- }
|
|
|
-
|
|
|
- alertMessage(alertTitle, str, null);
|
|
|
- const selectDrive = $('.panel-item.on');
|
|
|
- selectDrive.removeClass('on');
|
|
|
- selectDrive.click();
|
|
|
-
|
|
|
- },
|
|
|
- error: (error) => {
|
|
|
- // $('#load').remove();
|
|
|
- alertMessage(alertTitle, error, null);
|
|
|
- // console.log('==============error=============\n');
|
|
|
- // console.log(error);
|
|
|
- },
|
|
|
-
|
|
|
- });
|
|
|
-
|
|
|
+ upload(formData);
|
|
|
}
|
|
|
+
|
|
|
function uploadFolders(event) {
|
|
|
- console.log(event);
|
|
|
- event.file;
|
|
|
+ const srcEl = event.srcElement;
|
|
|
+ if (srcEl && srcEl.files) {
|
|
|
+ const files = srcEl.files;
|
|
|
+ if (files.length > 100) {
|
|
|
+ return alertMessage('폴더 업로드', '업로드 파일은 최대 100개 까지 가능합니다.<br>업로드 파일 수 : '+ files.length);
|
|
|
+ }
|
|
|
+ let folders = {};
|
|
|
+ const siteId = getSitesId();
|
|
|
+ let formData = new FormData($('<form enctype="multipart/form-data"></form>')[0]);
|
|
|
+ for (let file of files) {
|
|
|
+ let path = file.webkitRelativePath;
|
|
|
+ path = path.substring(0, path.lastIndexOf('/'));
|
|
|
+ formData.append('file', file);
|
|
|
+ let filePath = path;
|
|
|
+ if (filePath.substring(0,1) !== '/' ) {
|
|
|
+ filePath = '/'+filePath;
|
|
|
+ }
|
|
|
+ formData.append(file.name + '_path', filePath);
|
|
|
+ if (!folders[path]) {
|
|
|
+ let name = path
|
|
|
+ if (name.lastIndexOf('/') > -1) {
|
|
|
+ name = name.substring(0, name.lastIndexOf('/'));
|
|
|
+ }
|
|
|
+ let folderPath = name;
|
|
|
+ if (folderPath === path) {
|
|
|
+ folderPath = "";
|
|
|
+ }
|
|
|
+ formData.append('folder', JSON.stringify({name : name, path : folderPath}));
|
|
|
+ folders[path] = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ upload(formData);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
function menuOpen(event, className) {
|
|
@@ -218,12 +193,12 @@
|
|
|
$oneDriveBtn.text(text+'에서 열기');
|
|
|
$oneDriveBtn.off('click');
|
|
|
|
|
|
+ if (parentData && parentData.webUrl) {
|
|
|
+ $oneDriveBtn.on('click', ()=>{
|
|
|
+ window.open(parentData.webUrl);
|
|
|
+ });
|
|
|
+ };
|
|
|
if (jsonData && jsonData.value && jsonData.value.length > 0) {
|
|
|
- if (jsonData.value[0].webUrl) {
|
|
|
- $oneDriveBtn.on('click', ()=>{
|
|
|
- window.open(jsonData.value[0].webUrl);
|
|
|
- });
|
|
|
- };
|
|
|
_selectedData = jsonData;
|
|
|
const selectedPref = _selectedData.value[0].parentReference;
|
|
|
if (selectedPref && selectedPref.path) {
|
|
@@ -233,83 +208,14 @@
|
|
|
let str = "";
|
|
|
jsonData.value.forEach((obj, idx)=>{
|
|
|
dragAndDrop();
|
|
|
- let images = "/static/images/";
|
|
|
- let imageName = "";
|
|
|
|
|
|
let modifyName = "";
|
|
|
if (obj.lastModifiedBy && obj.lastModifiedBy.user) {
|
|
|
modifyName = obj.lastModifiedBy.user.displayName;
|
|
|
}
|
|
|
- if (obj.folder || obj.driveType) {
|
|
|
- images += "folder.png";
|
|
|
- imageName = "폴더 이미지";
|
|
|
- }
|
|
|
- else if (obj.file && obj.name) {
|
|
|
- imageName = "파일 이미지";
|
|
|
- let ext = obj.name.substring(obj.name.lastIndexOf('.') + 1);
|
|
|
- let imageExt = ".svg";
|
|
|
- //photo
|
|
|
- // if (obj.file.mimeType && obj.file.mimeType.includes('image')){
|
|
|
- if (['psd', 'bmp', 'rle', 'dib', 'jpeg', 'jpg', 'gif', 'png', 'tiff', 'raw', 'ico'].includes(ext)){
|
|
|
- ext = 'photo';
|
|
|
- }
|
|
|
- else if (['ai', 'eps', 'svg'].includes(ext)) {
|
|
|
- ext = 'vector';
|
|
|
- }
|
|
|
- else if (['txt', 'properties'].includes(ext)) {
|
|
|
- ext = 'txt';
|
|
|
- }
|
|
|
- else if (['pptx', 'ppt', 'pptm'].includes(ext)) {
|
|
|
- ext = 'pptx';
|
|
|
- }
|
|
|
- else if (['xlsx', 'xlsm', 'xlsb', 'xltx'].includes(ext)) {
|
|
|
- ext = 'xlsx';
|
|
|
- }
|
|
|
- else if (['pdf'].includes(ext)) {
|
|
|
- ext = 'pdf';
|
|
|
- }
|
|
|
- else if (['doc', 'docx'].includes(ext)) {
|
|
|
- ext = 'docx';
|
|
|
- }
|
|
|
- else if (['one', 'onetoc'].includes(ext)) {
|
|
|
- ext = 'onetoc';
|
|
|
- }
|
|
|
- else if (['vsd', 'vdx', 'vdw', 'vstx', 'vstm', 'vst', 'vtx', 'vsdx'].includes(ext)) {
|
|
|
- ext = 'vsdx';
|
|
|
- }
|
|
|
- else if (['zip', 'apk', 'rar', '7z', 'tar'].includes(ext)) {
|
|
|
- ext = 'zip';
|
|
|
- }
|
|
|
- else if (['jsp', 'js', 'css', 'php', 'config', 'ini', 'yml', 'json'].includes(ext)) {
|
|
|
- ext = 'code';
|
|
|
- }
|
|
|
- else if (['html'].includes(ext)) {
|
|
|
- ext = 'html';
|
|
|
- }
|
|
|
- else if (['exe', 'msi'].includes(ext)) {
|
|
|
- ext = 'exe';
|
|
|
- }
|
|
|
- else if (['jar', 'war', 'cab', 'dll', ].includes(ext)) {
|
|
|
- ext = 'sysfile';
|
|
|
- }
|
|
|
- else if (['mp4', 'mov', 'Webm', 'mp3','wav', 'Ogg'].includes(ext)) {
|
|
|
- ext = 'clipchamp';
|
|
|
- }
|
|
|
- else if (['bdf', 'chr', 'dfont', 'eot','etx', 'fnt', 'gdr', 'gf', 'mcf', 'xft', 'ttf', 'woff2',
|
|
|
- 'mf', 'otf', 'pfa', 'pfb', 'pfr', 'sfd', 'suit', 'tfm', 'ttc', 'vlw', 'woff', 'xfn'].includes(ext)) {
|
|
|
- ext = 'font';
|
|
|
- }
|
|
|
- else if (['xml'].includes(ext)) {
|
|
|
- ext = 'xml';
|
|
|
- }
|
|
|
- else {
|
|
|
- ext = 'genericfile';
|
|
|
- }
|
|
|
- images += ext + imageExt;
|
|
|
- }
|
|
|
- else {
|
|
|
- images += "genericfile.svg";
|
|
|
- }
|
|
|
+ const imageData = getFileImage(obj);
|
|
|
+ const images = imageData[0];
|
|
|
+ const imageName = imageData[1];
|
|
|
let amount = '0 Bytes';
|
|
|
if (obj.size) {
|
|
|
amount = getVolume(obj.size);
|
|
@@ -374,7 +280,7 @@
|
|
|
<div>탭으로 설정</div>
|
|
|
<div onclick="download()">다운로드</div>
|
|
|
<div onclick="deleteItem()">삭제</div>
|
|
|
- <div>이동</div>
|
|
|
+ <div onclick="moveItem()">이동</div>
|
|
|
<div>복사</div>
|
|
|
<div onclick="nameChange()">이름 바꾸기</div>`;
|
|
|
if (array && array.length > 0) {
|
|
@@ -427,6 +333,299 @@
|
|
|
panel.html(panelStr);
|
|
|
}
|
|
|
|
|
|
+ function getFileImage(obj) {
|
|
|
+ let images = "/static/images/";
|
|
|
+ let imageName = "";
|
|
|
+
|
|
|
+ if (obj.folder || obj.driveType) {
|
|
|
+ images += "folder.png";
|
|
|
+ imageName = "폴더 이미지";
|
|
|
+ }
|
|
|
+ else if (obj.file && obj.name) {
|
|
|
+ imageName = "파일 이미지";
|
|
|
+ let ext = obj.name.substring(obj.name.lastIndexOf('.') + 1);
|
|
|
+ let imageExt = ".svg";
|
|
|
+ //photo
|
|
|
+ // if (obj.file.mimeType && obj.file.mimeType.includes('image')){
|
|
|
+ if (['psd', 'bmp', 'rle', 'dib', 'jpeg', 'jpg', 'gif', 'png', 'tiff', 'raw', 'ico'].includes(ext)){
|
|
|
+ ext = 'photo';
|
|
|
+ }
|
|
|
+ else if (['ai', 'eps', 'svg'].includes(ext)) {
|
|
|
+ ext = 'vector';
|
|
|
+ }
|
|
|
+ else if (['txt', 'properties'].includes(ext)) {
|
|
|
+ ext = 'txt';
|
|
|
+ }
|
|
|
+ else if (['pptx', 'ppt', 'pptm'].includes(ext)) {
|
|
|
+ ext = 'pptx';
|
|
|
+ }
|
|
|
+ else if (['xlsx', 'xlsm', 'xlsb', 'xltx'].includes(ext)) {
|
|
|
+ ext = 'xlsx';
|
|
|
+ }
|
|
|
+ else if (['pdf'].includes(ext)) {
|
|
|
+ ext = 'pdf';
|
|
|
+ }
|
|
|
+ else if (['doc', 'docx'].includes(ext)) {
|
|
|
+ ext = 'docx';
|
|
|
+ }
|
|
|
+ else if (['one', 'onetoc'].includes(ext)) {
|
|
|
+ ext = 'onetoc';
|
|
|
+ }
|
|
|
+ else if (['vsd', 'vdx', 'vdw', 'vstx', 'vstm', 'vst', 'vtx', 'vsdx'].includes(ext)) {
|
|
|
+ ext = 'vsdx';
|
|
|
+ }
|
|
|
+ else if (['zip', 'apk', 'rar', '7z', 'tar'].includes(ext)) {
|
|
|
+ ext = 'zip';
|
|
|
+ }
|
|
|
+ else if (['jsp', 'js', 'css', 'php', 'ini', 'yml', 'json', 'java', 'c', 'cpp', 'h', 'm', 'mm',
|
|
|
+ 'pl', 'o', 'class', 'as', 'asp', 'cs', 'md'].includes(ext)) {
|
|
|
+ ext = 'code';
|
|
|
+ }
|
|
|
+ else if (['html'].includes(ext)) {
|
|
|
+ ext = 'html';
|
|
|
+ }
|
|
|
+ else if (['exe', 'msi'].includes(ext)) {
|
|
|
+ ext = 'exe';
|
|
|
+ }
|
|
|
+ else if (['jar', 'war', 'cab', 'dll', ].includes(ext)) {
|
|
|
+ ext = 'sysfile';
|
|
|
+ }
|
|
|
+ else if (['mp4', 'mov', 'Webm', 'mp3','wav', 'Ogg'].includes(ext)) {
|
|
|
+ ext = 'clipchamp';
|
|
|
+ }
|
|
|
+ else if (['bdf', 'chr', 'dfont', 'eot','etx', 'fnt', 'gdr', 'gf', 'mcf', 'xft', 'ttf', 'woff2',
|
|
|
+ 'mf', 'otf', 'pfa', 'pfb', 'pfr', 'sfd', 'suit', 'tfm', 'ttc', 'vlw', 'woff', 'xfn'].includes(ext)) {
|
|
|
+ ext = 'font';
|
|
|
+ }
|
|
|
+ else if (['xml'].includes(ext)) {
|
|
|
+ ext = 'xml';
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ ext = 'genericfile';
|
|
|
+ }
|
|
|
+ images += ext + imageExt;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ imageName = "파일 이미지";
|
|
|
+ images += 'genericfile.svg';
|
|
|
+ }
|
|
|
+
|
|
|
+ return [images, imageName];
|
|
|
+ }
|
|
|
+
|
|
|
+ function moveItem() {
|
|
|
+ const moveArr = $('.file-content div.on input[type="checkbox"]');
|
|
|
+ $.ajax({
|
|
|
+ method: 'post',
|
|
|
+ url : "/getGroupList",
|
|
|
+ success: (res)=> {
|
|
|
+ // drawList(res);
|
|
|
+ let oneDriveId = "";
|
|
|
+ if (res.oneDrive) {
|
|
|
+ oneDriveId = res.oneDrive.teams.sharePoint.siteId;
|
|
|
+ }
|
|
|
+ let str = `<div class="modal move" style="display: flex;">
|
|
|
+ <div class="modal-move-box">
|
|
|
+ <div class="left-box">
|
|
|
+ <h3 style="padding: 10px;">${moveArr.length}개 항목 이동</h3>
|
|
|
+ <div id="move_${oneDriveId}" class="my-file" onclick="setContent('${oneDriveId}', event)"><img src="/static/images/folder-icon.png" alt="폴더 이미지"> 내 파일</div>
|
|
|
+ <div class="">
|
|
|
+ <div></div>
|
|
|
+ </div>
|
|
|
+ <div class="access-box">
|
|
|
+ <div class="access">빠른 엑세스</div>`;
|
|
|
+ if (res) {
|
|
|
+ const {joinedTeams, oneDrive, sites} = res;
|
|
|
+ const groupImageUrl = '/_api/siteiconmanager/getsitelogo?type=1';
|
|
|
+
|
|
|
+ if (joinedTeams.teams.length > 0) {
|
|
|
+ const jTeam = joinedTeams.teams;
|
|
|
+ jTeam.forEach((obj, idx)=>{
|
|
|
+ const share = obj.sharePoint;
|
|
|
+ let classNm = '';
|
|
|
+ if (idx === 0) {
|
|
|
+ classNm = 'on';
|
|
|
+ }
|
|
|
+ str += `<div id="move_${share.siteId}" class="${classNm}" onclick="setContent('${share.siteId}', event)">
|
|
|
+ <div>
|
|
|
+ <img width="25" height="25" src="${share.siteUrl}${groupImageUrl}" alt="아이콘">
|
|
|
+ <div>${obj.displayName}</div>
|
|
|
+ </div>
|
|
|
+ </div>`
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ if (sites.teams) {
|
|
|
+ const sTeam = sites.teams;
|
|
|
+ const share = sTeam.sharePoint;
|
|
|
+ str += `<div id="move_${share.siteId}" onclick="setContent('${share.siteId}', event)">
|
|
|
+ <div>
|
|
|
+ <img width="25" height="25" src="${share.siteUrl + groupImageUrl}" alt="아이콘">
|
|
|
+ <div>${sTeam.displayName}</div>
|
|
|
+ </div>
|
|
|
+ </div>`
|
|
|
+ }
|
|
|
+ }
|
|
|
+ str +=`<div>
|
|
|
+ <div style="color: rgb(91, 95, 199); margin-left: 15px;">더 많은 장소...</div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="right-box">
|
|
|
+ <div class="panel"></div>
|
|
|
+ <div class="content">
|
|
|
+ <div class="header">
|
|
|
+ <div><img src="/static/images/file.png" width="20" alt="파일"></div>
|
|
|
+ <div>이름</div>
|
|
|
+ <div>수정된 날짜</div>
|
|
|
+ <div>수정한 사람</div>
|
|
|
+ </div>
|
|
|
+ <div class="list">
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="button-box">
|
|
|
+ <div id="move-btn" onclick="moveUpdate()">여기로 이동</div>
|
|
|
+ <div onclick="$('.modal').remove()">취소</div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>`;
|
|
|
+ $('body').append($(str));
|
|
|
+ $('.access-box div.on').click();
|
|
|
+ },
|
|
|
+ error: (error)=> {
|
|
|
+ console.log(error);
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ function moveUpdate() {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ function setContent(siteId, event) {
|
|
|
+ const selectEl = $('#move_' + siteId);
|
|
|
+ if (selectEl === $('.access-box .on')) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ $('.access-box .on').removeClass('on');
|
|
|
+ selectEl.addClass('on');
|
|
|
+
|
|
|
+ callApi('get', '/sites/' + siteId +'/drive/root/children', (jsonData)=>{
|
|
|
+ const panel = $('.modal-move-box .right-box .panel');
|
|
|
+ const content = $('.modal-move .right-box .content');
|
|
|
+ const imgSrc = $('#move_' + siteId+ ' img').attr('src');
|
|
|
+ const text = $('#move_' + siteId).text().trim();
|
|
|
+
|
|
|
+ let str = `<div class="panel-item on">`
|
|
|
+ if (text !== '내 파일') {
|
|
|
+ str +=`<img width="24" height="24" src="${imgSrc}" alt="아이콘"> `
|
|
|
+ }
|
|
|
+ str +=`${text}</div>`;
|
|
|
+ const $list = $('.modal-move-box .right-box .content .list');
|
|
|
+ panel.html(str);
|
|
|
+ $list.empty();
|
|
|
+ //하위 파일들이 있는지 먼저 체크
|
|
|
+ if (jsonData && jsonData.value && jsonData.value.length > 0) {
|
|
|
+ const itemArray = jsonData.value;
|
|
|
+ if (itemArray.length > 0) {
|
|
|
+ let listStr = '';
|
|
|
+ itemArray.forEach((obj, idx)=>{
|
|
|
+ let isFolder = obj.folder;
|
|
|
+ let className = '';
|
|
|
+ let date = '-';
|
|
|
+ let name = '-';
|
|
|
+ let modifyName = '-';
|
|
|
+ if (!isFolder) {
|
|
|
+ className = 'off';
|
|
|
+ }
|
|
|
+
|
|
|
+ if (obj.name) {
|
|
|
+ name = obj.name;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (obj.lastModifiedBy && obj.lastModifiedBy.user && obj.lastModifiedBy.user.displayName) {
|
|
|
+ modifyName = obj.lastModifiedBy.user.displayName;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (obj.lastModifiedDateTime) {
|
|
|
+ date = obj.lastModifiedDateTime.substring(0, obj.lastModifiedDateTime.indexOf('T'));
|
|
|
+ }
|
|
|
+ console.log(date);
|
|
|
+
|
|
|
+ const imgData = getFileImage(obj);
|
|
|
+ listStr += `<div class="move_row row_${idx} ${className}">
|
|
|
+ <div><img src="${imgData[0]}" alt="${imgData[1]}" width="25" height="25"></div>
|
|
|
+ <div>${name}</div>
|
|
|
+ <div>${date}</div>
|
|
|
+ <div>${modifyName}</div>
|
|
|
+ </div>`;
|
|
|
+ })
|
|
|
+ $list.html(listStr);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ $list.html(`<div class="empty-box">
|
|
|
+ <img src="/static/images/empty_folder_v2.svg" alt="이미지">
|
|
|
+ <div>이 폴더는 비어 있습니다.</div>
|
|
|
+ </div>`);
|
|
|
+ }
|
|
|
+ // let firstFolder = "";
|
|
|
+
|
|
|
+ // //하위 파일들 중 첫번째 폴더 선택
|
|
|
+ // for (let item of itemArray) {
|
|
|
+ // if (item.folder) {
|
|
|
+ // firstFolder = item;
|
|
|
+ // break;
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+
|
|
|
+ // if (firstFolder && firstFolder.folder.childCount) {
|
|
|
+ // const id = firstFolder.id;
|
|
|
+ // const name = firstFolder.name;
|
|
|
+ // const parentPath = firstFolder.parentReference.path;
|
|
|
+ // const path = parentPath + '/' + name;
|
|
|
+ // str+= `<div> > </div><div class="panel-item on">${name}</div>`
|
|
|
+ // panel.html(str);
|
|
|
+ // drawMoveItems(siteId, path, id, itemArray);
|
|
|
+ // }
|
|
|
+ // else { // 없는 경우 빈폴더를 보여준다.
|
|
|
+ // panel.html(str);
|
|
|
+ // const panelItem = panel.find('.panel-item');
|
|
|
+ // panelItem.addClass('on');
|
|
|
+ // panelItem.attr('onclick', '').unbind('click');
|
|
|
+ // $list.html(`<div class="empty-box">
|
|
|
+ // <img src="/static/images/empty_folder_v2.svg" alt="이미지">
|
|
|
+ // <div>이 폴더는 비어 있습니다.</div>
|
|
|
+ // </div>`);
|
|
|
+ // }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+
|
|
|
+ $list.html(`<div class="empty-box">
|
|
|
+ <img src="/static/images/empty_folder_v2.svg" alt="이미지">
|
|
|
+ <div>이 폴더는 비어 있습니다.</div>
|
|
|
+ </div>`);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ function drawMoveItems(siteId, path, id) {
|
|
|
+ callApi('get', '/sites/' +siteId +'/drive/items/' + id + '/children', (childrenData)=>{
|
|
|
+ const items = childrenData.value;
|
|
|
+ const $list = $('.modal-move-box .right-box .content .list');
|
|
|
+ console.log(items);
|
|
|
+ if (items && items.length > 0) {
|
|
|
+
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ $list.html(`<div class="empty-box">
|
|
|
+ <img src="/static/images/empty_folder_v2.svg" alt="이미지">
|
|
|
+ <div>이 폴더는 비어 있습니다.</div>
|
|
|
+ </div>`)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
//새로고침 이벤트
|
|
|
function refreshDrive() {
|
|
|
const selectedDrive = $('.panel-item.on');
|
|
@@ -436,6 +635,7 @@
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ //체크에 따른 css 적용
|
|
|
function checkState(event){
|
|
|
const $target = $(event.target);
|
|
|
const $row = $('#'+$target.attr('name'));
|
|
@@ -501,8 +701,9 @@
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ //
|
|
|
function getDrivePath() {
|
|
|
- console.log($('.panel-item'));
|
|
|
let path = '/drive/root';
|
|
|
if ($('.panel-item').length > 1) {
|
|
|
path += ':';
|
|
@@ -550,10 +751,9 @@
|
|
|
else {
|
|
|
let message = res.message;
|
|
|
if (res.error) {
|
|
|
- console.log(res.error);
|
|
|
message += '<br>' + res.error;
|
|
|
}
|
|
|
- alertMessage('다운로드',message);
|
|
|
+ alertMessage('다운로드', message);
|
|
|
}
|
|
|
},
|
|
|
error : (error) => {
|
|
@@ -641,12 +841,18 @@
|
|
|
const items = transfer.items;
|
|
|
_formData = new FormData($('<form enctype="multipart/form-data"></form>')[0]);
|
|
|
await getFilesDataTransferItems(items);
|
|
|
- const folders = _formData.getAll('folder');
|
|
|
- const files = _formData.getAll('folder');
|
|
|
+
|
|
|
+ upload(_formData);
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ function upload(formData) {
|
|
|
+ const folders = formData.getAll('folder');
|
|
|
+ const files = formData.getAll('file');
|
|
|
const alertTitle = '파일 업로드';
|
|
|
+ if (folders.length === 0 && files.length === 0) return;
|
|
|
if (folders && folders.length > 100) {
|
|
|
return alertMessage(alertTitle, '업로드 폴더는 최대 100개 까지 가능합니다.<br>업로드 폴더 수 : '+ folders.length, null);
|
|
|
- // return alert('업로드 폴더는 최대 100개 까지 가능합니다.\n업로드 폴더 수 : '+ folders.length);
|
|
|
}
|
|
|
|
|
|
if (files && files.length > 100) {
|
|
@@ -664,56 +870,35 @@
|
|
|
return alertMessage(alertTitle,'채널에는 업로드 할 수 없습니다. 채널 리스트를 먼저 선택해 주세요.');
|
|
|
}
|
|
|
|
|
|
- let sitePath = '/drive/root';
|
|
|
- if (pathArr.length > 1) {
|
|
|
- sitePath += ':';
|
|
|
- for (let ii = 0; ii < pathArr.length; ii++) {
|
|
|
- const path = pathArr.eq(ii).text();
|
|
|
- if (ii !== 0 && path !== " > ") {
|
|
|
- sitePath += "/" + path;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ let sitePath = getDrivePath();
|
|
|
+
|
|
|
+ formData.append('siteId', siteId);
|
|
|
+ formData.append('path', sitePath);
|
|
|
|
|
|
- _formData.append('siteId', siteId);
|
|
|
- _formData.append('path', sitePath);
|
|
|
- // $('body').append(`<div id="load">
|
|
|
- // <img src="/static/images/Settings.gif" alt="loading">
|
|
|
- // </div>`)
|
|
|
$.ajax({
|
|
|
method: 'post',
|
|
|
processData : false,
|
|
|
contentType : false,
|
|
|
- data : _formData,
|
|
|
+ data : formData,
|
|
|
url : '/uploadItems',
|
|
|
success: (res) => {
|
|
|
- // $('#load').remove();
|
|
|
let str = res.message;
|
|
|
+ console.log(res.error);
|
|
|
if (res.error) {
|
|
|
- str += '<br>오류 : ' + res.error;
|
|
|
+ str += '<br>오류 : ' + res.error.message;
|
|
|
}
|
|
|
alertMessage(alertTitle, str, null);
|
|
|
- // alert(res.message);
|
|
|
- // console.log(res.error);
|
|
|
const selectDrive = $('.panel-item.on');
|
|
|
selectDrive.removeClass('on');
|
|
|
selectDrive.click();
|
|
|
|
|
|
},
|
|
|
error: (error) => {
|
|
|
- // $('#load').remove();
|
|
|
+ console.log(error);
|
|
|
alertMessage(alertTitle, error, null);
|
|
|
- // console.log('==============error=============\n');
|
|
|
- // console.log(error);
|
|
|
},
|
|
|
|
|
|
});
|
|
|
- // const file = e.originalEvent.dataTransfer.files[0];
|
|
|
- // encryptFile(file, driveId);
|
|
|
- // if (file && file.type.startsWith("image")) {
|
|
|
- // displayImage(file);
|
|
|
- // }
|
|
|
- });
|
|
|
}
|
|
|
|
|
|
function alertMessage(title, message, color) {
|
|
@@ -795,9 +980,9 @@
|
|
|
if (item.isFile) {
|
|
|
item.file(file => {
|
|
|
let fileName = file.name;
|
|
|
- if (file.name.indexOf('.') > 0) {
|
|
|
- fileName = file.name.substring(0, file.name.lastIndexOf('.'));
|
|
|
- }
|
|
|
+ // if (file.name.indexOf('.') > 0) {
|
|
|
+ // fileName = file.name.substring(0, file.name.lastIndexOf('.'));
|
|
|
+ // }
|
|
|
let path = item.fullPath.substring(0, item.fullPath.lastIndexOf('/'));
|
|
|
if (!path) {
|
|
|
path = '';
|
|
@@ -873,7 +1058,6 @@
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- uploadFiles(driveId)
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1067,7 +1251,6 @@
|
|
|
let siteId = team.sharePoint.siteId;
|
|
|
let path;
|
|
|
let imageUrl;
|
|
|
- console.log(team.displayName);
|
|
|
str += `
|
|
|
<div id="${siteId}_li" onclick="siteDriveChildrenItems('${siteId}', '/drive/root', '${team.displayName}', '${siteId}', event)">
|
|
|
<img width="24" height="24" src="${team.sharePoint.siteUrl}${groupImageUrl}" alt="그룹 이미지"> ${team.displayName}
|
|
@@ -1176,6 +1359,8 @@
|
|
|
})
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ //새폴더 생성
|
|
|
function mkdir() {
|
|
|
const modalContainer = $(
|
|
|
`<div class="modal" style="display: flex;">
|
|
@@ -1227,9 +1412,9 @@
|
|
|
ext = name.substring(name.lastIndexOf("."));
|
|
|
width = 'calc(100% - 35px)';
|
|
|
}
|
|
|
- callApi('get', "/sites/"+ siteId + "/drive/items/" + itemId, (jsonData)=>{
|
|
|
- console.log(jsonData);
|
|
|
- })
|
|
|
+ // callApi('get', "/sites/"+ siteId + "/drive/items/" + itemId, (jsonData)=>{
|
|
|
+ // console.log(jsonData);
|
|
|
+ // })
|
|
|
|
|
|
const modalContainer = $(
|
|
|
`<div class="modal" style="display: flex;">
|
|
@@ -1243,11 +1428,11 @@
|
|
|
<div class="modal-content">
|
|
|
<div>이름</div>
|
|
|
<div style="display:flex; align-items:flex-end;">
|
|
|
- <input type="text" style="width:${width};" name="change_name" id="${itemId}" value="${inputVal}"> ${ext}
|
|
|
+ <input type="text" style="width:${width};" name="change_name" id="${itemId}_input" value="${inputVal}"> ${ext}
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="button-box">
|
|
|
- <div class="name-btn">이름 바꾸기</div>
|
|
|
+ <div class="name-btn" onclick="updateDriveItems('${siteId}','${itemId}')">이름 바꾸기</div>
|
|
|
<div class="cancel-btn" onclick="$('.modal').remove()">취소</div>
|
|
|
</div>
|
|
|
</div>
|
|
@@ -1255,4 +1440,36 @@
|
|
|
$('body').append(modalContainer);
|
|
|
}
|
|
|
|
|
|
+ function updateDriveItems(siteId, itemId) {
|
|
|
+ const input = $('#' + itemId + '_input');
|
|
|
+ console.log($('#' + itemId + '_input').val() , $('#' + itemId + '_input').parent().text().trim());
|
|
|
+ let name = input.val();
|
|
|
+ const ext = input.parent().text().trim();
|
|
|
+ if (ext) {
|
|
|
+ name += ext;
|
|
|
+ }
|
|
|
+
|
|
|
+ $.ajax({
|
|
|
+ method: 'post',
|
|
|
+ url : '/api/update-name',
|
|
|
+ data : {
|
|
|
+ siteId : siteId,
|
|
|
+ itemId : itemId,
|
|
|
+ name : name,
|
|
|
+ },
|
|
|
+ success : (res)=> {
|
|
|
+ if (res.success === 'S') {
|
|
|
+ const selectDrive = $('.panel-item.on');
|
|
|
+ selectDrive.removeClass('on');
|
|
|
+ selectDrive.click();
|
|
|
+ }
|
|
|
+ alertMessage('이름 변경',res.message);
|
|
|
+ },
|
|
|
+ error : (error) => {
|
|
|
+ alertMessage('이름 변경','오류가 발생하였습니다.<br>'+ error);
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
</script>
|