Commit 5f77055c authored by Amy Yan's avatar Amy Yan

added loading bar

parent 59f39552
...@@ -163,18 +163,18 @@ function download(url, fileName, cb) { ...@@ -163,18 +163,18 @@ function download(url, fileName, cb) {
let request = https.get(url, function(response) { let request = https.get(url, function(response) {
var partiallength = 0 var partiallength = 0 //sets partiallength to 0
var totallength = parseInt(response.headers['content-length'], 10); var totallength = parseInt(response.headers['content-length'], 10); //sets totallength of file
response.on("data", function(chunk) { response.on("data", function(chunk) {
partiallength += chunk.length partiallength += chunk.length //adds each time
if (partiallength / totallength != 1) { if (partiallength / totallength != 1) {
win.setProgressBar(partiallength / totallength) win.setProgressBar(partiallength / totallength) //sets progress bar to decimal
} }
else { else {
win.setProgressBar(0) win.setProgressBar(0) //sets progress bar to blank when done
} }
ipcMain.emit("downloadProgress", partiallength / totallength) ipcMain.emit("downloadProgress", partiallength / totallength) //emits decimal for download
}); });
response.pipe(file); response.pipe(file);
......
...@@ -11,19 +11,21 @@ ...@@ -11,19 +11,21 @@
<div class="download-list"> <div class="download-list">
<div class="download-item" v-for="(item,index) in downloadQueue"> <div class="download-item" v-for="(item,index) in downloadQueue">
<div class="download-item-grid">
<div class="cover" :style="'background-image: url(' + item.cover + '), url(' + require('@/assets/img/defaultAlbumArt.jpg') + ');'"></div> <div class="cover" :style="'background-image: url(' + item.cover + '), url(' + require('@/assets/img/defaultAlbumArt.jpg') + ');'"></div>
<div class="meta"> <div class="meta">
<div class="title">{{ item.title }}</div> <div class="title">{{ item.title }}</div>
<div class="artist">{{ item.artist }}</div> <div class="artist">{{ item.artist }}</div>
<div class="progress-bar" v-if="index == 0"></div> </div>
</div> </div>
<div class="progress-bar" v-if="index == 0" :style="{ width: downloadProgress * 100 + 'px' }"></div>
</div> </div>
</div> </div>
</div> </div>
</template> </template>
<script> <script>
import { remote } from 'electron'; import { remote, ipcMain } from 'electron';
const { shell } = remote; const { shell } = remote;
export default { export default {
...@@ -99,47 +101,50 @@ ...@@ -99,47 +101,50 @@
margin-bottom: 25px; margin-bottom: 25px;
& .download-item { & .download-item {
display: grid;
grid-template-columns: 50px 1fr;
grid-gap: 10px;
background: rgba(255,255,255,0.1); background: rgba(255,255,255,0.1);
margin-bottom: 5px; margin-bottom: 2px;
padding: 10px; padding: 10px;
border-radius: 5px; border-radius: 5px;
& .cover {
width: 50px;
height: 50px;
background-position: center;
background-size: cover;
border-radius: 5px;
}
& .meta { & .download-item-grid{
align-self: center; display: grid;
overflow: hidden; grid-template-columns: 50px 1fr;
grid-gap: 10px;
& .title { & .cover {
font-weight: bold; width: 50px;
overflow: hidden; height: 50px;
white-space: nowrap; background-position: center;
background-size: cover;
border-radius: 5px;
} }
& .artist {
margin-top: 5px; & .meta {
opacity: 0.6;
overflow: hidden;
white-space: nowrap;
}
& .progress-bar{
opacity: 1;
color: green;
background: green !important;
align-self: center; align-self: center;
z-index: 100; overflow: hidden;
height: 100%;
width: 100%; & .title {
font-weight: bold;
overflow: hidden;
white-space: nowrap;
}
& .artist {
margin-top: 5px;
opacity: 0.6;
overflow: hidden;
white-space: nowrap;
}
} }
} }
& .progress-bar{
border-radius: 5px;
margin-top: 6px;
background: #e22c78;
height: 3px;
width: 100%;
}
} }
} }
} }
......
...@@ -2,7 +2,7 @@ const axios = require('axios'); ...@@ -2,7 +2,7 @@ const axios = require('axios');
class SSAPI { class SSAPI {
constructor(isDev) { constructor(isDev) {
if(isDev) { if(!isDev) {
this.apiBase = "http://localhost/www/spinshare/server/public/index.php/api/"; this.apiBase = "http://localhost/www/spinshare/server/public/index.php/api/";
} else { } else {
this.apiBase = "https://spinsha.re/api/"; this.apiBase = "https://spinsha.re/api/";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment