11<script setup>
22import { ref , watch , onMounted , getCurrentInstance } from ' vue' ;
3- import { useRouter , useRoute } from ' vue-router/composables' ;
3+ import { useRoute } from ' vue-router/composables' ;
44import debounce from ' lodash/debounce' ;
55import InstanceTabs from ' ./InstanceTabs.vue' ;
66import types from ' ./assetTypes' ;
77import moment from ' moment' ;
88import Header from ' ./Header.vue' ;
99import InstallProgress from ' ./InstallProgress.vue' ;
1010
11- const router = useRouter ();
1211const route = useRoute ();
1312const vue = getCurrentInstance ().proxy ;
1413
@@ -18,9 +17,30 @@ const items = ref([]);
1817const meta = ref ({});
1918const filter = ref (" " );
2019const showInstallModal = ref (false );
20+ const showConfirmModal = ref (false );
21+ const selectedAsset = ref (null );
22+ const installMode = ref (' update' );
2123const page = ref (1 );
2224const perPage = ref (15 );
2325
26+ const load = () => {
27+ if (! typeConfig) {
28+ return ;
29+ }
30+ const queryParams = {
31+ url: typeConfig .url ,
32+ filter: filter .value ,
33+ per_page: perPage .value ,
34+ page: page .value
35+ };
36+ ProcessMaker .apiClient
37+ .get (` devlink/${ route .params .id } /remote-assets-listing` , { params: queryParams })
38+ .then ((result ) => {
39+ items .value = result .data .data ;
40+ meta .value = result .data .meta ;
41+ });
42+ };
43+
2444watch (page, () => {
2545 load ();
2646});
@@ -57,52 +77,42 @@ const fields = [
5777 },
5878 {
5979 key: ' menu' ,
60- label: ' '
80+ label: ' ' ,
6181 },
6282];
6383
6484
6585const install = (asset ) => {
66- vue .$bvModal .msgBoxConfirm (vue .$t (' Are you sure you want to install this asset onto this instance?' ), {
67- okTitle: vue .$t (' Ok' ),
68- cancelTitle: vue .$t (' Cancel' )
69- }).then ((confirm ) => {
70- if (confirm) {
71- showInstallModal .value = true ;
72- const params = {
73- class: typeConfig .class ,
74- id: asset .id
75- };
76- ProcessMaker .apiClient
77- .post (` /devlink/${ route .params .id } /install-remote-asset` , params)
78- .then ((response ) => {
79- });
80- }
81- });
86+ selectedAsset .value = asset;
87+ showConfirmModal .value = true ;
88+ };
89+
90+ const confirmInstall = () => {
91+ if (selectedAsset .value ) {
92+ showConfirmModal .value = false ;
93+ showInstallModal .value = true ;
94+ const params = {
95+ class: typeConfig .class ,
96+ id: selectedAsset .value .id ,
97+ updateType: installMode .value
98+ };
99+ ProcessMaker .apiClient
100+ .post (` /devlink/${ route .params .id } /install-remote-asset` , params)
101+ .then (() => {
102+ selectedAsset .value = null ;
103+ });
104+ }
105+ };
106+
107+ const cancelInstall = () => {
108+ selectedAsset .value = null ;
109+ showConfirmModal .value = false ;
82110};
83111
84112onMounted (() => {
85113 load ();
86114});
87115
88- const load = () => {
89- if (! typeConfig) {
90- return ;
91- }
92- const queryParams = {
93- url: typeConfig .url ,
94- filter: filter .value ,
95- per_page: perPage .value ,
96- page: page .value
97- };
98- ProcessMaker .apiClient
99- .get (` devlink/${ route .params .id } /remote-assets-listing` , { params: queryParams })
100- .then ((result ) => {
101- items .value = result .data .data ;
102- meta .value = result .data .meta ;
103- });
104- };
105-
106116// Debounced function
107117const debouncedLoad = debounce (load, 300 );
108118
@@ -152,6 +162,53 @@ const handleFilterChange = () => {
152162 @page-change =" page = $event"
153163 @per-page-change =" perPage = $event"
154164 />
165+ <!-- Confirmation Modal -->
166+ <b-modal
167+ id =" install-confirm"
168+ v-model =" showConfirmModal"
169+ :title =" $t('Install Asset')"
170+ @ok =" confirmInstall"
171+ @cancel =" cancelInstall"
172+ :ok-title =" $t('Install')"
173+ :cancel-title =" $t('Cancel')"
174+ >
175+ <div class =" mb-3" >
176+ <p >{{ $t('Do you want to proceed with installing the asset on your instance?') }}</p >
177+ <p v-if =" selectedAsset" class =" font-weight-bold" >{{ selectedAsset.name || selectedAsset.title }}</p >
178+ </div >
179+
180+ <div class =" form-group" >
181+ <label class =" font-weight-bold mb-2" >{{ $t('Installation Mode:') }}</label >
182+ <div class =" custom-control custom-radio" >
183+ <input
184+ id =" update-mode"
185+ v-model =" installMode"
186+ type =" radio"
187+ value =" update"
188+ class =" custom-control-input"
189+ >
190+ <label for =" update-mode" class =" custom-control-label" >
191+ <strong >{{ $t('Update') }}</strong >
192+ <div class =" text-muted small" >{{ $t('Update existing asset with the same name (recommended)') }}</div >
193+ </label >
194+ </div >
195+ <div class =" custom-control custom-radio mt-2" >
196+ <input
197+ id =" copy-mode"
198+ v-model =" installMode"
199+ type =" radio"
200+ value =" copy"
201+ class =" custom-control-input"
202+ >
203+ <label for =" copy-mode" class =" custom-control-label" >
204+ <strong >{{ $t('Copy') }}</strong >
205+ <div class =" text-muted small" >{{ $t('Create a new asset even if one with the same name exists') }}</div >
206+ </label >
207+ </div >
208+ </div >
209+ </b-modal >
210+
211+ <!-- Progress Modal -->
155212 <b-modal id =" install-progress" size =" lg" v-model =" showInstallModal" :title =" $t('Installation Progress')" hide-footer >
156213 <install-progress />
157214 </b-modal >
0 commit comments