From aaf2c7a9330f0dc9201395e4e3795a3f963939f3 Mon Sep 17 00:00:00 2001 From: lishutong Date: Thu, 22 Jul 2021 21:41:07 +0000 Subject: [PATCH] Refactor the frontend for batch generation. Following part has been modified: 1. Add tabs for selection between single generation and batch generation. (src/components/JobConfigure.vue) 2. Change the data structure of OTAConfiguration, now it only records the flags. The source/target build will be provided when submit jobs. (src/services/JobSubmission.js) 3. Seperate the OTAOptions as a single component, which only takes in the flags for backend. The selection of source/target build will be in a seperate component. (src/components/OTAOptions.vue, src/components/SingleOTAOptions.vue). 4. Now the partition selection can takes in more than one build, but only show the partition list of first one. Later on, this will be able to show the intersection of the partition lists from all given builds. (src/components/PartialCheckbox.vue) Point 1 enables the possibility of the dynamical loading of single/batch ota generation pages. Point 2,3,4 allow the OTAOptions components to be reused for batch generation. Test: Mannual tested. Change-Id: I1a29fa7c605596d717d19da25d31b81ce5b8fcba --- tools/otagui/src/components/OTAOptions.vue | 173 ++++++------------ .../otagui/src/components/PartialCheckbox.vue | 2 +- .../src/components/SingleOTAOptions.vue | 92 ++++++++++ tools/otagui/src/services/JobSubmission.js | 36 +++- tools/otagui/src/views/JobConfigure.vue | 82 +++++++-- 5 files changed, 248 insertions(+), 137 deletions(-) create mode 100644 tools/otagui/src/components/SingleOTAOptions.vue diff --git a/tools/otagui/src/components/OTAOptions.vue b/tools/otagui/src/components/OTAOptions.vue index b194b59b3..6aee09fe0 100644 --- a/tools/otagui/src/components/OTAOptions.vue +++ b/tools/otagui/src/components/OTAOptions.vue @@ -1,76 +1,55 @@ \ No newline at end of file diff --git a/tools/otagui/src/components/PartialCheckbox.vue b/tools/otagui/src/components/PartialCheckbox.vue index d18d011fb..9e716c36a 100644 --- a/tools/otagui/src/components/PartialCheckbox.vue +++ b/tools/otagui/src/components/PartialCheckbox.vue @@ -38,7 +38,7 @@ export default { default: new Array(), }, modelValue: { - type: String, + type: Array, required: true }, }, diff --git a/tools/otagui/src/components/SingleOTAOptions.vue b/tools/otagui/src/components/SingleOTAOptions.vue new file mode 100644 index 000000000..39addf8fc --- /dev/null +++ b/tools/otagui/src/components/SingleOTAOptions.vue @@ -0,0 +1,92 @@ + + + \ No newline at end of file diff --git a/tools/otagui/src/services/JobSubmission.js b/tools/otagui/src/services/JobSubmission.js index f6acfb54e..4c97486f1 100644 --- a/tools/otagui/src/services/JobSubmission.js +++ b/tools/otagui/src/services/JobSubmission.js @@ -21,32 +21,50 @@ export class OTAConfiguration { * disable checkboxes of which dependencies are not fulfilled. */ this.verbose = false, - this.target = '', - this.incremental = '', this.isIncremental = false, this.partial = [], this.isPartial = false, this.extra_keys = [], - this.extra = '', - this.id = uuid.v1() + this.extra = '' } /** - * Start the generation process, will throw an error if not succeed + * Start an OTA package generation from target build to incremental source. + * Throw an error if not succeed, otherwise will return the message from + * the backend. + * @param {String} targetBuild + * @param {String} incrementalSource + * @return String */ - async sendForm() { + async sendForm(targetBuild, incrementalSource='') { + let jsonOptions = Object.assign({}, this) + jsonOptions.target = targetBuild + jsonOptions.incremental = incrementalSource + jsonOptions.id = uuid.v1() for (let flag of OTAExtraFlags) { - if (this[flag.key]) { - this.extra_keys.push(flag.key) + if (jsonOptions[flag.key]) { + jsonOptions.extra_keys.push(flag.key) } } try { - let response = await ApiServices.postInput(JSON.stringify(this), this.id) + let response = await ApiServices.postInput(JSON.stringify(jsonOptions), jsonOptions.id) return response.data } catch (err) { throw err } } + + /** + * Reset all the flags being set in this object. + */ + reset() { + for (let flag of OTAExtraFlags) { + if (this[flag.key]) { + delete this[flag.key] + } + } + this.constructor() + } } export const OTABasicFlags = [ diff --git a/tools/otagui/src/views/JobConfigure.vue b/tools/otagui/src/views/JobConfigure.vue index 40e55e056..afd7252ae 100644 --- a/tools/otagui/src/views/JobConfigure.vue +++ b/tools/otagui/src/views/JobConfigure.vue @@ -1,14 +1,24 @@ > \ No newline at end of file