|
@@ -436,8 +436,7 @@
|
|
|
<div class="access">빠른 엑세스</div>`;
|
|
|
if (res) {
|
|
|
const {joinedTeams, oneDrive, sites} = res;
|
|
|
- const groupImageUrl = '/_api/siteiconmanager/getsitelogo?type=1';
|
|
|
-
|
|
|
+ const groupImageUrl = "/_api/siteiconmanager/getsitelogo?type='1'";
|
|
|
if (joinedTeams.teams.length > 0) {
|
|
|
const jTeam = joinedTeams.teams;
|
|
|
jTeam.forEach((obj, idx)=>{
|
|
@@ -532,100 +531,183 @@
|
|
|
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'));
|
|
|
+ let path = '/drive/root';
|
|
|
+ if (obj.parentReference && obj.parentReference.path) {
|
|
|
+ path = obj.parentReference.path + '/' + obj.name;
|
|
|
}
|
|
|
- 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);
|
|
|
+ listStr += getListStr(obj, idx, siteId, path);
|
|
|
+ })
|
|
|
+ $list.html(listStr);
|
|
|
}
|
|
|
else {
|
|
|
- $list.html(`<div class="empty-box">
|
|
|
- <img src="/static/images/empty_folder_v2.svg" alt="이미지">
|
|
|
- <div>이 폴더는 비어 있습니다.</div>
|
|
|
- </div>`);
|
|
|
+ $list.html(getEmptyBox());
|
|
|
}
|
|
|
- // 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>`);
|
|
|
+ $list.html(getEmptyBox());
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- function drawMoveItems(siteId, path, id) {
|
|
|
- callApi('get', '/sites/' +siteId +'/drive/items/' + id + '/children', (childrenData)=>{
|
|
|
- const items = childrenData.value;
|
|
|
+ function drawMoveItems(siteId, path) {
|
|
|
+ const $panel = $('.modal .modal-move-box .right-box .panel');
|
|
|
+ const imgSrc = $('#move_' + siteId+ ' img').attr('src');
|
|
|
+ const text = $('#move_' + siteId).text().trim();
|
|
|
+ let onOff = 'on';
|
|
|
+ if (path && path.includes('/drive/root:')) {
|
|
|
+ onOff = '';
|
|
|
+ }
|
|
|
+
|
|
|
+ let str = "";
|
|
|
+ if (path && path.includes('/drive/root:')) {
|
|
|
+ str = `<div class="panel-item" onclick="drawMoveItems('${siteId}', '/drive/root')">`
|
|
|
+ if (text !== '내 파일') {
|
|
|
+ str +=`<img width="24" height="24" src="${imgSrc}" alt="아이콘"> `
|
|
|
+ }
|
|
|
+ str +=`${text}</div>`;
|
|
|
+ let itemPath = path.replace('/drive/root:/', '');
|
|
|
+ let pathArr = itemPath.split('/');
|
|
|
+ if (pathArr && pathArr.length > 0) {
|
|
|
+ let directoryRoot = '';
|
|
|
+ pathArr.forEach((directory, idx)=>{
|
|
|
+ if (directory) {
|
|
|
+ onOff = '';
|
|
|
+ if (idx === pathArr.length - 1) {
|
|
|
+ onOff = 'on'
|
|
|
+ }
|
|
|
+ directoryRoot += `/${directory}`;
|
|
|
+ str += `<div> > </div><div class="panel-item ${onOff}" onclick="drawMoveItems('${siteId}', '/drive/root:${directoryRoot}')">${directory}</div>`
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ str = `<div class="panel-item on">`
|
|
|
+ if (text !== '내 파일') {
|
|
|
+ str +=`<img width="24" height="24" src="${imgSrc}" alt="아이콘"> `
|
|
|
+ }
|
|
|
+ str +=`${text}</div>`;
|
|
|
+ }
|
|
|
+
|
|
|
+ $panel.html(str);
|
|
|
+ const menuWidth = $('.modal .modal-move-box .right-box').width() - 40;
|
|
|
+ const menuArr = $panel.children();
|
|
|
+ console.log(menuArr);
|
|
|
+ let totalWidth = 0;
|
|
|
+ for (let ii = 0; ii < menuArr.length; ii++) {
|
|
|
+ const menu = menuArr.eq(ii);
|
|
|
+ console.log('width:', menu.width() + 10, ', text:', menu.text().trim());
|
|
|
+ let gap = 10;
|
|
|
+ if ( menuArr.length-1 === ii) {
|
|
|
+ gap = 0;
|
|
|
+ }
|
|
|
+ totalWidth += menu.width() + gap;
|
|
|
+ }
|
|
|
+ if (menuWidth < totalWidth) {
|
|
|
+ let div = '<div class="toggle-button" style="display:none; position:absolute; top:100px; padding:10px; border:1px solid #eeeeee; width:auto;">';
|
|
|
+ for (let ii = 0; ii < menuArr.length; ii++) {
|
|
|
+ const menu = menuArr.eq(ii);
|
|
|
+
|
|
|
+ totalWidth -= menu.width() + 10;
|
|
|
+ if (menu.attr('class') && menu.attr('class').trim() === 'panel-item') {
|
|
|
+ div += `<div onclick="${menu.attr('onclick')}">${menu.text().trim()}</div>`;
|
|
|
+ }
|
|
|
+ menu.css('display', 'none');
|
|
|
+
|
|
|
+ if (menuWidth - 30 >= totalWidth && !menu.attr('class')) {
|
|
|
+ console.log(menu.attr('class') !== 'panel-item');
|
|
|
+ console.log('마지막 메뉴 :',menu.text());
|
|
|
+ console.log('마지막 class :',menu.attr('class'));
|
|
|
+ div += '</div>';
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ console.log(div);
|
|
|
+ $panel.prepend($(`<div class="menu-button"><img src="/static/images/dote.png" width="20" height="20"></div>
|
|
|
+ ${div}
|
|
|
+ `));
|
|
|
+ $('.menu-button').off('click');
|
|
|
+ $('.menu-button').on('click', ()=>{
|
|
|
+ $('.toggle-button').toggle();
|
|
|
+ })
|
|
|
+ }
|
|
|
+ callApi('get', '/sites/' + siteId + path, (parentData)=>{
|
|
|
const $list = $('.modal-move-box .right-box .content .list');
|
|
|
- console.log(items);
|
|
|
- if (items && items.length > 0) {
|
|
|
-
|
|
|
+ if (parentData && parentData.folder && parentData.folder.childCount) {
|
|
|
+ callApi('get', '/sites/' +siteId +'/drive/items/' + parentData.id + '/children', (childrenData)=>{
|
|
|
+ const items = childrenData.value;
|
|
|
+ if (items && items.length > 0) {
|
|
|
+ let listStr = "";
|
|
|
+ for (let idx in items) {
|
|
|
+ const item = items[idx];
|
|
|
+ let itemPath = '/drive/root';
|
|
|
+ if (item.parentReference && item.parentReference.path) {
|
|
|
+ itemPath = item.parentReference.path + '/' + item.name;
|
|
|
+ }
|
|
|
+ listStr += getListStr(item, idx, siteId, itemPath);
|
|
|
+ }
|
|
|
+ $list.html(listStr);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ listStr = getListStr(null, null, siteId);
|
|
|
+ $list.html(listStr);
|
|
|
+ }
|
|
|
+ })
|
|
|
}
|
|
|
else {
|
|
|
- $list.html(`<div class="empty-box">
|
|
|
- <img src="/static/images/empty_folder_v2.svg" alt="이미지">
|
|
|
- <div>이 폴더는 비어 있습니다.</div>
|
|
|
- </div>`)
|
|
|
+ $list.html(getEmptyBox());
|
|
|
}
|
|
|
- })
|
|
|
+
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ function getListStr(obj, idx, siteId, itemPath) {
|
|
|
+ if (obj && !isNaN(Number(idx)) && siteId){
|
|
|
+ let isFolder = obj.folder;
|
|
|
+ let className = '';
|
|
|
+ let date = '-';
|
|
|
+ let name = '-';
|
|
|
+ let modifyName = '-';
|
|
|
+ let path = '/drive/root';
|
|
|
+ let method = `drawMoveItems('${siteId}', '${itemPath}')`;
|
|
|
+ if (!isFolder) {
|
|
|
+ className = 'off';
|
|
|
+ method = '';
|
|
|
+ }
|
|
|
+
|
|
|
+ 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'));
|
|
|
+ }
|
|
|
+
|
|
|
+ const imgData = getFileImage(obj);
|
|
|
+ return `<div class="move_row row_${idx} ${className}">
|
|
|
+ <div><img src="${imgData[0]}" alt="${imgData[1]}" width="25" height="25"></div>
|
|
|
+ <div><span onclick="${method}">${name}</span></div>
|
|
|
+ <div>${date}</div>
|
|
|
+ <div>${modifyName}</div>
|
|
|
+ </div>`;
|
|
|
+
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ return getEmptyBox();
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
+ function getEmptyBox() {
|
|
|
+ return `<div class="empty-box">
|
|
|
+ <img src="/static/images/empty_folder_v2.svg" alt="이미지">
|
|
|
+ <div>이 폴더는 비어 있습니다.</div>
|
|
|
+ </div>`
|
|
|
+ }
|
|
|
+
|
|
|
//새로고침 이벤트
|
|
|
function refreshDrive() {
|
|
|
const selectedDrive = $('.panel-item.on');
|
|
@@ -1203,7 +1285,7 @@
|
|
|
group.empty();
|
|
|
if (jsonData) {
|
|
|
_listData = jsonData;
|
|
|
- const groupImageUrl = '/_api/siteiconmanager/getsitelogo?type=1';
|
|
|
+ const groupImageUrl = "/_api/siteiconmanager/getsitelogo?type='1'";
|
|
|
const {oneDrive, joinedTeams, sites} = jsonData;
|
|
|
let parentId = '';
|
|
|
let siteId = '';
|