Skip to content

Commit

Permalink
Switched over to using the Forge-SDK and added stopping services
Browse files Browse the repository at this point in the history
  • Loading branch information
phppirate committed May 7, 2017
1 parent d652653 commit ceb5650
Show file tree
Hide file tree
Showing 12 changed files with 15,305 additions and 68 deletions.
279 changes: 278 additions & 1 deletion app/css/app.css

Large diffs are not rendered by default.

14,895 changes: 14,891 additions & 4 deletions app/js/app.js

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ mb.on('ready', () => {
{
role: 'about'
},
// {
// label: 'Toggle Developer Tools',
// accelerator: process.platform === 'darwin' ? 'Alt+Command+I' : 'Ctrl+Shift+I',
// click (item, focusedWindow) {
// if (focusedWindow) focusedWindow.webContents.toggleDevTools()
// }
// },
{
label: 'Toggle Developer Tools',
accelerator: process.platform === 'darwin' ? 'Alt+Command+I' : 'Ctrl+Shift+I',
click (item, focusedWindow) {
if (focusedWindow) focusedWindow.webContents.toggleDevTools()
}
},
{
role: 'reload'
},
Expand Down
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "anvil",
"version": "1.0.0",
"description": "",
"repository": "https://github.com/phppirate/anvil",
"main": "main.js",
"scripts": {
"pack": "electron-packager . --icon=app/icons/app-icon --overwrite",
Expand All @@ -14,8 +15,12 @@
"author": "",
"license": "ISC",
"dependencies": {
"forge-sdk": "^1.0.0",
"menubar": "^5.2.3",
"osap": "^1.0.2"
"osap": "^1.0.2",
"vue": "^2.3.2",
"vue-router": "^2.5.3",
"vuex": "^2.3.1"
},
"devDependencies": {
"electron": "^1.6.6"
Expand Down
2 changes: 1 addition & 1 deletion src/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import routes from './routes.js';
import actions from './vuex/actions.js';
import getters from './vuex/getters.js';
import mutations from './vuex/mutations.js';
import Forge from './Forge.js';
import Forge from 'forge-sdk';

window.forge = config ? new Forge(config.api_token) : null;

Expand Down
96 changes: 77 additions & 19 deletions src/js/pages/server-details.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,49 @@

<div class="panel">
<div class="panel-body">
<div style="margin-bottom: 10px;">
<button class="btn is-success btn-block" @click="rebootServer" v-if="! rebooting">Reboot Server</button>
<button class="btn is-success btn-block disabled" v-else><span class="fa fa-spinner fa-pulse"></span></button>
</div>
<div id="services" class="flex">
<div class="reboot-services flex-1 mr-1">
<div style="margin-bottom: 10px;">
<button class="btn is-success btn-block" @click="rebootServer" v-if="! rebooting">Reboot Server</button>
<button class="btn is-success btn-block disabled" v-else><span class="fa fa-spinner fa-pulse"></span></button>
</div>

<div style="margin-bottom: 10px;">
<button class="btn is-success btn-block" @click="rebootMysql" v-if="! rebootingMysql">Reboot MySQL</button>
<button class="btn is-success btn-block disabled" v-else><span class="fa fa-spinner fa-pulse"></span></button>
</div>
<div style="margin-bottom: 10px;">
<button class="btn is-success btn-block" @click="rebootMysql" v-if="! rebootingMysql">Reboot MySQL</button>
<button class="btn is-success btn-block disabled" v-else><span class="fa fa-spinner fa-pulse"></span></button>
</div>

<div style="margin-bottom: 10px;">
<button class="btn is-success btn-block" @click="rebootNginx" v-if="! rebootingNginx">Reboot NginX</button>
<button class="btn is-success btn-block disabled" v-else><span class="fa fa-spinner fa-pulse"></span></button>
</div>
<div style="margin-bottom: 10px;">
<button class="btn is-success btn-block" @click="rebootNginx" v-if="! rebootingNginx">Reboot NginX</button>
<button class="btn is-success btn-block disabled" v-else><span class="fa fa-spinner fa-pulse"></span></button>
</div>

<div style="margin-bottom: 10px;">
<button class="btn is-success btn-block" @click="rebootPostgres" v-if="! rebootingPostgres">Reboot Postgres</button>
<button class="btn is-success btn-block disabled" v-else><span class="fa fa-spinner fa-pulse"></span></button>
</div>
</div>
<div class="stop-services flex-1 ml-1">
<div style="margin-bottom: 10px;">
<button class="btn is-danger btn-block" @click="stopServer" v-if="! stoping">Stop Server</button>
<button class="btn is-danger btn-block disabled" v-else><span class="fa fa-spinner fa-pulse"></span></button>
</div>

<div style="margin-bottom: 10px;">
<button class="btn is-danger btn-block" @click="stopMysql" v-if="! stopingMysql">Stop MySQL</button>
<button class="btn is-danger btn-block disabled" v-else><span class="fa fa-spinner fa-pulse"></span></button>
</div>

<div style="margin-bottom: 10px;">
<button class="btn is-success btn-block" @click="rebootPostgres" v-if="! rebootingPostgres">Reboot Postgres</button>
<button class="btn is-success btn-block disabled" v-else><span class="fa fa-spinner fa-pulse"></span></button>
<div style="margin-bottom: 10px;">
<button class="btn is-danger btn-block" @click="stopNginx" v-if="! stopingNginx">Stop NginX</button>
<button class="btn is-danger btn-block disabled" v-else><span class="fa fa-spinner fa-pulse"></span></button>
</div>

<div style="margin-bottom: 10px;">
<button class="btn is-danger btn-block" @click="stopPostgres" v-if="! stopingPostgres">Stop Postgres</button>
<button class="btn is-danger btn-block disabled" v-else><span class="fa fa-spinner fa-pulse"></span></button>
</div>
</div>
</div>

<div>
Expand All @@ -59,6 +84,11 @@
rebootingMysql: false,
rebootingNginx: false,
rebootingPostgres: false,
stoping: false,
stopingMysql: false,
stopingNginx: false,
stopingPostgres: false,
}),
computed: {
server(){
Expand All @@ -80,32 +110,60 @@
},
rebootServer(){
this.rebooting = true;
forge.rebootServer(this.server)
forge.rebootServer(this.server.id)
.then(r => {
this.rebooting = false;
});
},
rebootMysql(){
this.rebootingMysql = true;
forge.rebootMysql(this.server)
forge.rebootMysql(this.server.id)
.then(r => {
this.rebootingMysql = false;
});
},
rebootNginx(){
this.rebootingNginx = true;
forge.rebootNginx(this.server)
forge.rebootNginx(this.server.id)
.then(r => {
this.rebootingNginx = false;
});
},
rebootPostgres(){
this.rebootingPostgres = true;
forge.rebootPostgres(this.server)
forge.rebootPostgres(this.server.id)
.then(r => {
this.rebootingPostgres = false;
});
},
stopServer(){
this.stoping = true;
forge.stopServer(this.server.id)
.then(r => {
this.stoping = false;
});
},
stopMysql(){
this.stopingMysql = true;
forge.stopMysql(this.server.id)
.then(r => {
this.stopingMysql = false;
});
},
stopNginx(){
this.stopingNginx = true;
forge.stopNginx(this.server.id)
.then(r => {
this.stopingNginx = false;
});
},
stopPostgres(){
this.stopingPostgres = true;
forge.stopPostgres(this.server.id)
.then(r => {
this.stopingPostgres = false;
});
},
getSiteApp(site){
if(site.app){
if(site.app === 'WordPress'){
Expand Down
9 changes: 4 additions & 5 deletions src/js/pages/site-deployment-edit.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
</template>

<script>
import Forge from '../Forge.js';
let forge = config ? new Forge(config.api_token) : null;
export default {
data: () => ({
deployScript: null,
Expand All @@ -29,6 +26,7 @@
},
site(){
let site = this.$store.getters.getSiteById(this.$route.params.site_id)
console.log(site);
if(! this.deployScript){
this.getDeployScript(site)
}
Expand All @@ -42,13 +40,14 @@
},
save(){
this.saving = true;
forge.saveDeployScriptForSite(this.site, this.$refs.deployScriptBox.value)
forge.updateSiteDeploymentScript(this.server.id, this.site.id, this.$refs.deployScriptBox.value)
.then(r => {
this.$router.push('/servers/' + this.server.id + '/sites/' + this.site.id)
});
},
getDeployScript(site){
forge.getDeployScriptForSite(site)
console.log('SITE', site.id);
forge.siteDeploymentScript(this.server.id, site.id)
.then(r => {
console.log(r);
this.deployScript = r;
Expand Down
8 changes: 3 additions & 5 deletions src/js/pages/site-deployment-log.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
</template>

<script>
import Forge from '../Forge.js';
let forge = config ? new Forge(config.api_token) : null;
export default {
data: () => ({
log: null,
Expand All @@ -29,7 +26,7 @@
},
site(){
let site = this.$store.getters.getSiteById(this.$route.params.site_id)
if(! this.deployScript){
if(! this.log){
this.getDeploymentLog(site)
}
return site
Expand All @@ -41,7 +38,8 @@
return this.$router.push('/servers/' + this.server.id + '/sites/' + this.site.id)
},
getDeploymentLog(site){
forge.getDeploymentLog(site)
console.log(this.server, site);
forge.siteDeploymentLog(this.server.id, site.id)
.then(r => {
console.log(r);
this.loading = false;
Expand Down
9 changes: 1 addition & 8 deletions src/js/pages/site-details.vue
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,6 @@
back(){
return this.$router.push('/servers/' + this.server.id)
},
getDeployScript(site){
forge.getDeployScriptForSite(site)
.then(r => {
console.log(r);
this.deployScript = r;
});
},
visitSite(){
console.log('Opening', shell);
shell.openExternal('http://' + this.site.name);
Expand Down Expand Up @@ -112,7 +105,7 @@
},
deployNow(){
this.deploying = true;
forge.deployServerSite(this.server, this.site)
forge.deploySite(this.server.id, this.site.id)
.then(r => this.deploying = false );
},
toggleQuickDeploy(){
Expand Down
10 changes: 4 additions & 6 deletions src/js/pages/site-env-edit.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
</template>

<script>
import Forge from '../Forge.js';
let forge = config ? new Forge(config.api_token) : null;
export default {
data: () => ({
env: null,
Expand All @@ -42,13 +39,14 @@
},
save(){
this.saving = true;
forge.saveEnvForSite(this.site, this.env)
forge.updateSiteEnvironmentFile(this.server.id, this.site.id, this.env)
.then(r => {
this.env = r;
// this.env = r;
this.back()
});
},
getEnv(site){
forge.getEnvForSite(site)
forge.siteEnvironmentFile(this.server.id, site.id)
.then(r => {
console.log(r);
this.env = r;
Expand Down
18 changes: 7 additions & 11 deletions src/js/vuex/actions.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
import Forge from '../Forge.js';

let forge = config ? new Forge(config.api_token) : null;

export default {
getServers({commit, dispatch}){
forge.getServers()
forge.servers()
.then(r => {
commit('set-servers', r.servers)
r.servers.forEach(s => {
commit('set-servers', r)
r.forEach(s => {
dispatch('getServerSites', s)
})
})
},
getServerSites({commit}, server){
forge.getSites(server)
forge.sites(server.id)
.then(r => {
commit('add-sites', r.sites.map(site => {
commit('add-sites', r.map(site => {
site.server_id = server.id;
return site;
}))
Expand All @@ -26,10 +22,10 @@ export default {
if(site.quick_deploy){
site.quick_deploy = false;
commit('set-site', site)
return forge.disableQuickDeploy(server, site);
return forge.disableQuickDeploy(server.id, site.id);
}
site.quick_deploy = true;
commit('set-site', site)
return forge.enableQuickDeploy(server, site);
return forge.enableQuickDeploy(server.id, site.id);
}
}
26 changes: 26 additions & 0 deletions src/scss/app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ html, body {

* { box-sizing: border-box; }

// Margins
.mr-1{margin-right: 5px; }
.ml-1{margin-left: 5px; }

.titlebar{
position: fixed;
top: 0px;
Expand Down Expand Up @@ -97,6 +101,10 @@ html, body {
justify-content: space-between;
}

.flex-1{
flex: 1;
}




Expand All @@ -122,6 +130,24 @@ html, body {
}
}

.btn.is-danger{
background: #EF5350;
color: #fff;
border: 1px solid darken(#EF5350, 5%);
&:hover{
background: darken(#EF5350, 5%);
}
}

.btn.is-danger.disabled{
background: #E57373;
color: #fff;
border: 1px solid darken(#E57373, 5%);
&:hover{
background: darken(#E57373, 5%);
}
}

.btn-block{
display: block;
width: 100%;
Expand Down

0 comments on commit ceb5650

Please sign in to comment.