infrastructure for multiple schedules
This commit is contained in:
14
package-lock.json
generated
14
package-lock.json
generated
@@ -9,7 +9,7 @@
|
||||
"version": "0.0.0",
|
||||
"dependencies": {
|
||||
"@types/sql.js": "^1.4.4",
|
||||
"chrome-extension-toolkit": "^0.0.23",
|
||||
"chrome-extension-toolkit": "^0.0.32",
|
||||
"classnames": "^2.3.2",
|
||||
"clean-webpack-plugin": "^4.0.0",
|
||||
"highcharts": "^10.3.3",
|
||||
@@ -4808,9 +4808,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/chrome-extension-toolkit": {
|
||||
"version": "0.0.23",
|
||||
"resolved": "https://registry.npmjs.org/chrome-extension-toolkit/-/chrome-extension-toolkit-0.0.23.tgz",
|
||||
"integrity": "sha512-Xjj96nyXDbnD/1sCInEW7WtQ+bsOHFXSyjfV5KAUX7IdhhNb0BXfTX4Q7FGh00JhxPW2rUwe0l0u0iYN9GaxZw==",
|
||||
"version": "0.0.32",
|
||||
"resolved": "https://registry.npmjs.org/chrome-extension-toolkit/-/chrome-extension-toolkit-0.0.32.tgz",
|
||||
"integrity": "sha512-0MZFp7MfVVgW1OSZbJD120+21GLS5DFjUG3sAsmAUoPUxbOhmqltGkQT9S23KuipjslcRCwzSlWR+lIkxeXHKw==",
|
||||
"dependencies": {
|
||||
"react": "^18.2.0",
|
||||
"react-dom": "^18.2.0"
|
||||
@@ -21236,9 +21236,9 @@
|
||||
}
|
||||
},
|
||||
"chrome-extension-toolkit": {
|
||||
"version": "0.0.23",
|
||||
"resolved": "https://registry.npmjs.org/chrome-extension-toolkit/-/chrome-extension-toolkit-0.0.23.tgz",
|
||||
"integrity": "sha512-Xjj96nyXDbnD/1sCInEW7WtQ+bsOHFXSyjfV5KAUX7IdhhNb0BXfTX4Q7FGh00JhxPW2rUwe0l0u0iYN9GaxZw==",
|
||||
"version": "0.0.32",
|
||||
"resolved": "https://registry.npmjs.org/chrome-extension-toolkit/-/chrome-extension-toolkit-0.0.32.tgz",
|
||||
"integrity": "sha512-0MZFp7MfVVgW1OSZbJD120+21GLS5DFjUG3sAsmAUoPUxbOhmqltGkQT9S23KuipjslcRCwzSlWR+lIkxeXHKw==",
|
||||
"requires": {
|
||||
"react": "^18.2.0",
|
||||
"react-dom": "^18.2.0"
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@types/sql.js": "^1.4.4",
|
||||
"chrome-extension-toolkit": "^0.0.23",
|
||||
"chrome-extension-toolkit": "^0.0.32",
|
||||
"classnames": "^2.3.2",
|
||||
"clean-webpack-plugin": "^4.0.0",
|
||||
"highcharts": "^10.3.3",
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { createStore } from 'chrome-extension-toolkit';
|
||||
import { createLocalStore, debugStore } from 'chrome-extension-toolkit';
|
||||
|
||||
/**
|
||||
* A store that is used to store data that is only relevant during development
|
||||
@@ -16,10 +16,12 @@ interface IDevStore {
|
||||
reloadTabId?: number;
|
||||
}
|
||||
|
||||
export const DevStore = createStore<IDevStore>('DEV_STORE', {
|
||||
export const DevStore = createLocalStore<IDevStore>({
|
||||
debugTabId: undefined,
|
||||
isTabReloading: true,
|
||||
wasDebugTabVisible: false,
|
||||
isExtensionReloading: true,
|
||||
reloadTabId: undefined,
|
||||
});
|
||||
|
||||
debugStore({ DevStore });
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
import { createStore } from 'chrome-extension-toolkit';
|
||||
import { createLocalStore, debugStore } from 'chrome-extension-toolkit';
|
||||
|
||||
/**
|
||||
* A store that is used for storing user options
|
||||
@@ -13,19 +13,27 @@ interface IExtensionStore {
|
||||
deviceId: string;
|
||||
}
|
||||
|
||||
const base = createStore<IExtensionStore>('EXTENSION_STORE', {
|
||||
interface Actions {
|
||||
getDeviceId(): Promise<string>;
|
||||
}
|
||||
|
||||
const ExtensionStore = createLocalStore<IExtensionStore, Actions>(
|
||||
{
|
||||
version: chrome.runtime.getManifest().version,
|
||||
lastUpdate: Date.now(),
|
||||
deviceId: '',
|
||||
});
|
||||
|
||||
export const ExtensionStore = base.modify({
|
||||
async getDeviceId() {
|
||||
const deviceId = await base.getDeviceId();
|
||||
},
|
||||
store => ({
|
||||
getDeviceId: async () => {
|
||||
const deviceId = await store.getDeviceId();
|
||||
if (deviceId) {
|
||||
return deviceId;
|
||||
}
|
||||
const newDeviceId = uuidv4();
|
||||
await store.setDeviceId(newDeviceId);
|
||||
return newDeviceId;
|
||||
},
|
||||
});
|
||||
})
|
||||
);
|
||||
|
||||
debugStore({ ExtensionStore });
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { createStore } from 'chrome-extension-toolkit';
|
||||
import { createSyncStore, debugStore } from 'chrome-extension-toolkit';
|
||||
|
||||
/**
|
||||
* A store that is used for storing user options
|
||||
@@ -10,7 +10,9 @@ interface IOptionsStore {
|
||||
shouldScrollToLoad: boolean;
|
||||
}
|
||||
|
||||
export const OptionsStore = createStore<IOptionsStore>('OPTIONS_STORE', {
|
||||
export const OptionsStore = createSyncStore<IOptionsStore>({
|
||||
shouldHighlightConflicts: true,
|
||||
shouldScrollToLoad: true,
|
||||
});
|
||||
|
||||
debugStore({ OptionsStore });
|
||||
|
||||
@@ -1,15 +1,11 @@
|
||||
import { createStore, Store } from 'chrome-extension-toolkit';
|
||||
import { createSessionStore, debugStore } from 'chrome-extension-toolkit';
|
||||
|
||||
interface ISessionStore {
|
||||
chromeSessionId?: string;
|
||||
}
|
||||
|
||||
export const SessionStore = createStore<ISessionStore>(
|
||||
'SESSION_STORE',
|
||||
{
|
||||
export const SessionStore = createSessionStore<ISessionStore>({
|
||||
chromeSessionId: undefined,
|
||||
},
|
||||
{
|
||||
area: 'session',
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
debugStore({ SessionStore });
|
||||
|
||||
62
src/background/storage/UserScheduleStore.ts
Normal file
62
src/background/storage/UserScheduleStore.ts
Normal file
@@ -0,0 +1,62 @@
|
||||
import { createLocalStore, debugStore, Serialized } from 'chrome-extension-toolkit';
|
||||
import { Course } from 'src/shared/types/Course';
|
||||
/**
|
||||
* A store that is used for storing user options
|
||||
*/
|
||||
interface IUserScheduleStore {
|
||||
current: string;
|
||||
schedules: {
|
||||
[id: string]: Course[];
|
||||
};
|
||||
}
|
||||
|
||||
interface Actions {
|
||||
createSchedule(name: string): Promise<void>;
|
||||
addCourseToSchedule(name: string, course: Course): Promise<void>;
|
||||
removeCourseFromSchedule(name: string, course: Course): Promise<void>;
|
||||
removeSchedule(name: string): Promise<void>;
|
||||
getSchedule(name: string): Promise<Course[] | undefined>;
|
||||
}
|
||||
|
||||
const UserScheduleStore = createLocalStore<IUserScheduleStore, Actions>(
|
||||
{
|
||||
current: 'Schedule 1',
|
||||
schedules: {},
|
||||
},
|
||||
store => ({
|
||||
async createSchedule(name: string) {
|
||||
const schedules = await store.getSchedules();
|
||||
if (!schedules[name]) {
|
||||
schedules[name] = [];
|
||||
await store.setSchedules(schedules as any);
|
||||
}
|
||||
},
|
||||
async removeSchedule(name: string) {
|
||||
const schedules = await store.getSchedules();
|
||||
delete schedules[name];
|
||||
await store.setSchedules(schedules);
|
||||
},
|
||||
async getSchedule(name) {
|
||||
const schedules = await store.getSchedules();
|
||||
return schedules[name]?.map(course => new Course(course));
|
||||
},
|
||||
async addCourseToSchedule(name, course) {
|
||||
const schedules = await store.getSchedules();
|
||||
const scheduleToEdit = schedules[name];
|
||||
if (scheduleToEdit) {
|
||||
scheduleToEdit.push(course as Serialized<Course>);
|
||||
await store.setSchedules(schedules);
|
||||
}
|
||||
},
|
||||
async removeCourseFromSchedule(name, course) {
|
||||
const schedules = await store.getSchedules();
|
||||
const scheduleToEdit = schedules[name];
|
||||
if (scheduleToEdit) {
|
||||
schedules[name] = scheduleToEdit.filter(c => c.uniqueId !== course.uniqueId);
|
||||
await store.setSchedules(schedules);
|
||||
}
|
||||
},
|
||||
})
|
||||
);
|
||||
|
||||
debugStore({ UserScheduleStore });
|
||||
@@ -1,3 +1,4 @@
|
||||
/* eslint-disable max-classes-per-file */
|
||||
import { Serialized } from 'chrome-extension-toolkit';
|
||||
import { capitalize } from '../util/string';
|
||||
import { CourseSchedule } from './CourseSchedule';
|
||||
|
||||
@@ -16,7 +16,8 @@
|
||||
select {
|
||||
z-index: $MAX_Z_INDEX;
|
||||
padding: 4px;
|
||||
border-radius: 12px;
|
||||
font-family: 'Inter';
|
||||
border-radius: 8px;
|
||||
border-color: $charcoal;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ import {
|
||||
queryAggregateDistribution,
|
||||
querySemesterDistribution,
|
||||
} from 'src/views/lib/database/queryDistribution';
|
||||
import { bMessenger } from 'src/shared/messages';
|
||||
import styles from './GradeDistribution.module.scss';
|
||||
|
||||
enum DataStatus {
|
||||
|
||||
4
todo.md
4
todo.md
@@ -23,7 +23,7 @@ Last Updated: 03/4/2023
|
||||
- [ ] Tooltip that says which classes conflict, maybe suggest a different section or time that doesn't conflict
|
||||
- [ ] import / export schedules from JSON file
|
||||
- [ ] Search for classes from within extension
|
||||
- [ ] Grade distribution
|
||||
- [x] Grade distribution
|
||||
- [x] Course description
|
||||
- [x] Highlight and use rich text to make course description more readable
|
||||
- [ ] calendar
|
||||
@@ -71,7 +71,7 @@ Last Updated: 03/4/2023
|
||||
- [ ] polish
|
||||
- [ ] more 'at a glance info'
|
||||
- [ ] Rearrange Courses
|
||||
- [ ] Firefo Support
|
||||
- [ ] Firefox Support
|
||||
- [ ] RMP (cumulative score for class based off CIS, RMP, grade dist., etc.)
|
||||
- [ ] Conflict indicator ( Possible different section? )
|
||||
- [ ] Compare classes mode
|
||||
|
||||
Reference in New Issue
Block a user