Skip to content
This repository has been archived by the owner on Nov 4, 2023. It is now read-only.

Commit

Permalink
- localized number formats for weather
Browse files Browse the repository at this point in the history
- minor changes to weather tile
  • Loading branch information
mikyjazz committed Mar 6, 2021
1 parent ce92ad1 commit a005e07
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 20 deletions.
6 changes: 5 additions & 1 deletion scripts/controllers/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { TYPES, FEATURES, HEADER_ITEMS, MENU_POSITIONS, CUSTOM_THEMES, GROUP_ALI
import { debounce, leadZero, supportsFeature, toAbsoluteServerURL } from '../globals/utils';
import Noty from '../models/noty';

App.controller('Main', function ($scope, $timeout, $location, Api, tmhDynamicLocale) {
App.controller('Main', function ($scope, $timeout, $location, Api, tmhDynamicLocale, $filter) {
if (!window.CONFIG) {
return;
}
Expand Down Expand Up @@ -605,6 +605,10 @@ App.controller('Main', function ($scope, $timeout, $location, Api, tmhDynamicLoc
return value;
};

$scope.filterNumber = function (number, precision) {
return $filter('number')(number, precision);
};

$scope.climateTarget = function (item, entity) {
const value = entity.attributes.temperature || [
entity.attributes.target_temp_low,
Expand Down
2 changes: 1 addition & 1 deletion scripts/directives/headerItem.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
</div>

<div class="header-weather--temperature" ng-if="item.fields.temperature">
<span ng-bind="getWeatherField('temperature', item, {})"></span>
<span ng-bind="(getWeatherField('temperature', item, {}) | number:1)"></span>
<span ng-bind="getWeatherField('temperatureUnit', item, {})"></span>
</div>

Expand Down
37 changes: 20 additions & 17 deletions scripts/directives/tile.html
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@
</div>

<div class="weather-temperature" ng-if="item.fields.temperature">
<span ng-bind="getWeatherField('temperature', item, entity)"></span>
<span ng-bind="(getWeatherField('temperature', item, entity) | number:1)"></span>
<span ng-bind="getWeatherField('temperatureUnit', item, entity)"></span>
</div>

Expand All @@ -365,67 +365,70 @@
<div class="weather-line -items">
<span ng-if="item.fields.lowTemperature" class="weather-item">
<i class="mdi mdi-arrow-collapse-down"></i>
<span ng-bind="getWeatherField('lowTemperature', item, entity)"></span><!--
<span ng-bind="(getWeatherField('lowTemperature', item, entity) | number:1)"></span><!--
--><span ng-bind="getWeatherField('lowTemperatureUnit', item, entity)"></span>
</span>
</div>

<div class="weather-line -items" ng-if="effectiveTileSize(page, item).width >= 140">
<span ng-if="item.fields.humidity" class="weather-item">
<i class="mdi mdi-water"></i>
<span ng-bind="getWeatherField('humidity', item, entity)"></span>
<span ng-bind="(getWeatherField('humidity', item, entity) | number:0)"></span>
<span ng-bind="getWeatherField('humidityUnit', item, entity)"></span>
</span>
<span ng-if="item.fields.windSpeed" class="weather-item">
<i class="mdi mdi-weather-windy"></i>
<span ng-bind="getWeatherField('windSpeed', item, entity)"></span>
<span ng-bind="(getWeatherField('windSpeed', item, entity) | number:0)"></span>
<span ng-bind="getWeatherField('windSpeedUnit', item, entity)"></span>
</span>
</div>

<div class="weather-line -items" ng-if="effectiveTileSize(page, item).width < 140">
<span ng-if="item.fields.humidity" class="weather-item">
<i class="mdi mdi-water"></i>
<span ng-bind="getWeatherField('humidity', item, entity)"></span>
<span ng-bind="(getWeatherField('humidity', item, entity) | number:0)"></span>
<span ng-bind="getWeatherField('humidityUnit', item, entity)"></span>
</span>
</div>
<div class="weather-line -items" ng-if="effectiveTileSize(page, item).width < 140">
<span ng-if="item.fields.windSpeed" class="weather-item">
<i class="mdi mdi-weather-windy"></i>
<span ng-bind="getWeatherField('windSpeed', item, entity)"></span>
<span ng-bind="(getWeatherField('windSpeed', item, entity) | number:0)"></span>
<span ng-bind="getWeatherField('windSpeedUnit', item, entity)"></span>
</span>
</div>

<div class="weather-line" ng-repeat="line in item.fields.list">
<span ng-bind="getWeatherLine(line, item, entity)"></span>
<div class="weather-line -items">
<span ng-if="item.fields.windSpeed" class="weather-item">
<i class="mdi mdi-gauge"></i>
<span ng-bind="(getWeatherField('pressure', item, entity) | number:0)"></span>
<span ng-bind="getWeatherField('pressureUnit', item, entity)"></span>
</span>
</div>

<!-- DEPRECATED -->
<div class="weather-line" ng-if="item.fields.apparentTemperature">
Feels like
<span ng-bind="getWeatherField('apparentTemperature', item, entity)"></span>
<span ng-bind="(getWeatherField('apparentTemperature', item, entity) | number:1)"></span>
<span ng-bind="getWeatherField('apparentTemperatureUnit', item, entity)"></span>
</div>

<div class="weather-line" ng-if="item.fields.pressure">
Pressure
<span ng-bind="getWeatherField('pressure', item, entity)"></span>
<span ng-bind="getWeatherField('pressureUnit', item, entity)"></span>
</div>

<div class="weather-line" ng-if="item.fields.pollen">
Pollen
<span ng-bind="getWeatherField('pollen', item, entity)"></span>
</div>

<div class="weather-line" ng-if="item.fields.precipProbability">
<span ng-bind="getWeatherField('precipProbability', item, entity)"></span><!--
--><span ng-bind="getWeatherField('precipProbabilityUnit', item, entity)"></span>
<span ng-bind="(getWeatherField('precipProbability', item, entity) | number:0)"></span>
<span ng-bind="getWeatherField('precipProbabilityUnit', item, entity)"></span>
chance of rain
</div>
<!-- ///DEPRECATED -->

<div class="weather-line" ng-repeat="line in item.fields.list">
<span ng-bind="getWeatherLine(line, item, entity)"></span>
</div>

</div>
</div>

Expand Down
2 changes: 1 addition & 1 deletion styles/main.less
Original file line number Diff line number Diff line change
Expand Up @@ -1699,7 +1699,7 @@ camera_stream {
margin-right: 10px;

.mdi {
margin: 0 0px 0 -3px;
margin: 0 0px 0 0px;
}
}
}
Expand Down

0 comments on commit a005e07

Please sign in to comment.