<template>
	<v-layout wrap>
		<v-container class="Header">
			<v-icon class="Menu" @click.stop="drawer = !drawer" dark>WMi-menu</v-icon>
			<a :href="mainHref">
				<v-icon class="Home" dark>WMi-Real-Estate</v-icon>
			</a>
            <div class="Name caption"> {{ getAuthUser.name }} </div>
			<div class="Time">
				<div class="WM-Font-22 En Bold">{{ getCurrentTime }}</div>
				<div class="WM-Font-14 Fa FaNum">{{  new Date() | moment("dddd  jDD  jMMMM jYYYY") }}</div>
			</div>
			<!-- <div class="Notification" dark>
                <wm-notifications></wm-notifications>
			</div>-->
		</v-container>

		<v-navigation-drawer v-model="drawer" app temporary right width="320">
			<v-list class="pa-1">
                <div class="row user-info">
                    <v-flex lg9 class="pa-3">
						<img class="Avatar" :src="$_getPath()+'images/Global/Misc/Avatar.png'" />
                        <div class="Title">
                            <div class="Name Fa">{{ getAuthUser.name }}</div>
                            <div class="Role Fa">مدیریت</div>
                        </div>
                    </v-flex>
                    <v-flex lg3>
						<a class="LogOut">
							<v-tooltip bottom color="black" transition="slide-x-transition">
                                <template v-slot:activator="{ on }">
                                    <v-btn class="mt-4" small @click.native.stop="logout" slot="activator" outlined fab color="black" dark v-on="on">
                                        <v-icon dark>WMi-off-1</v-icon>
                                    </v-btn>
                                </template>
								<span>خروج از حساب کاربری</span>
							</v-tooltip>
						</a>
                    </v-flex>
                </div>
			</v-list>

			<v-list class="pt-0" dense>
				<v-divider class="Divider"/>
				<a :href="item.href" v-for="(item, key) in Items" :key="key">
					<template v-if="!item.permissionClass || $_can(item.permissionClass, false, item.module)">
						<wm-list-tile :TitleFa="item.titleFa" :TitleEn="item.titleEn" :icon="item.icon" :tileClass="item.tileClass"/>
					</template>
				</a>
			</v-list>
		</v-navigation-drawer>
	</v-layout>
</template>

<script>
import Tile from "@Global/components/Drawer/Tile";
import Notifications from "@Global/components/Drawer/Notifications";
import Routes from "@Global/utils/common/routes";
import { mapActions, mapGetters } from "vuex";
// import { getTime } from "@Global/utils/date/time";
export default {
	data() {
		return {
			fav: true,
			menu: true,
			message: false,
			hints: true,
			drawer: false,
			Items: [
				{ titleEn: 'My Profile', titleFa: ' حساب کاربری من ', icon: 'user', permissionClass: null, href: '/user/profile' },
				{
					titleEn: " My Users ",
					titleFa: " کاربران مجموعه ی من ",
					icon: "users",
					permissionClass: "User::index",
					module: "core",
					href: Routes.user(),
                    tileClass: 'red-theme',
                },
                {
					titleEn: " Product Management ",
					titleFa: " مدیریت محصولات ",
					icon: "dropbox",
					permissionClass: "Product::index",
					href: '/product/home',
                    tileClass: 'cyan-theme',
				},
                {
                    titleEn: " Blog Management ",
                    titleFa: " مدیریت خبرنامه ",
                    icon: "rss",
                    permissionClass: "SMS::manage",
                    href: '/blog',
                    tileClass: 'orange-theme',
                },
                {
                    titleEn: " Portfolio Management ",
                    titleFa: " مدیریت نمونه کارها ",
                    icon: "rss",
                    href: '/portfolio',
                },
                {
					titleEn: " SMS Management ",
					titleFa: " مدیریت پیام های کوتاه ",
					icon: "comment-alt",
					permissionClass: "SMS::manage",
					href: '/sms/manage',
				}
			],
			user: { name: "" },
			mainHref: Routes.main(),
		};
	},
	mounted() {
		let self = this;
	},
	components: {
		"wm-list-tile": Tile,
		"wm-notifications": Notifications
	},
	computed: {
		...mapGetters("auth", ["getAuthUser"]),
		...mapGetters("common", ["getCurrentTime"]),
	},
	methods: {
		...mapActions("auth", ["logout"]),
	}
};
</script>

<style lang="scss" scoped>

.user-info .Title {
    float: right;
}
.user-info .Avatar {
    float: right;
    width: 48px;
    margin: 0px 10px;
}
.user-info .Title .Name {
    font-size: 14px;
}

.Header .Menu {
	position: absolute;
	right: 20px;
	top: 20px;
}
.Header .Home {
	position: absolute;
	right: 50px;
	top: 20px;
}
.Header .Name {
	position: absolute;
    right: 80px;
    top: 20px;
    color: #fff;
    line-height: 18px;
}

.Notification {
	position: absolute;
	left: 20px;
	top: 20px;
}
.Divider {
	margin: 0px;
}
.Name {
	font-size: 16px;
}
.Role {
	font-size: 14px;
	color: #aaaaaa;
}
.Time {
	text-align: center;
	color: #fff;
	margin-top: -10px;
}
.Header {
	padding-bottom: 0px;
}
.LogOut {
	position: absolute;
	left: 10px;
}
.drawer-trigger {
	position: fixed;
	top: 0px;
	padding: 40px;
	background-color: white;
	left: 400px;
}

.drawer-trigger.active {
	color: red;
}

.drawer {
	position: fixed;
	top: 0px;
	left: -600px;
	bottom: 0px;
	background-color: white;
	width: 600px;
}

.drawer.open {
	left: 0px;
}
</style>
