Skip to content

Commit

Permalink
feat: show managers in purple on grid
Browse files Browse the repository at this point in the history
  • Loading branch information
rutmanz committed Sep 10, 2024
1 parent b453f0f commit ef8b6be
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 40 deletions.
23 changes: 1 addition & 22 deletions dev/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,28 +70,7 @@
},
"oauth_config": {
"scopes": {
"bot": [
"app_mentions:read",
"channels:history",
"channels:join",
"channels:read",
"chat:write",
"chat:write.public",
"commands",
"files:write",
"groups:read",
"im:history",
"im:read",
"im:write",
"mpim:read",
"mpim:write",
"reactions:write",
"usergroups:read",
"users.profile:read",
"users:read",
"users:read.email",
"mpim:write.topic"
]
"bot": ["app_mentions:read", "channels:history", "channels:join", "channels:read", "chat:write", "chat:write.public", "commands", "files:write", "groups:read", "im:history", "im:read", "im:write", "mpim:read", "mpim:write", "reactions:write", "usergroups:read", "users.profile:read", "users:read", "users:read.email", "mpim:write.topic"]
}
},
"settings": {
Expand Down
15 changes: 13 additions & 2 deletions src/routes/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,17 @@ router.get('/members', requireReadAPI, async (c) => {
use_slack_photo: true,
slack_photo: true,
slack_photo_small: true,
fallback_photo: true
fallback_photo: true,
MemberCerts: {
where: {
Cert: {
isManager: true
}
},
select: {
cert_id: true
}
}
},
where: {
active: true
Expand All @@ -34,7 +44,8 @@ router.get('/members', requireReadAPI, async (c) => {
first_name: member.first_name,
full_name: member.full_name,
photo: getMemberPhotoOrDefault(member, false),
photo_small: getMemberPhotoOrDefault(member, true)
photo_small: getMemberPhotoOrDefault(member, true),
isManager: member.MemberCerts.length > 0
}))
return c.json(resp)
})
Expand Down
26 changes: 13 additions & 13 deletions src/slack/handlers/actions/checkin.ts
Original file line number Diff line number Diff line change
@@ -1,44 +1,44 @@
import config from "~lib/config"
import logger from "~lib/logger"
import prisma from "~lib/prisma"
import { EventMiddleware } from "~slack/lib/types"
import config from '~lib/config'
import logger from '~lib/logger'
import prisma from '~lib/prisma'
import { EventMiddleware } from '~slack/lib/types'

export const handleAppMentioned: EventMiddleware<'app_mention'> = async ({ event, client }) => {
if (event.channel == config.slack.channels.checkin) {
await client.reactions.add({
channel: event.channel,
timestamp: event.ts,
name: "stopwatch"
name: 'stopwatch'
})
const user = await client.auth.test()
const managers = await prisma.member.findMany({where: {MemberCerts: {some: {Cert: {isManager: true}}}}})
const copres_string = config.slack.users.copres.join(",")
const managers = await prisma.member.findMany({ where: { MemberCerts: { some: { Cert: { isManager: true } } } } })
const copres_string = config.slack.users.copres.join(',')
for (const manager of managers) {
if (!manager.slack_id) {
logger.warn("No slack id for manager "+manager.email)
logger.warn('No slack id for manager ' + manager.email)
continue
}
const dm = await client.conversations.open({
users: copres_string+","+manager.slack_id,
users: copres_string + ',' + manager.slack_id
})
if (dm.channel?.id == null) {
logger.warn("No group dm for manager "+manager.email)
logger.warn('No group dm for manager ' + manager.email)
continue
}
await client.chat.postMessage({
channel:dm.channel!.id!,
channel: dm.channel!.id!,
text: event.text.replace(user.user_id!, manager.slack_id)
})
}
await client.reactions.remove({
channel: event.channel,
timestamp: event.ts,
name: "stopwatch"
name: 'stopwatch'
})
await client.reactions.add({
channel: event.channel,
timestamp: event.ts,
name: "white_check_mark"
name: 'white_check_mark'
})
}
}
1 change: 0 additions & 1 deletion src/tasks/calendar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { emitCluckChange } from '~lib/sockets'
import { slack_client } from '~slack'
import responses from '~slack/blocks/responses'


export async function promptCheckinMessage() {
await slack_client.chat.postMessage({
channel: config.slack.channels.checkin,
Expand Down
2 changes: 1 addition & 1 deletion src/tasks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export function scheduleTasks() {
tasks['Logout All'] = scheduleCronTask(createTaskFunc(logoutAll), '0 0 * * *')

// Slack is silly and can only handle 5 items in the overflow menu
scheduleCronTask(createTaskFunc(promptCheckinMessage), "0 9 * * SAT")
scheduleCronTask(createTaskFunc(promptCheckinMessage), '0 9 * * SAT')
scheduleTask(syncSlackMembers, 60 * 60, isProd, 0) // can be run from the admin members page
scheduleTask(updateProfileCerts, 60 * 60 * 24, isProd, 5 * 60)
}
Expand Down
1 change: 1 addition & 0 deletions src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export type APIMember = {
full_name: string
photo: string
photo_small: string
isManager: boolean
}

export type APIClockLabRequest = {
Expand Down
3 changes: 3 additions & 0 deletions src/views/grid/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ export async function buildGrid() {
// Init button
const memberButton = document.createElement('div')
memberButton.classList.add('memberButton')
if (member.isManager) {
memberButton.classList.add('manager')
}
memberButton.id = member.email

// Set click toggle
Expand Down
10 changes: 10 additions & 0 deletions src/views/grid/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,12 @@ box-shadow: inset 0 0 0 1000px rgba(0, 255, 85, 0.2); */
}
}

.memberButton.manager[data-loggedin='true'] {
box-shadow:
inset 0 0 0 1000px rgba(255, 255, 255, 0),
0 0 15px 7px rgb(251, 0, 255);
}

body[data-gridstyle='void'] {
.memberButton {
.buttonText {
Expand All @@ -124,6 +130,10 @@ body[data-gridstyle='void'] {
}
}

.manager .buttonText {
box-shadow: inset 0 0 0 1000px rgba(255, 70, 237, 0.6);
}

.buttonText {
user-select: none;
box-shadow: inset 0 0 0 1000px rgba(70, 255, 169, 0.6);
Expand Down
2 changes: 1 addition & 1 deletion src/views/grid/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ if (gridstyle == 'void') {

export function applyRandomStyles(e: HTMLDivElement) {
e.classList.add(randomChoice('labelLeft', 'labelRight', 'labelCenter'))
e.classList.add(randomChoice('labelTop', 'labelBottom'))
// e.classList.add(randomChoice('labelTop', 'labelBottom'))
e.style.fontFamily = randomChoice('gilroy', 'cocogoose', 'tcm')
}

Expand Down

0 comments on commit ef8b6be

Please sign in to comment.