Skip to content

Commit

Permalink
setup autoupdate
Browse files Browse the repository at this point in the history
  • Loading branch information
iwate committed Feb 20, 2020
1 parent 3195ebf commit d6ad1ac
Show file tree
Hide file tree
Showing 11 changed files with 161 additions and 64 deletions.
9 changes: 8 additions & 1 deletion src/Aiplugs.PoshApp/Controllers/DefaultController.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
using System.Diagnostics;
using Microsoft.AspNetCore.Mvc;
using Aiplugs.PoshApp.ViewModels;
using System.Threading.Tasks;
using ElectronNET.API;

namespace Aiplugs.PoshApp.Controllers
{
public class DefaultController : Controller
{
public IActionResult Index()
public async Task<IActionResult> Index()
{
if (HybridSupport.IsElectronActive)
{
ViewBag.Version = await Electron.App.GetVersionAsync();
}

return View();
}

Expand Down
62 changes: 58 additions & 4 deletions src/Aiplugs.PoshApp/ElectronIpc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,75 @@ public class ElectronIpc
{
public static void Setup()
{
Electron.IpcMain.On("select-directory", async (args) => {
var menu = new MenuItem[] {
new MenuItem {
Label = "View",
Submenu = new MenuItem[] {
new MenuItem
{
Label = "Reload",
Accelerator = "CmdOrCtrl+R",
Click = () =>
{
// on reload, start fresh and close any old
// open secondary windows
Electron.WindowManager.BrowserWindows.ToList().ForEach(browserWindow => {
if(browserWindow.Id != 1)
{
browserWindow.Close();
}
else
{
browserWindow.Reload();
}
});
}
},
new MenuItem
{
Label = "Open Developer Tools",
Accelerator = "CmdOrCtrl+I",
Click = () => Electron.WindowManager.BrowserWindows.First().WebContents.OpenDevTools()
}
}
},
new MenuItem {
Label = "Help",
Role = MenuRole.help,
Submenu = new MenuItem[] {
new MenuItem
{
Label = "Learn More",
Click = async () => await Electron.Shell.OpenExternalAsync("https://github.com/aiplugs/poshapp")
}
}
}
};

Electron.Menu.SetApplicationMenu(menu);

Electron.IpcMain.On("select-directory", async (args) =>
{
var mainWindow = Electron.WindowManager.BrowserWindows.First();
var options = new OpenDialogOptions
{
Properties = new OpenDialogProperty[] {
OpenDialogProperty.openDirectory
}
}
};

string[] dirs = await Electron.Dialog.ShowOpenDialogAsync(mainWindow, options);
Electron.IpcMain.Send(mainWindow, "select-directory-reply", dirs, args);
});

Electron.IpcMain.On("select-file", async (args) => {
Electron.IpcMain.On("select-file", async (args) =>
{
var mainWindow = Electron.WindowManager.BrowserWindows.First();
var options = new OpenDialogOptions
{
Properties = new OpenDialogProperty[] {
OpenDialogProperty.openFile,
}
}
};

string[] dirs = await Electron.Dialog.ShowOpenDialogAsync(mainWindow, options);
Expand All @@ -43,6 +92,11 @@ public static void Setup()
{
Electron.Clipboard.WriteText(text.ToString());
});

Electron.IpcMain.On("check-update", async (args) =>
{
await Electron.AutoUpdater.CheckForUpdatesAndNotifyAsync();
});
}
}
}
5 changes: 2 additions & 3 deletions src/Aiplugs.PoshApp/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,13 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
}
public async void ElectronBootstrap()
{
var browserWindow = await Electron.WindowManager.CreateWindowAsync(new BrowserWindowOptions
await Electron.WindowManager.CreateWindowAsync(new BrowserWindowOptions
{
Title = "POSH App",
Width = 1152,
Height = 864,
Show = true,
});

browserWindow.SetTitle("POSH App");
}
}
}
52 changes: 4 additions & 48 deletions src/Aiplugs.PoshApp/Views/Shared/App.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -46,60 +46,16 @@

<Toast></Toast>
</div>
<v-dialog v-model="display" max-width="600">
<v-card>
<v-card-title>FREE Plan limit exceeded</v-card-title>
<v-card-text>
<v-row align="center">
<v-col>
<span class="display-2">$0.00</span>
forever
</v-col>
<v-col>
<span class="display-2">$1.49</span> / month・machine
</v-col>
</v-row>
<v-row>
<v-col>
<ul>
<li><span class="font-weight-bold">2</span> repositories</li>
<li><span class="font-weight-bold">10</span> scripts / repository</li>
</ul>
</v-col>
<v-col>
<ul>
<li>Unlimited repositories</li>
<li>Unlimites scripts</li>
</ul>
</v-col>
</v-row>
</v-card-text>
<v-divider></v-divider>
<v-card-actions>
<v-spacer></v-spacer>
<v-btn text v-on:click="hideActivationNotice">No thank you</v-btn>
<v-btn color="primary" v-on:click="moveToActivation">Activate</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
<ActivationNotice></ActivationNotice>
</v-app>
</template>
<script>
Vue.component('App', {
template: "#app-component",
computed: {
...Vuex.mapState('activation', ['display'])
},
methods: {
...Vuex.mapMutations('activation', ['hideActivationNotice']),
...Vuex.mapActions('activation', ['loadActivationStatus']),
moveToActivation() {
this.hideActivationNotice();
this.$router.push('/settings/activation');
}
},
mounted() {
this.loadActivationStatus();
setTimeout(() => {
ipcRenderer.send('check-update');
}, 5000);
}
})
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<template id="activation-notice-component">
<v-dialog v-model="display" max-width="600">
<v-card>
<v-card-title>FREE Plan limit exceeded</v-card-title>
<v-card-text>
<v-row align="center">
<v-col>
<span class="display-2">$0.00</span>
forever
</v-col>
<v-col>
<span class="display-2">$1.49</span> / month・machine
</v-col>
</v-row>
<v-row>
<v-col>
<ul>
<li><span class="font-weight-bold">2</span> repositories</li>
<li><span class="font-weight-bold">10</span> scripts / repository</li>
</ul>
</v-col>
<v-col>
<ul>
<li>Unlimited repositories</li>
<li>Unlimites scripts</li>
</ul>
</v-col>
</v-row>
</v-card-text>
<v-divider></v-divider>
<v-card-actions>
<v-spacer></v-spacer>
<v-btn text v-on:click="hideActivationNotice">No thank you</v-btn>
<v-btn color="primary" v-on:click="moveToActivation">Activate</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
</template>
<script>
Vue.component('activationnotice', {
template: '#activation-notice-component',
computed: {
...Vuex.mapState('activation', ['display'])
},
methods: {
...Vuex.mapMutations('activation', ['hideActivationNotice']),
...Vuex.mapActions('activation', ['loadActivationStatus']),
moveToActivation() {
this.hideActivationNotice();
this.$router.push('/settings/activation');
}
},
mounted() {
this.loadActivationStatus();
}
})
</script>
2 changes: 2 additions & 0 deletions src/Aiplugs.PoshApp/Views/Shared/Index.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
<script>
const { ipcRenderer } = require("electron");
</script>
<partial name="Components/ActivationNotice" />
<partial name="Components/DateTime" />
<partial name="Components/Toast" />
<partial name="PowershellUI/Prompt" />
Expand All @@ -37,6 +38,7 @@
<partial name="PowershellUI/Index" />
<partial name="Settings/Nav" />
<partial name="Settings/Activation" />
<partial name="Settings/Version" />
<partial name="Scripts/Nav" />
<partial name="Scripts/Index" />
<partial name="Repositories/Nav" />
Expand Down
3 changes: 3 additions & 0 deletions src/Aiplugs.PoshApp/Views/Shared/Repositories/Index.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@
this.$signalr.on('GitLogNotFound', name => {
if (this.$route.params.id == name) {
this.items.splice(0);
this.status.splice(0);
this.origin = null;
this.local = null;
this.message = 'This repository have not initialized git.'
}
})
Expand Down
7 changes: 5 additions & 2 deletions src/Aiplugs.PoshApp/Views/Shared/Settings/Nav.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
<v-list-item-title>Activation</v-list-item-title>
</v-list-item-content>
</v-list-item>
<v-list-item to="/settings/version">
<v-list-item-content>
<v-list-item-title>Version</v-list-item-title>
</v-list-item-content>
</v-list-item>
</v-list>
</section>
</template>
Expand All @@ -19,8 +24,6 @@
computed: {
},
methods: {
},
async mounted() {
}
})
</script>
10 changes: 10 additions & 0 deletions src/Aiplugs.PoshApp/Views/Shared/Settings/Version.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<template id="version-component">
<div>
Version @ViewBag.Version
</div>
</template>
<script>
Vue.component('Version', {
template: '#version-component'
})
</script>
17 changes: 11 additions & 6 deletions src/Aiplugs.PoshApp/electron.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,33 @@
"splashscreen": {
"imageFile": ""
},
"singleInstance": false,
"singleInstance": true,
"build": {
"appId": "com.Aiplugs.PoshApp.app",
"productName": "Aiplugs.PoshApp",
"appId": "com.aiplugs.poshapp",
"productName": "POSH App",
"copyright": "Copyright © 2019",
"buildVersion": "1.0.0",
"buildVersion": "0.9.7",
"compression": "maximum",
"directories": {
"output": "../../../bin/Desktop"
},
"publish": [{
"provider": "github",
"owner": "aiplugs",
"repo": "poshapp"
}],
"extraResources": [
{
"from": "./bin",
"to": "bin",
"filter": ["**/*"]
"filter": [ "**/*" ]
}
],
"files": [
{
"from": "./ElectronHostHook/node_modules",
"to": "ElectronHostHook/node_modules",
"filter": ["**/*"]
"filter": [ "**/*" ]
},
"**/*"
]
Expand Down
1 change: 1 addition & 0 deletions src/Aiplugs.PoshApp/wwwroot/js/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ export default new VueRouter({
{ path: '/repositories/:id', components: { default: Vue.component('Repository'), nav: Vue.component('RepositoryNav') } },
{ path: '/settings/', components: { nav: Vue.component('SettingsNav') } },
{ path: '/settings/activation', components: { default: Vue.component('Activation'), nav: Vue.component('SettingsNav') } },
{ path: '/settings/version', components: { default: Vue.component('Version'), nav: Vue.component('SettingsNav') } },
]
})

0 comments on commit d6ad1ac

Please sign in to comment.