text:
<hole x="2.5" y="0" drill="0.8"/>
<wire x1="-4.15" y1="1.6" x2="-4.15" y2="0.5" width="0.127" layer="46"/>
<wire x1="-3.3" y1="1.6" x2="-3.3" y2="0.5" width="0.127" layer="46"/>
<wire x1="-4.15" y1="-2.27" x2="-4.15" y2="-3.23" width="0.127" layer="46"/>
<text x="-0.9" y="-4.68" size="0.4064" layer="51">PCB edge</text>
<text x="-1.6" y="-0.75" size="0.8128" layer="21">1</text>
<text x="-1.6" y="-0.75" size="0.8128" layer="48">1</text>
<wire x1="-3.6" y1="-2.27" x2="-3.6" y2="-3.23" width="0.127" layer="46"/>
<wire x1="-2.92" y1="1.45" x2="-1.77" y2="1.45" width="0.127" layer="21"/>
<wire x1="1.71" y1="1.45" x2="2.93" y2="1.45" width="0.127" layer="21"/>
<wire x1="-4" y1="-0.31" x2="-4" y2="-1.64" width="0.127" layer="21"/>
<wire x1="4" y1="-0.32" x2="4" y2="-1.65" width="0.127" layer="21"/>
<wire x1="-4" y1="-3.9" x2="-4" y2="-5.15" width="0.127" layer="21"/>
<wire x1="4" y1="-3.85" x2="4" y2="-5.15" width="0.127" layer="21"/>
<polygon width="0.127" layer="39">
<vertex x="-4.75" y="2.5"/>
<vertex x="4.75" y="2.5"/>
<vertex x="4.75" y="-5.4"/>
<vertex x="-4.75" y="-5.4"/>
</polygon>
<wire x1="-4" y1="1.75" x2="-3.45" y2="1.75" width="0.127" layer="46"/>
<wire x1="-4" y1="0.35" x2="-3.45" y2="0.35" width="0.127" layer="46"/>
<wire x1="-4.15" y1="1.6" x2="-4" y2="1.75" width="0.127" layer="46" curve="-90"/>
<wire x1="-3.45" y1="1.75" x2="-3.3" y2="1.6" width="0.127" layer="46" curve="-90"/>
<wire x1="-4" y1="0.35" x2="-4.15" y2="0.5" width="0.127" layer="46" curve="-90"/>
<wire x1="-3.3" y1="0.5" x2="-3.45" y2="0.35" width="0.127" layer="46" curve="-90"/>
<wire x1="3.3" y1="1.6" x2="3.3" y2="0.5" width="0.127" layer="46"/>
<wire x1="4.15" y1="1.6" x2="4.15" y2="0.5" width="0.127" layer="46"/>
<wire x1="3.45" y1="1.75" x2="4" y2="1.75" width="0.127" layer="46"/>
<wire x1="3.45" y1="0.35" x2="4" y2="0.35" width="0.127" layer="46"/>
<wire x1="3.3" y1="1.6" x2="3.45" y2="1.75" width="0.127" layer="46" curve="-90"/>
<wire x1="4" y1="1.75" x2="4.15" y2="1.6" width="0.127" layer="46" curve="-90"/>
<wire x1="3.45" y1="0.35" x2="3.3" y2="0.5" width="0.127" layer="46" curve="-90"/>
<wire x1="4.15" y1="0.5" x2="4" y2="0.35" width="0.127" layer="46" curve="-90"/>
<wire x1="-4.03" y1="-2.15" x2="-3.72" y2="-2.15" width="0.127" layer="46"/>
<wire x1="-4.03" y1="-3.35" x2="-3.72" y2="-3.35" width="0.127" layer="46"/>
<wire x1="-4.15" y1="-2.27" x2="-4.03" y2="-2.15" width="0.127" layer="46" curve="-90"/>
<wire x1="-3.72" y1="-2.15" x2="-3.6" y2="-2.27" width="0.127" layer="46" curve="-90"/>
<wire x1="-4.03" y1="-3.35" x2="-4.15" y2="-3.23" width="0.127" layer="46" curve="-90"/>
<wire x1="-3.6" y1="-3.23" x2="-3.72" y2="-3.35" width="0.127" layer="46" curve="-90"/>
<wire x1="3.6" y1="-2.27" x2="3.6" y2="-3.23" width="0.127" layer="46"/>
<wire x1="4.15" y1="-2.27" x2="4.15" y2="-3.23" width="0.127" layer="46"/>
<wire x1="3.72" y1="-2.15" x2="4.03" y2="-2.15" width="0.127" layer="46"/>
<wire x1="3.72" y1="-3.35" x2="4.03" y2="-3.35" width="0.127" layer="46"/>
<wire x1="3.6" y1="-2.27" x2="3.72" y2="-2.15" width="0.127" layer="46" curve="-90"/>
<wire x1="4.03" y1="-2.15" x2="4.15" y2="-2.27" width="0.127" layer="46" curve="-90"/>
<wire x1="3.72" y1="-3.35" x2="3.6" y2="-3.23" width="0.127" layer="46" curve="-90"/>
<wire x1="4.15" y1="-3.23" x2="4.03" y2="-3.35" width="0.127" layer="46" curve="-90"/>
</package>
</packages>
<symbols>
<symbol name="5_USB_A">
<wire x1="-2.54" y1="-7.62" x2="-2.54" y2="7.62" width="0.254" layer="94"/>
<wire x1="-2.54" y1="7.62" x2="3.81" y2="7.62" width="0.254" layer="94"/>
<wire x1="3.81" y1="-7.62" x2="-2.54" y2="-7.62" width="0.254" layer="94"/>
<text x="-2.54" y="10.668" size="1.778" layer="95">>NAME</text>
<text x="-2.54" y="-13.97" size="1.778" layer="96">>VALUE</text>
<pin name="GND" x="-7.62" y="5.08" length="middle" direction="pas"/>
<pin name="ID" x="-7.62" y="2.54" length="middle" direction="pas"/>
<pin name="D+" x="-7.62" y="0" length="middle" direction="pas"/>
<pin name="D-" x="-7.62" y="-2.54" length="middle" direction="pas"/>
<pin name="VBUS" x="-7.62" y="-5.08" length="middle" direction="pas"/>
<wire x1="5.08" y1="8.89" x2="5.08" y2="-8.89" width="0.254" layer="94" style="shortdash"/>
<wire x1="5.08" y1="-8.89" x2="1.27" y2="-8.89" width="0.254" layer="94" style="shortdash"/>
<wire x1="1.27" y1="-8.89" x2="1.27" y2="-10.16" width="0.254" layer="94" style="shortdash"/>
<pin name="SHIELD" x="-5.08" y="-10.16" length="middle" direction="pas"/>
<wire x1="0" y1="-10.16" x2="1.27" y2="-10.16" width="0.254" layer="94" style="shortdash"/>
<wire x1="1.27" y1="8.89" x2="5.08" y2="8.89" width="0.254" layer="94" style="shortdash"/>
<text x="4.445" y="-2.2225" size="1.778" layer="94" rot="R90">USB</text>
</symbol>
</symbols>
<devicesets>
<deviceset name="629105150521" prefix="J" uservalue="yes">
<description>WR-COM_USB_Micro Type B_Horizontal_SMT ;

Micro Type B Horizontal SMT - 3A current at Pin1 & Pin 5 - with Pegs and THT shielding Pins  - T&R Packaging

Code : Con_I-O_COM_USB_2.0_B_629105150521_629105150521

Details see: http://katalog.we-online.de/em/datasheet/629105150521.pdf

Created 12/08/2014, Dan Xu

