finished mvp

master
Ayush Mukherjee 5 years ago
parent fc39080041
commit c4d327d385

@ -0,0 +1,82 @@
html,
body {
margin: 0;
padding: 0;
box-sizing: border-box;
color: #292929;
/* max-width: 99vw; */
}
*,
*::before,
*::after {
box-sizing: inherit;
}
header {
height: 80px;
display: flex;
justify-content: center;
align-content: center;
box-shadow: 1px 3px 4px rgba(0, 0, 0, 0.05);
}
header > h1 {
font-family: 'Montserrat', sans-serif;
letter-spacing: 0.3rem;
font-size: 2.2rem;
}
.container {
display: grid;
grid-template-rows: 1fr;
/* grid-column-gap: 10px; */
grid-template-columns: 300px 0px 1fr;
grid-template-areas: 'left gap right';
height: 100%;
background: #eee;
min-height: 0;
min-width: 0;
overflow-wrap: break-word;
}
.container > .left {
grid-area: left;
background: #999;
padding: 1.5em 1em;
overflow: hidden;
min-width: 0;
}
.left > .user_email {
margin: 50px 0;
}
.container > .right {
grid-area: right;
padding: 1.5em 1em;
overflow: hidden;
min-width: 0;
}
.container > .right > #status {
width: 100%;
height: 300px;
overflow-y: scroll;
overflow-x: hidden;
overflow-wrap: break-word;
background: transparent;
border: 1px solid;
border-radius: 5px;
}
.container > .right > #log {
width: 100%;
height: 300px;
overflow-y: scroll;
overflow-x: hidden;
overflow-wrap: break-word;
background: transparent;
border: 1px solid;
border-radius: 5px;
}

@ -1,10 +1,40 @@
<html> <html>
<head> <head>
<title>CPGC</title> <title>CPGC</title>
<link href="https://fonts.googleapis.com/css?family=Montserrat:800i&display=swap" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="css/main.css">
</head> </head>
<body> <body>
Hello, world! <header>
<p id="a"></p> <h1>CPGC</h1>
</header>
<div class="container">
<div class="left">
<div class="user_name">
User Name:
<span id="user_name"></span>
</div>
<div class="user_email">
User Email:
<span id="user_email"></span>
</div>
<div class="remote">
Remote URL: <br>
<span id="remote"></span>
</div>
</div>
<div class="right">
Current Branch: <span id="branch"></span>
<br>
Git Status: <br>
<textarea name="status" id="status" cols="30" rows="10"></textarea>
Git Log: <br>
<textarea name="log" id="log" cols="30" rows="10"></textarea>
</div>
</div>
</body> </body>
<script> <script>
@ -12,8 +42,25 @@
const ipc = electron.ipcRenderer; const ipc = electron.ipcRenderer;
ipc.on('send_username', function(event, args) { ipc.on('send_username', function(event, args) {
console.log(args); document.getElementById("user_name").innerHTML = args;
document.getElementById("a").innerHTML = args; });
ipc.on('send_useremail', function(event, args) {
document.getElementById("user_email").innerHTML = args;
});
ipc.on('send_remote', function(event, args) {
document.getElementById("remote").innerHTML = args;
});
ipc.on('send_status', function(event, args) {
document.getElementById("status").innerHTML = args;
});
ipc.on('send_log', function(event, args) {
document.getElementById("log").innerHTML = args;
});
ipc.on('send_branch', function(event, args) {
document.getElementById("branch").innerHTML = args;
}); });
</script> </script>
</html> </html>

@ -5,49 +5,8 @@ const path = require('path');
const { app, BrowserWindow } = require('electron'); const { app, BrowserWindow } = require('electron');
const ipc = require('electron').ipcMain; const ipc = require('electron').ipcMain;
const list_dir = () => {
if(platform == 'linux') {
return execSync("ls -lA | awk '{print $9}'")
.toString()
.split(EOL);
}
}
var origin;
let user = execSync("git config --list").toString().split(EOL);
//console.log(user);
const m = list_dir().forEach((l) => {
if(l == '.git') {
origin = fs.open(path.join(__dirname, '.git/config'), 'r', function(err, file) {
if(err)
console.log(err + '1');
fs.readFile(file, function(err, data) {
if(err)
console.log(err);
let i = data.toString().indexOf('url') + 6;
let c = data.toString()[i];
origin = c;
while(c != '\n') {
i++;
c = data.toString()[i];
origin += c;
}
return origin;
});
});
}
});
console.log(user[0]);
let win;
function createWindow() { function createWindow() {
win = new BrowserWindow({ let win = new BrowserWindow({
width: 800, width: 800,
height: 600, height: 600,
webPreferences: { webPreferences: {
@ -56,9 +15,24 @@ function createWindow() {
}); });
win.loadFile('html/index.html'); win.loadFile('html/index.html');
win.webContents.send('send_username', user[0]); // win.webContents.openDevTools()
win.webContents.openDevTools() win.webContents.on('did-finish-load', () => {
win.webContents.send('send_username', name);
win.webContents.send('send_useremail', email);
win.webContents.send('send_remote', remote);
win.webContents.send('send_status', status);
win.webContents.send('send_log', log);
win.webContents.send('send_branch', branch);
});
} }
app.on('ready', createWindow); app.on('ready', createWindow);
let user = execSync("git config --list").toString().split(EOL);
let email = user[0].split('=')[1];
let name = user[1].split('=')[1];
let remote = user[6].split('=')[1];
let status = execSync("git status").toString();
let log = execSync("git log").toString();
let branch = execSync("git branch | grep \* | cut -d ' ' -f2").toString();
Loading…
Cancel
Save