修改前端存储路由

pull/5/head
youngS 4 years ago
parent 65fadc2718
commit 504b27831d
  1. 2
      fir_client/src/components/FirHeader.vue
  2. 3
      fir_client/src/components/FirSuperSignBase.vue
  3. 19
      fir_client/src/components/FirUserProfileBase.vue
  4. 163
      fir_client/src/components/FirUserStorage.vue
  5. 23
      fir_client/src/router/index.js
  6. 4
      fir_ser/api/utils/utils.py
  7. 16
      fir_ser/api/views/storage.py

@ -98,7 +98,7 @@
} else if (command === 'chpasswd') {
this.$router.push({name: 'FirUserProfileChangePwd'})
} else if (command === 'storage') {
this.$router.push({name: 'FirUserProfileStorage'})
this.$router.push({name: 'FirUserStorage', params: {act: "change"}})
} else if (command === 'supersign') {
this.$store.dispatch('doucurrentapp', {});
this.$router.push({"name": 'FirSuperSignBase', params: {act: "iosdeveloper"}})

@ -615,9 +615,6 @@
// this.dialogaddDeveloperVisible=true;
} else if (tabname === "iosdeveloper") {
this.iosdeveloperFun({"methods": "GET", "data": data})
} else if (tabname === "goback") {
alert('goback')
this.$router.go(-1);
}
},
// eslint-disable-next-line no-unused-vars