2014 (C) Wurth Elektronik</description>
<gates>
<gate name="G$1" symbol="5_USB_A" x="0" y="0"/>
</gates>
<devices>
<device name="" package="629105150521">
<connects>
<connect gate="G$1" pin="D+" pad="3"/>
<connect gate="G$1" pin="D-" pad="2"/>
<connect gate="G$1" pin="GND" pad="5"/>
<connect gate="G$1" pin="ID" pad="4"/>
<connect gate="G$1" pin="SHIELD" pad="SHELL SHELL1 SHELL2 SHELL3"/>
<connect gate="G$1" pin="VBUS" pad="1"/>
</connects>
<technologies>
<technology name=""/>
</technologies>
</device>
</devices>
</deviceset>
</devicesets>
</library>
</libraries>
<attributes>
</attributes>
<variantdefs>
</variantdefs>
<classes>
<class number="0" name="default" width="0" drill="0">
</class>
</classes>
<parts>
<part name="GND" library="iframe" deviceset="TPS65217ARSLR" device=""/>
<part name="C3" library="marius" deviceset="C" device="0603" package3d_urn="urn:adsk.eagle:package:5911006/3"/>
<part name="C4" library="marius" deviceset="C" device="0603" package3d_urn="urn:adsk.eagle:package:5911006/3" value="10uF"/>
<part name="C5" library="marius" deviceset="C" device="0603" package3d_urn="urn:adsk.eagle:package:5911006/3" value="4.7uF"/>
<part name="C6" library="marius" deviceset="C" device="0603" package3d_urn="urn:adsk.eagle:package:5911006/3" value="10uF"/>
<part name="C7" library="marius" deviceset="C" device="0603" package3d_urn="urn:adsk.eagle:package:5911006/3" value="100nF"/>
<part name="C9" library="marius" deviceset="C" device="0603" package3d_urn="urn:adsk.eagle:package:5911006/3" value="100nF"/>
<part name="C10" library="marius" deviceset="C" device="0603" package3d_urn="urn:adsk.eagle:package:5911006/3" value="10uF"/>
<part name="R5" library="marius" deviceset="R" device="0603" package3d_urn="urn:adsk.eagle:package:5911033/3" value="4.7K"/>
<part name="R6" library="marius" deviceset="R" device="0603" package3d_urn="urn:adsk.eagle:package:5911033/3" value="4.7K"/>
<part name="R7" library="marius" deviceset="R" device="0603" package3d_urn="urn:adsk.eagle:package:5911033/3" value="75K"/>
<part name="GND1" library="marius" deviceset="GND" device=""/>
<part name="GND3" library="marius" deviceset="GND" device=""/>
<part name="GND4" library="marius" deviceset="GND" device=""/>
<part name="GND5" library="marius" deviceset="GND" device=""/>
<part name="C16" library="marius" deviceset="C" device="0603" package3d_urn="urn:adsk.eagle:package:5911006/3" value="10uF"/>
<part name="C17" library="marius" deviceset="C" device="0603" package3d_urn="urn:adsk.eagle:package:5911006/3" value="1uF"/>
<part name="C18" library="marius" deviceset="C" device="0603" package3d_urn="urn:adsk.eagle:package:5911006/3" value="1uF"/>
<part name="C19" library="marius" deviceset="C" device="0603" package3d_urn="urn:adsk.eagle:package:5911006/3" value="10uF"/>
<part name="C20" library="marius" deviceset="C" device="0603" package3d_urn="urn:adsk.eagle:package:5911006/3" value="10uF"/>
<part name="GND7" library="marius" deviceset="GND" device=""/>
<part name="GND8" library="marius" deviceset="GND" device=""/>
<part name="C21" library="marius" deviceset="C" device="0603" package3d_urn="urn:adsk.eagle:package:5911006/3" value="10uF"/>
<part name="GND9" library="marius" deviceset="GND" device=""/>
<part name="GND10" library="marius" deviceset="GND" device=""/>
<part name="GND11" library="marius" deviceset="GND" device=""/>
<part name="GND12" library="marius" deviceset="GND" device=""/>
<part name="GND13" library="marius" deviceset="GND" device=""/>
<part name="L1" library="marius" deviceset="L" device="4X4" package3d_urn="urn:adsk.eagle:package:5911044/1"/>
<part name="L2" library="marius" deviceset="L" device="4X4" package3d_urn="urn:adsk.eagle:package:5911044/1"/>
<part name="L3" library="marius" deviceset="L" device="4X4" package3d_urn="urn:adsk.eagle:package:5911044/1"/>
<part name="GND6" library="marius" deviceset="GND" device=""/>
<part name="R8" library="marius" deviceset="R" device="0603" package3d_urn="urn:adsk.eagle:package:5911033/3" value="100k"/>
<part name="R9" library="marius" deviceset="R" device="0603" package3d_urn="urn:adsk.eagle:package:5911033/3" value="100k"/>
<part name="GND14" library="marius" deviceset="GND" device=""/>
<part name="C22" library="marius" deviceset="C" device="0603" package3d_urn="urn:adsk.eagle:package:5911006/3" value="10uF"/>
<part name="C23" library="marius" deviceset="C" device="0603" package3d_urn="urn:adsk.eagle:package:5911006/3" value="10uF"/>
<part name="GND15" library="marius" deviceset="GND" device=""/>
<part name="R10" library="marius" deviceset="R" device="0603" package3d_urn="urn:adsk.eagle:package:5911033/3" value="100K"/>
<part name="R11" library="marius" deviceset="R" device="0603" package3d_urn="urn:adsk.eagle:package:5911033/3" value="10K"/>
<part name="1V2" library="marius" deviceset="TEST_TESTPOINT" device="" package3d_urn="urn:adsk.eagle:package:5911110/1"/>
<part name="3V3" library="marius" deviceset="TEST_TESTPOINT" device="" package3d_urn="urn:adsk.eagle:package:5911110/1"/>
<part name="1V8" library="marius" deviceset="TEST_TESTPOINT" device="" package3d_urn="urn:adsk.eagle:package:5911110/1"/>
<part name="SDA" library="marius" deviceset="TEST_TESTPOINT" device="" package3d_urn="urn:adsk.eagle:package:5911110/1"/>
<part name="SCL" library="marius" deviceset="TEST_TESTPOINT" device="" package3d_urn="urn:adsk.eagle:package:5911110/1"/>
<part name="SYS" library="marius" deviceset="TEST_TESTPOINT" device="" package3d_urn="urn:adsk.eagle:package:5911110/1"/>
<part name="PWR_EN" library="marius" deviceset="TEST_TESTPOINT" device="" package3d_urn="urn:adsk.eagle:package:5911110/1"/>
<part name="NRESET" library="marius" deviceset="TEST_TESTPOINT" device="" package3d_urn="urn:adsk.eagle:package:5911110/1"/>
<part name="LDO1V8" library="marius" deviceset="TEST_TESTPOINT" device="" package3d_urn="urn:adsk.eagle:package:5911110/1"/>
<part name="LDO3V3" library="marius" deviceset="TEST_TESTPOINT" device="" package3d_urn="urn:adsk.eagle:package:5911110/1"/>
<part name="MUX" library="marius" deviceset="TEST_TESTPOINT" device="" package3d_urn="urn:adsk.eagle:package:5911110/1"/>
<part name="CN1" library="adafruit" library_urn="urn:adsk.eagle:library:420" deviceset="JST_2PIN" device="-SMT-RA" package3d_urn="urn:adsk.eagle:package:6240692/1"/>
<part name="J1" library="InputOutputIO (rev19a)" deviceset="629105150521" device=""/>
<part name="LDO4" library="marius" deviceset="TEST_TESTPOINT" device="" package3d_urn="urn:adsk.eagle:package:5911110/1"/>
<part name="LDO3" library="marius" deviceset="TEST_TESTPOINT" device="" package3d_urn="urn:adsk.eagle:package:5911110/1"/>
</parts>
<sheets>
<sheet>
<plain>
</plain>
<instances>
<instance part="GND" gate="A" x="33.02" y="83.82" smashed="yes">
<attribute name="NAME" x="81.6356" y="103.0986" size="2.0828" layer="95" ratio="6" rot="SR0"/>
<attribute name="VALUE" x="81.0006" y="98.0186" size="2.0828" layer="96" ratio="6" rot="SR0"/>
</instance>
<instance part="C3" gate="G$1" x="25.4" y="58.42" smashed="yes" rot="R90">
<attribute name="NAME" x="25.019" y="59.944" size="1.778" layer="95" rot="R90"/>
<attribute name="VALUE" x="30.099" y="59.944" size="1.778" layer="96" rot="R90"/>
</instance>
<instance part="C4" gate="G$1" x="22.86" y="48.26" smashed="yes" rot="R180">
<attribute name="NAME" x="21.336" y="47.879" size="1.778" layer="95" rot="R180"/>
<attribute name="VALUE" x="21.336" y="52.959" size="1.778" layer="96" rot="R180"/>
</instance>
<instance part="C5" gate="G$1" x="22.86" y="40.64" smashed="yes" rot="R90">
<attribute name="NAME" x="22.479" y="42.164" size="1.778" layer="95" rot="R90"/>
<attribute name="VALUE" x="27.559" y="42.164" size="1.778" layer="96" rot="R90"/>
</instance>
<instance part="C6" gate="G$1" x="25.4" y="25.4" smashed="yes" rot="R90">
<attribute name="NAME" x="23.876" y="27.559" size="1.778" layer="95" rot="R180"/>
<attribute name="VALUE" x="34.036" y="27.559" size="1.778" layer="96" rot="R180"/>
</instance>
<instance part="C7" gate="G$1" x="12.7" y="-2.54" smashed="yes" rot="R90">
<attribute name="NAME" x="11.176" y="-0.381" size="1.778" layer="95" rot="R180"/>
<attribute name="VALUE" x="16.764" y="-2.159" size="1.778" layer="96"/>
</instance>
<instance part="C9" gate="G$1" x="144.78" y="48.26" smashed="yes" rot="R270">
<attribute name="NAME" x="138.684" y="46.101" size="1.778" layer="95"/>
<attribute name="VALUE" x="141.224" y="51.181" size="1.778" layer="96"/>
</instance>
<instance part="C10" gate="G$1" x="147.32" y="40.64" smashed="yes" rot="R270">
<attribute name="NAME" x="148.844" y="41.021" size="1.778" layer="95"/>
<attribute name="VALUE" x="138.684" y="41.021" size="1.778" layer="96"/>
</instance>
<instance part="R5" gate="A" x="-40.64" y="71.12" smashed="yes" rot="R180">
<attribute name="NAME" x="-36.83" y="69.6214" size="1.778" layer="95" rot="R180"/>
<attribute name="VALUE" x="-36.83" y="74.422" size="1.778" layer="96" rot="R180"/>
</instance>
<instance part="R6" gate="A" x="-40.64" y="76.2" smashed="yes" rot="R180">
<attribute name="NAME" x="-36.83" y="74.7014" size="1.778" layer="95" rot="R180"/>
<attribute name="VALUE" x="-36.83" y="79.502" size="1.778" layer="96" rot="R180"/>
</instance>
<instance part="R7" gate="A" x="10.16" y="76.2" smashed="yes">
<attribute name="NAME" x="6.35" y="77.6986" size="1.778" layer="95"/>
<attribute name="VALUE" x="6.35" y="72.898" size="1.778" layer="96"/>
</instance>
<instance part="GND1" gate="1" x="-5.08" y="76.2" smashed="yes" rot="R270">
<attribute name="VALUE" x="-7.62" y="78.74" size="1.778" layer="96" rot="R270"/>
</instance>
<instance part="GND3" gate="1" x="17.78" y="58.42" smashed="yes" rot="R270">
<attribute name="VALUE" x="15.24" y="60.96" size="1.778" layer="96" rot="R270"/>
</instance>
<instance part="GND4" gate="1" x="-12.7" y="45.72" smashed="yes" rot="R270">
<attribute name="VALUE" x="-15.24" y="48.26" size="1.778" layer="96" rot="R270"/>
</instance>
<instance part="GND5" gate="1" x="15.24" y="40.64" smashed="yes" rot="R270">
<attribute name="VALUE" x="12.7" y="43.18" size="1.778" layer="96" rot="R270"/>
</instance>
<instance part="C16" gate="G$1" x="15.24" y="48.26" smashed="yes" rot="R180">
<attribute name="NAME" x="13.716" y="47.879" size="1.778" layer="95" rot="R180"/>
<attribute name="VALUE" x="13.716" y="52.959" size="1.778" layer="96" rot="R180"/>
</instance>
<instance part="C17" gate="G$1" x="7.62" y="48.26" smashed="yes" rot="R180">
<attribute name="NAME" x="6.096" y="47.879" size="1.778" layer="95" rot="R180"/>
<attribute name="VALUE" x="6.096" y="52.959" size="1.778" layer="96" rot="R180"/>
</instance>
<instance part="C18" gate="G$1" x="0" y="48.26" smashed="yes" rot="R180">
<attribute name="NAME" x="-1.524" y="47.879" size="1.778" layer="95" rot="R180"/>
<attribute name="VALUE" x="-1.524" y="52.959" size="1.778" layer="96" rot="R180"/>
</instance>
<instance part="C19" gate="G$1" x="147.32" y="35.56" smashed="yes" rot="R270">
<attribute name="NAME" x="148.844" y="35.941" size="1.778" layer="95"/>
<attribute name="VALUE" x="138.684" y="35.941" size="1.778" layer="96"/>
</instance>
<instance part="C20" gate="G$1" x="147.32" y="30.48" smashed="yes" rot="R270">
<attribute name="NAME" x="148.844" y="30.861" size="1.778" layer="95"/>
<attribute name="VALUE" x="138.684" y="30.861" size="1.778" layer="96"/>
</instance>
<instance part="GND7" gate="1" x="160.02" y="30.48" smashed="yes" rot="R90">
<attribute name="VALUE" x="162.56" y="27.94" size="1.778" layer="96" rot="R90"/>
</instance>
<instance part="GND8" gate="1" x="17.78" y="25.4" smashed="yes" rot="R270">
<attribute name="VALUE" x="15.24" y="27.94" size="1.778" layer="96" rot="R270"/>
</instance>
<instance part="C21" gate="G$1" x="12.7" y="17.78" smashed="yes" rot="R90">
<attribute name="NAME" x="11.176" y="19.939" size="1.778" layer="95" rot="R180"/>
<attribute name="VALUE" x="16.764" y="18.161" size="1.778" layer="96"/>
</instance>
<instance part="GND9" gate="1" x="5.08" y="17.78" smashed="yes" rot="R270">
<attribute name="VALUE" x="2.54" y="20.32" size="1.778" layer="96" rot="R270"/>
</instance>
<instance part="GND10" gate="1" x="5.08" y="-2.54" smashed="yes" rot="R270">
<attribute name="VALUE" x="2.54" y="0" size="1.778" layer="96" rot="R270"/>
</instance>
<instance part="GND11" gate="1" x="149.86" y="78.74" smashed="yes" rot="R90">
<attribute name="VALUE" x="152.4" y="76.2" size="1.778" layer="96" rot="R90"/>
</instance>
<instance part="GND12" gate="1" x="149.86" y="73.66" smashed="yes" rot="R90">
<attribute name="VALUE" x="152.4" y="71.12" size="1.778" layer="96" rot="R90"/>
</instance>
<instance part="GND13" gate="1" x="149.86" y="83.82" smashed="yes" rot="R90">
<attribute name="VALUE" x="152.4" y="81.28" size="1.778" layer="96" rot="R90"/>
</instance>
<instance part="L1" gate="A" x="160.02" y="-58.42" smashed="yes" rot="R270">
<attribute name="NAME" x="154.94" y="-57.15" size="1.778" layer="95"/>
<attribute name="VALUE" x="154.94" y="-62.23" size="1.778" layer="96"/>
</instance>
<instance part="L2" gate="A" x="160.02" y="-53.34" smashed="yes" rot="R270">
<attribute name="NAME" x="154.94" y="-52.07" size="1.778" layer="95"/>
<attribute name="VALUE" x="154.94" y="-57.15" size="1.778" layer="96"/>
</instance>
<instance part="L3" gate="A" x="160.02" y="-48.26" smashed="yes" rot="R270">
<attribute name="NAME" x="154.94" y="-46.99" size="1.778" layer="95"/>
<attribute name="VALUE" x="154.94" y="-52.07" size="1.778" layer="96"/>
</instance>
<instance part="GND6" gate="1" x="180.34" y="7.62" smashed="yes" rot="MR0">
<attribute name="VALUE" x="182.88" y="5.08" size="1.778" layer="96" rot="MR0"/>
</instance>
<instance part="R8" gate="A" x="172.72" y="22.86" smashed="yes">
<attribute name="NAME" x="168.91" y="24.3586" size="1.778" layer="95"/>
<attribute name="VALUE" x="168.91" y="19.558" size="1.778" layer="96"/>
</instance>
<instance part="R9" gate="A" x="172.72" y="15.24" smashed="yes">
<attribute name="NAME" x="168.91" y="16.7386" size="1.778" layer="95"/>
<attribute name="VALUE" x="168.91" y="11.938" size="1.778" layer="96"/>
</instance>
<instance part="GND14" gate="1" x="152.4" y="48.26" smashed="yes" rot="R90">
<attribute name="VALUE" x="154.94" y="45.72" size="1.778" layer="96" rot="R90"/>
</instance>
<instance part="C22" gate="G$1" x="172.72" y="55.88" smashed="yes" rot="R270">
<attribute name="NAME" x="166.624" y="53.721" size="1.778" layer="95"/>
<attribute name="VALUE" x="169.164" y="58.801" size="1.778" layer="96"/>
</instance>
<instance part="C23" gate="G$1" x="165.1" y="60.96" smashed="yes" rot="R270">
<attribute name="NAME" x="159.004" y="58.801" size="1.778" layer="95"/>
<attribute name="VALUE" x="161.544" y="63.881" size="1.778" layer="96"/>
</instance>
<instance part="GND15" gate="1" x="182.88" y="55.88" smashed="yes" rot="R90">
<attribute name="VALUE" x="185.42" y="53.34" size="1.778" layer="96" rot="R90"/>
</instance>
<instance part="R10" gate="A" x="17.78" y="-7.62" smashed="yes" rot="R180">
<attribute name="NAME" x="21.59" y="-9.1186" size="1.778" layer="95" rot="R180"/>
<attribute name="VALUE" x="21.59" y="-4.318" size="1.778" layer="96" rot="R180"/>
</instance>
<instance part="R11" gate="A" x="22.86" y="33.02" smashed="yes" rot="R180">
<attribute name="NAME" x="26.67" y="31.5214" size="1.778" layer="95" rot="R180"/>
<attribute name="VALUE" x="26.67" y="36.322" size="1.778" layer="96" rot="R180"/>
</instance>
<instance part="1V2" gate="G$1" x="182.88" y="-48.26" smashed="yes">
<attribute name="NAME" x="188.722" y="-48.26" size="1.778" layer="95" align="center-left"/>
</instance>
<instance part="3V3" gate="G$1" x="182.88" y="-53.34" smashed="yes">
<attribute name="NAME" x="188.722" y="-53.34" size="1.778" layer="95" align="center-left"/>
</instance>
<instance part="1V8" gate="G$1" x="182.88" y="-58.42" smashed="yes">
<attribute name="NAME" x="188.722" y="-58.42" size="1.778" layer="95" align="center-left"/>
</instance>
<instance part="SDA" gate="G$1" x="-33.02" y="71.12" smashed="yes" rot="R270">
<attribute name="NAME" x="-33.02" y="65.278" size="1.778" layer="95" rot="R270" align="center-left"/>
</instance>
<instance part="SCL" gate="G$1" x="-33.02" y="76.2" smashed="yes" rot="R90">
<attribute name="NAME" x="-33.02" y="82.042" size="1.778" layer="95" rot="R90" align="center-left"/>
</instance>
<instance part="SYS" gate="G$1" x="-7.62" y="53.34" smashed="yes" rot="R90">
<attribute name="NAME" x="-7.62" y="59.182" size="1.778" layer="95" rot="R90" align="center-left"/>
</instance>
<instance part="PWR_EN" gate="G$1" x="22.86" y="7.62" smashed="yes" rot="R180">
<attribute name="NAME" x="17.018" y="7.62" size="1.778" layer="95" rot="R180" align="center-left"/>
</instance>
<instance part="NRESET" gate="G$1" x="22.86" y="12.7" smashed="yes" rot="R180">
<attribute name="NAME" x="17.018" y="12.7" size="1.778" layer="95" rot="R180" align="center-left"/>
</instance>
<instance part="LDO1V8" gate="G$1" x="147.32" y="-17.78" smashed="yes" rot="R270">
<attribute name="NAME" x="147.32" y="-23.622" size="1.778" layer="95" rot="R270" align="center-left"/>
</instance>
<instance part="LDO3V3" gate="G$1" x="147.32" y="-12.7" smashed="yes" rot="R90">
<attribute name="NAME" x="147.32" y="-6.858" size="1.778" layer="95" rot="R90" align="center-left"/>
</instance>
<instance part="MUX" gate="G$1" x="162.56" y="53.34" smashed="yes" rot="R270">
<attribute name="NAME" x="162.56" y="47.498" size="1.778" layer="95" rot="R270" align="center-left"/>
</instance>
<instance part="CN1" gate="G$1" x="-60.96" y="0" smashed="yes" rot="R180">
<attribute name="NAME" x="-54.61" y="-5.715" size="1.778" layer="95" rot="R180"/>
<attribute name="VALUE" x="-54.61" y="5.08" size="1.778" layer="96" rot="R180"/>
</instance>
<instance part="J1" gate="G$1" x="-66.04" y="38.1" smashed="yes" rot="R180">
<attribute name="NAME" x="-63.5" y="27.432" size="1.778" layer="95" rot="R180"/>
<attribute name="VALUE" x="-63.5" y="52.07" size="1.778" layer="96" rot="R180"/>
</instance>
<instance part="LDO4" gate="G$1" x="149.86" y="63.5" smashed="yes" rot="R90">
<attribute name="NAME" x="149.86" y="69.342" size="1.778" layer="95" rot="R90" align="center-left"/>
</instance>
<instance part="LDO3" gate="G$1" x="142.24" y="58.42" smashed="yes" rot="R90">
<attribute name="NAME" x="142.24" y="64.262" size="1.778" layer="95" rot="R90" align="center-left"/>
</instance>
</instances>
<busses>
</busses>
<nets>
<net name="VUSB" class="0">
<segment>
<pinref part="GND" gate="A" pin="USB"/>
<pinref part="C5" gate="G$1" pin="2"/>
<wire x1="35.56" y1="43.18" x2="27.94" y2="43.18" width="0.1524" layer="91"/>
<wire x1="27.94" y1="43.18" x2="27.94" y2="40.64" width="0.1524" layer="91"/>
<wire x1="27.94" y1="43.18" x2="10.16" y2="43.18" width="0.1524" layer="91"/>
<junction x="27.94" y="43.18"/>

</segment>
<segment>
<pinref part="J1" gate="G$1" pin="VBUS"/>
<wire x1="-58.42" y1="43.18" x2="-45.72" y2="43.18" width="0.1524" layer="91"/>

</segment>
</net>
<net name="VBAT" class="0">
<segment>
<pinref part="GND" gate="A" pin="BAT"/>
<wire x1="35.56" y1="58.42" x2="30.48" y2="58.42" width="0.1524" layer="91"/>
<wire x1="30.48" y1="58.42" x2="30.48" y2="63.5" width="0.1524" layer="91"/>
<pinref part="GND" gate="A" pin="BAT_2"/>
<wire x1="30.48" y1="63.5" x2="35.56" y2="63.5" width="0.1524" layer="91"/>
<wire x1="30.48" y1="63.5" x2="22.86" y2="63.5" width="0.1524" layer="91"/>
<junction x="30.48" y="63.5"/>

<pinref part="C3" gate="G$1" pin="2"/>
<junction x="30.48" y="58.42"/>
</segment>
<segment>
<pinref part="GND" gate="A" pin="BAT_SENSE"/>
<wire x1="35.56" y1="-12.7" x2="20.32" y2="-12.7" width="0.1524" layer="91"/>

</segment>
<segment>
<pinref part="CN1" gate="G$1" pin="1"/>
<wire x1="-58.42" y1="-2.54" x2="-50.8" y2="-2.54" width="0.1524" layer="91"/>

</segment>
</net>
<net name="SCL" class="0">
<segment>
<pinref part="GND" gate="A" pin="SCL"/>
<wire x1="35.56" y1="73.66" x2="30.48" y2="73.66" width="0.1524" layer="91"/>

</segment>
<segment>
<pinref part="R6" gate="A" pin="1"/>
<wire x1="-35.56" y1="76.2" x2="-33.02" y2="76.2" width="0.1524" layer="91"/>

<pinref part="SCL" gate="G$1" pin="2"/>
<wire x1="-33.02" y1="76.2" x2="-30.48" y2="76.2" width="0.1524" layer="91"/>
<junction x="-33.02" y="76.2"/>
</segment>
</net>
<net name="SDA" class="0">
<segment>
<pinref part="GND" gate="A" pin="SDA"/>
<wire x1="35.56" y1="68.58" x2="30.48" y2="68.58" width="0.1524" layer="91"/>

</segment>
<segment>
<pinref part="R5" gate="A" pin="1"/>
<wire x1="-35.56" y1="71.12" x2="-33.02" y2="71.12" width="0.1524" layer="91"/>

<pinref part="SDA" gate="G$1" pin="2"/>
<wire x1="-33.02" y1="71.12" x2="-30.48" y2="71.12" width="0.1524" layer="91"/>
<junction x="-33.02" y="71.12"/>
</segment>
</net>
<net name="LDO4" class="0">
<segment>
<pinref part="GND" gate="A" pin="LS2_OUT"/>
<wire x1="137.16" y1="63.5" x2="144.78" y2="63.5" width="0.1524" layer="91"/>

<wire x1="144.78" y1="63.5" x2="149.86" y2="63.5" width="0.1524" layer="91"/>
<wire x1="144.78" y1="63.5" x2="144.78" y2="60.96" width="0.1524" layer="91"/>
<junction x="144.78" y="63.5"/>
<pinref part="C23" gate="G$1" pin="2"/>
<wire x1="144.78" y1="60.96" x2="160.02" y2="60.96" width="0.1524" layer="91"/>
<pinref part="LDO4" gate="G$1" pin="2"/>
</segment>
</net>
<net name="LDO3" class="0">
<segment>
<pinref part="GND" gate="A" pin="LS1_OUT"/>
<wire x1="137.16" y1="58.42" x2="142.24" y2="58.42" width="0.1524" layer="91"/>

<wire x1="142.24" y1="58.42" x2="144.78" y2="58.42" width="0.1524" layer="91"/>
<wire x1="144.78" y1="58.42" x2="149.86" y2="58.42" width="0.1524" layer="91"/>
<wire x1="144.78" y1="58.42" x2="144.78" y2="55.88" width="0.1524" layer="91"/>
<junction x="144.78" y="58.42"/>
<pinref part="C22" gate="G$1" pin="2"/>
<wire x1="144.78" y1="55.88" x2="167.64" y2="55.88" width="0.1524" layer="91"/>
<pinref part="LDO3" gate="G$1" pin="2"/>
<junction x="142.24" y="58.42"/>
</segment>
</net>
<net name="MUX_OUT" class="0">
<segment>
<pinref part="GND" gate="A" pin="MUX_OUT"/>
<wire x1="137.16" y1="53.34" x2="139.7" y2="53.34" width="0.1524" layer="91"/>

<wire x1="139.7" y1="53.34" x2="139.7" y2="48.26" width="0.1524" layer="91"/>
<junction x="139.7" y="53.34"/>
<pinref part="C9" gate="G$1" pin="2"/>
<pinref part="MUX" gate="G$1" pin="2"/>
<wire x1="139.7" y1="53.34" x2="162.56" y2="53.34" width="0.1524" layer="91"/>
<wire x1="162.56" y1="53.34" x2="190.5" y2="53.34" width="0.1524" layer="91"/>
<junction x="162.56" y="53.34"/>
</segment>
</net>
<net name="SYS" class="0">
<segment>
<pinref part="GND" gate="A" pin="VIN_DCDC3"/>
<wire x1="137.16" y1="43.18" x2="139.7" y2="43.18" width="0.1524" layer="91"/>

<pinref part="C10" gate="G$1" pin="2"/>
<wire x1="139.7" y1="43.18" x2="152.4" y2="43.18" width="0.1524" layer="91"/>
<wire x1="142.24" y1="40.64" x2="139.7" y2="40.64" width="0.1524" layer="91"/>
<wire x1="139.7" y1="40.64" x2="139.7" y2="43.18" width="0.1524" layer="91"/>
<junction x="139.7" y="43.18"/>
<pinref part="GND" gate="A" pin="VIN_DCDC1"/>
<wire x1="137.16" y1="33.02" x2="139.7" y2="33.02" width="0.1524" layer="91"/>

<wire x1="139.7" y1="33.02" x2="154.94" y2="33.02" width="0.1524" layer="91"/>
<wire x1="139.7" y1="33.02" x2="139.7" y2="30.48" width="0.1524" layer="91"/>
<junction x="139.7" y="33.02"/>
<pinref part="C20" gate="G$1" pin="2"/>
<wire x1="139.7" y1="30.48" x2="142.24" y2="30.48" width="0.1524" layer="91"/>
<wire x1="154.94" y1="33.02" x2="154.94" y2="38.1" width="0.1524" layer="91"/>
<wire x1="154.94" y1="38.1" x2="157.48" y2="38.1" width="0.1524" layer="91"/>

<pinref part="GND" gate="A" pin="VIN_DCDC2"/>
<wire x1="137.16" y1="38.1" x2="139.7" y2="38.1" width="0.1524" layer="91"/>

<wire x1="139.7" y1="38.1" x2="154.94" y2="38.1" width="0.1524" layer="91"/>
<wire x1="139.7" y1="38.1" x2="139.7" y2="35.56" width="0.1524" layer="91"/>
<junction x="139.7" y="38.1"/>
<pinref part="C19" gate="G$1" pin="2"/>
<wire x1="139.7" y1="35.56" x2="142.24" y2="35.56" width="0.1524" layer="91"/>
<junction x="154.94" y="38.1"/>
<wire x1="154.94" y1="38.1" x2="154.94" y2="43.18" width="0.1524" layer="91"/>
<wire x1="154.94" y1="43.18" x2="152.4" y2="43.18" width="0.1524" layer="91"/>
</segment>
<segment>
<pinref part="GND" gate="A" pin="VINLDO"/>

<pinref part="C6" gate="G$1" pin="2"/>
<wire x1="30.48" y1="25.4" x2="35.56" y2="25.4" width="0.1524" layer="91"/>
<wire x1="35.56" y1="25.4" x2="35.56" y2="27.94" width="0.1524" layer="91"/>
<junction x="35.56" y="27.94"/>
<wire x1="35.56" y1="27.94" x2="10.16" y2="27.94" width="0.1524" layer="91"/>

</segment>
<segment>
<pinref part="GND" gate="A" pin="LS1_IN"/>
<wire x1="35.56" y1="-38.1" x2="25.4" y2="-38.1" width="0.1524" layer="91"/>

</segment>
<segment>
<pinref part="GND" gate="A" pin="LS2_IN"/>
<wire x1="35.56" y1="-43.18" x2="25.4" y2="-43.18" width="0.1524" layer="91"/>

</segment>
<segment>
<pinref part="GND" gate="A" pin="SYS_2"/>
<wire x1="35.56" y1="53.34" x2="30.48" y2="53.34" width="0.1524" layer="91"/>

<pinref part="GND" gate="A" pin="SYS"/>
<wire x1="30.48" y1="53.34" x2="22.86" y2="53.34" width="0.1524" layer="91"/>
<wire x1="22.86" y1="53.34" x2="15.24" y2="53.34" width="0.1524" layer="91"/>
<wire x1="15.24" y1="53.34" x2="7.62" y2="53.34" width="0.1524" layer="91"/>
<wire x1="7.62" y1="53.34" x2="0" y2="53.34" width="0.1524" layer="91"/>
<wire x1="0" y1="53.34" x2="-7.62" y2="53.34" width="0.1524" layer="91"/>
<wire x1="-7.62" y1="53.34" x2="-10.16" y2="53.34" width="0.1524" layer="91"/>
<wire x1="35.56" y1="48.26" x2="30.48" y2="48.26" width="0.1524" layer="91"/>
<wire x1="30.48" y1="48.26" x2="30.48" y2="53.34" width="0.1524" layer="91"/>
<junction x="30.48" y="53.34"/>
<pinref part="C4" gate="G$1" pin="2"/>
<junction x="22.86" y="53.34"/>
<pinref part="C16" gate="G$1" pin="2"/>
<junction x="15.24" y="53.34"/>
<pinref part="C17" gate="G$1" pin="2"/>
<junction x="7.62" y="53.34"/>
<pinref part="C18" gate="G$1" pin="2"/>
<junction x="0" y="53.34"/>
<pinref part="SYS" gate="G$1" pin="2"/>
<junction x="-7.62" y="53.34"/>
</segment>
</net>
<net name="VDCDC3" class="0">
<segment>
<pinref part="GND" gate="A" pin="VDCDC3"/>

<wire x1="137.16" y1="22.86" x2="167.64" y2="22.86" width="0.1524" layer="91"/>
<pinref part="R8" gate="A" pin="1"/>
<pinref part="R9" gate="A" pin="1"/>
<wire x1="167.64" y1="22.86" x2="167.64" y2="15.24" width="0.1524" layer="91"/>
<junction x="167.64" y="22.86"/>
</segment>
</net>
<net name="LDO3V3" class="0">
<segment>
<pinref part="GND" gate="A" pin="VLDO2"/>
<wire x1="137.16" y1="-12.7" x2="147.32" y2="-12.7" width="0.1524" layer="91"/>

<pinref part="LDO3V3" gate="G$1" pin="2"/>
</segment>
</net>
<net name="LDO1V8" class="0">
<segment>
<pinref part="GND" gate="A" pin="VLDO1"/>
<wire x1="137.16" y1="-17.78" x2="147.32" y2="-17.78" width="0.1524" layer="91"/>

<pinref part="LDO1V8" gate="G$1" pin="2"/>
</segment>
<segment>
<pinref part="GND" gate="A" pin="VIO"/>
<wire x1="35.56" y1="38.1" x2="10.16" y2="38.1" width="0.1524" layer="91"/>

</segment>
</net>
<net name="L2" class="0">
<segment>
<pinref part="GND" gate="A" pin="L2"/>

<pinref part="L2" gate="A" pin="2"/>
<wire x1="152.4" y1="-53.34" x2="137.16" y2="-53.34" width="0.1524" layer="91"/>
</segment>
</net>
<net name="L1" class="0">
<segment>
<pinref part="GND" gate="A" pin="L1"/>

<pinref part="L1" gate="A" pin="2"/>
<wire x1="137.16" y1="-58.42" x2="152.4" y2="-58.42" width="0.1524" layer="91"/>
</segment>
</net>
<net name="NWAKEUP" class="0">
<segment>
<pinref part="GND" gate="A" pin="NWAKEUP"/>
<wire x1="35.56" y1="-7.62" x2="22.86" y2="-7.62" width="0.1524" layer="91"/>

<pinref part="R10" gate="A" pin="1"/>
</segment>
</net>
<net name="INT_LDO" class="0">
<segment>
<pinref part="GND" gate="A" pin="INT_LDO"/>
<wire x1="35.56" y1="-2.54" x2="17.78" y2="-2.54" width="0.1524" layer="91"/>

<pinref part="C7" gate="G$1" pin="2"/>
</segment>
</net>
<net name="PWR_EN" class="0">
<segment>
<pinref part="GND" gate="A" pin="PWR_EN"/>
<wire x1="35.56" y1="7.62" x2="22.86" y2="7.62" width="0.1524" layer="91"/>

<pinref part="PWR_EN" gate="G$1" pin="2"/>
</segment>
</net>
<net name="NRESET" class="0">
<segment>
<pinref part="GND" gate="A" pin="NRESET"/>
<wire x1="35.56" y1="12.7" x2="22.86" y2="12.7" width="0.1524" layer="91"/>

<pinref part="NRESET" gate="G$1" pin="2"/>
</segment>
</net>
<net name="BYPASS" class="0">
<segment>
<pinref part="GND" gate="A" pin="BYPASS"/>
<wire x1="35.56" y1="17.78" x2="17.78" y2="17.78" width="0.1524" layer="91"/>

<pinref part="C21" gate="G$1" pin="2"/>
</segment>
</net>
<net name="NINT" class="0">
<segment>
<pinref part="GND" gate="A" pin="NINT"/>
<wire x1="35.56" y1="33.02" x2="27.94" y2="33.02" width="0.1524" layer="91"/>

<pinref part="R11" gate="A" pin="1"/>
<wire x1="27.94" y1="33.02" x2="25.4" y2="33.02" width="0.1524" layer="91"/>
<junction x="27.94" y="33.02"/>
</segment>
</net>
<net name="BATTERYTEMP_10KNTC" class="0">
<segment>

<pinref part="R7" gate="A" pin="2"/>
<wire x1="15.24" y1="68.58" x2="15.24" y2="76.2" width="0.1524" layer="91"/>
<wire x1="15.24" y1="76.2" x2="33.02" y2="76.2" width="0.1524" layer="91"/>
<junction x="15.24" y="76.2"/>
<wire x1="33.02" y1="76.2" x2="33.02" y2="78.74" width="0.1524" layer="91"/>
<pinref part="GND" gate="A" pin="TS"/>
<wire x1="33.02" y1="78.74" x2="35.56" y2="78.74" width="0.1524" layer="91"/>

</segment>
</net>
<net name="L3" class="0">
<segment>
<pinref part="GND" gate="A" pin="L3"/>

<pinref part="L3" gate="A" pin="2"/>
<wire x1="137.16" y1="-48.26" x2="152.4" y2="-48.26" width="0.1524" layer="91"/>
</segment>
</net>
<net name="GND" class="0">
<segment>
<pinref part="R7" gate="A" pin="1"/>
<wire x1="5.08" y1="76.2" x2="-2.54" y2="76.2" width="0.1524" layer="91"/>
<pinref part="GND1" gate="1" pin="GND"/>
</segment>
<segment>
<pinref part="C3" gate="G$1" pin="1"/>
<wire x1="22.86" y1="58.42" x2="20.32" y2="58.42" width="0.1524" layer="91"/>
<pinref part="GND3" gate="1" pin="GND"/>
</segment>
<segment>
<pinref part="C4" gate="G$1" pin="1"/>
<wire x1="22.86" y1="45.72" x2="15.24" y2="45.72" width="0.1524" layer="91"/>
<pinref part="GND4" gate="1" pin="GND"/>
<pinref part="C16" gate="G$1" pin="1"/>
<wire x1="15.24" y1="45.72" x2="7.62" y2="45.72" width="0.1524" layer="91"/>
<junction x="15.24" y="45.72"/>
<pinref part="C17" gate="G$1" pin="1"/>
<wire x1="7.62" y1="45.72" x2="0" y2="45.72" width="0.1524" layer="91"/>
<junction x="7.62" y="45.72"/>
<pinref part="C18" gate="G$1" pin="1"/>
<wire x1="0" y1="45.72" x2="-10.16" y2="45.72" width="0.1524" layer="91"/>
<junction x="0" y="45.72"/>
</segment>
<segment>
<pinref part="GND5" gate="1" pin="GND"/>
<pinref part="C5" gate="G$1" pin="1"/>
<wire x1="17.78" y1="40.64" x2="20.32" y2="40.64" width="0.1524" layer="91"/>
</segment>
<segment>
<pinref part="C20" gate="G$1" pin="1"/>
<wire x1="149.86" y1="30.48" x2="152.4" y2="30.48" width="0.1524" layer="91"/>
<pinref part="C19" gate="G$1" pin="1"/>
<wire x1="149.86" y1="35.56" x2="152.4" y2="35.56" width="0.1524" layer="91"/>
<wire x1="152.4" y1="30.48" x2="152.4" y2="35.56" width="0.1524" layer="91"/>
<pinref part="C10" gate="G$1" pin="1"/>
<wire x1="149.86" y1="40.64" x2="152.4" y2="40.64" width="0.1524" layer="91"/>
<wire x1="152.4" y1="35.56" x2="152.4" y2="40.64" width="0.1524" layer="91"/>
<junction x="152.4" y="35.56"/>
<junction x="152.4" y="30.48"/>
<wire x1="152.4" y1="30.48" x2="157.48" y2="30.48" width="0.1524" layer="91"/>
<pinref part="GND7" gate="1" pin="GND"/>
</segment>
<segment>
<pinref part="C6" gate="G$1" pin="1"/>
<wire x1="22.86" y1="25.4" x2="20.32" y2="25.4" width="0.1524" layer="91"/>
<pinref part="GND8" gate="1" pin="GND"/>
</segment>
<segment>
<pinref part="C21" gate="G$1" pin="1"/>
<pinref part="GND9" gate="1" pin="GND"/>
<wire x1="10.16" y1="17.78" x2="7.62" y2="17.78" width="0.1524" layer="91"/>
</segment>
<segment>
<pinref part="GND10" gate="1" pin="GND"/>
<pinref part="C7" gate="G$1" pin="1"/>
<wire x1="7.62" y1="-2.54" x2="10.16" y2="-2.54" width="0.1524" layer="91"/>
</segment>
<segment>
<pinref part="GND" gate="A" pin="PGND"/>
<wire x1="137.16" y1="78.74" x2="147.32" y2="78.74" width="0.1524" layer="91"/>

<pinref part="GND11" gate="1" pin="GND"/>
</segment>
<segment>
<pinref part="GND" gate="A" pin="AGND"/>
<wire x1="137.16" y1="73.66" x2="147.32" y2="73.66" width="0.1524" layer="91"/>

<pinref part="GND12" gate="1" pin="GND"/>
</segment>
<segment>
<pinref part="GND" gate="A" pin="EPAD"/>
<wire x1="137.16" y1="83.82" x2="147.32" y2="83.82" width="0.1524" layer="91"/>

<pinref part="GND13" gate="1" pin="GND"/>
</segment>
<segment>
<pinref part="R9" gate="A" pin="2"/>
<wire x1="177.8" y1="15.24" x2="180.34" y2="15.24" width="0.1524" layer="91"/>
<wire x1="180.34" y1="15.24" x2="180.34" y2="10.16" width="0.1524" layer="91"/>
<pinref part="GND6" gate="1" pin="GND"/>
</segment>
<segment>
<pinref part="C9" gate="G$1" pin="1"/>
<wire x1="147.32" y1="48.26" x2="149.86" y2="48.26" width="0.1524" layer="91"/>
<pinref part="GND14" gate="1" pin="GND"/>
</segment>
<segment>
<pinref part="C23" gate="G$1" pin="1"/>
<wire x1="167.64" y1="60.96" x2="177.8" y2="60.96" width="0.1524" layer="91"/>
<wire x1="177.8" y1="60.96" x2="177.8" y2="55.88" width="0.1524" layer="91"/>
<pinref part="C22" gate="G$1" pin="1"/>
<wire x1="177.8" y1="55.88" x2="175.26" y2="55.88" width="0.1524" layer="91"/>
<wire x1="177.8" y1="55.88" x2="180.34" y2="55.88" width="0.1524" layer="91"/>
<junction x="177.8" y="55.88"/>
<pinref part="GND15" gate="1" pin="GND"/>
</segment>
<segment>
<pinref part="CN1" gate="G$1" pin="2"/>
<wire x1="-58.42" y1="0" x2="-50.8" y2="0" width="0.1524" layer="91"/>

</segment>
<segment>
<pinref part="J1" gate="G$1" pin="GND"/>
<wire x1="-58.42" y1="33.02" x2="-48.26" y2="33.02" width="0.1524" layer="91"/>

</segment>
</net>
<net name="3V3" class="0">
<segment>
<pinref part="R6" gate="A" pin="2"/>
<wire x1="-45.72" y1="76.2" x2="-50.8" y2="76.2" width="0.1524" layer="91"/>

</segment>
<segment>
<pinref part="R5" gate="A" pin="2"/>
<wire x1="-45.72" y1="71.12" x2="-50.8" y2="71.12" width="0.1524" layer="91"/>

</segment>
<segment>
<pinref part="GND" gate="A" pin="VDCDC2"/>
<wire x1="137.16" y1="17.78" x2="149.86" y2="17.78" width="0.1524" layer="91"/>

</segment>
<segment>
<pinref part="L2" gate="A" pin="1"/>
<wire x1="167.64" y1="-53.34" x2="182.88" y2="-53.34" width="0.1524" layer="91"/>

<pinref part="3V3" gate="G$1" pin="2"/>
</segment>
<segment>
<pinref part="GND" gate="A" pin="MUX_IN"/>
<wire x1="35.56" y1="-33.02" x2="22.86" y2="-33.02" width="0.1524" layer="91"/>

</segment>
<segment>
<pinref part="R10" gate="A" pin="2"/>
<wire x1="12.7" y1="-7.62" x2="7.62" y2="-7.62" width="0.1524" layer="91"/>

</segment>
<segment>
<pinref part="R11" gate="A" pin="2"/>
<wire x1="17.78" y1="33.02" x2="12.7" y2="33.02" width="0.1524" layer="91"/>

</segment>
</net>
<net name="1V2" class="0">
<segment>
<pinref part="L3" gate="A" pin="1"/>
<wire x1="167.64" y1="-48.26" x2="182.88" y2="-48.26" width="0.1524" layer="91"/>

<pinref part="1V2" gate="G$1" pin="2"/>
</segment>
<segment>
<pinref part="R8" gate="A" pin="2"/>
<wire x1="177.8" y1="22.86" x2="180.34" y2="22.86" width="0.1524" layer="91"/>

</segment>
</net>
<net name="1V8" class="0">
<segment>
<pinref part="GND" gate="A" pin="VDCDC1"/>
<wire x1="137.16" y1="12.7" x2="149.86" y2="12.7" width="0.1524" layer="91"/>

</segment>
<segment>
<pinref part="L1" gate="A" pin="1"/>
<wire x1="167.64" y1="-58.42" x2="182.88" y2="-58.42" width="0.1524" layer="91"/>

<pinref part="1V8" gate="G$1" pin="2"/>
</segment>
</net>
<net name="D-" class="0">
<segment>
<pinref part="J1" gate="G$1" pin="D-"/>
<wire x1="-58.42" y1="40.64" x2="-50.8" y2="40.64" width="0.1524" layer="91"/>

</segment>
</net>
<net name="D+" class="0">
<segment>
<pinref part="J1" gate="G$1" pin="D+"/>
<wire x1="-58.42" y1="38.1" x2="-50.8" y2="38.1" width="0.1524" layer="91"/>

</segment>
</net>
<net name="ID" class="0">
<segment>
<pinref part="J1" gate="G$1" pin="ID"/>
<wire x1="-58.42" y1="35.56" x2="-50.8" y2="35.56" width="0.1524" layer="91"/>

</segment>
</net>
</nets>
</sheet>
</sheets>
</schematic>
</drawing>
<compatibility>
<note version="8.2" severity="warning">
Since Version 8.2, EAGLE supports online libraries. The ids
of those online libraries will not be understood (or retained)
with this version.
</note>
<note version="8.3" severity="warning">
Since Version 8.3, EAGLE supports URNs for individual library
assets (packages, symbols, and devices). The URNs of those assets
will not be understood (or retained) with this version.
</note>
<note version="8.3" severity="warning">
Since Version 8.3, EAGLE supports the association of 3D packages
with devices in libraries, schematics, and board files. Those 3D
packages will not be understood (or retained) with this version.
</note>
<note version="9.0" severity="warning">
Since Version 9.0, EAGLE supports the align property for labels.
Labels in schematic will not be understood with this version. Update EAGLE to the latest version
for full support of labels.
</note>
</compatibility>
</eagle>

path: /TPS65217A Evaluation Board.sch

extension: sch

filename: TPS65217A Evaluation Board.sch


text:
package main

import (
	"context"
	"flag"
	"fmt"
	"net/http"
	"os"

	corev1 "k8s.io/api/core/v1"
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

	"github.com/sirupsen/logrus"
	kwhhttp "github.com/slok/kubewebhook/v2/pkg/http"
	kwhlogrus "github.com/slok/kubewebhook/v2/pkg/log/logrus"
	kwhmodel "github.com/slok/kubewebhook/v2/pkg/model"
	kwhmutating "github.com/slok/kubewebhook/v2/pkg/webhook/mutating"
)

type config struct {
	certFile string
	keyFile  string
}

func initFlags() *config {
	cfg := &config{}

	fl := flag.NewFlagSet(os.Args[0], flag.ExitOnError)
	fl.StringVar(&cfg.certFile, "tls-cert-file", "", "TLS certificate file")
	fl.StringVar(&cfg.keyFile, "tls-key-file", "", "TLS key file")

	fl.Parse(os.Args[1:])
	return cfg
}

func run() error {
	logrusLogEntry := logrus.NewEntry(logrus.New())
	logrusLogEntry.Logger.SetLevel(logrus.DebugLevel)
	logger := kwhlogrus.NewLogrus(logrusLogEntry)

	cfg := initFlags()

	// Create mutator.
	mt := kwhmutating.MutatorFunc(func(_ context.Context, _ *kwhmodel.AdmissionReview, obj metav1.Object) (*kwhmutating.MutatorResult, error) {
		pod, ok := obj.(*corev1.Pod)
		if !ok {
			return &kwhmutating.MutatorResult{}, nil
		}

		// Mutate our object with the required annotations.
		if pod.Annotations == nil {
			pod.Annotations = make(map[string]string)
		}
		pod.Annotations["mutated"] = "true"
		pod.Annotations["mutator"] = "pod-annotate"

		return &kwhmutating.MutatorResult{MutatedObject: pod}, nil
	})

	// Create webhook.
	mcfg := kwhmutating.WebhookConfig{
		ID:      "pod-annotate",
		Mutator: mt,
		Logger:  logger,
	}
	wh, err := kwhmutating.NewWebhook(mcfg)
	if err != nil {
		return fmt.Errorf("error creating webhook: %w", err)
	}

	// Get HTTP handler from webhook.
	whHandler, err := kwhhttp.HandlerFor(kwhhttp.HandlerConfig{Webhook: wh, Logger: logger})
	if err != nil {
		return fmt.Errorf("error creating webhook handler: %w", err)
	}

	// Serve.
	logger.Infof("Listening on :8080")
	err = http.ListenAndServeTLS(":8080", cfg.certFile, cfg.keyFile, whHandler)
	if err != nil {
		return fmt.Errorf("error serving webhook: %w", err)
	}

	return nil
}

func main() {
	err := run()
	if err != nil {
		fmt.Fprintf(os.Stderr, "error running app: %s", err)
		os.Exit(1)
	}
}

repository: shaneutt/kubewebhook

license_type: permissive

repo_name: shaneutt/kubewebhook

branch_name: refs/heads/master

gha_language: Go

extension: go


text:
require xorg-app-common.inc
PE = "1"

DESCRIPTION = "X fontserver"

DEPENDS += " libfs libxfont xtrans"

license: MIT

extension: bb


text:
/**
 * Copyright 2020 Bonitasoft S.A.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import { TDefinitions } from '../../../../model/bpmn/json/BPMN20';
import { ConvertedElements } from './utils';
import { TGlobalTask } from '../../../../model/bpmn/json/baseElement/rootElement/globalTask';
import { ensureIsArray } from '../../../helpers/array-utils';

/**
 * @internal
 */
export default class GlobalTaskConverter {
  constructor(readonly convertedElements: ConvertedElements) {}

  deserialize(definitions: TDefinitions): void {
    this.parseGlobalTasks(definitions.globalTask);
    this.parseGlobalTasks(definitions.globalBusinessRuleTask);
    this.parseGlobalTasks(definitions.globalManualTask);
    this.parseGlobalTasks(definitions.globalScriptTask);
    this.parseGlobalTasks(definitions.globalUserTask);
  }

  private parseGlobalTasks<T extends TGlobalTask>(globalTasks: T | T[]): void {
    ensureIsArray<T>(globalTasks).forEach(globalTask => {
      this.convertedElements.registerGlobalTask(globalTask.id);
    });
  }
}

extension: ts


text:
/*
 * minmax.hpp --
 *
 * This file is part of phlib library.
 *
 * Copyright (c) 2012 Andrey V. Nakin <andrey.nakin@gmail.com>
 * All rights reserved.
 *
 * See the file "COPYING" for information on usage and redistribution
 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 *
 */

#ifndef MINMAX_HPP_
#define MINMAX_HPP_

#include <algorithm>

namespace phlib {

	template <class T>
	const T& min(const T& a, const T& b, const T& c) {
		return std::min(a, std::min(b, c));
	}

	template <class T>
	const T& max(const T& a, const T& b, const T& c) {
		return std::max(a, std::max(b, c));
	}
}

#endif /* MINMAX_HPP_ */

repository: andrey-nakin/phlib

repo_name: andrey-nakin/phlib

extension: hpp


text:
SUMMARY = "Common macros for building GNOME applications"
HOMEPAGE = "http://www.gnome.org/"
BUGTRACKER = "https://bugzilla.gnome.org/"

LICENSE = "GPL-2.0-or-later"
LIC_FILES_CHKSUM = "file://COPYING;md5=b234ee4d69f5fce4486a80fdaf4a4263"

SECTION = "x11/gnome"
inherit gnomebase allarch

SRC_URI = "${GNOME_MIRROR}/${GNOMEBN}/${@gnome_verdir("${PV}")}/${GNOMEBN}-${PV}.tar.${GNOME_COMPRESS_TYPE};name=archive"
SRC_URI[archive.md5sum] = "933258d9c23e218eb6eec9cc1951b053"
SRC_URI[archive.sha256sum] = "22569e370ae755e04527b76328befc4c73b62bfd4a572499fde116b8318af8cf"

EXTRA_OECONF = "--with-autoconf-archive"
EXTRA_AUTORECONF = ""
DEPENDS = ""

FILES:${PN} += "${datadir}/aclocal"
FILES:${PN}-dev = ""

BBCLASSEXTEND = "native"

repository: brl/citadel

repo_name: brl/citadel

gha_language: BitBake


text:
package main

import (
	"context"
	"fmt"
	"html/template"
	"io"
	"net/http"
	"sort"
	"strconv"
	"strings"
	"time"

	"github.com/go-kit/kit/log"
	"github.com/go-kit/kit/log/level"
	"github.com/gorilla/mux"
	"github.com/oklog/ulid"
	"github.com/pkg/errors"
)

func loggingMiddleware(logger log.Logger) func(next http.Handler) http.Handler {
	return func(next http.Handler) http.Handler {
		return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
			var (
				begin = time.Now()
				iw    = &interceptingWriter{http.StatusOK, w}
			)
			next.ServeHTTP(iw, r)
			level.Info(logger).Log(
				"method", r.Method,
				"uri", r.RequestURI,
				"content_length", r.ContentLength,
				"status_code", iw.code,
				"took", time.Since(begin),
			)
		})
	}
}

func auditingMiddleware(log *auditLog) func(next http.Handler) http.Handler {
	return func(next http.Handler) http.Handler {
		return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
			var (
				begin = time.Now()
				e     = newAuditEvent(r)
				ctx   = context.WithValue(r.Context(), auditEventKey, e)
				rr    = r.WithContext(ctx)
				iw    = &interceptingWriter{http.StatusOK, w}
			)
			next.ServeHTTP(iw, rr)
			e.finalize(time.Since(begin), iw.code)
			log.logEvent(e)
		})
	}
}

type eventLogger interface {
	logEvent(*auditEvent)
}

const auditEventKey = "audit_event"

func setAuditEvent(ctx context.Context, k auditEventKind) *auditEvent {
	e := ctx.Value(auditEventKey).(*auditEvent)
	e.setKind(k)
	return e
}

func registerDoorbellRoutes(
	router *mux.Router,
	forwardText string,
	forwardNumber string,
	noResponseText string,
	rm *recordingManager,
) {
	var (
		greeting  = handleGreeting()
		forward   = handleForward(forwardText, forwardNumber, noResponseText)
		recording = handleRecording(rm)
	)
	router.Methods("POST").Path("/v1/greeting").Handler(greeting)
	router.Methods("POST").Path("/v1/forward").Handler(forward)
	router.Methods("POST").Path("/v1/recordings").Handler(recording)
}

func handleGreeting() http.Handler {
	return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		setAuditEvent(r.Context(), doorbellGreeting)

		fmt.Fprint(w, `<?xml version="1.0" encoding="UTF-8"?>
			<Response>
				<Redirect>/v1/forward</Redirect>
			</Response>
	`)
	})
}

