How to reload app.component on event in ionic 4 - ionic4

I'm stuck with the following problem.
app.component.ts is listening to event 'login' which works fine. But, when then event is firing I want to reload my app.component-page as I want to show a different side menu when a user is logged in.
I found some examples with Content but Content is not included in #ionic/angular anymore.
Has someone a working example? This would me a lot.
Thank you in advance.
Following my environment infos
Ionic CLI : 5.2.6 (/usr/local/lib/node_modules/ionic)
Ionic Framework : #ionic/angular 4.4.2
#angular-devkit/build-angular : 0.13.9
#angular-devkit/schematics : 7.3.9
#angular/cli : 7.3.9
#ionic/angular-toolkit : 1.5.1

Instead of reloading the page which is not a best practice, you should bind the menu to a list of data that you can change depending on the logged in status.
If you want to make structural changes as well then you can just put those on a *ngIf for the two versions.
This tutorial shows how to bind the menu from an array of pages.
You just set up a data structure to hold the menu items:
sideMenu()
{
this.navigate =
[
{
title : "Home",
url : "/home",
icon : "home"
},
{
title : "Chat",
url : "/chat",
icon : "chatboxes"
},
{
title : "Contacts",
url : "/contacts",
icon : "contacts"
},
]
}
And then loop it on the front end:
<ion-list *ngFor="let pages of navigate">
<ion-menu-toggle auto-hide="true">
<ion-item [routerLink]="pages.url" routerDirection="forward">
<ion-icon [name]="pages.icon" slot="start"></ion-icon>
{{pages.title}}
</ion-item>
</ion-menu-toggle>
</ion-list>

Related

Laravel 8 Tailwind 3 darkmode isn't working

