1
+ <template >
2
+ <div >
3
+ <complex-table :data =" pods" v-loading =" loading" @search =" search" >
4
+ <el-table-column :label =" $t('commons.table.version')" prop =" name" min-width =" 80" show-overflow-tooltip >
5
+ <template v-slot :default =" {row } " >
6
+ <span >{{ row.metadata.annotations["deployment.kubernetes.io/revision"] }}</span >
7
+ </template >
8
+ </el-table-column >
9
+ <el-table-column :label =" $t('commons.table.image')" prop =" image" min-width =" 80" show-overflow-tooltip >
10
+ <template v-slot :default =" {row } " >
11
+ <span v-for =" (k, index) in row.spec.template.spec.containers" :key =" index" >
12
+ <span class =" label-custom wd" type =" info" >{{ k.image }}</span >
13
+ </span >
14
+ </template >
15
+ </el-table-column >
16
+ <el-table-column :label =" $t('commons.table.time')" prop =" time" min-width =" 80" show-overflow-tooltip >
17
+ <template v-slot :default =" {row } " >
18
+ <span >{{ row.metadata.creationTimestamp | age }}</span >
19
+ </template >
20
+ </el-table-column >
21
+ <ko-table-operations :buttons =" buttons" :label =" $t('commons.table.action')" ></ko-table-operations >
22
+ </complex-table >
23
+ </div >
24
+ </template >
25
+
26
+ <script >
27
+ import ComplexTable from " @/components/complex-table"
28
+ import KoTableOperations from " @/components/ko-table-operations"
29
+ import {checkPermissions } from " @/utils/permission"
30
+ import {listNsReplicaSetsWorkload } from " @/api/replicasets"
31
+ import { patchDeployment } from " @/api/deployments"
32
+
33
+
34
+ export default {
35
+ name: " KoDetailReplicasets" ,
36
+ components: { ComplexTable, KoTableOperations },
37
+ props: {
38
+ cluster: String ,
39
+ namespace: String ,
40
+ selector: String ,
41
+ fieldSelector: String ,
42
+ name: String ,
43
+ },
44
+ watch: {
45
+ selector: {
46
+ handler (newSelector ) {
47
+ if (newSelector) {
48
+ this .search ()
49
+ }
50
+ },
51
+ immediate: true ,
52
+ },
53
+ fieldSelector: {
54
+ handler (newSelector ) {
55
+ if (newSelector) {
56
+ this .search ()
57
+ }
58
+ },
59
+ immediate: true ,
60
+ },
61
+ },
62
+ data () {
63
+ return {
64
+ buttons: [
65
+ {
66
+ label: this .$t (" commons.button.rollback" ),
67
+ icon: " el-icon-back" ,
68
+ click : (row ) => {
69
+ this .OptionRollback (row)
70
+ },
71
+ disabled : () => {
72
+ return ! checkPermissions ({ scope: " namespace" , apiGroup: " " , resource: " pods/log" , verb: " *" })
73
+ },
74
+ },
75
+ ],
76
+ loading: false ,
77
+ pods: [],
78
+ podUsage: [],
79
+ }
80
+ },
81
+ methods: {
82
+ search (resetPage ) {
83
+ this .loading = true
84
+ if (resetPage) {
85
+ this .paginationConfig .currentPage = 1
86
+ }
87
+ if (! checkPermissions ({ scope: " namespace" , apiGroup: " " , resource: " pods" , verb: " list" })) {
88
+ return
89
+ }
90
+ listNsReplicaSetsWorkload (this .cluster , this .namespace , this .selector , this .fieldSelector ).then ((res ) => {
91
+ this .loading = false
92
+ res .items .sort ((a , b ) => b .metadata .annotations [" deployment.kubernetes.io/revision" ] - a .metadata .annotations [" deployment.kubernetes.io/revision" ])
93
+ for (var i = 0 ; i < res .items .length ; i++ ) {
94
+ this .pods .push (res .items [i])
95
+ }
96
+ })
97
+
98
+ },
99
+ OptionRollback (row ) {
100
+ this .$confirm (
101
+ this .$t (" commons.confirm_message.rollback" ),
102
+ this .$t (" commons.message_box.prompt" ), {
103
+ confirmButtonText: this .$t (" commons.button.confirm" ),
104
+ cancelButtonText: this .$t (" commons.button.cancel" ),
105
+ type: " warning" ,
106
+ }).then (() => {
107
+ patchDeployment (this .cluster , row .metadata .namespace , this .name , {" spec" : {" template" : row .spec .template }})
108
+ .then (() => {
109
+ this .dialogModifyVersionVisible = false
110
+ this .loading = true
111
+ this .$message ({
112
+ type: " success" ,
113
+ message: this .$t (" commons.msg.operation_success" ),
114
+ })
115
+ })
116
+ .finally (() => {
117
+ this .loading = false
118
+ })
119
+ })
120
+ },
121
+ },
122
+ mounted () {
123
+ this .clusterName = this .$route .query .cluster
124
+ },
125
+ }
126
+ </script >
127
+
128
+ <style scoped>
129
+ .btnSize {
130
+ width : 28px ;
131
+ height : 28px ;
132
+ }
133
+ </style >
0 commit comments