func handleForward(forwardText, forwardNumber, noResponseText string) http.Handler {
	return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		setAuditEvent(r.Context(), doorbellForward)

		fmt.Fprintf(w, `<?xml version="1.0" encoding="UTF-8"?>
			<Response>
				<Say>%s</Say>
				<Dial record="record-from-ringing" recordingStatusCallback="/v1/recordings" recordingStatusCallbackMethod="POST">
					<Number>%s</Number>
				</Dial>
				<Say>%s</Say>
				<Hangup />
			</Response>
		`, forwardText, forwardNumber, noResponseText)
	})
}

func handleRecording(m *recordingManager) http.Handler {
	return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		e := setAuditEvent(r.Context(), doorbellRecording)

		r.ParseForm()
		var (
			url = r.FormValue("RecordingUrl")
			sid = r.FormValue("RecordingSid")
			dur = r.FormValue("RecordingDuration")
		)

		if url == "" || sid == "" || dur == "" {
			e.eventLog("Recording request was missing data; not saved")
			http.NotFound(w, r)
			return
		}

		var (
			date = time.Now().Format("2006-01-02-15-04-05")
			name = date + "-" + dur + "sec" + "-" + sid + ".wav"
		)
		if err := m.saveRecording(name, url); err != nil {
			e.eventLogf("Recording save failed: %v", err)
			http.Error(w, errors.Wrap(err, "saving recording").Error(), http.StatusInternalServerError)
			return
		}

		e.eventLog("Recording saved successfully")
		fmt.Fprintf(w, "Saved %s OK\n", name)
	})
}

//
//
//

func authMiddleware(realm, user, pass string) func(next http.Handler) http.Handler {
	return func(next http.Handler) http.Handler {
		return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
			requser, reqpass, _ := r.BasicAuth()
			if requser != user || reqpass != pass {
				w.Header().Set("WWW-Authenticate", fmt.Sprintf(`Basic realm="%s"`, realm))
				w.WriteHeader(http.StatusUnauthorized)
				fmt.Fprintln(w, http.StatusText(http.StatusUnauthorized))
				return
			}
			next.ServeHTTP(w, r)
		})
	}
}

func registerAdminRoutes(
	router *mux.Router,
	basicAuthRealm, basicAuthUser, basicAuthPass string,
	log *auditLog,
	rm *recordingManager,
) {
	auth := authMiddleware(basicAuthRealm, basicAuthUser, basicAuthPass)
	router.Methods("GET").Path("/").Handler(auth(handleIndex()))
	router.Methods("GET").Path("/events").Handler(auth(handleGetEvents(log)))
	router.Methods("GET").Path("/events/{id}").Handler(auth(handleGetEvent(log)))
	router.Methods("GET").Path("/recordings").Handler(auth(handleGetRecordings(rm)))
	router.Methods("GET").Path("/recordings/{id}").Handler(auth(handleGetRecording(rm)))
}

func handleIndex() http.Handler {
	return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		http.Redirect(w, r, "/events", http.StatusTemporaryRedirect)
	})
}

func handleGetEvents(log *auditLog) http.Handler {
	return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		setAuditEvent(r.Context(), adminGetEvents)

		r.ParseForm()
		var (
			from     = r.FormValue("from")
			countStr = r.FormValue("count")
			count, _ = strconv.Atoi(countStr)
		)
		if count == 0 {
			count = 100
		}

		events, err := log.getEvents(from, count)
		if err != nil {
			http.Error(w, errors.Wrap(err, "couldn't list events").Error(), http.StatusInternalServerError)
			return
		}

		type templateEvent struct {
			Color   string
			ULID    string
			Time    string
			Kind    string
			Details []string
		}

		templateEvents := make([]templateEvent, len(events))
		for i, event := range events {
			templateEvents[i] = templateEvent{
				Color:   string(event.Kind.Color),
				ULID:    event.ID,
				Time:    ulid2localtime(event.ID),
				Kind:    event.Kind.Name,
				Details: event.Details,
			}
		}

		var nextPage string
		if len(templateEvents) >= count {
			nextPage = templateEvents[len(templateEvents)-1].ULID
		}

		aggregate := headerTemplate + eventsTemplate + footerTemplate
		if err := template.Must(template.New("events").Parse(aggregate)).Execute(w, struct {
			Events   []templateEvent
			NextPage string
		}{
			Events:   templateEvents,
			NextPage: nextPage,
		}); err != nil {
			http.Error(w, errors.Wrap(err, "executing events template").Error(), http.StatusInternalServerError)
			return
		}
	})
}

func handleGetEvent(log *auditLog) http.Handler {
	return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		setAuditEvent(r.Context(), adminGetEvent)

		id := mux.Vars(r)["id"]
		if id == "" {
			http.Error(w, "no event ID provided; bad routing", http.StatusInternalServerError)
			return
		}

		e, err := log.getEvent(id)
		if err != nil {
			http.Error(w, errors.Wrap(err, "getting event").Error(), http.StatusNotFound)
			return
		}

		var httpDetails []string
		httpDetails = append(httpDetails, fmt.Sprintf("%s %s", e.Request.Method, e.Request.URI))
		for k, vs := range e.Request.Headers {
			httpDetails = append(httpDetails, fmt.Sprintf("%s: %s", k, strings.Join(vs, ", ")))
		}
		sort.Strings(httpDetails)

		aggregate := headerTemplate + eventTemplate + footerTemplate
		if err := template.Must(template.New("event").Parse(aggregate)).Execute(w, struct {
			Color   string
			ULID    string
			Time    string
			UTC     string
			Kind    string
			Details []string
			HTTP    []string
		}{
			Color:   string(e.Kind.Color),
			ULID:    e.ID,
			Time:    ulid2localtime(e.ID),
			UTC:     ulid2utctime(e.ID),
			Kind:    e.Kind.Name,
			Details: e.Details,
			HTTP:    httpDetails,
		}); err != nil {
			http.Error(w, errors.Wrap(err, "executing event template").Error(), http.StatusInternalServerError)
			return
		}
	})
}

func handleGetRecordings(rm *recordingManager) http.Handler {
	return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		setAuditEvent(r.Context(), adminGetRecordings)

		recordings := rm.listRecordings()

		aggregate := headerTemplate + recordingsTemplate + footerTemplate
		if err := template.Must(template.New("recordings").Parse(aggregate)).Execute(w, struct {
			Recordings []string
		}{
			Recordings: recordings,
		}); err != nil {
			http.Error(w, errors.Wrap(err, "executing recordings template").Error(), http.StatusInternalServerError)
			return
		}
	})
}

func handleGetRecording(rm *recordingManager) http.Handler {
	return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		e := setAuditEvent(r.Context(), adminGetRecording)

		id, ok := mux.Vars(r)["id"]
		if !ok {
			http.Error(w, "recording ID not provided", http.StatusBadRequest)
			return
		}

		rec, err := rm.getRecording(id)
		if err != nil {
			http.Error(w, errors.Wrap(err, "fetching recording").Error(), http.StatusInternalServerError)
			return
		}

		w.Header().Set("Transfer-Encoding", "chunked")
		w.Header().Set("Content-Type", "audio/wav")
		n, err := io.Copy(w, rec)
		if err != nil {
			http.Error(w, errors.Wrap(err, "streaming recording to user").Error(), http.StatusInternalServerError)
			return
		}

		e.eventLogf("Streamed %dB to client", n)
	})
}

//
//
//

type interceptingWriter struct {
	code int
	http.ResponseWriter
}

func (iw *interceptingWriter) WriteHeader(code int) {
	iw.code = code
	iw.ResponseWriter.WriteHeader(code)
}

func isNumeric(s string) bool {
	for _, r := range s {
		switch r {
		case '0', '1', '2', '3', '4', '5', '6', '7', '8', '9':
		default:
			return false
		}
	}
	return true
}

func ulid2localtime(id string) string {
	u, err := ulid.Parse(id)
	if err != nil {
		return "(couldn't parse time from ID)"
	}
	var (
		msec = u.Time()
		sec  = msec / 1e3
		nsec = (msec % 1e3) * 1e6
		t    = time.Unix(int64(sec), int64(nsec))
	)
	return t.Format(myDate)
}

func ulid2utctime(id string) string {
	u, err := ulid.Parse(id)
	if err != nil {
		return "(couldn't parse time from ID)"
	}
	var (
		msec = u.Time()
		sec  = msec / 1e3
		nsec = (msec % 1e3) * 1e6
		t    = time.Unix(int64(sec), int64(nsec))
	)
	return t.UTC().Format(time.RFC3339Nano)
}

const myDate = "Monday 02 Jan 2006 15:04:05 MST"

repository: peterbourgon/squawkbox

repo_name: peterbourgon/squawkbox


text:
import {
  Component,
  OnInit
} from '@angular/core';
import {
  FormGroup,
  FormControl,
  Validators,
  FormBuilder
} from '@angular/forms';
import { AnnotationService } from '../services/annotation.service';
import { ResourceService } from '../services/resource.service';
import { CognitoUserService } from '../services';
import { ToastService } from '../mdb-type/pro/alerts';
import * as uuid from 'uuid';

function isEmpty(obj) {
  for (const key in obj) {
    if (obj.hasOwnProperty(key)) {
      return false;
    }
  }
  return true;
}
function notEmpty(obj) {
  return !isEmpty(obj);
}

@Component({
  selector: 'app-annotations',
  templateUrl: './annotations.component.html',
  styleUrls: ['./annotations.component.scss']
})

export class AnnotationsComponent implements OnInit {

  currentUser;

  isLoading = true;
  isEditing = false;
  isAdding = false;

  annotation = {
    _id: null,
    id: '',
    type: 'Annotation',
    creator_ref: null,
    created: null,
    generator_ref: null,
    generated: null,
    modified: null,
    audience: null,
    motivation: null,
    rights: null,
    body_ref: null,
    target_ref: null
  };
  annotations = [];
  bodys = [];
  targets = [];
  motivations = [];
  motivationId = null;
  localhost = window.location.protocol + '://' + window.location.host;
  currentUser_id = this.auth.currentUser._id;

  addAnnotationForm: FormGroup;
  id = new FormControl('');
  type = 'Annotation';
  audience = new FormControl('');
  motivation = new FormControl('');
  rights = new FormControl('');
  body = new FormControl('');
  target = new FormControl(''); // , [ Validators.required ]);
  creator_ref = new FormControl('');
  created = new FormControl('');
  modifier_ref = new FormControl('');
  modified = new FormControl('');
  generator_ref = new FormControl('');
  generated = new FormControl('');

  countries = [];
  country = null;

  constructor(
    private annotationService: AnnotationService,
    private resourceService: ResourceService,
    private auth: CognitoUserService,
    private fb: FormBuilder,
    public  toast: ToastService
  ) { }

