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