mirror of https://github.com/openspug/spug
commit
34f36566c5
|
@ -17,11 +17,12 @@ import json
|
||||||
class RepositoryView(View):
|
class RepositoryView(View):
|
||||||
@auth('deploy.repository.view|deploy.request.add|deploy.request.edit')
|
@auth('deploy.repository.view|deploy.request.add|deploy.request.edit')
|
||||||
def get(self, request):
|
def get(self, request):
|
||||||
|
apps = request.user.deploy_perms['apps']
|
||||||
deploy_id = request.GET.get('deploy_id')
|
deploy_id = request.GET.get('deploy_id')
|
||||||
data = Repository.objects.annotate(
|
data = Repository.objects.annotate(
|
||||||
app_name=F('app__name'),
|
app_name=F('app__name'),
|
||||||
env_name=F('env__name'),
|
env_name=F('env__name'),
|
||||||
created_by_user=F('created_by__nickname'))
|
created_by_user=F('created_by__nickname')).filter(deploy_id__in=apps)
|
||||||
if deploy_id:
|
if deploy_id:
|
||||||
data = data.filter(deploy_id=deploy_id, status='5')
|
data = data.filter(deploy_id=deploy_id, status='5')
|
||||||
return json_response([x.to_view() for x in data])
|
return json_response([x.to_view() for x in data])
|
||||||
|
|
|
@ -18,6 +18,7 @@ import { AuthButton, Action } from 'components';
|
||||||
import { http, uniqueId, X_TOKEN } from 'libs';
|
import { http, uniqueId, X_TOKEN } from 'libs';
|
||||||
import lds from 'lodash';
|
import lds from 'lodash';
|
||||||
import styles from './index.module.less'
|
import styles from './index.module.less'
|
||||||
|
import moment from 'moment';
|
||||||
|
|
||||||
|
|
||||||
class FileManager extends React.Component {
|
class FileManager extends React.Component {
|
||||||
|
@ -25,6 +26,7 @@ class FileManager extends React.Component {
|
||||||
super(props);
|
super(props);
|
||||||
this.input = null;
|
this.input = null;
|
||||||
this.input2 = null
|
this.input2 = null
|
||||||
|
this.pwdHistoryCaches = new Map()
|
||||||
this.state = {
|
this.state = {
|
||||||
fetching: false,
|
fetching: false,
|
||||||
showDot: false,
|
showDot: false,
|
||||||
|
@ -72,6 +74,7 @@ class FileManager extends React.Component {
|
||||||
}, {
|
}, {
|
||||||
title: '修改时间',
|
title: '修改时间',
|
||||||
dataIndex: 'date',
|
dataIndex: 'date',
|
||||||
|
sorter: (a, b) => moment(a.date).unix() - moment(b.date).unix(),
|
||||||
width: 190
|
width: 190
|
||||||
}, {
|
}, {
|
||||||
title: '属性',
|
title: '属性',
|
||||||
|
@ -97,13 +100,19 @@ class FileManager extends React.Component {
|
||||||
};
|
};
|
||||||
|
|
||||||
fetchFiles = (pwd) => {
|
fetchFiles = (pwd) => {
|
||||||
this.setState({fetching: true});
|
this.setState({ fetching: true });
|
||||||
pwd = pwd || this.state.pwd;
|
pwd = pwd || (this.pwdHistoryCaches.get(this.props.id) || []);
|
||||||
|
if (this.pwdHistoryCaches.has(this.props.id)) {
|
||||||
|
let pwdCache = this.pwdHistoryCaches.get(this.props.id)
|
||||||
|
pwdCache.push(pwd.length > 0 ? pwd.splice(-1) : null)
|
||||||
|
pwd = pwdCache.filter(x => !!x)
|
||||||
|
}
|
||||||
const path = '/' + pwd.join('/');
|
const path = '/' + pwd.join('/');
|
||||||
return http.get('/api/file/', {params: {id: this.props.id, path}})
|
return http.get('/api/file/', {params: {id: this.props.id, path}})
|
||||||
.then(res => {
|
.then(res => {
|
||||||
const objects = lds.orderBy(res, [this._kindSort, 'name'], ['desc', 'asc']);
|
const objects = lds.orderBy(res, [this._kindSort, 'name'], ['desc', 'asc']);
|
||||||
this.setState({objects, pwd})
|
this.setState({objects, pwd})
|
||||||
|
this.pwdHistoryCaches.set(this.props.id, pwd)
|
||||||
this.state.inputPath !== null && this.setState({inputPath: path})
|
this.state.inputPath !== null && this.setState({inputPath: path})
|
||||||
})
|
})
|
||||||
.finally(() => this.setState({fetching: false}))
|
.finally(() => this.setState({fetching: false}))
|
||||||
|
|
Loading…
Reference in New Issue