mirror of https://github.com/Lissy93/dashy.git
⚡ Displays progress bar during requests
This commit is contained in:
parent
7c64740d22
commit
f1df24ef72
|
@ -31,6 +31,7 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
|
import ProgressBar from 'rsup-progress';
|
||||||
import ErrorHandler from '@/utils/ErrorHandler';
|
import ErrorHandler from '@/utils/ErrorHandler';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
@ -39,6 +40,7 @@ export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
appVersion: process.env.VUE_APP_VERSION, // Current version, from package.json
|
appVersion: process.env.VUE_APP_VERSION, // Current version, from package.json
|
||||||
|
progress: new ProgressBar(),
|
||||||
latestVersion: '', // Will store latest version, when request returns
|
latestVersion: '', // Will store latest version, when request returns
|
||||||
checksEnabled: true, // Should we check for updates
|
checksEnabled: true, // Should we check for updates
|
||||||
isUpToDate: true, // Is current version === latest version
|
isUpToDate: true, // Is current version === latest version
|
||||||
|
@ -60,14 +62,17 @@ export default {
|
||||||
/* Gets the apps latest version from Dashy's git repo */
|
/* Gets the apps latest version from Dashy's git repo */
|
||||||
checkVersion() {
|
checkVersion() {
|
||||||
const packageUrl = 'https://raw.githubusercontent.com/Lissy93/dashy/master/package.json';
|
const packageUrl = 'https://raw.githubusercontent.com/Lissy93/dashy/master/package.json';
|
||||||
|
this.progress.start();
|
||||||
axios.get(packageUrl).then((response) => {
|
axios.get(packageUrl).then((response) => {
|
||||||
if (response && response.data && response.data.version) {
|
if (response && response.data && response.data.version) {
|
||||||
this.latestVersion = response.data.version;
|
this.latestVersion = response.data.version;
|
||||||
this.isUpToDate = this.checkIfUpToDate(this.appVersion, this.latestVersion);
|
this.isUpToDate = this.checkIfUpToDate(this.appVersion, this.latestVersion);
|
||||||
this.finished = true;
|
this.finished = true;
|
||||||
|
this.progress.end();
|
||||||
}
|
}
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
this.error = true;
|
this.error = true;
|
||||||
|
this.progress.end();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
/* Compares the current version, with the package.json version */
|
/* Compares the current version, with the package.json version */
|
||||||
|
|
|
@ -59,6 +59,7 @@
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
import sha256 from 'crypto-js/sha256';
|
import sha256 from 'crypto-js/sha256';
|
||||||
|
import ProgressBar from 'rsup-progress';
|
||||||
import Button from '@/components/FormElements/Button';
|
import Button from '@/components/FormElements/Button';
|
||||||
import Input from '@/components/FormElements/Input';
|
import Input from '@/components/FormElements/Input';
|
||||||
import IconBackup from '@/assets/interface-icons/config-backup.svg';
|
import IconBackup from '@/assets/interface-icons/config-backup.svg';
|
||||||
|
@ -77,6 +78,7 @@ export default {
|
||||||
restorePassword: '',
|
restorePassword: '',
|
||||||
restoreCode: '',
|
restoreCode: '',
|
||||||
backupId: localStorage[localStorageKeys.BACKUP_ID] || '',
|
backupId: localStorage[localStorageKeys.BACKUP_ID] || '',
|
||||||
|
progress: new ProgressBar(),
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
|
@ -87,11 +89,14 @@ export default {
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
restoreBackup() {
|
restoreBackup() {
|
||||||
|
this.progress.start();
|
||||||
restore(this.restoreCode, this.restorePassword)
|
restore(this.restoreCode, this.restorePassword)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
this.restoreFromBackup(response, this.restoreCode);
|
this.restoreFromBackup(response, this.restoreCode);
|
||||||
|
this.progress.end();
|
||||||
}).catch((msg) => {
|
}).catch((msg) => {
|
||||||
this.showErrorMsg(msg);
|
this.showErrorMsg(msg);
|
||||||
|
this.progress.end();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
checkPass() {
|
checkPass() {
|
||||||
|
@ -107,6 +112,7 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
makeBackup() {
|
makeBackup() {
|
||||||
|
this.progress.start();
|
||||||
backup(this.config, this.backupPassword)
|
backup(this.config, this.backupPassword)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
if (!response.data || response.data.errorMsg || !response.data.backupId) {
|
if (!response.data || response.data.errorMsg || !response.data.backupId) {
|
||||||
|
@ -114,11 +120,14 @@ export default {
|
||||||
} else { // All clear, no error
|
} else { // All clear, no error
|
||||||
this.updateUiAfterBackup(response.data.backupId, false);
|
this.updateUiAfterBackup(response.data.backupId, false);
|
||||||
}
|
}
|
||||||
|
this.progress.end();
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
this.showErrorMsg(this.$t('cloud-sync.backup-error-unknown'));
|
this.showErrorMsg(this.$t('cloud-sync.backup-error-unknown'));
|
||||||
|
this.progress.end();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
makeUpdate() {
|
makeUpdate() {
|
||||||
|
this.progress.start();
|
||||||
update(this.config, this.backupPassword, this.backupId)
|
update(this.config, this.backupPassword, this.backupId)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
if (!response.data || response.data.errorMsg || !response.data.backupId) {
|
if (!response.data || response.data.errorMsg || !response.data.backupId) {
|
||||||
|
@ -126,8 +135,10 @@ export default {
|
||||||
} else { // All clear, no error
|
} else { // All clear, no error
|
||||||
this.updateUiAfterBackup(response.data.backupId, true);
|
this.updateUiAfterBackup(response.data.backupId, true);
|
||||||
}
|
}
|
||||||
|
this.progress.end();
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
this.showErrorMsg(this.$t('cloud-sync.backup-error-unknown'));
|
this.showErrorMsg(this.$t('cloud-sync.backup-error-unknown'));
|
||||||
|
this.progress.end();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
restoreFromBackup(config, backupId) {
|
restoreFromBackup(config, backupId) {
|
||||||
|
|
|
@ -59,6 +59,7 @@
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
|
import ProgressBar from 'rsup-progress';
|
||||||
import VJsoneditor from 'v-jsoneditor';
|
import VJsoneditor from 'v-jsoneditor';
|
||||||
import { localStorageKeys } from '@/utils/defaults';
|
import { localStorageKeys } from '@/utils/defaults';
|
||||||
import configSchema from '@/utils/ConfigSchema.json';
|
import configSchema from '@/utils/ConfigSchema.json';
|
||||||
|
@ -89,6 +90,7 @@ export default {
|
||||||
responseText: '',
|
responseText: '',
|
||||||
saveSuccess: undefined,
|
saveSuccess: undefined,
|
||||||
allowWriteToDisk: this.shouldAllowWriteToDisk(),
|
allowWriteToDisk: this.shouldAllowWriteToDisk(),
|
||||||
|
progress: new ProgressBar(),
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
@ -123,6 +125,7 @@ export default {
|
||||||
const body = { config: yaml, timestamp: new Date() };
|
const body = { config: yaml, timestamp: new Date() };
|
||||||
const request = axios.post(endpoint, body, headers);
|
const request = axios.post(endpoint, body, headers);
|
||||||
// 3. Make the request, and handle response
|
// 3. Make the request, and handle response
|
||||||
|
this.progress.start();
|
||||||
request.then((response) => {
|
request.then((response) => {
|
||||||
this.saveSuccess = response.data.success || false;
|
this.saveSuccess = response.data.success || false;
|
||||||
this.responseText = response.data.message;
|
this.responseText = response.data.message;
|
||||||
|
@ -132,11 +135,13 @@ export default {
|
||||||
} else {
|
} else {
|
||||||
this.showToast(this.$t('config-editor.error-msg-cannot-save'), false);
|
this.showToast(this.$t('config-editor.error-msg-cannot-save'), false);
|
||||||
}
|
}
|
||||||
|
this.progress.end();
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
this.saveSuccess = false;
|
this.saveSuccess = false;
|
||||||
this.responseText = error;
|
this.responseText = error;
|
||||||
this.showToast(error, false);
|
this.showToast(error, false);
|
||||||
|
this.progress.end();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
saveConfigLocally() {
|
saveConfigLocally() {
|
||||||
|
|
|
@ -46,6 +46,7 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
|
import ProgressBar from 'rsup-progress';
|
||||||
import Button from '@/components/FormElements/Button';
|
import Button from '@/components/FormElements/Button';
|
||||||
import { modalNames } from '@/utils/defaults';
|
import { modalNames } from '@/utils/defaults';
|
||||||
import RebuildIcon from '@/assets/interface-icons/application-rebuild.svg';
|
import RebuildIcon from '@/assets/interface-icons/application-rebuild.svg';
|
||||||
|
@ -69,6 +70,7 @@ export default {
|
||||||
output: '',
|
output: '',
|
||||||
message: '',
|
message: '',
|
||||||
allowRebuild: true,
|
allowRebuild: true,
|
||||||
|
progress: new ProgressBar(),
|
||||||
}),
|
}),
|
||||||
methods: {
|
methods: {
|
||||||
/* Calls to the rebuild endpoint, to kickoff the app build */
|
/* Calls to the rebuild endpoint, to kickoff the app build */
|
||||||
|
@ -76,12 +78,15 @@ export default {
|
||||||
const baseUrl = process.env.VUE_APP_DOMAIN || window.location.origin;
|
const baseUrl = process.env.VUE_APP_DOMAIN || window.location.origin;
|
||||||
const endpoint = `${baseUrl}/config-manager/rebuild`;
|
const endpoint = `${baseUrl}/config-manager/rebuild`;
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
|
this.progress.start();
|
||||||
axios.get(endpoint)
|
axios.get(endpoint)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
this.finished(response.data || false);
|
this.finished(response.data || false);
|
||||||
|
this.progress.end();
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
this.finished({ success: false, error });
|
this.finished({ success: false, error });
|
||||||
|
this.progress.end();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
/* Called when rebuild is complete, updates UI with either success or fail message */
|
/* Called when rebuild is complete, updates UI with either success or fail message */
|
||||||
|
|
Loading…
Reference in New Issue