Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
NishalJohn committed Mar 25, 2024
2 parents b4f9c3e + 00028d9 commit 688bf9e
Show file tree
Hide file tree
Showing 15 changed files with 710 additions and 188 deletions.
359 changes: 359 additions & 0 deletions firebase-debug.log

Large diffs are not rendered by default.

67 changes: 66 additions & 1 deletion functions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,21 @@ const { onRequest } = require("firebase-functions/v2/https");
const logger = require("firebase-functions/logger");
const { beforeUserCreated, HttpsError } = require("firebase-functions/v2/identity")

// The Cloud Functions for Firebase SDK to set up triggers and logging.
const { onSchedule } = require("firebase-functions/v2/scheduler");
const nodemailer = require('nodemailer');

// The Firebase Admin SDK to delete inactive users.
const admin = require("firebase-admin");
admin.initializeApp();

// The es6-promise-pool to limit the concurrency of promises.
const PromisePool = require("es6-promise-pool").default;
// Maximum concurrent account deletions.
const MAX_CONCURRENT = 3;



// Create and deploy your first functions
// https://firebase.google.com/docs/functions/get-started

Expand All @@ -21,9 +36,59 @@ const { beforeUserCreated, HttpsError } = require("firebase-functions/v2/identit
// });


var transporter = nodemailer.createTransport({
service: 'gmail',
auth: {
user: '[email protected]',
pass: '*ADragonWorksHappy28!*'
}
});

var mailOptions = {
from: '[email protected]',
to: '[email protected]',
subject: 'Sending Email using Node.js',
text: 'That was easy!'
};



exports.restrictunAuthUsers = beforeUserCreated(event => {
let user = event.data;
if (!user.email?.includes('@revox.io')) {
if (!user.email?.includes('@revox.io') || !user.email?.includes('@rundownstudios.com')) {
throw new HttpsError('invalid-argument', 'Unauhorized email');
}
});


// exports.birthdayReminder = onSchedule("every day 00:00", async (event) => {
// // // Fetch all user details.
// // const inactiveUsers = await getInactiveUsers();

// // // Use a pool so that we delete maximum `MAX_CONCURRENT` users in parallel.
// // const promisePool = new PromisePool(
// // () => deleteInactiveUser(inactiveUsers),
// // MAX_CONCURRENT,
// // );
// // await promisePool.start();

// transporter.sendMail(mailOptions, function (error, info) {
// if (error) {
// console.log(error);
// } else {
// console.log('Email sent: ' + info.response);
// }
// });

// logger.log("User cleanup finished");
// });

exports.scheduledFunctionCrontab = onSchedule("*/30 * * * *", async (event) => {
transporter.sendMail(mailOptions, function (error, info) {
if (error) {
console.log(error);
} else {
console.log('Email sent: ' + info.response);
}
});
});
18 changes: 18 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
"antd": "^5.8.4",
"es6-promise-pool": "^2.5.0",
"fast-sort": "^3.4.0",
"firebase": "^10.3.0",
"nodemailer": "^6.9.7",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-router-dom": "^6.15.0",
Expand Down
6 changes: 4 additions & 2 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import './App.css';

import { AssetLibrary } from "./pages/AssetLibrary/AssetLibrary"
import { EditAsset } from "./pages/AssetLibrary/AssetActions/EditAsset"
import { DocumentLibrary } from "./pages/DocumentLibrary/DocumentLibrary"
import { ResourceLibrary } from "./pages/ResourceLibrary/ResourceLibrary"
import { AddResource } from "./pages/ResourceLibrary/AddResource"
Expand All @@ -23,9 +24,10 @@ function App() {
<Row type="flex" justify="center">
<Col span={24}>
<Routes>
<Route path='/' element={<Login />} />
<Route path='/home' element={<Home />} />
<Route path='/' element={<Home />} />
<Route path='/login' element={<Login />} />
<Route path='/assets' element={<AssetLibrary />} />
<Route path='/assets/edit' element={<EditAsset />} />
<Route path='/documents' element={<DocumentLibrary />} />
<Route path='/resources' element={<ResourceLibrary />} />
<Route path='/resources/add' element={<AddResource />} />
Expand Down
9 changes: 7 additions & 2 deletions src/components/auth.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState } from 'react';
import React, { useEffect, useState } from 'react';
import { auth, googleProvider } from "../config/firebase";
import { createUserWithEmailAndPassword, signInWithPopup, signOut } from "firebase/auth";
import { Button, Form, Input, Tooltip, Space } from 'antd';
Expand All @@ -9,10 +9,15 @@ import { Navigate } from 'react-router-dom';

export const Auth = () => {


// const user = auth.currentUser;
const [logingError, setError] = useState(false);
const [user, setUser] = useState(auth.currentUser);

// useEffect(() => {
// auth().onAuthStateChanged(setUser)
// }, [])

const signInwithGoogle = async () => {
try {
await signInWithPopup(auth, googleProvider).then((result) => {
Expand All @@ -28,7 +33,7 @@ export const Auth = () => {

if (user || auth.currentUser) {
console.log(auth.currentUser);
return <Navigate to="/home" replace={true} />
return <Navigate to="/" replace={true} />
}

return (
Expand Down
54 changes: 7 additions & 47 deletions src/pages/AssetLibrary/AnimationAssetLibraryModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ export const AnimationAssetLibraryModal = ({ onAddResource }) => {
const [open, setOpen] = useState(false);
const [confirmLoading, setConfirmLoading] = useState(false);
const [modalText, setModalText] = useState('Content of the modal');
const [priorityLevel, setPriorityLevel] = useState('Priority: Moderate');
const { Text, Link } = Typography;
const { Option } = Select;
const { Title } = Typography;
Expand Down Expand Up @@ -88,11 +87,10 @@ export const AnimationAssetLibraryModal = ({ onAddResource }) => {
try {
await addDoc(resourceListRef, {
'assetName': values.assetName,
'description': values.description,
// 'description': values.description,
'project': values.project,
'assettype': values.assettype,
'assetLink': values.assetUrl,
'priority': values.priority,
'dateUpdated': Date.now(),
'pipeline': JSON.stringify(pipelineAssignees),
'tags': selectedTags,
Expand All @@ -112,29 +110,6 @@ export const AnimationAssetLibraryModal = ({ onAddResource }) => {



const onChangePriority = (value) => {
switch (value) {
case 1:
setPriorityLevel("Priority: Very Low");
break;
case 2:
setPriorityLevel("Priority: Low");
break;
case 3:
setPriorityLevel("Priority: Moderate");
break;
case 4:
setPriorityLevel("Priority: High");
break;
case 5:
setPriorityLevel("Priority: Urgent");
break;
default:
setPriorityLevel("Priority: Moderate");
break;
}
};


//---------------------

Expand All @@ -160,9 +135,6 @@ export const AnimationAssetLibraryModal = ({ onAddResource }) => {

//--------------

const onDescriptionorSpecialNotesAdd = (e) => {
// console.log('Change:', e.target.value);
};


const onProjectChange = (e) => {
Expand Down Expand Up @@ -254,9 +226,9 @@ export const AnimationAssetLibraryModal = ({ onAddResource }) => {
autoComplete="off"
layout='vertical'
initialValues={{
priority: 3,
assettype: "Prop",
project: "Internal",
specialnotes: "-",
}}
>
<div className='modal-inner'>
Expand All @@ -275,10 +247,10 @@ export const AnimationAssetLibraryModal = ({ onAddResource }) => {
<Input />
</Form.Item>

{/* Asset Description */}
{/* Asset Description
<Form.Item name={'description'} label="Description">
<TextArea showCount maxLength={100} onChange={onDescriptionorSpecialNotesAdd} />
</Form.Item>
</Form.Item> */}

{/* ====================In House Items ======================== */}
<Form.Item
Expand Down Expand Up @@ -324,22 +296,10 @@ export const AnimationAssetLibraryModal = ({ onAddResource }) => {
rules={[{ required: true }, { type: 'url', warningOnly: true }, { type: 'string', min: 6 }]}
// style={{ marginTop: "30px" }}
>
<Input addonBefore="OneDrive Link" placeholder="Asset Folder URL (Ensure all asset items are in one folder)" />
<Input addonBefore="Asset Link" placeholder="Asset URL (EPIC, UNITY OR ONEDRIVE)" />
</Form.Item>


<Form.Item name="priority" label={priorityLevel} style={{ marginBottom: "20px" }}>
<Slider max={5} min={1} defaultValue={3} onChange={onChangePriority} initialValues={3}
marks={{
1: '1',
2: '2',
3: '3',
4: '4',
5: '5',
}}
/>
</Form.Item>



{/* //-------------------Tags---------------------- */}
Expand Down Expand Up @@ -537,8 +497,8 @@ export const AnimationAssetLibraryModal = ({ onAddResource }) => {
/>

{/* Asset Description */}
<Form.Item name={'specialnotes'} label="Special Notes">
<TextArea showCount maxLength={100} onChange={onDescriptionorSpecialNotesAdd} />
<Form.Item name="specialnotes" label="Special Notes">
<TextArea showCount maxLength={100} />
</Form.Item>

</div>
Expand Down
Loading

0 comments on commit 688bf9e

Please sign in to comment.