From e60a7640800b02f44cddf448eadabdeace6470b1 Mon Sep 17 00:00:00 2001 From: iwate Date: Tue, 28 Apr 2020 17:33:07 +0900 Subject: [PATCH] move signalr&ipc code to vuex --- src/Aiplugs.PoshApp/Services/Git/GitWorker.cs | 7 +- .../Services/ScriptsService.cs | 2 +- src/Aiplugs.PoshApp/Views/Shared/App.cshtml | 13 +- .../Shared/Components/UpdateNotice.cshtml | 22 +- src/Aiplugs.PoshApp/Views/Shared/Index.cshtml | 11 +- .../Views/Shared/Pages/Detail.cshtml | 29 +- .../Views/Shared/Pages/List.cshtml | 141 ++++---- .../Shared/Pages/Parts/ParametersForm.cshtml | 72 ++-- .../Views/Shared/Pages/Singleton.cshtml | 64 ++-- .../Views/Shared/PowershellUI/Log.cshtml | 40 +-- .../Shared/PowershellUI/LogForError.cshtml | 29 +- .../Views/Shared/PowershellUI/Progress.cshtml | 80 ++--- .../Shared/PowershellUI/ProgressForGit.cshtml | 33 +- .../Views/Shared/PowershellUI/Prompt.cshtml | 93 +++--- .../PowershellUI/PromptForChoice.cshtml | 37 +-- .../PowershellUI/PromptForCredential.cshtml | 67 +--- .../Views/Shared/PowershellUI/Status.cshtml | 63 ++-- .../Views/Shared/Repositories/Index.cshtml | 87 ++--- .../Views/Shared/Repositories/Nav.cshtml | 34 +- .../Views/Shared/Settings/Activation.cshtml | 23 +- src/Aiplugs.PoshApp/wwwroot/js/main.js | 4 +- src/Aiplugs.PoshApp/wwwroot/js/store/index.js | 19 +- src/Aiplugs.PoshApp/wwwroot/js/store/ipc.js | 74 +++++ .../wwwroot/js/store/signalr.js | 307 ++++++++++++++++++ 24 files changed, 731 insertions(+), 620 deletions(-) create mode 100644 src/Aiplugs.PoshApp/wwwroot/js/store/ipc.js create mode 100644 src/Aiplugs.PoshApp/wwwroot/js/store/signalr.js diff --git a/src/Aiplugs.PoshApp/Services/Git/GitWorker.cs b/src/Aiplugs.PoshApp/Services/Git/GitWorker.cs index a944f64..0e4c9ba 100644 --- a/src/Aiplugs.PoshApp/Services/Git/GitWorker.cs +++ b/src/Aiplugs.PoshApp/Services/Git/GitWorker.cs @@ -90,13 +90,14 @@ public void Clone(CloneCommand cmd) CredentialsProvider = new LibGit2Sharp.Handlers.CredentialsHandler(GetCredential) }); } - catch(Exception) + catch (Exception ex) { - if (_credentials.ContainsKey(cmd.Origin)) { + if (_credentials.ContainsKey(cmd.Origin)) + { _credentials.Remove(cmd.Origin); } Client.SendAsync("GitCloneFaild", cmd.Name).Wait(); - throw; + throw ex; } Client.SendAsync("GitClone", cmd.Name).Wait(); diff --git a/src/Aiplugs.PoshApp/Services/ScriptsService.cs b/src/Aiplugs.PoshApp/Services/ScriptsService.cs index 504f81c..d36a941 100644 --- a/src/Aiplugs.PoshApp/Services/ScriptsService.cs +++ b/src/Aiplugs.PoshApp/Services/ScriptsService.cs @@ -16,7 +16,7 @@ public class ScriptsService [ScriptType.List] = "param(\n\t[int]\n\t$Page,\n\n\t[int]\n\t$PageSize\n)\n", [ScriptType.Detail] = "param(\n\t[Parameter(ValueFromPipeline=$true,Mandatory=$true)]\n\t[PSObject]\n\t$InputObject\n)\n", [ScriptType.Singleton] = "", - [ScriptType.Action] = "param(\n\t[Parameter(ValueFromPipeline=$true)]\n\t[PSObject[]]\n\t$InputObject\n)\nprocess {\n\n}" + [ScriptType.Action] = "param(\n\t[Parameter(ValueFromPipeline=$true)]\n\t[PSObject[]]\n\t$InputObject\n)\n" }; private readonly ConfigAccessor _configAccessor; private readonly LicenseService _license; diff --git a/src/Aiplugs.PoshApp/Views/Shared/App.cshtml b/src/Aiplugs.PoshApp/Views/Shared/App.cshtml index 60bd985..6e66509 100644 --- a/src/Aiplugs.PoshApp/Views/Shared/App.cshtml +++ b/src/Aiplugs.PoshApp/Views/Shared/App.cshtml @@ -51,14 +51,17 @@ \ No newline at end of file diff --git a/src/Aiplugs.PoshApp/Views/Shared/Components/UpdateNotice.cshtml b/src/Aiplugs.PoshApp/Views/Shared/Components/UpdateNotice.cshtml index e1f3aeb..19601a4 100644 --- a/src/Aiplugs.PoshApp/Views/Shared/Components/UpdateNotice.cshtml +++ b/src/Aiplugs.PoshApp/Views/Shared/Components/UpdateNotice.cshtml @@ -1,12 +1,12 @@  - \ No newline at end of file diff --git a/src/Aiplugs.PoshApp/Views/Shared/Pages/Parts/ParametersForm.cshtml b/src/Aiplugs.PoshApp/Views/Shared/Pages/Parts/ParametersForm.cshtml index e89dffd..bd1fb6a 100644 --- a/src/Aiplugs.PoshApp/Views/Shared/Pages/Parts/ParametersForm.cshtml +++ b/src/Aiplugs.PoshApp/Views/Shared/Pages/Parts/ParametersForm.cshtml @@ -3,7 +3,7 @@ p.name == 'Page'); - if (p) { - this.$set(p, 'value', value - 1); - } - }, - setPageSize(value) { - const p = this.parameters.find(p => p.name == 'PageSize'); - if (p) { - this.$set(p, 'value', value); - } - }, + ...Vuex.mapActions('signalr', ['invokeGetParameters']), isNumberType(type) { const numberTypes = ['System.Int32','System.Int64','System.Single','System.Double','System.Decimal']; return numberTypes.includes(type); @@ -145,37 +140,22 @@ }, getClixmls() { return this.parameters.reduce((o, p) => { - if (p.value !== undefined) { - o[p.name] = createCliXml(p.type, p.value); + if (this.value[p.name] !== undefined) { + o[p.name] = createCliXml(p.type, this.value[p.name]); } return o; }, {}); }, - getPageSize() { - const p = this.parameters.find(p => p.name == 'PageSize'); - return p ? parseInt(p.value) : null; - }, emitRun() { - this.$emit('run', this.getClixmls()); + this.$emit('run', { + value: this.getClixmls(), + page: this.value.Page - 0 + 1, + pageSize: this.value.PageSize - 0 + }); }, - getParameters() { - this.loadingParams = true; - this.$signalr.invoke('GetParameters', this.script); - } }, mounted() { - this.$signalr.on("GetParameters", parameters => { - this.parameters.splice(0, this.parameters.length, ...parameters); - this.setPage(this.page); - this.setPageSize(this.pageSize); - this.loadingParams = false; - }) - this.$signalr.onconnected(() => { - this.getParameters(); - }) - }, - beforeDestroy() { - this.$signalr.off('DetailResult') + this.invokeGetParameters({ scriptId: this.script }); } }) \ No newline at end of file diff --git a/src/Aiplugs.PoshApp/Views/Shared/Pages/Singleton.cshtml b/src/Aiplugs.PoshApp/Views/Shared/Pages/Singleton.cshtml index 324c6c3..454dce0 100644 --- a/src/Aiplugs.PoshApp/Views/Shared/Pages/Singleton.cshtml +++ b/src/Aiplugs.PoshApp/Views/Shared/Pages/Singleton.cshtml @@ -3,33 +3,37 @@
- + + - {{action.displayName || action.id}} + {{action.displayName || action.id}}
- +
mdi-xml - \ No newline at end of file diff --git a/src/Aiplugs.PoshApp/Views/Shared/PowershellUI/Log.cshtml b/src/Aiplugs.PoshApp/Views/Shared/PowershellUI/Log.cshtml index fe5ebe8..a834e24 100644 --- a/src/Aiplugs.PoshApp/Views/Shared/PowershellUI/Log.cshtml +++ b/src/Aiplugs.PoshApp/Views/Shared/PowershellUI/Log.cshtml @@ -11,7 +11,7 @@
-

             
@@ -25,16 +25,21 @@ \ No newline at end of file diff --git a/src/Aiplugs.PoshApp/Views/Shared/PowershellUI/LogForError.cshtml b/src/Aiplugs.PoshApp/Views/Shared/PowershellUI/LogForError.cshtml index 1b70bbd..d074fd3 100644 --- a/src/Aiplugs.PoshApp/Views/Shared/PowershellUI/LogForError.cshtml +++ b/src/Aiplugs.PoshApp/Views/Shared/PowershellUI/LogForError.cshtml @@ -1,14 +1,15 @@