@ -39,15 +39,15 @@
</el-col>
<el-col :span="6" v-if="userinfo.storage_active">
<div class="col-4">
<a ref="storage" class="" @click="$router.push({name:'FirUserProfileStorage'})">
<span><i class="el-icon-coin"></i></span>
存储配置
</a>
</div>
<!-- <el-col :span="6" v-if="userinfo.storage_active">-->
<!-- <div class="col-4">-->
<!-- <a ref="storage" class="" @click="$router.push({name:'FirUserStorage'})">-->
<!-- <span><i class="el-icon-coin"></i></span>-->
<!-- 存储配置-->
<!-- </a>-->
<!-- </div>-->
</el-col>
<!-- </el-col>-->
</el-row>
@ -131,7 +131,8 @@
this.$store.dispatch('doucurrentapp', {});
this.imageUrl = data.data.head_img;
if (this.userinfo.storage_active) {
this.tspan = 6
// this.tspan = 6
this.tspan = 9
}
if (datainfo.data) {
this.$message.success("更新成功")

@ -1,5 +1,5 @@
<template>
<div style="text-align:center">
<el-main style="text-align:center">
<h2 v-if="is_admin_storage">管理员存储您配置的存储将决定其他用户配置的默认存储请谨慎修改</h2>
<el-dialog :title="title" :visible.sync="dialogstorageVisible" :destroy-on-close="true"
:close-on-click-modal="false">
@ -73,8 +73,8 @@
</el-form>
</el-dialog>
<el-tabs v-model="activeName" @tab-click="handleClick" tab-position="right">
<el-tab-pane label="存储选择" name="chostorage">
<el-tabs v-model="activeName" @tab-click="handleClick" tab-position="top" type="border-card">
<el-tab-pane label="存储选择" name="change">
<el-select v-model="use_storage_id" filterable :placeholder="selectlabel" @change="select_storage">
@ -169,7 +169,7 @@
</el-form>
</el-tab-pane>
<el-tab-pane label="存储管理" name="setstorage">
<el-tab-pane label="存储管理" name="edit">
<el-table
:data="storage_info_lists"
border
@ -190,12 +190,12 @@
<el-table-column
prop="domain_name"
label="下载域名"
width="160">
width="180">
</el-table-column>
<el-table-column
prop="bucket_name"
label="bucket_name"
width="120">
width="130">
</el-table-column>
<el-table-column
@ -207,12 +207,12 @@
<el-table-column
prop="description"
label="备注"
width="160">
width="200">
</el-table-column>
<el-table-column
fixed="right"
label="操作"
width="120">
>
<template slot-scope="scope">
<div v-if="scope.row.id === org_storage_id">
<el-button v-if="scope.row.id === org_storage_id" @click="showstorage(scope.row)"
@ -229,20 +229,86 @@
</el-table-column>
</el-table>
</el-tab-pane>
<el-tab-pane label="新增存储" name="addstorage">
<el-tab-pane label="存储新增" name="add">
<el-form ref="storageinfoform" :model="editstorageinfo"
label-width="80px" style="margin:0 auto;">
<el-form-item label-width="100px" label="存储类型">
<el-select v-model="editstorageinfo.storage_type" placeholder="存储类型"
style="margin-left: -100px">
<el-option v-for="st in storage_list" :key="st.id" :label="st.name"
:value="st.id"></el-option>
</el-select>
</el-form-item>
<div v-if="editstorageinfo.storage_type">
<el-form-item label-width="110px" label="存储名称">
<el-input v-model="editstorageinfo.name"></el-input>
</el-form-item>
<el-form-item label-width="110px" label="key">
<el-input v-model="editstorageinfo.access_key"></el-input>
</el-form-item>
<el-form-item label-width="110px" label="secret">
<el-input v-model="editstorageinfo.secret_key"></el-input>
</el-form-item>
<el-form-item label-width="110px" label="bucket_name">
<el-input v-model="editstorageinfo.bucket_name"></el-input>
</el-form-item>
<el-form-item label-width="110px" label="下载域名">
<el-input v-model="editstorageinfo.domain_name"></el-input>
</el-form-item>
<div v-if="editstorageinfo.storage_type === 2">
<el-form-item label-width="110px" label="sts_role_arn">
<el-input
v-model="editstorageinfo.additionalparameter.sts_role_arn"></el-input>
</el-form-item>
<el-form-item label-width="110px" label="endpoint">
<el-input
v-model="editstorageinfo.additionalparameter.endpoint"></el-input>
</el-form-item>
<el-form-item label-width="110px" label="下载授权方式">
<el-select v-model="editstorageinfo.additionalparameter.download_auth_type"
placeholder="下载授权方式"
style="width: 80%">
<el-option v-for="st in download_auth_type_list" :key="st.id" :label="st.name"
:value="st.id"></el-option>
</el-select>
<el-form-item label-width="120px" style="margin-top: 10px;margin-left: 70px;width: 60%"
label="CDN鉴权主KEY"
v-if="editstorageinfo.additionalparameter.download_auth_type === 2">
<el-input placeholder="CDN鉴权主KEY"
v-model="editstorageinfo.additionalparameter.cnd_auth_key"/>
</el-form-item>
</el-form-item>
</div>
<el-form-item label-width="110px" label="备注">
<el-input v-model="editstorageinfo.description"></el-input>
</el-form-item>
<el-button @click="updateorcreate">校验并保存</el-button>
</div>
</el-form>
</el-tab-pane>
</el-tabs>
</div>
</el-main>
</template>
<script>
import {getStorageinfo} from "../restful";
import {getStorageinfo, userinfos} from "../restful";
import {deepCopy} from "../utils";
export default {
name: "FirUserProfileStorage",
name: "FirUserStorage",
data() {
return {
fstorage_lists: [],
@ -257,16 +323,24 @@
storage_list: [],
disabled: true,
isaddflag: false,
activeName: 'chostorage',
activeName: 'change',
storage_info_lists: [],
is_admin_storage: false,
download_auth_type_list: [{id: 1, name: 'OSS模式: 需要把OSS权限开启私有模式'}, {
id: 2,
name: 'CDN模式: 请先配置好阿里云CDN,开启阿里云OSS私有Bucket回源,将使用鉴权A方式'
},]
},],
}
}, methods: {
getUserInfoFun() {
userinfos(data => {
if (data.code === 1000) {
this.$store.dispatch("doUserinfo", data.data);
} else {
this.$message.error("用户信息获取失败")
}
}, {"methods": "GET"})
},
showstorage(editstorageinfo) {
this.title = '查看存储信息';
this.disabled = true;
@ -288,9 +362,7 @@
},
// eslint-disable-next-line no-unused-vars
handleClick(tab, event) {
if (tab.name === 'addstorage') {
this.add_storage_click()
}
this.get_data_from_tabname(tab.name);
},
updateorcreate() {
let methods = "PUT";
@ -342,7 +414,14 @@
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
const loading = this.$loading({
lock: true,
text: '执行中,请耐心等待...',
spinner: 'el-icon-loading',
background: 'rgba(0, 0, 0, 0.7)'
});
getStorageinfo(data => {
loading.close();
if (data.code === 1000) {
this.$message.success('修改成功');
this.getstorageinfoFun();
@ -430,13 +509,55 @@
} else
return '';
},
// eslint-disable-next-line no-unused-vars
get_data_from_tabname(tabname, data = {}) {
this.$router.push({"name": 'FirUserStorage', params: {act: tabname}});
if (tabname === "change") {
this.getstorageinfoFun();
} else if (tabname === "edit") {
this.getstorageinfoFun();
} else if (tabname === "add") {
getStorageinfo(data => {
if (data.code === 1000) {
this.storage_list = data.storage_list;
this.editstorageinfo = {
'additionalparameter': {download_auth_type: 1},
storage_type: this.storage_list[0].id
};
this.isaddflag = true;
} else {
this.$message.error('存储列表获取失败,' + data);
}
}, {"methods": 'GET', "data": {'act': 'storage_type'}});
}
},
}, mounted() {
this.$store.dispatch('douserInfoIndex', 2);
this.getstorageinfoFun();
this.getUserInfoFun();
if (this.$route.params.act) {
let activeName = this.$route.params.act;
let activeName_list = ["change", "edit", "add"];
for (let index in activeName_list) {
if (activeName_list[index] === activeName) {
this.activeName = activeName;
this.get_data_from_tabname(activeName);
return
}
}
}
this.get_data_from_tabname(this.activeName);
}, filters: {}
}
</script>
<style scoped>
.el-main {
margin: 10px auto 100px;
width: 1166px;
position: relative;
padding-bottom: 1px;
background-color: #bfe7f9;
color: #9b9b9b;
-webkit-font-smoothing: antialiased;
border-radius: 1%;
}
</style>

@ -132,13 +132,7 @@ const router = new VueRouter({
// component: FirUserProfileChangePwd
component: () => import("@/components/FirUserProfileChangePwd"),
}, {
path: 'storage',
name: 'FirUserProfileStorage',
// component: FirUserProfileStorage
component: () => import("@/components/FirUserProfileStorage"),
}
},
]
}
@ -166,6 +160,21 @@ const router = new VueRouter({
}
]
},
{
path: '/storage',
// component: FirAppBase,
component: () => import("@/components/FirAppBase"),
children: [
{
path: ':act',
name: 'FirUserStorage',
// component: FirUserProfileStorage
component: () => import("@/components/FirUserStorage"),
}
]
},
{
path: '/register',
name: 'FirRegist',

@ -279,6 +279,10 @@ def migrating_storage_file_data(user_obj, filename, new_storage_obj, clean_old_d
else:
new_storage_obj = Storage(user_obj, new_storage_obj)
if old_storage_obj.get_storage_type() == new_storage_obj.get_storage_type():
# 同一个存储,无需迁移数据
return True
if old_storage_obj.get_storage_type() == 3:
if new_storage_obj.get_storage_type() == 3:
# 都是本地存储,无需操作

@ -24,6 +24,16 @@ class StorageView(APIView):
def get(self, request):
res = BaseResponse()
res.storage_list = []
storage_org_list = list(AppStorage.storage_choices)
for storage_t in storage_org_list:
if storage_t[0] in [0, 3]: continue
res.storage_list.append({'id': storage_t[0], 'name': storage_t[1]})
act = request.query_params.get("act", None)
if act == 'storage_type':
return Response(res.dict)
# [1,2] 表示七牛存储和阿里云存储
storage_obj = AppStorage.objects.filter(user_id=request.user, storage_type__in=[1, 2])
if storage_obj:
@ -43,12 +53,6 @@ class StorageView(APIView):
else:
res.storage = -1 # 默认存储
res.storage_list = []
storage_org_list = list(AppStorage.storage_choices)
for storage_t in storage_org_list:
if storage_t[0] in [0, 3]: continue
res.storage_list.append({'id': storage_t[0], 'name': storage_t[1]})
admin_storage = UserInfo.objects.filter(is_superuser=True).order_by('pk').first()
res.is_admin_storage = False
if admin_storage and admin_storage.uid == request.user.uid:

Loading…
Cancel
Save