-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #35 from MZC-CSC/develop
update workflow frontend
- Loading branch information
Showing
45 changed files
with
8,343 additions
and
1,794 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 |
---|---|---|
@@ -1,38 +1,43 @@ | ||
import { defineStore } from 'pinia'; | ||
import { ref, Ref } from 'vue'; | ||
import { IMci } from './types.ts'; | ||
|
||
// api 요청은 실제 사용하는 page에서 실행. | ||
// list도 여기서 | ||
// 다른 store 참조가능 | ||
// 각각의 store load는 feature에서 진행. | ||
import { IMci, IVm } from './types.ts'; | ||
|
||
const NAMESPACE = 'MCI'; | ||
|
||
export interface IMciStore { | ||
mcis: Ref<IMci[]>; | ||
setMcis: (val: IMci[]) => void; | ||
loadMciById: (id: string) => IMci | null; | ||
} | ||
|
||
export const useMCIStore = defineStore(NAMESPACE, (): IMciStore => { | ||
export const useMCIStore = defineStore(NAMESPACE, () => { | ||
const mcis = ref<IMci[]>([]); | ||
|
||
function setMcis(_mcis: IMci[]) { | ||
mcis.value = _mcis; | ||
} | ||
|
||
function loadMciById(mciId: string) { | ||
function getMciById(mciId: string) { | ||
return ( | ||
mcis.value.find((mci: IMci) => { | ||
return mci.id === mciId; | ||
}) || null | ||
); | ||
} | ||
|
||
function setVmsInfo(mciID: string, vm: Array<IVm>) { | ||
const mci = getMciById(mciID); | ||
if (mci) { | ||
mci.vm = vm; | ||
} | ||
} | ||
|
||
function setVmInfo(mciID: string, vm: IVm) { | ||
const mci = getMciById(mciID); | ||
const targetVm = mci?.vm.find(_vm => _vm.id === vm.id); | ||
if (targetVm) { | ||
Object.assign(targetVm, vm); | ||
} | ||
} | ||
return { | ||
mcis, | ||
setMcis, | ||
loadMciById, | ||
getMciById, | ||
setVmsInfo, | ||
setVmInfo, | ||
}; | ||
}); |
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.