  ngOnInit() {
    this.getAnnotations();
    this.addAnnotationForm = this.fb.group({
      id: this.id,
      type: this.type,
      creator_ref: this.creator_ref,
      created: this.created,
      generator_ref: this.generator_ref,
      generated: this.generated,
      modifier_ref: this.modifier_ref,
      modified: this.modified,
      audience: this.audience,
      motivation: this.motivation,
      rights: this.rights,
      body: this.body,
      target: this.target
    });
    let currentUser = localStorage.getItem('currentUser');
    if (currentUser) {
      currentUser = JSON.parse(currentUser);
      if (currentUser) {
        this.currentUser = currentUser;
      } else {
        this.currentUser = {};
      }
    } else {
      this.currentUser = {};
    }
    this.getBodys();
    this.body = null;
    this.getTargets();
    this.target = null;
    this.motivations = [
      {id: 'bookmarking', name: 'bookmarking'},
      {id: 'tagging', name: 'tagging'},
      {id: 'highlighting', name: 'highlighting'},
      {id: 'commenting', name: 'commenting'},
      {id: 'describing', name: 'describing'},
      {id: 'linking', name: 'linking'},
      {id: 'classifying', name: 'classifying'},
      {id: 'assessing', name: 'assessing'},
      {id: 'identifying', name: 'identifying'},
      {id: 'editing', name: 'editing'},
      {id: 'moderating', name: 'moderating'},
      {id: 'questioning', name: 'questioning'},
      {id: 'replying', name: 'replying'}
    ];
    this.motivationId = null;
  }

  getBodys() {
    // let key, item;
    this.resourceService
      .getResources(this.currentUser)
      .subscribe(
        data => {
          this.bodys = data;
        },
        error => console.log(error)
      );
  }

  getTargets() {
    // let key, item;
    this.resourceService
      .getResources(this.currentUser)
      .subscribe(
        data => {
          this.targets = data.filter((item) => {
            return ('TextualBody' !== item.type);
          });
        },
        error => console.log(error)
      );
  }

  getAnnotations() {
    this.annotationService
      .getAnnotations(this.currentUser)
      .subscribe(
        data => {
          this.annotations = data.map((item) => {
            return item;
          });
        },
        error => console.log(error),
        () => this.isLoading = false
      );
  }

  addAnnotation() {
    const ctrl = this;
    const formValue = ctrl.addAnnotationForm.value;
    const uuidV4 = uuid.v4();
    if (notEmpty(formValue)) {
      ctrl.annotation = {
        _id: uuidV4,
        id: ctrl.localhost + '/' + uuidV4,
        type: 'Annotation',
        creator_ref: ctrl.auth.currentUser._id,
        created: new Date().toISOString(),
        generator_ref: formValue.generatorId,
        generated: formValue.generated,
        modified: formValue.modified,
        audience: formValue.audience,
        motivation: formValue.motivation.name,
        rights: formValue.rights,
        body_ref: formValue.body._id || '',
        target_ref: formValue.target._id || ''
      };
      ctrl.annotationService.addAnnotation(ctrl.annotation).subscribe(
        res => {
          const newAnnotation = res.json();
          console.log(newAnnotation);
          ctrl.annotations.push(newAnnotation);
          ctrl.addAnnotationForm.reset();
          ctrl.toastMessage(newAnnotation.name + ' added successfully.', 'success');
        },
        error => console.log(error)
      );
      // reload the annotations to reset the editing
      ctrl.getAnnotations();
    }
  }

  enableAdding() {
    const ctrl = this;
    ctrl.isEditing = false;
    ctrl.isAdding = true;
    setTimeout( () => {
      const selects = document.getElementsByTagName('select');
      const w = window.innerWidth / selects.length - 100;
      for (const key in selects) { if (selects.hasOwnProperty(key)) {
        selects[key].setAttribute('style', 'width: ' + w + 'px');
      }}
    }, 200);
  }

  enableEditing(annotation) {
    const ctrl = this;
    ctrl.isEditing = true;
    ctrl.isAdding = false;
    ctrl.annotation = annotation;
  }

  cancelEditing() {
    const ctrl = this;
    ctrl.isEditing = false;
    ctrl.isAdding = false;
    ctrl.annotation = {
      _id: null,
      id: '',
      type: 'Annotation',
      creator_ref: null,
      created: null,
      generator_ref: null,
      generated: null,
      modified: null,
      audience: null,
      motivation: null,
      rights: null,
      body_ref: null,
      target_ref: null
    };
    ctrl.toastMessage('item editing cancelled.', 'warning');
    // reload the annotations to reset the editing
    ctrl.getAnnotations();
  }

  editAnnotation(annotation) {
    const ctrl = this;
    ctrl.body = annotation.body_ref;
    ctrl.resourceService.editResource(ctrl.body).subscribe(
      res => {
        const editedAnnotation = res.json();
        console.log(editedAnnotation);
        ctrl.toastMessage(JSON.stringify(res.body) + ' edited successfully.', 'success');
      },
      error => console.log(error)
    );
    annotation.body_ref = annotation.body_ref._id;
    annotation.target_ref = annotation.target_ref._id;
    annotation.modified = new Date().toISOString();
    ctrl.annotationService.editAnnotation(annotation).subscribe(
      res => {
        ctrl.isEditing = false;
        ctrl.annotation = annotation;
        ctrl.toastMessage(JSON.stringify(annotation) + ' edited successfully.', 'success');
      },
      error => console.log(error)
    );
  }

  deleteAnnotation(annotation) {
    // const ctrl = this;
    if (window.confirm('Are you sure you want to permanently delete ctrl item?')) {
      this.annotationService.deleteAnnotation(annotation).subscribe(
        res => {
          const pos = this.annotations.map(elem => { return elem._id; }).indexOf(annotation._id);
          this.annotations.splice(pos, 1);
          this.toastMessage('item deleted successfully.', 'success');
        },
        error => console.log(error)
      );
    }
  }

  toastMessage(message: string, action: string) {
    const
      options = {
        closeButton: true,
        positionClass: 'toast-bottom-center'
      };
    this.toast[action](message, action.toUpperCase(), options);
  }

}

repository: pontsoleil/WuWei

repo_name: pontsoleil/WuWei

gha_license_id: MIT

gha_language: TypeScript


text:
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { NgModule } from '@angular/core';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
import { RouterModule } from '@angular/router';
import { HttpClientModule, HttpClient } from '@angular/common/http';
import { TranslateModule, TranslateLoader } from '@ngx-translate/core';
import { TranslateHttpLoader } from '@ngx-translate/http-loader';
import { BrowserModule } from '@angular/platform-browser';
import { CommonModule } from '@angular/common';
import { AppRoutingModule } from './app.routing';
import { ComponentsModule } from './components/components.module';

import { AppComponent } from './app.component';
import { AuthGuard , AuthService} from './shared';

import { DashboardComponent } from './dashboard/dashboard.component';
import { UserProfileComponent } from './user-profile/user-profile.component';
import { TableListComponent } from './table-list/table-list.component';
import { TypographyComponent } from './typography/typography.component';
import { IconsComponent } from './icons/icons.component';
// import { MapsComponent } from './maps/maps.component';
import { NotificationsComponent } from './notifications/notifications.component';
import { UpgradeComponent } from './upgrade/upgrade.component';

import { ProjectService } from './services/project-service';
import { LoginService } from './services/login-service';
import { LogoutService } from './services/logout-service';

import { HTTP_INTERCEPTORS } from '@angular/common/http';

import { NgPipesModule} from 'ngx-pipes';
import { SigninEmitterService} from './services/signin-emitter.service';
import { SignoutEmitterService} from './services/signout-emitter.service';
import { DatafileDetailService} from './layout/datafile-detail/datafile-detail-service';
import { SignupService } from './services/signup-service';
import { ResetPasswordService } from './services/reset-password-service';
import { TokenInterceptor } from './shared/interceptor/token.interceptor';
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
import { ChartsModule } from 'ng2-charts';
import { FullScreenService } from './services/full-screen.service';
import { ParamsModalService } from './services/params-modal.service';
import { FullScreenComponent } from './full-screen/full-screen.component';
import { HelpModalService } from './services/help-modal.service';
import { HelpModalComponent } from './help-modal/help-modal.component';

import { WorkerService } from './services/worker.service';

import { CommentModalComponent } from './comment-modal/comment-modal.component';
// import { CommentsListComponent } from './comments-list/comments-list.component';
import { ParamsModalComponent } from './params-modal/params-modal.component';
import { CommentModalSubmitService } from './services/comment-modal-submit.service';
import { NgxSortableModule } from 'ngx-sortable';
import { NgMultiSelectDropDownModule } from 'ng-multiselect-dropdown';
import { ColorPickerModule } from 'ngx-color-picker';
import { LogoutComponent } from './logout/logout.component';
import { LoginComponent } from './login/login.component';

import { LoginModule } from './login/login.module';

import {
  AgmCoreModule
} from '@agm/core';
// import { AdminLayoutComponent } from './layouts/admin-layout/admin-layout.component';

export function createTranslateLoader(http: HttpClient) {
    // for development

    return new TranslateHttpLoader(http, './assets/i18n/', '.json');
}

@NgModule({
  imports: [

    CommonModule,
    BrowserModule,
    HttpClientModule,
    ChartsModule,
    NgxSortableModule,
    ColorPickerModule,
    NgbModule,
    // NgbModule.forRoot(),
    TranslateModule.forRoot({
        loader: {
            provide: TranslateLoader,
            useFactory: createTranslateLoader,
            deps: [HttpClient]
        }
    }),
    NgMultiSelectDropDownModule.forRoot(),

    FormsModule,
    NgPipesModule,

    BrowserAnimationsModule,
    ReactiveFormsModule,
    // HttpModule,
    ComponentsModule,
    RouterModule,
    AppRoutingModule,
    AgmCoreModule.forRoot({
      apiKey: 'YOUR_GOOGLE_MAPS_API_KEY'
    })
  ],
  entryComponents: [
       FullScreenComponent,
       HelpModalComponent,
       CommentModalComponent,
       // CommentsListComponent,
       ParamsModalComponent,
   ],
  // declarations: [
  //   AppComponent,
  //   AdminLayoutComponent,
  //
  // ],

  // declarations: [AppComponent, AdminLayoutComponent, HelpModalComponent, CommentModalComponent, FullScreenComponent, ParamsModalComponent, LoginComponent],
  declarations: [AppComponent, HelpModalComponent, CommentModalComponent, FullScreenComponent, ParamsModalComponent],

  providers: [AuthGuard, ProjectService, LoginService, SignupService, ResetPasswordService, LogoutService, AuthService, LogoutComponent,
              SigninEmitterService, SignoutEmitterService, HelpModalService, FullScreenService, CommentModalSubmitService, WorkerService, ParamsModalService, DatafileDetailService, {

    provide: HTTP_INTERCEPTORS,
    useClass: TokenInterceptor,
    multi: true
  }],
  bootstrap: [AppComponent]

  // providers: [],
  // bootstrap: [AppComponent]
})
export class AppModule { }