-
Notifications
You must be signed in to change notification settings - Fork 373
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* update repo trash * update code * select trash * update * update * merge clean trash * fix-uni-test-and-code-optimize * Update mysql.sql * code-optimize * update select * update sql * update UI * change trash dialog style * optimize code * fix code format * Update repo_trash.py * update * add clean trash Command * update * optimize code * support page * support frontend page * update * Update __init__.py * Update clean_repo_trash.py * Update clean_repo_trash.py * Update clean_repo_trash.py * Update trash-dialog.js * Update clean_repo_trash.py * set default by 90 * Update clean_repo_trash.py * update --------- Co-authored-by: 孙永强 <[email protected]> Co-authored-by: r350178982 <[email protected]> Co-authored-by: Michael An <[email protected]>
- Loading branch information
1 parent
cf7272c
commit 0981a0d
Showing
16 changed files
with
714 additions
and
15 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
.trash-dialog { | ||
max-width: 1100px; | ||
} | ||
|
||
.trash-dialog .modal-header { | ||
align-items: center; | ||
} | ||
|
||
.trash-dialog .modal-header .trash-dialog-old-page { | ||
margin-left: auto; | ||
} | ||
|
||
.trash-dialog .modal-header .trash-dialog-close-icon { | ||
color: #000; | ||
opacity: 0.5; | ||
font-weight: 700; | ||
cursor: pointer; | ||
} | ||
|
||
.trash-dialog .modal-header .trash-dialog-close-icon:hover { | ||
opacity: 0.75; | ||
} | ||
|
||
.trash-dialog .modal-header .clean { | ||
height: 30px; | ||
line-height: 28px; | ||
padding: 0 0.5rem; | ||
} | ||
|
||
.trash-dialog .modal-body { | ||
height: 500px; | ||
overflow-y: auto; | ||
} | ||
|
||
.trash-dialog .modal-body .more { | ||
background: #efefef; | ||
border: 0; | ||
color: #777; | ||
} | ||
|
||
.trash-dialog .modal-body .more:hover { | ||
color: #000; | ||
background: #dfdfdf; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import axios from 'axios'; | ||
import cookie from 'react-cookies'; | ||
import { siteRoot } from './constants'; | ||
|
||
class RepotrashAPI { | ||
|
||
init({ server, username, password, token }) { | ||
this.server = server; | ||
this.username = username; | ||
this.password = password; | ||
this.token = token; //none | ||
if (this.token && this.server) { | ||
this.req = axios.create({ | ||
baseURL: this.server, | ||
headers: { 'Authorization': 'Token ' + this.token }, | ||
}); | ||
} | ||
return this; | ||
} | ||
|
||
initForSeahubUsage({ siteRoot, xcsrfHeaders }) { | ||
if (siteRoot && siteRoot.charAt(siteRoot.length - 1) === '/') { | ||
var server = siteRoot.substring(0, siteRoot.length - 1); | ||
this.server = server; | ||
} else { | ||
this.server = siteRoot; | ||
} | ||
|
||
this.req = axios.create({ | ||
headers: { | ||
'X-CSRFToken': xcsrfHeaders, | ||
} | ||
}); | ||
return this; | ||
} | ||
|
||
getRepoFolderTrash2(repoID, page, per_page) { | ||
const url = this.server + '/api/v2.1/repos/' + repoID + '/trash2/'; | ||
let params = { | ||
page: page || 1, | ||
per_page: per_page | ||
}; | ||
return this.req.get(url, {params: params}); | ||
} | ||
} | ||
|
||
let repotrashAPI = new RepotrashAPI(); | ||
let xcsrfHeaders = cookie.load('sfcsrftoken'); | ||
repotrashAPI.initForSeahubUsage({ siteRoot, xcsrfHeaders }); | ||
|
||
export { repotrashAPI }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import logging | ||
from datetime import datetime | ||
from seahub.utils import SeafEventsSession | ||
from seafevents import seafevents_api | ||
from django.core.management.base import BaseCommand | ||
|
||
|
||
logger = logging.getLogger(__name__) | ||
|
||
class Command(BaseCommand): | ||
help = 'Clear repo trash within the specified time' | ||
label = 'clean_repo_trash' | ||
|
||
def print_msg(self, msg): | ||
self.stdout.write('[%s] %s\n' % (datetime.now(), msg)) | ||
|
||
def add_arguments(self, parser): | ||
parser.add_argument('--keep-days', help='keep days', type=int, default=90) | ||
|
||
def handle(self, *args, **options): | ||
days = options.get('keep_days') | ||
if days < 0: | ||
self.print_msg('keep-days cannot be set to nagative number') | ||
return | ||
logger.info('Start clean repo trash...') | ||
self.print_msg('Start clean repo trash...') | ||
self.do_action(days) | ||
self.print_msg('Finish clean repo trash.\n') | ||
logger.info('Finish clean repo trash.\n') | ||
|
||
def do_action(self, days): | ||
try: | ||
session = SeafEventsSession() | ||
seafevents_api.clean_up_all_repo_trash(session, days) | ||
except Exception as e: | ||
logger.debug('Clean up repo trash error: %s' % e) | ||
self.print_msg('Clean up repo trash error: %s' % e) | ||
return | ||
|
||
logger.info('Successfully cleared repo trash older than %s days' % days) | ||
self.print_msg('Successfully cleared repo trash older than %s days' % days) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.