So I'm trying to enable darkmode on my site. I've added a toggle to my app.layouts file which adds and removes the dark class to the element at the root of my file and toggling the checkbox adds and removes this class.
I have added darkMode: 'class', to the top of my tailwind.config.js file (right below module.exports = {
I have ran npm run dev and npm run dev watch and Ive cleared my caches (i have this in a route for convenience at the moment)
my page has a div which contains a background colour and one when in dark mode
<div class="w-full text-center bg-blue-300 dark:bg-blue-600">34</div>
tailwind is loading and the region is being shown with the bg-blue-300 colour shown but when i toggle to dark mode nothing changes except the class of dark is added to my <html> element like this <html class="dark" lang="en">. I have checked the docs and can't see any step I have missed.
I followed this tut https://www.section.io/engineering-education/implementing-dark-mode-using-tailwind-css/
my plan is to switch the tailwind config setting from class to media and remove the toggle button once I know it will work.
** EDIT **
thanks to #lordisp it seems that the underlying functionality is working but the classes in the css are not present. I guess I could add a full minified tailwind.css file but would rather just compile the assets I need.
So looking in my tailwind.config.js file i have the following in the content section
ontent: [
'./vendor/laravel/framework/src/Illuminate/Pagination/resources/views/*.blade.php',
'./vendor/laravel/jetstream/**/*.blade.php',
'./vendor/wire-elements/modal/resources/views/*.blade.php',
'./storage/framework/views/*.php',
'./resources/views/**/*.blade.php',
],
So it looks like the livewire components are getting loaded so they should have the css added right?
Add your dark-mode classes to Safelisting classes in your tailwind.config.js:
module.exports = {
darkMode: 'class',
content: [
'./vendor/laravel/framework/src/Illuminate/Pagination/resources/views/*.blade.php',
'./vendor/laravel/jetstream/**/*.blade.php',
'./vendor/wire-elements/modal/resources/views/*.blade.php',
'./storage/framework/views/*.php',
'./resources/views/**/*.blade.php',
],
safelist: [
'bg-blue-300',
'bg-blue-600',
],
// ...
}

Ionic 4 View PDF

Under android 10 (Samsung A50), I installed the document viewer plugin to be able to open a pdf that I have on a website.
ionic cordova plugin add cordova-plugin-document-viewer
npm install # ionic-native / document-viewer
When I try to open the pdf, it offers me to open it with google play store or galaxy store.
I would like to know what I am doing wrong, and if there is any way to open the pdf directly, without choosing which program to open it with.
I send used code, and I also inform them that with fileopener it works correctly, except that it asks me if I want to open with the pdf viewer or another program, and I want the opening of the pdf to be direct, without that step of choosing a program.
Ionic CLI : 6.10.0
Ionic Framework : #ionic/angular 4.11.5
#angular/cli : 8.1.3
Cordova CLI : 9.0.0 (cordova-lib#9.0.1)
Cordova Platforms : android 8.1.0
*********************************************
async pdf2() {
const options: DocumentViewerOptions = {
title: 'My PDF',
openWith: { enabled: true},
bookmarks : {
enabled : true
},
search : {
enabled : true
},
autoClose: {
onPause : true
}
}
let path = null;
if (this.platform.is('ios')) {
path = this.file.documentsDirectory;
} else {
path = this.file.dataDirectory;
}
const transfer = this.transfer.create();
transfer.download('https://www.zzzzz.com/site/pdfs/blabla.pdf', path + 'myfile.pdf').then(entry => {
let url = entry.toURL();
this.document.viewDocument(url, 'application/pdf', options);
})
}
thanks!!

defaultProtocol not working for links with ckeditor5-vue

Vue component
<ckeditor :editor="classiceditor" v-model="report_notes" :config="editorConfig" #blur="editReportNotes()" #keyup.enter="editReportNotes()"></ckeditor>
vuejs code
classiceditor:ClassicEditor,
editorConfig: {
// plugins: [ Underline],
toolbar: {
items: [
'bold','italic',
'|','link',
'|','bulletedList', 'numberedList',
]
},
placeholder :'Write a note...',
link: {
defaultProtocol: 'http://'
}
},
Issue is defaultProtocal is not setting. when i give gogole.com as link, It is opening as my-domain/google.com which is a non existing page
I need it as http://google.com
I followed this doc defaultProtocal
Thank you in advance
re-installeed and Upgraded from version 16.0.0 to 22.0.0. Because the feature is recently added
npm install --save #ckeditor/ckeditor5-vue #ckeditor/ckeditor5-build-classic

AngularFireAuthGuard with multiple conditions

I am working on a Ionic project which is using AngularFire. Application has two main features.
Feature 1. Requires users to create an account and login.
Feature 2. Doesn't require an account or logging in.
I am using AngularFireAuthGuard with "redirectUnauthorizedToLogin" pipe to control routing.
const redirectUnauthorizedToLogin = () => redirectUnauthorizedTo(['login']);
{ path: '...', loadChildren: '...', canActivate: [AngularFireAuthGuard], data: { authGuardPipe: redirectUnauthorizedToLogin } },
Both features interact with FireStore. Due to security reasons, I want to implement Firebase Anonymous Sign-in. So, for the feature 2, I can control who can write to db without allowing permission to everyone. Meanwhile feature 1 will still require an account.
Here comes the problem because I couldn't find a way to add two conditions to the feature 1 guard something like
if (is anonymous || not logged in) redirectToLogin
As far as I can see, redirectUnauthorizedToLogin counts anonymous sign-in as authorized.
I checked the official documents and I see that there is an "IsNotAnonymous" built-in pipe but it is only referred once and I couldn't find any other usage of it.
I hope someone can help me about this.
Thanks in advance,
Ionic:
Ionic CLI : 5.2.1
Ionic Framework : #ionic/angular 4.6.0
#angular-devkit/build-angular : 0.13.9
#angular-devkit/schematics : 7.2.4
#angular/cli : 7.3.9
#ionic/angular-toolkit : 1.4.0
"#angular/fire": "^5.2.1",
"firebase": "^5.11.1",
Cordova:
Cordova CLI : 8.1.2 (cordova-lib#8.1.1)
Cordova Platforms : android 7.1.4
Utility:
cordova-res : 0.6.0
native-run : 0.2.7
System:
Android SDK Tools : 26.1.1 (D:\Sdk)
NodeJS : v11.4.0 (D:\nodejs\node.exe)
npm : 6.4.1
OS : Windows 10
If you checkout the source code, you can see how they implemented isNotAnonymous here: https://github.com/angular/angularfire/blob/5.2.3/src/auth-guard/auth-guard.ts#L32 but the problem is that isNotAnonymous rejects but does not redirect. I think you can basically emulate this line: https://github.com/angular/angularfire/blob/5.2.3/src/auth-guard/auth-guard.ts#L37 to add the redirect.
These are pipe-able, so you should be good to go with:
import { AngularFireAuthGuard, isNotAnonymous } from '#angular/fire/auth-guard';
export const redirectAnonymousTo = (redirect: any[]) =>
pipe(isNotAnonymous, map(loggedIn => loggedIn || redirect)
);
const redirectUnauthorizedToLogin = () => redirectAnonymousTo(['login']);
export const routes: Routes = [
{ path: '', component: AppComponent },
{
path: 'items',
component: ItemListComponent,
canActivate: [AngularFireAuthGuard],
data: { authGuardPipe: redirectUnauthorizedToLogin }
}
];
If unauthenticated or anonymous, it will return false, so the redirect will happen, otherwise it will resolve to true.
I have not tried executing this code, but hopefully it will be a good start.

odoo version 10 javascript error, failed modules

I'm trying to start a small page but it doesn't work
I am using odoo 10, I have the website module installed but apparently it throws some mistakes
main.js
odoo.define('gencontratos.main_page',function(require){
"use strict";
var Widget = require('web.Widget');
var RootPage = Widget.extend({
template:'qwebRoot',
start:function(){
console.log(this.$el);
console.log('start----------');
}
})
var page = new RootPage();
//page.setElement('#root');
page.appendTo('#root');
console.log('loaded---------------------');
})
root.xml
<templates id="templates" xml:space="preserve">
<t t-name="qwebRoot">
<div>
qweb
</div>
</t>
</templates>
error: Some modules could not be started web.assets_common.js:2995:302
Missing dependencies:
Array(4) [ "web.web_client", "web_editor.editor", "web_editor.summernote", "web_editor.transcoder" ]
web.assets_common.js:2995:431
Failed modules:
Array [ "gencontratos.main_page" ]
web.assets_common.js:2996:24
Rejected modules:
Array(4) [ "website_portal", "website_payment.website_payment", "website_sale.website_sale_category", "website_sale.website_sale" ]
web.assets_common.js:2997:26
Non loaded modules:
Array(16) [ "web.ChangePassword", "web.Apps", "account.reconciliation", "website_sale.backend", "mail.chat_client_action", "mail.ExtendedChatWindow", "mail.composer", "mail.chat_manager", "mail.Chatter", "mail.systray", … ]
I need help, I am starting a project for this version but it does not work, I have been missing for two days trying to solve this problem, the documentation does not say anything that can help me and on the Internet I have not found anything that could help me