allow to customize the push-server for testing

This commit is contained in:
2023-11-12 11:35:36 -07:00
parent fc70a11bd8
commit 65a5edf26b
5 changed files with 115 additions and 21 deletions

View File

@@ -324,19 +324,55 @@
</button>
<button
class="px-4 rounded bg-slate-200 border border-slate-400"
@click="setApiServerInput(Constants.PROD_ENDORSER_API_SERVER)"
@click="apiServerInput = AppConstants.PROD_ENDORSER_API_SERVER"
>
Use Prod
</button>
<button
class="px-4 rounded bg-slate-200 border border-slate-400"
@click="setApiServerInput(Constants.TEST_ENDORSER_API_SERVER)"
@click="apiServerInput = AppConstants.TEST_ENDORSER_API_SERVER"
>
Use Test
</button>
<button
class="px-4 rounded bg-slate-200 border border-slate-400"
@click="setApiServerInput(Constants.LOCAL_ENDORSER_API_SERVER)"
@click="apiServerInput = AppConstants.LOCAL_ENDORSER_API_SERVER"
>
Use Local
</button>
</div>
<div class="flex py-4">
<h2 class="text-slate-500 text-sm font-bold mb-2">
Notification Push Server
</h2>
<input
type="text"
class="block w-full rounded border border-slate-400 px-3 py-2"
v-model="pushServerInput"
/>
<button
v-if="pushServerInput != pushServer"
class="px-4 rounded bg-red-500 border border-slate-400"
@click="onClickSavePushServer()"
>
<fa icon="floppy-disk" class="fa-fw" color="white"></fa>
</button>
<button
class="px-4 rounded bg-slate-200 border border-slate-400"
@click="pushServerInput = AppConstants.PROD_PUSH_SERVER"
>
Use Prod
</button>
<button
class="px-4 rounded bg-slate-200 border border-slate-400"
@click="pushServerInput = AppConstants.TEST_PUSH_SERVER"
>
Use Test
</button>
<button
class="px-4 rounded bg-slate-200 border border-slate-400"
@click="pushServerInput = AppConstants.LOCAL_PUSH_SERVER"
>
Use Local
</button>
@@ -346,7 +382,7 @@
</template>
<script lang="ts">
import { AxiosError } from "axios";
import { AxiosError, AxiosRequestConfig } from "axios";
import "dexie-export-import";
import { Component, Vue } from "vue-facing-decorator";
import { useClipboard } from "@vueuse/core";
@@ -380,7 +416,7 @@ interface IAccount {
export default class AccountViewView extends Vue {
$notify!: (notification: Notification, timeout?: number) => void;
Constants = AppString;
AppConstants = AppString;
activeDid = "";
apiServer = "";
@@ -391,6 +427,8 @@ export default class AccountViewView extends Vue {
numAccounts = 0;
publicHex = "";
publicBase64 = "";
pushServer = "";
pushServerInput = "";
limits: RateLimits | null = null;
limitsMessage = "";
loadingLimits = true; // might as well now that we do it on mount, to avoid flashing the registration message
@@ -515,6 +553,8 @@ export default class AccountViewView extends Vue {
(settings?.firstName || "") +
(settings?.lastName ? ` ${settings.lastName}` : ""); // pre v 0.1.3
this.isRegistered = !!settings?.isRegistered;
this.pushServer = (settings?.pushServer as string) || "";
this.pushServerInput = (settings?.pushServer as string) || "";
this.showContactGives = !!settings?.showContactGivesInline;
}
@@ -739,7 +779,7 @@ export default class AccountViewView extends Vue {
private async fetchRateLimits(identity: IIdentifier) {
const url = `${this.apiServer}/api/report/rateLimits`;
const headers = await this.getHeaders(identity);
return await this.axios.get(url, { headers });
return await this.axios.get(url, { headers } as AxiosRequestConfig);
}
/**
@@ -843,8 +883,12 @@ export default class AccountViewView extends Vue {
this.apiServer = this.apiServerInput;
}
setApiServerInput(value: string) {
this.apiServerInput = value;
async onClickSavePushServer() {
await db.open();
db.settings.update(MASTER_SETTINGS_KEY, {
pushServer: this.pushServerInput,
});
this.pushServer = this.pushServerInput;
}
}
</script>