include data.pug

mixin navbarMixin(selectedItem)
    .navbar
        each navbarUrl,navbarName in navbarItems
            if navbarName == selectedItem
                a.navbar__link-wrapper(href=navbarUrl)
                    .navbar__item.navbar__item_selected #{navbarName}
            else
                a.navbar__link-wrapper(href=navbarUrl)
                    .navbar__item #{navbarName}

mixin infoCardsMinxin()
  each cardData in  smallCards 
    .small-card
        .small-card__content 
          h3.small-card__header #{cardData.header}
          p.small-card__text #{cardData.text}
          a.small-card__link(href=cardData.link) Подробнее»
        .small-card__image
          img(src=cardData.image alt=cardData.imageAlt)

mixin galleryMixin()
  each img in galleryImages
     img.gallery__image(src=img.src alt=img.alt)

mixin filtersMixin()
    details.filters
        summary.filters__summary Filters
        form.filters__form
            fieldset.filters__fieldset
                .filter-group
                    i.filter-group__label 
                        b Location
                    br
                    .filter-group__items
                        each filter in locationFilters
                            input.filter-group__checkbox(type="checkbox" id=filter.id name="location" value=filter.value)
                            span  #{filter.label}
                            br

                .filter-group
                    i.filter-group__label 
                        b Sensor Type
                    br
                    .filter-group__items
                        each filter in sensorTypeFilters
                            input.filter-group__checkbox(type="checkbox" id=filter.id name="sensor_type" value=filter.value)
                            span #{filter.label}
                            br

                .filter-group
                    i.filter-group__label 
                        b Numeric Values
                    br
                    .filter-group__range
                        span Temperature from: 
                        input.filter-group__input(type="number" name="temp_min" placeholder="20")
                        span  to: 
                        input.filter-group__input(type="number" name="temp_max" placeholder="30")
                        br
                        span Humidity from: 
                        input.filter-group__input(type="number" name="humidity_min" placeholder="40")
                        span  to: 
                        input.filter-group__input(type="number" name="humidity_max" placeholder="60")
                        br

                .filter-group
                    i.filter-group__label 
                        b Device Specific Filters
                    br
                    .filter-group__items
                        span Sensor Name: 
                        input.filter-group__input(type="text" name="sensor_name")
                        br
                        span Days Since Calibration (max): 
                        input.filter-group__input(type="number" name="calibration_days" placeholder="30")
                        br

                .filter-group
                    i.filter-group__label 
                        b Measurement Period
                    br
                    .filter-group__dates
                        span From: 
                        input.filter-group__input(type="date" name="date_from")
                        br
                        span To: 
                        input.filter-group__input(type="date" name="date_to")
                        br

                .filter-group__buttons
                    input.filter-group__button.filter-group__button--submit(type="submit" value="Apply Filters")
                    input.filter-group__button.filter-group__button--reset(type="reset" value="Reset Filters")

mixin sortLevel(level)
    .sort-level
        i.sort-level__label 
            b Sort Level #{level}
        br
        label.sort-level__field-label(for=`sort${level}`) Field:
        select.sort-level__select(id=`sort${level}` name=`sort${level}`)
            each option in sortOptions
                option(value=option.value) #{option.label}
        label.sort-level__reverse-label(for=`sort${level}_reverse`)
            input.sort-level__checkbox(type="checkbox" id=`sort${level}_reverse` name=`sort${level}_reverse`)
            span  Reverse
        br
        if level === '3'
            input.sort-level__submit(type="submit" value="Sort")
        else
            br

mixin sortingMixin()
    - const sortLevels = ['1', '2', '3'];
    details.sorting
        summary.sorting__summary Sortings
        form.sorting__form
            fieldset.sorting__fieldset
                each level in sortLevels
                    +sortLevel(level)

mixin graphXOption(option)
    if option.checked
        input.axis-group__radio(type="radio" id=option.id name="x_axis" value=option.value checked)
    else
        input.axis-group__radio(type="radio" id=option.id name="x_axis" value=option.value)
    label.axis-group__option-label(for=option.id) #{option.label}
    br

mixin graphYOption(option)
    if option.checked
        input.values-group__checkbox(type="checkbox" id=option.id name="values" value=option.value checked)
    else
        input.values-group__checkbox(type="checkbox" id=option.id name="values" value=option.value)
    label.values-group__option-label(for=option.id) #{option.label}
    br

mixin graphMixin()
    details.graph
        summary.graph__summary Graph
        form.graph__form
            fieldset.graph__fieldset
                .axis-group
                    i.axis-group__label 
                        b X axis
                    br
                    .axis-group__options
                        each option in axisOptions
                            +graphXOption(option)
                .values-group
                    i.values-group__label 
                        b Values
                    br
                    .values-group__options
                        each option in valueOptions
                            +graphYOption(option)
                        button.values-group__button(type="submit" id="build_graph" name="build_graph") Build