Compare commits
No commits in common. "b038e425420eabbc29e92be72731ca0641c7d9da" and "7be11d211fdec5e368a7253891ba03ae751bd451" have entirely different histories.
b038e42542
...
7be11d211f
1
.gitignore
vendored
1
.gitignore
vendored
@ -2,4 +2,3 @@
|
|||||||
/dist/
|
/dist/
|
||||||
/node_modules/
|
/node_modules/
|
||||||
/package-lock.json
|
/package-lock.json
|
||||||
/*.json
|
|
||||||
|
@ -1,6 +0,0 @@
|
|||||||
import requests
|
|
||||||
|
|
||||||
r = requests.get('https://wiki.claremontmakerspace.org/api.php?action=askargs&conditions=Asset Tag::%2B&printouts=Asset Tag|Requires Certification|Has Reservation URL&format=json&api_version=2')
|
|
||||||
|
|
||||||
with open('wiki-tools.json', 'w') as f:
|
|
||||||
f.write(r.text)
|
|
@ -1,68 +0,0 @@
|
|||||||
<template>
|
|
||||||
<span class="text-content">
|
|
||||||
<div class="name">{{ decodedName }}</div>
|
|
||||||
<!-- <div class="name">{{ asset.model.name }}</div> -->
|
|
||||||
<!-- ideas: model info? -->
|
|
||||||
<div class="certification">Certification: {{ certification }}</div>
|
|
||||||
<div class="reservation">Reservation: {{ reservation }}</div>
|
|
||||||
</span>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup lang="ts">
|
|
||||||
import { computed, ComputedRef, defineProps } from 'vue';
|
|
||||||
|
|
||||||
import snipeit from './snipeit';
|
|
||||||
import mediawiki from './mediawiki';
|
|
||||||
|
|
||||||
import wikiTools from '../wiki-tools.json';
|
|
||||||
|
|
||||||
const props = defineProps<{
|
|
||||||
asset: snipeit.Hardware;
|
|
||||||
}>();
|
|
||||||
|
|
||||||
const decodedName: ComputedRef<string> = computed(() => {
|
|
||||||
const doc = new DOMParser().parseFromString(props.asset.name, 'text/html');
|
|
||||||
return doc.documentElement.textContent ?? 'invalid name!';
|
|
||||||
});
|
|
||||||
|
|
||||||
const wikiTool: ComputedRef<mediawiki.AskResult | undefined> = computed(() => {
|
|
||||||
return Object.values((wikiTools as mediawiki.apiAsk).query.results).find(
|
|
||||||
(x) => x.printouts['Asset Tag'].includes(props.asset.asset_tag)
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
const certification: ComputedRef<string> = computed(() => {
|
|
||||||
if (!wikiTool) {
|
|
||||||
return 'Unknown';
|
|
||||||
}
|
|
||||||
return (
|
|
||||||
wikiTool.value?.printouts[
|
|
||||||
'Requires Certification'
|
|
||||||
][0] as mediawiki.PageValue
|
|
||||||
).fulltext;
|
|
||||||
});
|
|
||||||
|
|
||||||
const reservation: ComputedRef<string> = computed(() => {
|
|
||||||
if (!wikiTool) {
|
|
||||||
return 'Unknown';
|
|
||||||
}
|
|
||||||
let reservationLinks = wikiTool.value?.printouts['Has Reservation URL'];
|
|
||||||
return reservationLinks && reservationLinks.length === 0 ? 'No' : 'Yes';
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
.text-content {
|
|
||||||
font-family: monospace;
|
|
||||||
font-size: 10px;
|
|
||||||
line-height: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
.name {
|
|
||||||
text-decoration: underline;
|
|
||||||
}
|
|
||||||
|
|
||||||
.certification {
|
|
||||||
font-size: 10px;
|
|
||||||
}
|
|
||||||
</style>
|
|
36
src/mediawiki.d.ts
vendored
36
src/mediawiki.d.ts
vendored
@ -1,36 +0,0 @@
|
|||||||
export interface PrintRequest {
|
|
||||||
label: string;
|
|
||||||
key: string;
|
|
||||||
redi: string;
|
|
||||||
typeid: string;
|
|
||||||
mode: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface PageValue {
|
|
||||||
fulltext: string;
|
|
||||||
fullurl: string;
|
|
||||||
namespace: number;
|
|
||||||
exists: string; // TODO: might be '0'|'1'
|
|
||||||
displaytitle: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: more prop types exist
|
|
||||||
export type PropValue = string | PageValue;
|
|
||||||
|
|
||||||
export interface AskResult {
|
|
||||||
printouts: {
|
|
||||||
[prop: string]: PropValue[];
|
|
||||||
};
|
|
||||||
fulltext: string;
|
|
||||||
fullurl: string;
|
|
||||||
namespace: number;
|
|
||||||
exists: string; // TODO: might be '0'|'1'
|
|
||||||
displaytitle: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface apiAsk {
|
|
||||||
query: {
|
|
||||||
printrequests: PrintRequest[];
|
|
||||||
results: { [name: string]: AskResult };
|
|
||||||
};
|
|
||||||
}
|
|
Reference in New Issue
Block a user