- Introduce `OpenAI` module in `superUser` with configuration management (`Config.vue`, `OpenAI.vue`). - Add `ConfigurationOpenAI.vue` for superuser dashboard, enabling settings management for OpenAI integration. - Update `router.js` and superuser navigation for OpenAI configuration paths. - Enhance `SuperUserDashboardConfigurationNavigation.vue` with OpenAI entry. - Integrate general settings and API key handling in the OpenAI configuration UI.
91 lines
3.5 KiB
Vue
91 lines
3.5 KiB
Vue
<script>
|
|
import { authenticatedRequest } from "@/components/session/authenticatedRequest.vue";
|
|
import { parseError } from "@/components/request/HandleGlobalError.vue";
|
|
import { DatabaseSystemObject } from "@/components/session/token/superUser/systemDatabase.vue";
|
|
import { Cron } from "@/components/session/token/superUser/cron.vue";
|
|
import { Economic } from "@/components/session/token/superUser/modules/Economic/Economic.vue";
|
|
import { reCAPTCHA } from "@/components/session/token/superUser/modules/reCAPTCHA/reCAPTCHA.vue";
|
|
import { Email } from "@/components/session/token/superUser/modules/Email/Email.vue";
|
|
import { Backups } from "@/components/session/token/superUser/modules/Backups/Backups.vue";
|
|
import { MotorAPI } from "@/components/session/token/superUser/modules/motorapi/MotorAPI.vue";
|
|
import { Stripe } from "@/components/session/token/superUser/modules/stripe/Stripe.vue";
|
|
import { FXRatesAPI } from "@/components/session/token/superUser/modules/fxratesapi/FXRatesAPI.vue";
|
|
import { GatewayAPI } from "@/components/session/token/superUser/modules/gatewayapi/GatewayAPI.vue";
|
|
import { XLVask } from "@/components/session/token/superUser/modules/xlvask/XLVask.vue";
|
|
import { Entra } from "@/components/session/token/superUser/modules/entra/Entra.vue";
|
|
import { Limble } from "@/components/session/token/superUser/modules/limble/Limble.vue";
|
|
import { OcrSpace } from "@/components/session/token/superUser/modules/ocrSpace/OcrSpace.vue";
|
|
import { OpenAI } from "@/components/session/token/superUser/modules/openAI/OpenAI.vue";
|
|
|
|
/**
|
|
* The superuser object
|
|
*/
|
|
export const SuperUserObject = {
|
|
system: {
|
|
database: DatabaseSystemObject,
|
|
},
|
|
modules: {
|
|
economic: Economic,
|
|
reCAPTCHA: reCAPTCHA,
|
|
email: Email,
|
|
backups: Backups,
|
|
motorapi: MotorAPI,
|
|
stripe: Stripe,
|
|
fxratesapi: FXRatesAPI,
|
|
gatewayapi: GatewayAPI,
|
|
xlvask: XLVask,
|
|
entra: Entra,
|
|
limble: Limble,
|
|
ocrspace: OcrSpace,
|
|
openai: OpenAI,
|
|
},
|
|
/** Intimidate a user */
|
|
intimidate: {
|
|
/**
|
|
* Intimidate a user
|
|
* @param userId
|
|
* @returns {Promise<void>}
|
|
*/
|
|
intimidateUser: async (userId) => {
|
|
return await authenticatedRequest("/su/intimidate", "POST", {user_id: userId})
|
|
.then(
|
|
(response) => {
|
|
// Save the current token, so we can restore it after the user has been intimidated
|
|
const currentToken = localStorage.getItem("token");
|
|
localStorage.setItem("superuser_token", currentToken);
|
|
// Set the token in the local storage
|
|
localStorage.setItem("token", response.data.data.token);
|
|
// Redirect the user to the dashboard
|
|
window.location = "/";
|
|
}
|
|
)
|
|
.catch(
|
|
(error) => {
|
|
parseError(error, 'auth');
|
|
}
|
|
);
|
|
},
|
|
/**
|
|
* Go back from intimidating a user
|
|
*/
|
|
goBack: () => {
|
|
// Get the superuser token
|
|
const superuserToken = localStorage.getItem("superuser_token");
|
|
// Set the token in the local storage
|
|
localStorage.setItem("token", superuserToken);
|
|
// Clear the superuser token
|
|
localStorage.removeItem("superuser_token");
|
|
// Redirect the user to the dashboard
|
|
window.location = "/";
|
|
},
|
|
/**
|
|
* Check if the superuser is currently intimidating a user
|
|
* @returns {boolean}
|
|
*/
|
|
isIntimidated: () => {
|
|
return localStorage.getItem("superuser_token") !== null;
|
|
}
|
|
},
|
|
cron: Cron
|
|
};
|
|
</script> |