\ No newline at end of file
diff --git a/tools/otagui/src/components/PartialCheckbox.vue b/tools/otagui/src/components/PartialCheckbox.vue
index 426b261f8..fc7694fa6 100644
--- a/tools/otagui/src/components/PartialCheckbox.vue
+++ b/tools/otagui/src/components/PartialCheckbox.vue
@@ -34,4 +34,15 @@ export default {
},
},
}
-
\ No newline at end of file
+
+
+
\ No newline at end of file
diff --git a/tools/otagui/src/components/PayloadComposition.vue b/tools/otagui/src/components/PayloadComposition.vue
new file mode 100644
index 000000000..420b96df6
--- /dev/null
+++ b/tools/otagui/src/components/PayloadComposition.vue
@@ -0,0 +1,71 @@
+
+
+
+
+
+ {{ listData }}
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/tools/otagui/src/components/PayloadDetail.vue b/tools/otagui/src/components/PayloadDetail.vue
index 245be24a1..478119048 100644
--- a/tools/otagui/src/components/PayloadDetail.vue
+++ b/tools/otagui/src/components/PayloadDetail.vue
@@ -8,6 +8,10 @@
+
Payload Compositin
+
+
+
Partition List
import PartitionDetail from './PartitionDetail.vue'
+import PayloadComposition from './PayloadComposition.vue'
import { Payload } from '@/services/payload.js'
export default {
components: {
PartitionDetail,
+ PayloadComposition,
},
props: {
zipFile: {
diff --git a/tools/otagui/src/services/echarts_data.js b/tools/otagui/src/services/echarts_data.js
new file mode 100644
index 000000000..faddeecc9
--- /dev/null
+++ b/tools/otagui/src/services/echarts_data.js
@@ -0,0 +1,14 @@
+// This function will be used later for generating a pie chart through eCharts
+export class EchartsData {
+ constructor(statisticData) {
+ this.statisticData = statisticData
+ }
+
+ listData() {
+ let table = ''
+ for (let [key, value] of this.statisticData) {
+ table += key + ' : ' + value.toString() + ' Blocks' + '\n'
+ }
+ return table
+ }
+}
\ No newline at end of file
diff --git a/tools/otagui/src/services/payload_composition.js b/tools/otagui/src/services/payload_composition.js
new file mode 100644
index 000000000..b5ad85d91
--- /dev/null
+++ b/tools/otagui/src/services/payload_composition.js
@@ -0,0 +1,73 @@
+import { OpType } from '@/services/payload.js'
+
+/**
+ * Return a statistics over the numbers of blocks (in destination) that are
+ * being operated by different installation operation (e.g. REPLACE, BSDIFF).
+ * Only partitions that are being passed in will be included.
+ * @param {Array} partitions
+ * @return {Map}
+ */
+export function operatedBlockStatistics(partitions) {
+ let operatedBlocks = new Map()
+ let opType = new OpType()
+ for (let partition of partitions) {
+ for (let operation of partition.operations) {
+ let operationType = opType.mapType.get(operation.type)
+ if (!operatedBlocks.get(operationType)) {
+ operatedBlocks.set(operationType, 0)
+ }
+ operatedBlocks.set(
+ operationType,
+ operatedBlocks.get(operationType) + numBlocks(operation.dstExtents)
+ )
+ }
+ }
+ return operatedBlocks
+}
+
+/**
+ * Return a statistics over the disk usage of payload.bin, based on the type of
+ * installation operations. Only partitions that are being passed in will be
+ * included.
+ * @param {Array} partitions
+ * @return {Map}
+ */
+export function operatedPayloadStatistics(partitions) {
+ let operatedBlocks = new Map()
+ let opType = new OpType()
+ for (let partition of partitions) {
+ for (let operation of partition.operations) {
+ let operationType = opType.mapType.get(operation.type)
+ if (!operatedBlocks.get(operationType)) {
+ operatedBlocks.set(operationType, 0)
+ }
+ operatedBlocks.set(
+ operationType,
+ operatedBlocks.get(operationType) + operation.dataLength
+ )
+ }
+ }
+ return operatedBlocks
+}
+
+/**
+ * Calculate the number of blocks being operated
+ * @param {Array} exts
+ * @return {number}
+ */
+export function numBlocks(exts) {
+ const accumulator = (total, ext) => total + ext.numBlocks
+ return exts.reduce(accumulator, 0)
+}
+
+/**
+ * Return a string that indicates the blocks being operated
+ * in the manner of (start_block, block_length)
+ * @param {Array
+ total + '(' + ext.startBlock + ',' + ext.numBlocks + ')'
+ return exts.reduce(accumulator, '')
+}
\ No newline at end of file